WT1.1.0+41 error fixing

This commit is contained in:
bossanyit 2020-12-29 13:20:35 +01:00
parent 9755cc764a
commit 2aecb9d431
22 changed files with 492 additions and 137 deletions

File diff suppressed because one or more lines are too long

View File

@ -73,7 +73,7 @@
"repeat": "ismétlés",
"meter": "meter",
"meter": "méter",
"percent": "százalék",
"kg": "kg",
"kilogram": "kilogramm",
@ -148,7 +148,7 @@
"Edit My Custom Plan": "Egyéni edzésterv",
"Suggested Training Plan": "Javasolt edzésterv",
"My Special Plan": "Speciális edzésterv",
"My Arnold's Plan": "Sztárok edzésterves",
"Star's Exercise Plan": "Sztárok edzésterve",
"My Trainee's Plan" : "Kliensem edzésterve",
"Execute My Trainee's Training Plan": "Kliensem edzéstervének végrehajtása",
@ -250,6 +250,22 @@
"Min BPM":"Min pulzus",
"Average BPM":"Átl pulzus",
"Fatburn %":"Zsírégetés %",
"Health Data Summary":"Egészségadatok összefoglalás"
"Health Data Summary":"Egészségadatok összefoglalás",
"Congratulation!":"Gratulálok!",
"You have achieved to first 100% test-round!":"Teljesítetted az első 100%-os tesztköröd!",
"Now you unlocked: Development By Muscles and the Suggested Trainings Plan":"Mostantól elérheted az 'Izomcsoportok fejlődése' és a 'Javasolt edzésterv' kategóriákat.",
"The": "A",
"the first":"az első",
"the second":"a második",
"Go Premium":"Válts Prémiumra",
"Unleash your potential with WorkoutTest Premium!":"Bontakoztasd ki az erősségeidet WorkoutTest Prémiummal!",
"feature is reachable after you finished":"funkció elérhető számodra, miután teljesítetted",
"100% test circles":"100%-os teszt-köröd",
"Enjoy also this premium fetaure to show all old evaluation data of your successful exercises.":"Élvezd ezt a prémium funkciót is, amely megjeleníti a korábbi gyakorlatok teljes kiértékelését"
}

View File

@ -366,7 +366,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 41;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -388,7 +388,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
@ -509,7 +509,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 41;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -532,7 +532,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@ -544,7 +544,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 41;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -566,7 +566,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;

View File

@ -49,7 +49,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
}
if (context == null) return;
percent = percent * 100;
log("Percent " + percent.toString());
//log("Percent " + percent.toString());
if (percent == -1 || percent == 0) {
infoTitle = t("Greetings!");
infoText = t("The purpose is to measure you physical condition") +
@ -66,6 +66,10 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
infoTitle = t("Persistence!") + " " + t("Not so much left");
} else if (percent > 80 && percent < 100) {
infoTitle = t("Almost!") + " " + t("You have only 1-2 exercise left to finish!");
} else {
infoTitle = t("Congratulation!");
infoText2 = t("You have achieved to first 100% test-round!");
infoText3 = t("Now you unlocked: Development By Muscles and the Suggested Trainings Plan");
}
menuTreeRepository.sortByMuscleType();

View File

@ -3,6 +3,7 @@ import 'package:aitrainer_app/bloc/sales/sales_bloc.dart';
import 'package:aitrainer_app/push_notifications.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
import 'package:aitrainer_app/service/firebase_api.dart';
import 'package:aitrainer_app/util/session.dart';
import 'package:aitrainer_app/view/account.dart';
import 'package:aitrainer_app/view/custom_exercise_page.dart';
@ -117,6 +118,9 @@ Future<Null> main() async {
// - https://www.dartlang.org/articles/libraries/zones
runZonedGuarded<Future<Null>>(() async {
final WorkoutTreeRepository menuTreeRepository = WorkoutTreeRepository();
WidgetsFlutterBinding.ensureInitialized();
print(" -- FireBase init..");
await FirebaseApi().initializeFlutterFire();
runApp(MultiBlocProvider(
providers: [
BlocProvider<SessionBloc>(

View File

@ -424,11 +424,11 @@ class Cache with Logging {
await CustomerApi().getCustomer(customerId);
Cache().startPage = "home";
Flurry.setUserId(customerId.toString());
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
Cache().setCustomerDevices(customerDevices);
await ExerciseTypeApi().getExerciseTypes();
await ExerciseTreeApi().getExerciseTree();
await ExerciseDeviceApi().getDevices();
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
Cache().setCustomerDevices(customerDevices);
ExerciseRepository exerciseRepository = ExerciseRepository();
await exerciseRepository.getExercisesByCustomer(customerId);

View File

@ -11,6 +11,7 @@ class CustomerExerciseDeviceApi with Logging {
Future<List<CustomerExerciseDevice>> getDevices(int customerId) async {
List<CustomerExerciseDevice> devices;
try {
log(" --- get customer_exercise_devices: ");
final body = await _client.get("customer_exercise_device/customer/" + customerId.toString(), "");
final Iterable json = jsonDecode(body);
devices = json.map((device) => CustomerExerciseDevice.fromJson(device)).toList();

View File

@ -1,6 +1,7 @@
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/purchase.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/util/not_found_exception.dart';
import 'dart:convert';
import 'api.dart';
@ -8,10 +9,15 @@ class PurchaseApi with Logging {
final APIClient _client = new APIClient();
Future<List<Purchase>> getPurchasesByCustomer(int customerId) async {
final body = await _client.get("purchase/customer/" + customerId.toString(), "");
final Iterable json = jsonDecode(body);
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
Cache().setPurchases(purchases);
List<Purchase> purchases = List();
try {
final body = await _client.get("purchase/customer/" + customerId.toString(), "");
final Iterable json = jsonDecode(body);
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
Cache().setPurchases(purchases);
} on NotFoundException catch (e) {
log("No purchases found");
}
return purchases;
}

View File

@ -1,13 +1,11 @@
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/service/api.dart';
import 'package:aitrainer_app/service/firebase_api.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/service/product_service.dart';
import 'package:aitrainer_app/service/property_service.dart';
import 'package:devicelocale/devicelocale.dart';
import 'package:flutter/services.dart';
import 'package:mockito/mockito.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:aitrainer_app/model/cache.dart';
@ -28,8 +26,6 @@ class Session with Logging {
Cache().setServerAddress(_sharedPreferences);
Cache().getHardware(_sharedPreferences);
await _fetchToken(_sharedPreferences);
log(" -- FireBase init..");
await FirebaseApi().initializeFlutterFire();
//initDeviceLocale();
// Create the initialization Future outside of `build`:

View File

@ -7,7 +7,6 @@ import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:aitrainer_app/widgets/treeview_parent_widget.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
@ -155,7 +154,7 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
IconButton(
icon: element.executed
? Icon(Icons.check_box, color: Colors.green)
? Icon(Icons.check_box, color: Colors.green[200])
: Icon(
Icons.indeterminate_check_box,
color: Colors.blue.shade800,

View File

@ -79,6 +79,7 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: BouncingScrollPhysics(),
controller: ScrollController(
initialScrollOffset: exerciseBloc.scrollOffset,
),

View File

@ -239,10 +239,12 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
context: context,
builder: (BuildContext context) {
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "Enjoy also this premium fetaure to show all old evaluation data of your successful exercises.",
text: "OK",
unlocked: true,
unlockRound: 1,
unlockedText: t("Enjoy also this premium fetaure to show all old evaluation data of your successful exercises."),
function: "My Exercise Logs",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
});
}
@ -255,6 +257,8 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
? "on the " + DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd.toUtc())
: DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd.toUtc()) + "-n";
final String unitQuantity = exercise.unitQuantity == null ? "" : "x" + exercise.unitQuantity.toStringAsFixed(0);
showCupertinoDialog(
useRootNavigator: true,
context: context,
@ -268,7 +272,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
style: (TextStyle(color: Colors.blue)),
),
Text(
exercise.quantity.toStringAsFixed(0) + "x" + exercise.unitQuantity.toStringAsFixed(0) + " ",
exercise.quantity.toStringAsFixed(0) + unitQuantity + " ",
//+
//exerciseType.unitQuantityUnit == null
// ? ""

View File

@ -1,4 +1,5 @@
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/widgets/app_bar_min.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -6,17 +7,19 @@ class Gdpr extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBarMin(
back: true,
),
body: Container(
padding: const EdgeInsets.only(left: 15, right: 15),
child: ListView(
children: <Widget>[
new InkWell(
child: new Text(
InkWell(
child: Text(
AppLocalizations.of(context).translate('gdpr_text'),
),
customBorder: Border.all(color: Colors.teal, width: 1),
customBorder: Border.all(color: Colors.orange, width: 1),
),
Spacer(flex: 2),
],
)));
}

View File

@ -33,11 +33,12 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
setContext(context);
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "The Body Development feature is reachable if you finished the second 100% test-circles",
text: "OK",
unlocked: false,
unlockRound: 2,
function: "My Whole Body Development",
unlockedText: "",
onTap: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
);

View File

@ -38,10 +38,10 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
barrierDismissible: false,
builder: (BuildContext context) {
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "The Muscle Development feature is reachable if you finished the first 100% test-circles",
text: "OK",
unlocked: false,
unlockRound: 1,
function: "Development Of Muscles",
unlockedText: "",
onTap: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
);

View File

@ -107,12 +107,11 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
context: context,
builder: (BuildContext context) {
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "The Predictions feature is reachable if you finished the second 100% test-circles",
text: "OK",
unlocked: false,
unlockRound: 2,
function: "Predictions",
unlockedText: "",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
})
},

View File

@ -95,10 +95,10 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
context: context,
builder: (BuildContext context) {
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "The Suggested Training Plan is reachable if you finished the first 100% test-circles",
text: "OK",
unlocked: false,
unlockRound: 1,
function: "Suggested Training Plan",
unlockedText: "",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
@ -123,10 +123,10 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
context: context,
builder: (BuildContext context) {
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "The Special Plan is reachable if you finished the first 100% test-circles",
text: "OK",
unlocked: false,
unlockRound: 1,
function: "My Special Plan",
unlockedText: "",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
@ -151,10 +151,10 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging
context: context,
builder: (BuildContext context) {
return DialogPremium(
title: "Go Premium",
descriptions: "Unleash your potential with WorkoutTest Premium!",
description2: "The Star's Exericise Plan is reachable if you finished the second 100% test-circles",
text: "OK",
unlocked: false,
unlockRound: 2,
function: "Star's Exercise Plan",
unlockedText: "",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);

View File

@ -84,50 +84,7 @@ class SalesPage extends StatelessWidget with Trans {
),
])),
SliverGrid(
delegate: SliverChildListDelegate(getButtons(bloc)
/* [
SalesButton(
title: "Annual",
price: "9970 Ft / év",
desc1: "Development programs",
desc2: "Suggestions based on your actual status",
desc3: "Special customized training plans",
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
badgeText: "2 months free",
badgeColor: Colors.orange,
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
onTap: () {
print("1");
//bloc.sessionBloc.add(event)
},
),
SalesButton(
title: "Annual",
price: "10970 Ft / év",
desc1: "Development programs",
desc2: "Suggestions based on your actual status",
desc3: "Special customized training plans",
desc4: "AI driven predictions",
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
badgeText: "one month free",
badgeColor: Colors.orange,
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
onTap: () => {print("2")},
),
SalesButton(
title: "Monthly",
price: "970 Ft / hó",
desc1: "Development programs",
desc2: "Suggestions based on your actual status",
desc3: "Special customized training plans",
desc4: "AI driven predictions",
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
badgeColor: Colors.transparent,
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
onTap: () => {print("3")},
),
] */
),
delegate: SliverChildListDelegate(getButtons(bloc)),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 10.0,

View File

@ -1,5 +1,6 @@
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:badges/badges.dart';
import 'package:flurry/flurry.dart';
@ -17,7 +18,7 @@ class BottomNavigator extends StatefulWidget {
_NawDrawerWidget createState() => _NawDrawerWidget();
}
class _NawDrawerWidget extends State<BottomNavigator> with Trans {
class _NawDrawerWidget extends State<BottomNavigator> with Trans, Logging {
@override
void initState() {
super.initState();

View File

@ -0,0 +1,176 @@
import 'package:aitrainer_app/util/trans.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
// ignore: must_be_immutable
class DialogCommon extends StatefulWidget {
final String title, descriptions, text;
final VoidCallback onTap;
final VoidCallback onCancel;
String description2;
final Image img;
DialogCommon({Key key, this.title, this.descriptions, this.description2, this.text, this.img, this.onTap, this.onCancel})
: super(key: key) {
description2 = description2 ?? "";
}
@override
_DialogPremiumState createState() {
return _DialogPremiumState();
}
}
class _DialogPremiumState extends State<DialogCommon> with Trans {
bool isStart = true;
@override
Widget build(BuildContext context) {
setContext(context);
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(31),
),
elevation: 0,
backgroundColor: Colors.transparent,
child: contentBox(context),
);
}
contentBox(context) {
return Stack(alignment: AlignmentDirectional.topStart, children: [
Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20, top: 24, right: 20, bottom: 30),
margin: EdgeInsets.only(top: 30),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
boxShadow: [BoxShadow(color: Colors.black, offset: Offset(0, 10), blurRadius: 10)],
image: DecorationImage(
image: AssetImage('asset/image/WT_black_G_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 5,
),
Stack(
alignment: AlignmentDirectional.topEnd,
children: [
Text(
widget.title + " ",
style: GoogleFonts.archivoBlack(
fontSize: 18,
color: Colors.yellow[400],
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
),
],
),
SizedBox(
height: 35,
),
Text(
widget.descriptions,
style: GoogleFonts.inter(
fontSize: 14,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
textAlign: TextAlign.center,
),
SizedBox(
height: 15,
),
Text(
widget.description2,
style: GoogleFonts.inter(
fontSize: 14,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
textAlign: TextAlign.center,
),
SizedBox(
height: 62,
),
Align(
alignment: Alignment.center,
child: GestureDetector(
onTap: widget.onTap ?? widget.onTap,
child: Stack(
alignment: Alignment.center,
children: [
Image.asset('asset/icon/gomb_orange_c.png', width: 100, height: 45),
Text(
t("OK"),
style: TextStyle(fontSize: 16, color: Colors.white),
),
],
))),
],
),
),
],
),
GestureDetector(
onTap: () {
if (widget.onCancel == null) {
Navigator.of(context).pop();
} else {
widget.onCancel();
}
},
child: CircleAvatar(
backgroundColor: Colors.transparent,
radius: 28,
child: Text(
"X",
style: GoogleFonts.archivoBlack(fontSize: 32, color: Colors.white54),
),
)),
]);
}
@override
void dispose() {
super.dispose();
}
}

View File

@ -7,15 +7,26 @@ import 'package:google_fonts/google_fonts.dart';
// ignore: must_be_immutable
class DialogPremium extends StatefulWidget {
final String title, descriptions, text;
final VoidCallback onTap;
final VoidCallback onCancel;
String description2;
final Image img;
String description, function, unlockedText;
final int unlockRound;
DialogPremium({Key key, this.title, this.descriptions, this.description2, this.text, this.img, this.onTap, this.onCancel})
final bool unlocked;
DialogPremium(
{Key key,
@required this.unlockRound,
this.description,
this.onTap,
this.onCancel,
@required this.unlocked,
this.unlockedText,
@required this.function})
: super(key: key) {
description2 = description2 ?? "";
description = description ?? "";
function = function ?? "";
unlockedText = unlockedText ?? "";
}
@override
@ -77,7 +88,7 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
alignment: AlignmentDirectional.topEnd,
children: [
Text(
widget.title + " ",
t("Go Premium") + " ",
style: GoogleFonts.archivoBlack(
fontSize: 24,
color: Colors.yellow[400],
@ -120,7 +131,7 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
height: 35,
),
Text(
widget.descriptions,
t("Unleash your potential with WorkoutTest Premium!"),
style: GoogleFonts.inter(
fontSize: 14,
color: Colors.white,
@ -142,26 +153,7 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
SizedBox(
height: 15,
),
Text(
widget.description2,
style: GoogleFonts.inter(
fontSize: 14,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
textAlign: TextAlign.center,
),
getDescription(),
SizedBox(
height: 62,
),
@ -185,7 +177,13 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
],
),
GestureDetector(
onTap: () => widget.onCancel == null ? Navigator.of(context).pop() : widget.onCancel,
onTap: () {
if (widget.onCancel == null) {
Navigator.of(context).pop();
} else {
widget.onCancel();
}
},
child: CircleAvatar(
backgroundColor: Colors.transparent,
radius: 28,
@ -197,6 +195,92 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
]);
}
RichText getDescription() {
return RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
children: getDescriptionText()));
}
List<TextSpan> getDescriptionText() {
List<TextSpan> list = List();
if (widget.unlocked) {
list.add(TextSpan(text: widget.unlockedText));
} else {
list.add(TextSpan(text: t("The")));
list.add(TextSpan(text: t(" ")));
list.add(
TextSpan(
text: t(widget.function),
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.yellow[300],
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
),
);
list.add(TextSpan(text: t(" ")));
list.add(TextSpan(text: t("feature is reachable after you finished")));
list.add(TextSpan(text: t(" ")));
list.add(
TextSpan(
text: widget.unlockRound == 1 ? t("the first") : t("the second"),
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.yellow[300],
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
),
);
list.add(TextSpan(text: t(" ")));
list.add(TextSpan(text: t("100% test circles")));
}
return list;
}
@override
void dispose() {
_timer.cancel();

View File

@ -1,11 +1,15 @@
import 'dart:async';
import 'dart:ui';
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:aitrainer_app/library/custom_icon_icons.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/workout_menu_tree.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/dialog_common.dart';
import 'package:badges/badges.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -16,13 +20,41 @@ import 'package:google_fonts/google_fonts.dart';
import 'menu_info_widget.dart';
// ignore: must_be_immutable
class MenuPageWidget extends StatelessWidget with Trans {
class MenuPageWidget extends StatefulWidget {
int parent;
final double baseWidth = 312;
final double baseHeight = 675.2;
MenuPageWidget({this.parent});
@override
_MenuPageWidgetState createState() => _MenuPageWidgetState();
}
class _MenuPageWidgetState extends State<MenuPageWidget> with Trans, Logging {
final double baseWidth = 312;
final double baseHeight = 675.2;
bool isFirst = true;
bool wait = false;
Timer _timer, _waitTimer;
@override
void initState() {
isFirst = true;
_timer = Timer.periodic(
Duration(milliseconds: 800),
(Timer timer) => setState(() {
if (!wait) {
isFirst = !isFirst;
//wait = true;
}
}));
_waitTimer = Timer.periodic(
Duration(milliseconds: 5000),
(Timer timer) => setState(() {
wait = !wait;
}));
super.initState();
}
@override
Widget build(BuildContext context) {
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
@ -30,7 +62,7 @@ class MenuPageWidget extends StatelessWidget with Trans {
double cWidth = MediaQuery.of(context).size.width;
double cHeight = MediaQuery.of(context).size.height;
return CustomScrollView(scrollDirection: Axis.vertical, slivers: buildMenuColumn(parent, context, menuBloc, cWidth, cHeight));
return CustomScrollView(scrollDirection: Axis.vertical, slivers: buildMenuColumn(widget.parent, context, menuBloc, cWidth, cHeight));
}
List<Widget> buildMenuColumn(int parent, BuildContext context, MenuBloc menuBloc, double cWidth, double cHeight) {
@ -170,7 +202,56 @@ class MenuPageWidget extends StatelessWidget with Trans {
return sliverList;
}
SliverGrid getInfoWidget(BuildContext context, MenuBloc menuBloc) {
SliverList getInfoWidget(BuildContext context, MenuBloc menuBloc) {
List<Widget> widgets = List();
if (context != null) {
menuBloc.setContext(context);
menuBloc.setMenuInfo();
widgets.add(SizedBox(
height: 10,
));
widgets.add(
GestureDetector(
onTap: () => {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return DialogCommon(
title: menuBloc.infoTitle,
descriptions: menuBloc.infoText2,
description2: menuBloc.infoText3,
text: "OK",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
})
},
child: Align(
alignment: Alignment.center,
child: SizedBox(
height: 35,
child: AnimatedSwitcher(
duration: Duration(milliseconds: 800),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(child: child, scale: animation);
},
child: isFirst && !wait
? Icon(
CustomIcon.question_circle,
color: Colors.yellow[300],
size: 40,
)
: Offstage())))),
);
}
SliverList sliverList = SliverList(delegate: SliverChildListDelegate(widgets));
return sliverList;
}
SliverGrid getInfoWidget2(BuildContext context, MenuBloc menuBloc) {
final List<Widget> _columnChildren = List();
if (context != null) {
menuBloc.setContext(context);
@ -281,4 +362,11 @@ class MenuPageWidget extends StatelessWidget with Trans {
child: _getButtonImage(workoutMenuTree, cWidth, cHeight),
);
}
@override
void dispose() {
_timer.cancel();
_waitTimer.cancel();
super.dispose();
}
}