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
+2 -1
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();
+176
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();
}
}
+112 -28
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();
+93 -5
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();
}
}