fixed linting warnings in the rest of the dart code
This commit is contained in:
parent
ff2dd7b3d6
commit
e388a7140e
7 changed files with 91 additions and 94 deletions
|
@ -8,11 +8,11 @@ class PickPizzaRecipePage extends StatelessWidget {
|
|||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Pick Pizza Recipe"),
|
||||
title: const Text("Pick Pizza Recipe"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: Hive.box<PizzaRecipe>("PizzaRecipes").listenable(),
|
||||
builder: (context, Box<PizzaRecipe> pizzaRecipesBox, widget) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import 'package:vibration/vibration.dart';
|
|||
class PizzaEventNotificationPage extends StatefulWidget {
|
||||
final String? payload;
|
||||
|
||||
PizzaEventNotificationPage(this.payload);
|
||||
const PizzaEventNotificationPage(this.payload);
|
||||
|
||||
@override
|
||||
PizzaEventNotificationState createState() => PizzaEventNotificationState();
|
||||
|
@ -31,15 +31,14 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (this.widget.payload == null){
|
||||
print("Redirected to notification page but no payload... Popping");
|
||||
if (widget.payload == null){
|
||||
Navigator.pop(context);
|
||||
}
|
||||
var split = this.widget.payload!.split("__");
|
||||
var pizzaEventId = int.parse(split[0]);
|
||||
var recipeStepId = int.parse(split[1]);
|
||||
final split = widget.payload!.split("__");
|
||||
final pizzaEventId = int.parse(split[0]);
|
||||
final recipeStepId = int.parse(split[1]);
|
||||
|
||||
var pizzaEventsBox = Hive.box<PizzaEvent>("PizzaEvents");
|
||||
final pizzaEventsBox = Hive.box<PizzaEvent>("PizzaEvents");
|
||||
|
||||
pizzaEvent = pizzaEventsBox.get(pizzaEventId)!;
|
||||
recipeStep = pizzaEvent.recipe.recipeSteps[recipeStepId];
|
||||
|
@ -59,11 +58,11 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("From notification"),
|
||||
title: const Text("From notification"),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: EdgeInsets.fromLTRB(40, 10, 40, 10),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
|
@ -78,61 +77,59 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
child: Text(recipeStep.name)
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
flex: 10,
|
||||
child: Container(
|
||||
color: Colors.blue,
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
child: Text("Ignore", style: TextStyle(color: Colors.white)),
|
||||
onPressed: () async {
|
||||
showDialog(context: context, builder: (BuildContext context) {
|
||||
return buildIgnoreDialog();
|
||||
});
|
||||
},
|
||||
child: const Text("Ignore", style: TextStyle(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
flex: 30,
|
||||
child: Container(
|
||||
color: Colors.blue,
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
child: Text("Snooze 15 minutes", style: TextStyle(color: Colors.white)),
|
||||
onPressed: () async {
|
||||
setRecipeStepNotificatcion(DateTime.now().add(const Duration(minutes: 15)));
|
||||
setRecipeStepNotification(DateTime.now().add(const Duration(minutes: 15)));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onLongPress: () async {
|
||||
var future5Min = DateTime.now().add(Duration(minutes: 5));
|
||||
final future5Min = DateTime.now().add(const Duration(minutes: 5));
|
||||
DatePicker.showDateTimePicker(context,
|
||||
showTitleActions: true,
|
||||
minTime: future5Min,
|
||||
currentTime: future5Min,
|
||||
maxTime: DateTime.now().add(Duration(days: 365*10)),
|
||||
maxTime: DateTime.now().add(const Duration(days: 365*10)),
|
||||
onConfirm: (newEventTime) {
|
||||
setState((){
|
||||
setRecipeStepNotificatcion(newEventTime);
|
||||
setRecipeStepNotification(newEventTime);
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
child: const Text("Snooze 15 minutes", style: TextStyle(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
flex: 40,
|
||||
child: Container(
|
||||
color: Colors.blue,
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
child: Text("Start!", style: TextStyle(color: Colors.white)),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(
|
||||
|
@ -144,6 +141,7 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
)
|
||||
);
|
||||
},
|
||||
child: const Text("Start!", style: TextStyle(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -162,17 +160,16 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
|
||||
AlertDialog buildIgnoreDialog(){
|
||||
return AlertDialog(
|
||||
title: Text("This step will be marked as completed."),
|
||||
content: Text("Instructions for this step can still be viewed on the Pizza Event page"),
|
||||
title: const Text("This step will be marked as completed."),
|
||||
content: const Text("Instructions for this step can still be viewed on the Pizza Event page"),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("Back"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Back"),
|
||||
),
|
||||
TextButton(
|
||||
child: Text("Complete"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
recipeStep.completeStepNow();
|
||||
|
@ -181,12 +178,13 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Complete"),
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
void setRecipeStepNotificatcion(DateTime newTime) async {
|
||||
Future<void> setRecipeStepNotification(DateTime newTime) async {
|
||||
flutterLocalNotificationsPlugin.cancel(recipeStep.notificationId);
|
||||
|
||||
const androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||
|
@ -205,7 +203,7 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
tz.TZDateTime.from(newTime, tz.local),
|
||||
platformChannelSpecific,
|
||||
androidAllowWhileIdle: true,
|
||||
payload: this.widget.payload,
|
||||
payload: widget.payload,
|
||||
uiLocalNotificationDateInterpretation:
|
||||
UILocalNotificationDateInterpretation.absoluteTime
|
||||
);
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||
class PizzaEventPage extends StatefulWidget {
|
||||
final PizzaEvent pizzaEvent;
|
||||
|
||||
PizzaEventPage(this.pizzaEvent);
|
||||
const PizzaEventPage(this.pizzaEvent);
|
||||
|
||||
@override
|
||||
PizzaEventPageState createState() => PizzaEventPageState();
|
||||
|
@ -24,76 +24,76 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var recipeStepCount = this.widget.pizzaEvent.recipe.recipeSteps.length;
|
||||
var completedRecipeStepCount = this.widget.pizzaEvent.recipe.recipeSteps.where((recipeStep) => recipeStep.completed).length;
|
||||
final recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.length;
|
||||
final completedRecipeStepCount = widget.pizzaEvent.recipe.recipeSteps.where((recipeStep) => recipeStep.completed).length;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(this.widget.pizzaEvent.name),
|
||||
title: Text(widget.pizzaEvent.name),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 15,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(this.widget.pizzaEvent.name),
|
||||
Text(getTimeRemainingString(this.widget.pizzaEvent.dateTime)),
|
||||
Text(widget.pizzaEvent.name),
|
||||
Text(getTimeRemainingString(widget.pizzaEvent.dateTime)),
|
||||
Container(
|
||||
color: Colors.blue,
|
||||
child: TextButton(
|
||||
child: Text(this.widget.pizzaEvent.recipe.name, style: TextStyle(color: Colors.white)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/event/recipe", arguments: this.widget.pizzaEvent);
|
||||
Navigator.pushNamed(context, "/event/recipe", arguments: widget.pizzaEvent);
|
||||
},
|
||||
child: Text(widget.pizzaEvent.recipe.name, style: const TextStyle(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
flex: 80,
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Center(
|
||||
const Center(
|
||||
child: Text("Ingredients")
|
||||
),
|
||||
Table(
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(4),
|
||||
1: FlexColumnWidth(3),
|
||||
3: FlexColumnWidth(1),
|
||||
3: FlexColumnWidth(),
|
||||
},
|
||||
children: <TableRow>[
|
||||
TableRow(
|
||||
const TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text("Ingredient")),
|
||||
TableCell(child: Text("Total")),
|
||||
TableCell(child: Center(child: Text("Bought")))
|
||||
]
|
||||
)
|
||||
] + this.widget.pizzaEvent.recipe.ingredients.map((ingredient) => buildIngredientWidget(ingredient)).toList(),
|
||||
] + widget.pizzaEvent.recipe.ingredients.map((ingredient) => buildIngredientWidget(ingredient)).toList(),
|
||||
),
|
||||
Table(
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(4),
|
||||
1: FlexColumnWidth(3),
|
||||
2: FlexColumnWidth(1),
|
||||
2: FlexColumnWidth(),
|
||||
},
|
||||
children: <TableRow>[
|
||||
TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text("Recipe Step")),
|
||||
TableCell(child: Text("When")),
|
||||
const TableCell(child: Text("Recipe Step")),
|
||||
const TableCell(child: Text("When")),
|
||||
TableCell(child: Text("$completedRecipeStepCount/$recipeStepCount")),
|
||||
]
|
||||
)
|
||||
] + this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList()
|
||||
] + widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList()
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
]
|
||||
)
|
||||
),
|
||||
|
@ -104,7 +104,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
}
|
||||
|
||||
TableRow buildIngredientWidget(Ingredient ingredient){
|
||||
int totalWeight = this.widget.pizzaEvent.pizzaCount * this.widget.pizzaEvent.doughBallSize;
|
||||
final int totalWeight = widget.pizzaEvent.pizzaCount * widget.pizzaEvent.doughBallSize;
|
||||
return TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text(ingredient.name)),
|
||||
|
@ -113,7 +113,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
value: ingredient.bought,
|
||||
onChanged: (bool? newValue) {
|
||||
setState((){ingredient.bought = newValue!;});
|
||||
this.widget.pizzaEvent.save();
|
||||
widget.pizzaEvent.save();
|
||||
},
|
||||
))),
|
||||
]
|
||||
|
|
|
@ -19,10 +19,10 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Pizza Events"),
|
||||
title: const Text("Pizza Events"),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: Hive.box<PizzaEvent>("PizzaEvents").listenable(),
|
||||
builder: (context, Box<PizzaEvent> box, widget) {
|
||||
|
@ -46,13 +46,13 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
|||
);
|
||||
|
||||
if (newPizzaEvent != null){
|
||||
this.addPizzaEvent(newPizzaEvent as PizzaEvent);
|
||||
addPizzaEvent(newPizzaEvent as PizzaEvent);
|
||||
}
|
||||
},
|
||||
tooltip: "Add Pizza Plans",
|
||||
child: Center(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
children: const <Widget>[
|
||||
Icon(Icons.add),
|
||||
Icon(Icons.local_pizza_rounded),
|
||||
]
|
||||
|
@ -63,7 +63,7 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
|||
}
|
||||
|
||||
void addPizzaEvent(PizzaEvent pizzaEvent){
|
||||
this.setState(() {
|
||||
setState(() {
|
||||
pizzaEvents.add(
|
||||
pizzaEvent
|
||||
);
|
||||
|
|
|
@ -18,8 +18,8 @@ class RecipeStepInstructionPage extends StatefulWidget {
|
|||
late final RecipeStep recipeStep;
|
||||
|
||||
RecipeStepInstructionPage(RecipeStepInstructionPageArguments arguments) {
|
||||
this.pizzaEvent = arguments.pizzaEvent;
|
||||
this.recipeStep = arguments.recipeStep;
|
||||
pizzaEvent = arguments.pizzaEvent;
|
||||
recipeStep = arguments.recipeStep;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,46 +36,46 @@ class RecipeStepInstructionState extends State<RecipeStepInstructionPage> {
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (this.widget.recipeStep.subSteps.isNotEmpty) {
|
||||
this.currentSubStep = this.widget.recipeStep.subSteps.first;
|
||||
if (widget.recipeStep.subSteps.isNotEmpty) {
|
||||
currentSubStep = widget.recipeStep.subSteps.first;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var nextButtonText = "Start";
|
||||
if (this.page == this.widget.recipeStep.subSteps.length){ // -1 because of description page
|
||||
if (page == widget.recipeStep.subSteps.length){ // -1 because of description page
|
||||
nextButtonText = "Finished";
|
||||
} else if (this.page > 0){
|
||||
} else if (page > 0){
|
||||
nextButtonText = "Next step";
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(this.widget.recipeStep.name),
|
||||
title: Text(widget.recipeStep.name),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 90,
|
||||
child: PageView(
|
||||
controller: this.controller,
|
||||
controller: controller,
|
||||
onPageChanged: (newPage) => setState(() {
|
||||
this.page = newPage;
|
||||
if (this.widget.recipeStep.subSteps.isNotEmpty && this.page != 0) {
|
||||
this.currentSubStep = this.widget.recipeStep.subSteps.elementAt(newPage-1);
|
||||
page = newPage;
|
||||
if (widget.recipeStep.subSteps.isNotEmpty && page != 0) {
|
||||
currentSubStep = widget.recipeStep.subSteps.elementAt(newPage-1);
|
||||
}
|
||||
}),
|
||||
children: <Widget>[
|
||||
Markdown(
|
||||
data: this.widget.recipeStep.description,
|
||||
data: widget.recipeStep.description,
|
||||
onTapLink: (text, url, title) {
|
||||
launch(url!);
|
||||
},
|
||||
)
|
||||
] + this.widget.recipeStep.subSteps.map((subStep) {
|
||||
] + widget.recipeStep.subSteps.map((subStep) {
|
||||
return Markdown(
|
||||
data: subStep.description,
|
||||
onTapLink: (text, url, title) {
|
||||
|
@ -95,17 +95,17 @@ class RecipeStepInstructionState extends State<RecipeStepInstructionPage> {
|
|||
width: double.infinity,
|
||||
color: Colors.blue,
|
||||
child: TextButton(
|
||||
child: Text("Back", style: TextStyle(color: Colors.white)),
|
||||
onPressed: () {
|
||||
if (page == 0){
|
||||
return;
|
||||
}
|
||||
if (this.currentSubStep != null){
|
||||
this.currentSubStep?.completedOn = null;
|
||||
this.widget.pizzaEvent.save();
|
||||
if (currentSubStep != null){
|
||||
currentSubStep?.completedOn = null;
|
||||
widget.pizzaEvent.save();
|
||||
}
|
||||
this.controller.previousPage(duration: const Duration(milliseconds: 100), curve: Curves.ease);
|
||||
controller.previousPage(duration: const Duration(milliseconds: 100), curve: Curves.ease);
|
||||
},
|
||||
child: const Text("Back", style: TextStyle(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -119,19 +119,19 @@ class RecipeStepInstructionState extends State<RecipeStepInstructionPage> {
|
|||
width: double.infinity,
|
||||
color: Colors.blue,
|
||||
child: TextButton(
|
||||
child: Text(nextButtonText, style: TextStyle(color: Colors.white)),
|
||||
onPressed: () {
|
||||
if (this.page == this.widget.recipeStep.subSteps.length){
|
||||
this.widget.recipeStep.completeStepNow();
|
||||
this.widget.pizzaEvent.save();
|
||||
if (page == widget.recipeStep.subSteps.length){
|
||||
widget.recipeStep.completeStepNow();
|
||||
widget.pizzaEvent.save();
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
} else if (this.currentSubStep != null){
|
||||
this.currentSubStep?.completeNow();
|
||||
this.widget.pizzaEvent.save();
|
||||
} else if (currentSubStep != null){
|
||||
currentSubStep?.completeNow();
|
||||
widget.pizzaEvent.save();
|
||||
}
|
||||
this.controller.nextPage(duration: const Duration(milliseconds: 100), curve: Curves.ease);
|
||||
controller.nextPage(duration: const Duration(milliseconds: 100), curve: Curves.ease);
|
||||
},
|
||||
child: Text(nextButtonText, style: const TextStyle(color: Colors.white)),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
|
|
@ -5,11 +5,18 @@ import 'package:pizzaplanner/util.dart';
|
|||
class PizzaEventWidget extends StatelessWidget {
|
||||
final PizzaEvent pizzaEvent;
|
||||
|
||||
PizzaEventWidget(this.pizzaEvent);
|
||||
const PizzaEventWidget(this.pizzaEvent);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
"/event/view",
|
||||
arguments: pizzaEvent
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: 120,
|
||||
color: Colors.blueAccent,
|
||||
|
@ -34,7 +41,6 @@ class PizzaEventWidget extends StatelessWidget {
|
|||
Expanded(
|
||||
child: IgnorePointer(
|
||||
child: Slider(
|
||||
min: 0.0,
|
||||
max: pizzaEvent.recipe.recipeSteps.length.toDouble(),
|
||||
divisions: pizzaEvent.recipe.recipeSteps.length,
|
||||
value: pizzaEvent.recipe.getStepsCompleted().toDouble(),
|
||||
|
@ -59,13 +65,6 @@ class PizzaEventWidget extends StatelessWidget {
|
|||
)
|
||||
)
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
"/event/view",
|
||||
arguments: this.pizzaEvent
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,11 +4,14 @@ import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
|||
class PizzaRecipeWidget extends StatelessWidget {
|
||||
final PizzaRecipe pizzaRecipe;
|
||||
|
||||
PizzaRecipeWidget(this.pizzaRecipe);
|
||||
const PizzaRecipeWidget(this.pizzaRecipe);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, "/event/add", arguments: this.pizzaRecipe);
|
||||
},
|
||||
child: Container(
|
||||
height: 120,
|
||||
color: Colors.blueAccent,
|
||||
|
@ -34,9 +37,6 @@ class PizzaRecipeWidget extends StatelessWidget {
|
|||
)
|
||||
)
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, "/event/add", arguments: this.pizzaRecipe);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue