mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-05 04:57:37 +01:00
Make workout day header dismissible, with placeholder actions
This commit is contained in:
@@ -24,12 +24,12 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
title: Text(AppLocalizations.of(context).labelWorkoutPlan),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.bar_chart),
|
||||
icon: Icon(Icons.menu),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Text("Would open weight log form"),
|
||||
content: Text("Would open options"),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
@@ -53,25 +53,6 @@ class _WorkoutPlanScreenState extends State<WorkoutPlanScreen> {
|
||||
return Scaffold(
|
||||
appBar: getAppBar(),
|
||||
//drawer: AppDrawer(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.play_arrow),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Text("Would start gym mode"),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
"Cancel",
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
body: FutureBuilder<WorkoutPlan>(
|
||||
future: _loadWorkoutPlanDetail(context, workoutPlan.id),
|
||||
builder: (context, AsyncSnapshot<WorkoutPlan> snapshot) =>
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager.
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wger Workout Manager is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wger/locale/locales.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
@@ -64,20 +80,7 @@ class WorkoutDayWidget extends StatelessWidget {
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(color: Colors.black12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
_day.description,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
Text(_day.getDaysText),
|
||||
],
|
||||
),
|
||||
),
|
||||
DayHeaderDismissible(day: _day),
|
||||
..._day.sets
|
||||
.map(
|
||||
(set) => getSetRow(set),
|
||||
@@ -87,11 +90,11 @@ class WorkoutDayWidget extends StatelessWidget {
|
||||
child: Text('Add exercise to day'),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SetFormWidget(
|
||||
formKey: _formKey, exercisesController: exercisesController);
|
||||
});
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SetFormWidget(formKey: _formKey, exercisesController: exercisesController);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
@@ -103,6 +106,109 @@ class WorkoutDayWidget extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class DayHeaderDismissible extends StatelessWidget {
|
||||
const DayHeaderDismissible({
|
||||
Key key,
|
||||
@required Day day,
|
||||
}) : _day = day,
|
||||
super(key: key);
|
||||
|
||||
final Day _day;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dismissible(
|
||||
key: Key(_day.id.toString()),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: Colors.black12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
_day.description,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
Text(_day.getDaysText),
|
||||
],
|
||||
),
|
||||
),
|
||||
secondaryBackground: Container(
|
||||
color: Theme.of(context).primaryColor,
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.bar_chart,
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
'Log weights',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
background: Container(
|
||||
color: Theme.of(context).accentColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Gym mode',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
confirmDismiss: (direction) async {
|
||||
// Weight log
|
||||
if (direction == DismissDirection.endToStart) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Text('Would open weight log form for this day'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
"Close",
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
// Gym mode
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Text('Would start gym mode for this day'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
"Close",
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SetFormWidget extends StatefulWidget {
|
||||
const SetFormWidget({
|
||||
Key key,
|
||||
|
||||
Reference in New Issue
Block a user