mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Cleanup app bars
The dashboard has the main app bar that allows to change the settings, while each screen has its own with custom actions
This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
"@successfullySaved": {
|
||||
"description": "Message when an item was successfully saved"
|
||||
},
|
||||
"exerciseList": "Exercise list",
|
||||
"exercise": "Exercise",
|
||||
"@exercise": {
|
||||
"description": "An exercise for a workout"
|
||||
@@ -584,6 +585,7 @@
|
||||
"images": "Images",
|
||||
"language": "Language",
|
||||
"addExercise": "Add exercise",
|
||||
"contributeExercise": "Contribute an exercise",
|
||||
"translation": "Translation",
|
||||
"translateExercise": "Translate this exercise now",
|
||||
"baseData": "Basics in English",
|
||||
|
||||
@@ -70,9 +70,7 @@ class _AddExerciseScreenState extends State<AddExerciseScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(
|
||||
AppLocalizations.of(context).addExercise,
|
||||
),
|
||||
appBar: EmptyAppBar(AppLocalizations.of(context).contributeExercise),
|
||||
body: Stepper(
|
||||
controlsBuilder: _controlsBuilder,
|
||||
steps: [
|
||||
|
||||
@@ -34,7 +34,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(AppLocalizations.of(context).labelDashboard),
|
||||
appBar: MainAppBar(AppLocalizations.of(context).labelDashboard),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
@@ -24,7 +24,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
|
||||
final exercisesList = Provider.of<ExercisesProvider>(context).filteredExerciseBases;
|
||||
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(AppLocalizations.of(context).exercises),
|
||||
appBar: EmptyAppBar(AppLocalizations.of(context).exercises),
|
||||
body: Column(
|
||||
children: [
|
||||
FilterRow(),
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -35,7 +34,7 @@ class GalleryScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(AppLocalizations.of(context).gallery),
|
||||
appBar: EmptyAppBar(AppLocalizations.of(context).gallery),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
|
||||
@@ -31,8 +31,8 @@ import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/dashboard.dart';
|
||||
import 'package:wger/screens/exercises_screen.dart';
|
||||
import 'package:wger/screens/gallery_screen.dart';
|
||||
import 'package:wger/screens/nutritional_plans_screen.dart';
|
||||
import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/screens/workout_plans_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
@@ -64,8 +64,7 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
|
||||
final _screenList = <Widget>[
|
||||
DashboardScreen(),
|
||||
WorkoutPlansScreen(),
|
||||
// Replaced [NutritionScreen] for debugging purposes
|
||||
ExercisesScreen(),
|
||||
NutritionScreen(),
|
||||
WeightScreen(),
|
||||
const GalleryScreen(),
|
||||
];
|
||||
|
||||
@@ -31,7 +31,7 @@ class NutritionScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(AppLocalizations.of(context).nutritionalPlans),
|
||||
appBar: EmptyAppBar(AppLocalizations.of(context).nutritionalPlans),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () async {
|
||||
|
||||
@@ -31,7 +31,7 @@ class WeightScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(AppLocalizations.of(context).weight),
|
||||
appBar: EmptyAppBar(AppLocalizations.of(context).weight),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () async {
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/models/workouts/workout_plan.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/workouts/app_bar.dart';
|
||||
import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/workouts/workout_plans_list.dart';
|
||||
|
||||
@@ -33,9 +32,7 @@ class WorkoutPlansScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: WgerAppBar(
|
||||
AppLocalizations.of(context).labelWorkoutPlans,
|
||||
),
|
||||
appBar: WorkoutOverviewAppBar(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
|
||||
@@ -27,10 +27,10 @@ import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/widgets/core/about.dart';
|
||||
|
||||
class WgerAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
class MainAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
final String _title;
|
||||
|
||||
WgerAppBar(this._title);
|
||||
MainAppBar(this._title);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -86,3 +86,21 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
/// App bar that only displays a title
|
||||
class EmptyAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
final String _title;
|
||||
|
||||
EmptyAppBar(this._title);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
title: Text(_title),
|
||||
actions: const [],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class _FilterRowState extends State<FilterRow> {
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<ExerciseMoreOption>(
|
||||
child: Text(AppLocalizations.of(context).addExercise),
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
value: ExerciseMoreOption.ADD_EXERCISE,
|
||||
)
|
||||
];
|
||||
|
||||
62
lib/widgets/workouts/app_bar.dart
Normal file
62
lib/widgets/workouts/app_bar.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
import 'package:wger/screens/exercises_screen.dart';
|
||||
|
||||
enum _WorkoutAppBarOptions {
|
||||
list,
|
||||
contribute,
|
||||
}
|
||||
|
||||
class WorkoutOverviewAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
title: Text(AppLocalizations.of(context).labelWorkoutPlans),
|
||||
actions: [
|
||||
PopupMenuButton(itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<_WorkoutAppBarOptions>(
|
||||
value: _WorkoutAppBarOptions.list,
|
||||
child: Text(AppLocalizations.of(context).exerciseList),
|
||||
),
|
||||
PopupMenuItem<_WorkoutAppBarOptions>(
|
||||
value: _WorkoutAppBarOptions.contribute,
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
),
|
||||
];
|
||||
}, onSelected: (value) {
|
||||
switch (value) {
|
||||
case _WorkoutAppBarOptions.contribute:
|
||||
Navigator.of(context).pushNamed(AddExerciseScreen.routeName);
|
||||
break;
|
||||
case _WorkoutAppBarOptions.list:
|
||||
Navigator.of(context).pushNamed(ExercisesScreen.routeName);
|
||||
break;
|
||||
}
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
Reference in New Issue
Block a user