mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 23:42:00 +01:00
Remove the CustomScrollView
This was only needed for the custom scrolling background / header that was removed some time ago
This commit is contained in:
@@ -34,7 +34,7 @@ class RoutineListScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const WorkoutOverviewAppBar(),
|
||||
appBar: const RoutineListAppBar(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
|
||||
@@ -17,20 +17,12 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/routine.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
import 'package:wger/widgets/routines/app_bar.dart';
|
||||
import 'package:wger/widgets/routines/workout_logs.dart';
|
||||
|
||||
enum WorkoutOptions {
|
||||
edit,
|
||||
delete,
|
||||
}
|
||||
|
||||
class WorkoutLogsScreen extends StatelessWidget {
|
||||
const WorkoutLogsScreen();
|
||||
|
||||
@@ -43,82 +35,25 @@ class WorkoutLogsScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const appBarForeground = Colors.white;
|
||||
final routine = ModalRoute.of(context)!.settings.arguments as Routine;
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
iconTheme: const IconThemeData(color: appBarForeground),
|
||||
backgroundColor: wgerPrimaryColor,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
titlePadding: const EdgeInsets.fromLTRB(56, 0, 56, 16),
|
||||
title: Text(
|
||||
routine.name,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(color: appBarForeground),
|
||||
appBar: RoutineDetailAppBar(routine),
|
||||
body: FutureBuilder(
|
||||
future: _loadFullWorkout(context, routine.id!),
|
||||
builder: (context, AsyncSnapshot<Routine> snapshot) => ListView(
|
||||
children: [
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
else
|
||||
Consumer<RoutinesProvider>(
|
||||
builder: (context, value, child) => WorkoutLogs(routine),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
PopupMenuButton<WorkoutOptions>(
|
||||
icon: const Icon(Icons.more_vert, color: appBarForeground),
|
||||
onSelected: (value) {
|
||||
// Edit
|
||||
if (value == WorkoutOptions.edit) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
WorkoutForm(routine),
|
||||
),
|
||||
);
|
||||
|
||||
// Delete
|
||||
} else if (value == WorkoutOptions.delete) {
|
||||
Provider.of<RoutinesProvider>(context, listen: false)
|
||||
.deleteWorkout(routine.id!);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// Toggle Mode
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.edit,
|
||||
child: Text(AppLocalizations.of(context).edit),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.delete,
|
||||
child: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _loadFullWorkout(context, routine.id!),
|
||||
builder: (context, AsyncSnapshot<Routine> snapshot) => SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
else
|
||||
Consumer<RoutinesProvider>(
|
||||
builder: (context, value, child) => WorkoutLogs(routine),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,22 +17,13 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/routine.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/routine_logs_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
import 'package:wger/widgets/core/progress_indicator.dart';
|
||||
import 'package:wger/widgets/routines/app_bar.dart';
|
||||
import 'package:wger/widgets/routines/routine_detail.dart';
|
||||
|
||||
enum WorkoutOptions {
|
||||
edit,
|
||||
delete,
|
||||
logs,
|
||||
}
|
||||
|
||||
class RoutineScreen extends StatelessWidget {
|
||||
const RoutineScreen();
|
||||
|
||||
@@ -45,90 +36,22 @@ class RoutineScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const appBarForeground = Colors.white;
|
||||
final routine = ModalRoute.of(context)!.settings.arguments as Routine;
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
iconTheme: const IconThemeData(color: appBarForeground),
|
||||
backgroundColor: wgerPrimaryColor,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
titlePadding: const EdgeInsets.fromLTRB(56, 0, 56, 16),
|
||||
title: Text(
|
||||
routine.name,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(color: appBarForeground),
|
||||
appBar: RoutineDetailAppBar(routine),
|
||||
body: FutureBuilder(
|
||||
future: _loadFullWorkout(context, routine.id!),
|
||||
builder: (context, AsyncSnapshot<Routine> snapshot) => ListView(
|
||||
children: [
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
const BoxedProgressIndicator()
|
||||
else
|
||||
Consumer<RoutinesProvider>(
|
||||
builder: (context, value, child) => RoutineDetail(routine),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
PopupMenuButton<WorkoutOptions>(
|
||||
icon: const Icon(Icons.more_vert, color: appBarForeground),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case WorkoutOptions.edit:
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
WorkoutForm(routine),
|
||||
),
|
||||
);
|
||||
|
||||
case WorkoutOptions.logs:
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
WorkoutLogsScreen.routeName,
|
||||
arguments: routine,
|
||||
);
|
||||
|
||||
case WorkoutOptions.delete:
|
||||
Provider.of<RoutinesProvider>(context, listen: false)
|
||||
.deleteWorkout(routine.id!);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.logs,
|
||||
child: Text(AppLocalizations.of(context).labelWorkoutLogs),
|
||||
),
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.edit,
|
||||
child: Text(AppLocalizations.of(context).edit),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<WorkoutOptions>(
|
||||
value: WorkoutOptions.delete,
|
||||
child: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _loadFullWorkout(context, routine.id!),
|
||||
builder: (context, AsyncSnapshot<Routine> snapshot) => SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
else
|
||||
Consumer<RoutinesProvider>(
|
||||
builder: (context, value, child) => RoutineDetail(routine),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
15
lib/widgets/core/progress_indicator.dart
Normal file
15
lib/widgets/core/progress_indicator.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BoxedProgressIndicator extends StatelessWidget {
|
||||
const BoxedProgressIndicator({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const SizedBox(
|
||||
height: 200,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,29 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/routine.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
import 'package:wger/screens/exercises_screen.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/screens/routine_logs_screen.dart';
|
||||
import 'package:wger/widgets/routines/forms.dart';
|
||||
|
||||
enum _WorkoutAppBarOptions {
|
||||
enum _RoutineAppBarOptions {
|
||||
list,
|
||||
contribute,
|
||||
}
|
||||
|
||||
class WorkoutOverviewAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const WorkoutOverviewAppBar();
|
||||
enum _RoutineDetailBarOptions {
|
||||
edit,
|
||||
delete,
|
||||
logs,
|
||||
}
|
||||
|
||||
class RoutineListAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const RoutineListAppBar();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
@@ -36,22 +49,22 @@ class WorkoutOverviewAppBar extends StatelessWidget implements PreferredSizeWidg
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<_WorkoutAppBarOptions>(
|
||||
value: _WorkoutAppBarOptions.list,
|
||||
PopupMenuItem<_RoutineAppBarOptions>(
|
||||
value: _RoutineAppBarOptions.list,
|
||||
child: Text(AppLocalizations.of(context).exerciseList),
|
||||
),
|
||||
PopupMenuItem<_WorkoutAppBarOptions>(
|
||||
value: _WorkoutAppBarOptions.contribute,
|
||||
PopupMenuItem<_RoutineAppBarOptions>(
|
||||
value: _RoutineAppBarOptions.contribute,
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
),
|
||||
];
|
||||
},
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case _WorkoutAppBarOptions.contribute:
|
||||
case _RoutineAppBarOptions.contribute:
|
||||
Navigator.of(context).pushNamed(AddExerciseScreen.routeName);
|
||||
break;
|
||||
case _WorkoutAppBarOptions.list:
|
||||
case _RoutineAppBarOptions.list:
|
||||
Navigator.of(context).pushNamed(ExercisesScreen.routeName);
|
||||
break;
|
||||
}
|
||||
@@ -64,3 +77,63 @@ class WorkoutOverviewAppBar extends StatelessWidget implements PreferredSizeWidg
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
class RoutineDetailAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Routine routine;
|
||||
|
||||
const RoutineDetailAppBar(this.routine);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
title: Text(routine.name),
|
||||
actions: [
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<_RoutineDetailBarOptions>(
|
||||
value: _RoutineDetailBarOptions.logs,
|
||||
child: Text(AppLocalizations.of(context).labelWorkoutLogs),
|
||||
),
|
||||
PopupMenuItem<_RoutineDetailBarOptions>(
|
||||
value: _RoutineDetailBarOptions.edit,
|
||||
child: Text(AppLocalizations.of(context).edit),
|
||||
),
|
||||
PopupMenuItem<_RoutineDetailBarOptions>(
|
||||
value: _RoutineDetailBarOptions.delete,
|
||||
child: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
];
|
||||
},
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case _RoutineDetailBarOptions.edit:
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
arguments: FormScreenArguments(
|
||||
AppLocalizations.of(context).edit,
|
||||
WorkoutForm(routine),
|
||||
),
|
||||
);
|
||||
|
||||
case _RoutineDetailBarOptions.logs:
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
WorkoutLogsScreen.routeName,
|
||||
arguments: routine,
|
||||
);
|
||||
|
||||
case _RoutineDetailBarOptions.delete:
|
||||
Provider.of<RoutinesProvider>(context, listen: false).deleteWorkout(routine.id!);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user