wt1.1a flutter_bloc
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BottomNavigator {
|
||||
BottomNavigationBar buildBottomNavigator(BuildContext context, State state) {
|
||||
class BottomNavigator extends StatefulWidget {
|
||||
int bottomNavIndex = 0;
|
||||
BottomNavigator({this.bottomNavIndex}) {
|
||||
this.bottomNavIndex = bottomNavIndex;
|
||||
}
|
||||
|
||||
@override
|
||||
_NawDrawerWidget createState() => _NawDrawerWidget();
|
||||
}
|
||||
|
||||
class _NawDrawerWidget extends State<BottomNavigator> {
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return BottomNavigationBar(
|
||||
currentIndex: 0, // this will be set when a new tab is tapped
|
||||
backgroundColor: Colors.black12,
|
||||
currentIndex: widget.bottomNavIndex, // this will be set when a new tab is tapped
|
||||
backgroundColor: Colors.transparent,
|
||||
selectedItemColor: Colors.yellow,
|
||||
unselectedItemColor: Colors.lightGreen,
|
||||
type: BottomNavigationBarType.shifting,
|
||||
//type: BottomNavigationBarType.shifting,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: true,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
@@ -18,23 +38,29 @@ class BottomNavigator {
|
||||
title: new Text(AppLocalizations.of(context).translate("Home")),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: new Icon(Icons.event, color: Colors.lightGreen),
|
||||
backgroundColor: Colors.black12,
|
||||
icon: new Icon(Icons.confirmation_number, color: Colors.lightGreen),
|
||||
activeIcon: new Icon(Icons.event, color: Colors.yellow,),
|
||||
title: new Text(AppLocalizations.of(context).translate("Events")),
|
||||
),
|
||||
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
icon: Icon(Icons.person, color: Colors.lightGreen,),
|
||||
activeIcon: new Icon(Icons.person, color: Colors.yellow,),
|
||||
title: Text(AppLocalizations.of(context).translate("Account"))
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
icon: Icon(Icons.settings, color: Colors.lightGreen),
|
||||
activeIcon: new Icon(Icons.settings, color: Colors.yellow,),
|
||||
title: Text(AppLocalizations.of(context).translate("Settings"))
|
||||
)
|
||||
],
|
||||
onTap:(index) {
|
||||
// ignore: invalid_use_of_protected_member
|
||||
setState(() {
|
||||
widget.bottomNavIndex = index;
|
||||
});
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.of(context).pop();
|
||||
@@ -59,4 +85,6 @@ class BottomNavigator {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import 'package:aitrainer_app/viewmodel/exercise_changing_view_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:aitrainer_app/viewmodel/customer_view_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CustomerListWidget extends StatefulWidget {
|
||||
static const routeName = '/customer_list';
|
||||
final List<CustomerViewModel> customers;
|
||||
|
||||
CustomerListWidget({this.customers});
|
||||
|
||||
@override
|
||||
_CustomerListWidget createState() => _CustomerListWidget();
|
||||
|
||||
}
|
||||
|
||||
class _CustomerListWidget extends State<CustomerListWidget> {
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
itemCount: widget.customers.length,
|
||||
itemBuilder: (context, index) {
|
||||
|
||||
final customer = widget.customers[index];
|
||||
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.all(10),
|
||||
leading:Icon(Icons.accessibility),
|
||||
title: Text(customer.name + " " + customer.firstName),
|
||||
subtitle:
|
||||
Container(
|
||||
child: Visibility(
|
||||
visible: customer.visibleDetails,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(customer.birthYear.toString() + " years, " + customer.sex),
|
||||
new RaisedButton(
|
||||
child: new Text('Modify'),
|
||||
color: Color.fromRGBO(244, 122, 22, 0.9),
|
||||
onPressed: () => {
|
||||
|
||||
},
|
||||
),
|
||||
new RaisedButton(
|
||||
child: new Text('Select'),
|
||||
color: Colors.blueGrey,
|
||||
onPressed: () => {
|
||||
Provider.of<ExerciseChangingViewModel>(context, listen: false).setCustomer(customer.customer),
|
||||
Navigator.pop(context)
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () { setState( () {
|
||||
customer.visibleDetails = customer.visibleDetails ? false : true;
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
|
||||
class CustomPicker extends CommonPickerModel {
|
||||
String digits(int value, int length) {
|
||||
return '$value'.padLeft(length, "0");
|
||||
}
|
||||
|
||||
CustomPicker({DateTime currentTime, LocaleType locale}) : super(locale: locale) {
|
||||
this.currentTime = currentTime ?? DateTime.now();
|
||||
this.setLeftIndex(this.currentTime.hour);
|
||||
this.setMiddleIndex(this.currentTime.minute);
|
||||
this.setRightIndex(this.currentTime.second);
|
||||
}
|
||||
|
||||
@override
|
||||
String leftStringAtIndex(int index) {
|
||||
if (index >= 0 && index < 24) {
|
||||
return this.digits(index, 2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String middleStringAtIndex(int index) {
|
||||
if (index >= 0 && index < 60) {
|
||||
return this.digits(index, 2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String rightStringAtIndex(int index) {
|
||||
if (index >= 0 && index < 60) {
|
||||
return this.digits(index, 2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String leftDivider() {
|
||||
return "|";
|
||||
}
|
||||
|
||||
@override
|
||||
String rightDivider() {
|
||||
return "|";
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> layoutProportions() {
|
||||
return [1, 2, 1];
|
||||
}
|
||||
|
||||
@override
|
||||
DateTime finalTime() {
|
||||
return currentTime.isUtc
|
||||
? DateTime.utc(currentTime.year, currentTime.month, currentTime.day,
|
||||
this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex())
|
||||
: DateTime(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(),
|
||||
this.currentMiddleIndex(), this.currentRightIndex());
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import 'package:aitrainer_app/viewmodel/exercise_changing_view_model.dart';
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_view_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ExerciseTypeListWidget extends StatefulWidget {
|
||||
final List<ExerciseTypeViewModel> exerciseTypes;
|
||||
ExerciseTypeListWidget({this.exerciseTypes});
|
||||
|
||||
@override
|
||||
_ExerciseTypeListWidgetState createState() => _ExerciseTypeListWidgetState();
|
||||
}
|
||||
|
||||
class _ExerciseTypeListWidgetState extends State<ExerciseTypeListWidget> {
|
||||
//static const routeName = '/exercise_type_list';
|
||||
bool visible = false;
|
||||
|
||||
// Push the page and remove everything else
|
||||
navigateToPage(BuildContext context, String page) {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(page, (Route<dynamic> route) => false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: widget.exerciseTypes.length,
|
||||
itemBuilder: (context, index) {
|
||||
|
||||
final exerciseType = widget.exerciseTypes[index];
|
||||
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.all(10),
|
||||
leading: Icon(Icons.directions_run),
|
||||
title: Text(exerciseType.name),
|
||||
subtitle:
|
||||
Container(
|
||||
child: Visibility(
|
||||
visible: exerciseType.visible,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(exerciseType.description),
|
||||
new RaisedButton(
|
||||
child: new Text('Modify'),
|
||||
color: Color.fromRGBO(244, 122, 22, 0.9),
|
||||
onPressed: () => {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'exerciseTypeModifyPage',
|
||||
arguments: exerciseType
|
||||
)
|
||||
},
|
||||
),
|
||||
new RaisedButton(
|
||||
child: new Text('Select'),
|
||||
color: Colors.blueGrey,
|
||||
onPressed: () => {
|
||||
Navigator.pop(context),
|
||||
Provider.of<ExerciseChangingViewModel>(context, listen: false).setExerciseType(exerciseType.exerciseType),
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () { setState( () {
|
||||
exerciseType.visible = true;
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+62
-30
@@ -1,12 +1,17 @@
|
||||
import 'package:aitrainer_app/bloc/session/session_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:aitrainer_app/view/login.dart';
|
||||
import 'package:aitrainer_app/view/menu_page.dart';
|
||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||
import 'package:aitrainer_app/view/registration.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'bottom_nav.dart';
|
||||
import 'nav_drawer.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'loading.dart';
|
||||
|
||||
|
||||
class AitrainerHome extends StatefulWidget {
|
||||
_HomePageState _state;
|
||||
@@ -15,10 +20,6 @@ class AitrainerHome extends StatefulWidget {
|
||||
_state = new _HomePageState();
|
||||
return _state;
|
||||
}
|
||||
|
||||
void callback() {
|
||||
_state.setLangNoContext();
|
||||
}
|
||||
}
|
||||
|
||||
class _HomePageState extends State<AitrainerHome> {
|
||||
@@ -28,30 +29,61 @@ class _HomePageState extends State<AitrainerHome> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MenuPage menu = MenuPage();
|
||||
BottomNavigator bottomNav = BottomNavigator();
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
drawer: NavDrawer(),
|
||||
body:Container(
|
||||
child: MenuPage(parent: 0),
|
||||
),
|
||||
bottomNavigationBar: bottomNav.buildBottomNavigator(context, widget._state)
|
||||
);
|
||||
}
|
||||
|
||||
void setLangNoContext() {
|
||||
print("--- Callback ");
|
||||
setState(() {
|
||||
final AppLanguage appLanguage = AppLanguage();
|
||||
AppLocalizations.of(context).setLocale(appLanguage.appLocal);
|
||||
AppLocalizations.of(context).load();
|
||||
print("--- Lang for context reloaded");
|
||||
/// We require the initializers to run after the loading screen is rendered
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
runDelayedEvent();
|
||||
});
|
||||
}
|
||||
|
||||
Future runDelayedEvent() async {
|
||||
await Future.delayed(Duration(seconds: 3), () async {
|
||||
if ( context != null) {
|
||||
// ignore: close_sinks
|
||||
SessionBloc sessionBloc = BlocProvider.of<SessionBloc>(context);
|
||||
if (sessionBloc.state != SessionReady()) {
|
||||
sessionBloc.add(SessionStart());
|
||||
// ignore: close_sinks
|
||||
SettingsBloc settingsBloc = BlocProvider.of<SettingsBloc>(context);
|
||||
settingsBloc.loadLang();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: Container(
|
||||
child: BlocConsumer<SessionBloc, SessionState>(
|
||||
listener: (context, state) {
|
||||
if ( state is SessionFailure) {
|
||||
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is SessionInitial) {
|
||||
return LoadingScreenMain();
|
||||
} else if (state is SessionLoading) {
|
||||
print("loading");
|
||||
return LoadingScreenMain();
|
||||
} else if (state is SessionReady) {
|
||||
print("ready");
|
||||
if (Auth().startPage == 'login') {
|
||||
return LoginPage();
|
||||
} else if (Auth().startPage == 'registration') {
|
||||
return RegistrationPage();
|
||||
} else {
|
||||
return MenuPage(parent: 0);
|
||||
}
|
||||
} else {
|
||||
print("else");
|
||||
return MenuPage(parent: 0);
|
||||
}
|
||||
}
|
||||
),
|
||||
),
|
||||
//bottomNavigationBar: BottomNavigator(bottomNavIndex: 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+54
-38
@@ -1,17 +1,7 @@
|
||||
import 'package:aitrainer_app/util/message_state.dart';
|
||||
import 'package:aitrainer_app/util/session.dart';
|
||||
import 'package:aitrainer_app/widgets/home.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:aitrainer_app/util/loading_screen.dart';
|
||||
|
||||
class LoadingScreenMain extends StatefulWidget {
|
||||
@override
|
||||
LoadingScreenMainState createState() => LoadingScreenMainState();
|
||||
}
|
||||
|
||||
class LoadingScreenMainState extends State<LoadingScreenMain> {
|
||||
|
||||
class LoadingScreenMain extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Image _backgroundImage = Image.asset('asset/image/WT01_loading_layers.png',
|
||||
@@ -20,34 +10,60 @@ class LoadingScreenMainState extends State<LoadingScreenMain> {
|
||||
width: double.infinity,
|
||||
alignment: Alignment.center,
|
||||
);
|
||||
dynamic _timer = <dynamic>[TimeMessages.timer];
|
||||
return Scaffold(
|
||||
body: LoadingScreen(
|
||||
initializers: _timer,
|
||||
navigateToWidget: AitrainerHome(),
|
||||
loaderColor: Colors.yellow,
|
||||
image: _backgroundImage,
|
||||
backgroundColor: Colors.black,
|
||||
styleTextUnderTheLoader: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.lightGreenAccent),
|
||||
)
|
||||
backgroundColor: Colors.white,
|
||||
body: new InkWell(
|
||||
child: new Stack(
|
||||
fit: StackFit.expand,
|
||||
children: <Widget>[
|
||||
/// Paint the area where the inner widgets are loaded with the
|
||||
/// background to keep consistency with the screen background
|
||||
new Container(
|
||||
decoration: BoxDecoration(color: Colors.white),
|
||||
),
|
||||
/// Render the background image
|
||||
new Container(
|
||||
child: _backgroundImage,
|
||||
),
|
||||
/// Render the Title widget, loader and messages below each other
|
||||
new Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
flex: 3,
|
||||
child: new Container(
|
||||
child: new Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(top: 30.0),
|
||||
),
|
||||
|
||||
],
|
||||
)),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
/// Loader Animation Widget
|
||||
CircularProgressIndicator(
|
||||
valueColor: new AlwaysStoppedAnimation<Color>(
|
||||
Colors.lightGreenAccent),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
),
|
||||
//Text(getMessage, style: widget.styleTextUnderTheLoader),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class TimeMessages {
|
||||
static Future timer(MessageState state, Function callback) async {
|
||||
//while (true) {
|
||||
await Future.delayed(Duration(seconds: 2), () {
|
||||
state.setMessage = DateTime.now().toIso8601String();
|
||||
print("---- TimeMessages initializer");
|
||||
Session session = Session();
|
||||
session.fetchSessionAndNavigate(callback);
|
||||
});
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MenuPageWidget extends StatelessWidget {
|
||||
int parent;
|
||||
|
||||
MenuPageWidget({this.parent});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
|
||||
return CustomScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: <Widget>[
|
||||
buildMenuColumn(parent, context, menuBloc)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
SliverList buildMenuColumn(int parent, BuildContext context, MenuBloc menuBloc) {
|
||||
final List<Widget> _columnChildren = List();
|
||||
|
||||
menuBloc.menuTreeRepository.getBranch(menuBloc.parent).forEach((treeName, value) {
|
||||
WorkoutTree workoutTree = value as WorkoutTree;
|
||||
_columnChildren.add(
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
child: Center(
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
overflow: Overflow.visible,
|
||||
children: [
|
||||
FlatButton(
|
||||
child: _getButtonImage(workoutTree),
|
||||
padding: EdgeInsets.all(0.0),
|
||||
onPressed:() =>
|
||||
{
|
||||
print("Hi!, Menu clicked " + workoutTree.id.toString()),
|
||||
if ( workoutTree.child == false ) {
|
||||
menuBloc.add(MenuTreeDown(parent: workoutTree.id)),
|
||||
|
||||
} else {
|
||||
menuBloc.add(MenuClickExercise(exerciseTypeId: workoutTree.id)),
|
||||
if ( Auth().userLoggedIn == null ) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('Please log in'),
|
||||
style: TextStyle(color: Colors.white))
|
||||
))
|
||||
} else {
|
||||
if ( workoutTree.exerciseType.name == "Custom") {
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseCustomPage',
|
||||
arguments: workoutTree.exerciseType),
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseNewPage',
|
||||
arguments: workoutTree.exerciseType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
),
|
||||
InkWell(
|
||||
child: Text(workoutTree.name, style: TextStyle(color: workoutTree.color, fontSize: workoutTree.fontSize, fontFamily: 'Arial', fontWeight: FontWeight.w900 ),),
|
||||
highlightColor: workoutTree.color,
|
||||
)]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
//_columnChildren.add(Spacer(flex: 3));
|
||||
SliverList sliverList =
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
_columnChildren
|
||||
)
|
||||
);
|
||||
|
||||
return sliverList;
|
||||
}
|
||||
|
||||
dynamic _getButtonImage(WorkoutTree workoutTree) {
|
||||
dynamic image;
|
||||
/*String url = workoutTree.imageName;
|
||||
if ( workoutTree.imageName.startsWith("https") ) {
|
||||
image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
} else {
|
||||
image = Image.asset(workoutTree.imageName, height: 180,);
|
||||
}*/
|
||||
|
||||
try {
|
||||
image = Image.asset(
|
||||
workoutTree.imageName,
|
||||
height: 180,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url = Auth.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
return image;
|
||||
},
|
||||
);
|
||||
} on Exception catch(_) {
|
||||
String url = Auth.mediaUrl + '/images/' + workoutTree.imageName;
|
||||
image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NavDrawer extends StatefulWidget {
|
||||
|
||||
@override
|
||||
_NawDrawerWidget createState() => _NawDrawerWidget();
|
||||
}
|
||||
|
||||
class _NawDrawerWidget extends State<NavDrawer> {
|
||||
final Auth auth = Auth();
|
||||
final AppLanguage appLanguage = AppLanguage();
|
||||
Locale _locale;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
DrawerHeader(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('Customers And Exercises'),
|
||||
style: TextStyle(color: Colors.blue, fontSize: 25),
|
||||
),
|
||||
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.home),
|
||||
title: Text( AppLocalizations.of(context).translate('Home')),
|
||||
onTap: () => Navigator.of(context).pushNamed('home'),
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.people),
|
||||
title: Text( AppLocalizations.of(context).translate('Customers')),
|
||||
onTap: () => Navigator.of(context).pushNamed('customersPage'),
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.directions_run),
|
||||
title: Text(AppLocalizations.of(context).translate('Exercises')),
|
||||
onTap: () =>
|
||||
Navigator.of(context).pushNamed('exerciseTypeListPage'),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.arrow_upward),
|
||||
title: Text(AppLocalizations.of(context).translate("TRAINING!")),
|
||||
onTap: () => Navigator.of(context).pushNamed('exerciseNewPage'),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.perm_identity),
|
||||
title: Text(AppLocalizations.of(context).translate('Login')),
|
||||
onTap: () => Navigator.of(context).pushNamed('login'),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.cancel),
|
||||
title: Text(AppLocalizations.of(context).translate('Logout')),
|
||||
onTap: () =>
|
||||
{
|
||||
auth.logout(),
|
||||
Navigator.of(context).pushNamed('home'),
|
||||
}
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.hearing),
|
||||
title: Text(AppLocalizations.of(context).translate('Change Language')),
|
||||
onTap: () => _tapped(),
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _tapped() => {
|
||||
/* _locale = Locale("hu"),
|
||||
appLanguage.changeLanguage(_locale),
|
||||
AppLocalizations.of(context).setLocale(_locale),
|
||||
AppLocalizations.of(context).load() */
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadingDialog extends StatelessWidget {
|
||||
static void show(BuildContext context, {Key key}) => showDialog<void>(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => LoadingDialog(key: key),
|
||||
).then((_) => FocusScope.of(context).requestFocus(FocusNode()));
|
||||
|
||||
static void hide(BuildContext context) => Navigator.pop(context);
|
||||
|
||||
LoadingDialog({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Center(
|
||||
child: Card(
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
padding: EdgeInsets.all(12.0),
|
||||
child: CircularProgressIndicator(backgroundColor: Colors.transparent,),
|
||||
color: Colors.transparent,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user