WT 1.1.19 App Upgrade
This commit is contained in:
+86
-41
@@ -1,7 +1,10 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:aitrainer_app/bloc/session/session_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:aitrainer_app/view/login.dart';
|
||||
import 'package:aitrainer_app/view/menu_page.dart';
|
||||
@@ -12,6 +15,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:upgrader/upgrader.dart';
|
||||
import 'loading.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
@@ -53,48 +57,62 @@ class _HomePageState extends State<AitrainerHome> with Logging, Trans {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
setContext(context);
|
||||
final appcastURL = "https://raw.githubusercontent.com/bossanyit/appcast/main/android_rss.xml";
|
||||
final cfg = AppcastConfiguration(url: appcastURL, supportedOS: ['android']);
|
||||
print("Packageinfo ${Cache().packageInfo}");
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: BlocConsumer<SessionBloc, SessionState>(listener: (context, state) {
|
||||
if (state is SessionFailure) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DialogCommon(
|
||||
title: t("Error"),
|
||||
descriptions: t(state.message),
|
||||
text: "OK",
|
||||
onTap: () => {
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
onCancel: () => {
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
if (state is SessionInitial) {
|
||||
return LoadingScreenMain();
|
||||
} else if (state is SessionLoading) {
|
||||
log("loading");
|
||||
return LoadingScreenMain();
|
||||
} else if (state is SessionReady) {
|
||||
log("ready menu with " + Cache().startPage);
|
||||
if (Cache().startPage == 'login') {
|
||||
return LoginPage();
|
||||
} else if (Cache().startPage == 'registration') {
|
||||
return RegistrationPage();
|
||||
} else {
|
||||
return MenuPage(parent: 0);
|
||||
}
|
||||
} else {
|
||||
log("home: unknown state");
|
||||
return MenuPage(parent: 0);
|
||||
//return LoginPage();
|
||||
}
|
||||
}),
|
||||
);
|
||||
key: _scaffoldKey,
|
||||
body: UpgradeAlert(
|
||||
appcastConfig: cfg,
|
||||
dialogStyle: UpgradeDialogStyle.cupertino,
|
||||
countryCode: AppLanguage().appLocal.languageCode,
|
||||
showIgnore: false,
|
||||
showLater: false,
|
||||
showReleaseNotes: false,
|
||||
debugLogging: true,
|
||||
//debugAlwaysUpgrade: true,
|
||||
//debugDisplayOnce: true,
|
||||
//minAppVersion: Cache().packageInfo != null ? Cache().packageInfo!.version : "99.99.99",
|
||||
messages: MyLocalizedUpgraderMessages(context: context),
|
||||
child: BlocConsumer<SessionBloc, SessionState>(listener: (context, state) {
|
||||
if (state is SessionFailure) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DialogCommon(
|
||||
title: t("Error"),
|
||||
descriptions: t(state.message),
|
||||
text: "OK",
|
||||
onTap: () => {
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
onCancel: () => {
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
if (state is SessionInitial) {
|
||||
return LoadingScreenMain();
|
||||
} else if (state is SessionLoading) {
|
||||
log("loading");
|
||||
return LoadingScreenMain();
|
||||
} else if (state is SessionReady) {
|
||||
log("ready menu with " + Cache().startPage);
|
||||
if (Cache().startPage == 'login') {
|
||||
return LoginPage();
|
||||
} else if (Cache().startPage == 'registration') {
|
||||
return RegistrationPage();
|
||||
} else {
|
||||
return MenuPage(parent: 0);
|
||||
}
|
||||
} else {
|
||||
log("home: unknown state");
|
||||
return MenuPage(parent: 0);
|
||||
}
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -102,3 +120,30 @@ class _HomePageState extends State<AitrainerHome> with Logging, Trans {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class MyLocalizedUpgraderMessages extends UpgraderMessages with Trans {
|
||||
/// Override the message function to provide custom language localization.
|
||||
final BuildContext context;
|
||||
MyLocalizedUpgraderMessages({required this.context}) : super();
|
||||
@override
|
||||
String message(UpgraderMessage messageKey) {
|
||||
setContext(context);
|
||||
switch (messageKey) {
|
||||
case UpgraderMessage.body:
|
||||
return t('A new version of Workout Test is available!');
|
||||
case UpgraderMessage.buttonTitleIgnore:
|
||||
return t('Ignore');
|
||||
case UpgraderMessage.buttonTitleLater:
|
||||
return t('Later');
|
||||
case UpgraderMessage.buttonTitleUpdate:
|
||||
return t('Update Now');
|
||||
case UpgraderMessage.prompt:
|
||||
return t('Want to update?');
|
||||
case UpgraderMessage.title:
|
||||
return t('Update App?');
|
||||
}
|
||||
|
||||
// Messages that are not provided above can still use the default values.
|
||||
//return super.message(messageKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,42 +163,23 @@ class _MenuPageWidgetState extends State<MenuPageWidget> with Trans, Logging {
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
)),
|
||||
child: Badge(
|
||||
showBadge: workoutTree.nameEnglish == "One Rep Max" || workoutTree.nameEnglish == "Endurance",
|
||||
animationDuration: Duration(milliseconds: 800),
|
||||
animationType: BadgeAnimationType.fade,
|
||||
badgeColor: Colors.blue[100]!,
|
||||
badgeContent: GestureDetector(
|
||||
onTap: () => {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DialogHTML(
|
||||
title: workoutTree.name,
|
||||
htmlData: workoutTree.nameEnglish == "Endurance"
|
||||
? AppLocalizations.of(context)!.translate("Endurance_desc")
|
||||
: AppLocalizations.of(context)!.translate("OneRepMax_desc"),
|
||||
);
|
||||
})
|
||||
},
|
||||
child: Icon(Icons.info_outline_rounded)),
|
||||
child: Stack(alignment: Alignment.bottomLeft, children: [
|
||||
TextButton(
|
||||
child: badgedIcon(workoutTree, cWidth, cHeight),
|
||||
onPressed: () => menuClick(workoutTree, menuBloc),
|
||||
child: Stack(alignment: Alignment.bottomLeft, children: [
|
||||
TextButton(
|
||||
child: badgedIcon(workoutTree, cWidth, cHeight),
|
||||
onPressed: () => menuClick(workoutTree, menuBloc),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 15, bottom: 8, right: 15),
|
||||
child: GestureDetector(
|
||||
onTap: () => menuClick(workoutTree, menuBloc),
|
||||
child: Text(
|
||||
workoutTree.name,
|
||||
maxLines: 4,
|
||||
style: GoogleFonts.archivoBlack(color: workoutTree.color, fontSize: workoutTree.fontSize, height: 1.1),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 15, bottom: 8, right: 15),
|
||||
child: GestureDetector(
|
||||
onTap: () => menuClick(workoutTree, menuBloc),
|
||||
child: Text(
|
||||
workoutTree.name,
|
||||
maxLines: 4,
|
||||
style: GoogleFonts.archivoBlack(color: workoutTree.color, fontSize: workoutTree.fontSize, height: 1.1),
|
||||
),
|
||||
),
|
||||
),
|
||||
])))));
|
||||
),
|
||||
),
|
||||
]))));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user