Skip to content

Commit

Permalink
fix: check min app version improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hig-dev committed Feb 6, 2024
1 parent b550a09 commit 8d36dc7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@
"pattern": {}
}
},
"app_outdated_message": "Ihre App ist veraltet.\nBitte aktualisieren Sie auf die neueste Version.",
"app_outdated_message": "Eine neue Version der StudyU App ist verfügbar. Bitte führen Sie eine Aktualisierung durch, um die neuesten Funktionen und Verbesserungen zu erhalten. Vielen Dank für Ihre Unterstützung!",
"open_store": "Store öffnen"
}
2 changes: 1 addition & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@
"pattern": {}
}
},
"app_outdated_message": "Your app is outdated.\nPlease update to the latest version.",
"app_outdated_message": "A new version of the StudyU app is available. Please update it to receive the latest features and improvements. Thank you for your support!",
"open_store": "Open Store"
}
7 changes: 4 additions & 3 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ Future<void> main() async {
String initialRoute = Routes.loading;
try {
appConfig = await AppConfig.getAppConfig();
if (await isAppOutdated(appConfig)) {
initialRoute = Routes.appOutdated;
}
} catch (error) {
// device could be offline
}

if (appConfig != null && await isAppOutdated(appConfig)) {
initialRoute = Routes.appOutdated;
}

await AppAnalytics.init();
if (!kDebugMode && AppAnalytics.isUserEnabled) {
AppAnalytics.start(appConfig, MyApp(queryParameters, appConfig, initialRoute: initialRoute));
Expand Down
16 changes: 6 additions & 10 deletions app/lib/screens/app_onboarding/app_outdated_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../models/app_state.dart';

class AppOutdatedScreen extends StatelessWidget {
static const String kPlayStoreUrl = 'https://play.google.com/store/apps/details?id=health.studyu.app';
static const String kAppstoreUrl = 'https://itunes.apple.com/app/id1571991198';

const AppOutdatedScreen({super.key});

@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context)!;
final state = context.read<AppState>();
String? storeUrl;
IconData? storeIcon;
if (Platform.isAndroid) {
storeUrl = state.appConfig?.appPlayStoreUrl;
storeUrl = kPlayStoreUrl;
storeIcon = MdiIcons.googlePlay;
} else if (Platform.isIOS) {
storeUrl = state.appConfig?.appAppstoreUrl;
storeUrl = kAppstoreUrl;
storeIcon = MdiIcons.apple;
}
return Scaffold(
Expand All @@ -43,10 +42,7 @@ class AppOutdatedScreen extends StatelessWidget {
? OutlinedButton.icon(
icon: Icon(storeIcon),
onPressed: () async {
await launchUrl(Uri.parse(storeUrl!),
mode: Platform.isAndroid
? LaunchMode.externalNonBrowserApplication
: LaunchMode.platformDefault);
await launchUrl(Uri.parse(storeUrl!), mode: LaunchMode.externalNonBrowserApplication);
},
label: Text(loc.open_store, style: const TextStyle(fontSize: 20)),
)
Expand Down
6 changes: 0 additions & 6 deletions core/lib/src/models/tables/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class AppConfig extends SupabaseObjectFunctions<AppConfig> {
String id;
@JsonKey(name: 'app_min_version')
String appMinVersion;
@JsonKey(name: 'app_playstore_url')
String appPlayStoreUrl;
@JsonKey(name: 'app_appstore_url')
String appAppstoreUrl;
@JsonKey(name: 'app_privacy')
Map<String, String> appPrivacy;
@JsonKey(name: 'app_terms')
Expand All @@ -33,8 +29,6 @@ class AppConfig extends SupabaseObjectFunctions<AppConfig> {
AppConfig(
this.id, {
required this.appMinVersion,
required this.appPlayStoreUrl,
required this.appAppstoreUrl,
required this.appPrivacy,
required this.appTerms,
required this.designerPrivacy,
Expand Down
4 changes: 0 additions & 4 deletions core/lib/src/models/tables/app_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions database/migration/migrate-app_min_version.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
ALTER TABLE public.app_config
ADD COLUMN app_min_version text NOT NULL DEFAULT '0.0.0';

ALTER TABLE public.app_config
ADD COLUMN app_playstore_url text NOT NULL DEFAULT 'https://play.google.com/store/apps/details?id=health.studyu.app';

ALTER TABLE public.app_config
ADD COLUMN app_appstore_url text NOT NULL DEFAULT 'https://itunes.apple.com/app/id1571991198';
ADD COLUMN app_min_version text NOT NULL;
4 changes: 1 addition & 3 deletions database/studyu-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ ALTER FUNCTION public.user_email(user_id uuid) OWNER TO postgres;

CREATE TABLE public.app_config (
id text NOT NULL,
app_min_version text NOT NULL DEFAULT '0.0.0',
app_playstore_url text NOT NULL DEFAULT 'https://play.google.com/store/apps/details?id=health.studyu.app',
app_appstore_url text NOT NULL DEFAULT 'https://itunes.apple.com/app/id1571991198',
app_min_version text NOT NULL,
app_privacy jsonb NOT NULL,
app_terms jsonb NOT NULL,
designer_privacy jsonb NOT NULL,
Expand Down

0 comments on commit 8d36dc7

Please sign in to comment.