moved to a wrapped scaffold, to get some consistency and one place to add the nav drawer
This commit is contained in:
parent
44cedd1a29
commit
af0be6fe8b
10 changed files with 577 additions and 580 deletions
|
@ -7,6 +7,7 @@ import 'package:fluttericon/font_awesome5_icons.dart';
|
|||
import 'package:pizzaplanner/entities/pizza_event.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
import 'package:pizzaplanner/main.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:pizzaplanner/util.dart';
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
|
@ -31,14 +32,9 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
return PizzaPlannerScaffold(
|
||||
title: const Text("Add Pizza Event"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 40,
|
||||
|
@ -201,8 +197,7 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
|||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter_markdown/flutter_markdown.dart';
|
|||
import 'package:pizzaplanner/entities/PizzaRecipe/ingredient.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class AddRecipePage extends StatefulWidget {
|
||||
|
@ -34,14 +35,9 @@ class AddRecipePageState extends State<AddRecipePage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Add Pizza Recipe"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ListView(
|
||||
return PizzaPlannerScaffold(
|
||||
title: const Text("Add Recipe"),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
|
@ -133,8 +129,7 @@ class AddRecipePageState extends State<AddRecipePage> {
|
|||
] + pizzaRecipe.ingredients.map((ingredient) => buildIngredientRow(ingredient)).toList() + [
|
||||
|
||||
],
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,20 +2,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
import 'package:pizzaplanner/pages/nav_drawer.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
||||
|
||||
class PickPizzaRecipePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: const Text("Pick Pizza Recipe"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ValueListenableBuilder(
|
||||
return PizzaPlannerScaffold(
|
||||
title: const Text("Pick Recipe"),
|
||||
body: ValueListenableBuilder(
|
||||
valueListenable: Hive.box<PizzaRecipe>("PizzaRecipes").listenable(),
|
||||
builder: (context, Box<PizzaRecipe> pizzaRecipesBox, widget) {
|
||||
return ListView.separated(
|
||||
|
@ -36,8 +31,7 @@ class PickPizzaRecipePage extends StatelessWidget {
|
|||
separatorBuilder: (BuildContext context, int i) => const Divider(),
|
||||
);
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import 'package:pizzaplanner/entities/pizza_event.dart';
|
|||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||
import 'package:pizzaplanner/main.dart';
|
||||
import 'package:pizzaplanner/pages/recipe_step_instruction_page.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
|
||||
import 'package:timezone/timezone.dart' as tz;
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
@ -56,14 +57,9 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("From notification"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
return PizzaPlannerScaffold(
|
||||
title: Text(recipeStep.name),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 10,
|
||||
|
@ -146,8 +142,7 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/ingredient.dart';
|
|||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_substep.dart';
|
||||
import 'package:pizzaplanner/main.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:pizzaplanner/util.dart';
|
||||
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
@ -26,14 +27,9 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
Widget build(BuildContext context) {
|
||||
final recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.length;
|
||||
final completedRecipeStepCount = widget.pizzaEvent.recipe.recipeSteps.where((recipeStep) => recipeStep.completed).length;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
return PizzaPlannerScaffold(
|
||||
title: Text(widget.pizzaEvent.name),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 15,
|
||||
|
@ -98,8 +94,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pizzaplanner/entities/pizza_event.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:pizzaplanner/widgets/pizza_event_widget.dart';
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
|
@ -17,13 +18,9 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
return PizzaPlannerScaffold(
|
||||
title: const Text("Pizza Events"),
|
||||
),
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ValueListenableBuilder(
|
||||
body: ValueListenableBuilder(
|
||||
valueListenable: Hive.box<PizzaEvent>("PizzaEvents").listenable(),
|
||||
builder: (context, Box<PizzaEvent> box, widget) {
|
||||
if (box.isEmpty){
|
||||
|
@ -37,7 +34,6 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
|||
);
|
||||
}
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
final dynamic newPizzaEvent = await Navigator.pushNamed(
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter_markdown/flutter_markdown.dart';
|
|||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
import 'package:pizzaplanner/entities/pizza_event.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class RecipePage extends StatefulWidget {
|
||||
|
@ -42,11 +43,8 @@ class RecipePageState extends State<RecipePage> {
|
|||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
return PizzaPlannerScaffold(
|
||||
title: Text(widget.pizzaRecipe.name),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -72,7 +70,7 @@ class RecipePageState extends State<RecipePage> {
|
|||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
|||
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_substep.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class RecipeStepInstructionPageArguments {
|
||||
|
@ -49,14 +50,10 @@ class RecipeStepInstructionState extends State<RecipeStepInstructionPage> {
|
|||
} else if (page > 0){
|
||||
nextButtonText = "Next step";
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
||||
return PizzaPlannerScaffold(
|
||||
title: Text(widget.recipeStep.name),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 90,
|
||||
|
@ -139,8 +136,7 @@ class RecipeStepInstructionState extends State<RecipeStepInstructionPage> {
|
|||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,20 +2,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
import 'package:pizzaplanner/pages/nav_drawer.dart';
|
||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
||||
|
||||
class RecipesPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: const Text("Recipes"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
return PizzaPlannerScaffold(
|
||||
title: const Text("Pizza Recipes"),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
const Expanded(
|
||||
flex: 5,
|
||||
|
@ -57,8 +52,7 @@ class RecipesPage extends StatelessWidget {
|
|||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
39
lib/pages/scaffold.dart
Normal file
39
lib/pages/scaffold.dart
Normal file
|
@ -0,0 +1,39 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:pizzaplanner/pages/nav_drawer.dart';
|
||||
|
||||
class PizzaPlannerScaffold extends StatelessWidget {
|
||||
late final Widget _body;
|
||||
late final Widget _appBarTitle;
|
||||
late final bool _resizeToAvoidBottomInset;
|
||||
late final EdgeInsets _edgeInsets;
|
||||
late final FloatingActionButton? _floatingActionButton;
|
||||
PizzaPlannerScaffold({
|
||||
required Widget body,
|
||||
required Widget title,
|
||||
bool resizeToAvoidBottomInset = false,
|
||||
EdgeInsets edgeInsets = const EdgeInsets.all(16),
|
||||
FloatingActionButton? floatingActionButton
|
||||
}){
|
||||
_body = body;
|
||||
_appBarTitle = title;
|
||||
_resizeToAvoidBottomInset = resizeToAvoidBottomInset;
|
||||
_edgeInsets = edgeInsets;
|
||||
_floatingActionButton = floatingActionButton;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
padding: _edgeInsets,
|
||||
child: _body
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: _appBarTitle,
|
||||
),
|
||||
resizeToAvoidBottomInset: _resizeToAvoidBottomInset,
|
||||
drawer: NavDrawer(),
|
||||
floatingActionButton: _floatingActionButton,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue