2023-03-03 12:49:42 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:smoke_cess_app/services/pages_service.dart';
|
2023-03-04 17:58:04 +01:00
|
|
|
import 'package:smoke_cess_app/widgets/round_button_widget.dart';
|
2023-03-03 12:49:42 +01:00
|
|
|
import '../providers/input_provider.dart';
|
|
|
|
import '../providers/page_provider.dart';
|
|
|
|
import '../providers/tasks_provider.dart';
|
2023-03-03 18:26:44 +01:00
|
|
|
import 'popup_for_task_done.dart';
|
2023-03-03 12:49:42 +01:00
|
|
|
|
|
|
|
class ViewFormPage extends StatelessWidget {
|
|
|
|
final Widget form;
|
|
|
|
final Widget view;
|
|
|
|
final Pages page;
|
|
|
|
const ViewFormPage(
|
|
|
|
{super.key, required this.form, required this.view, required this.page});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-03-05 17:33:27 +01:00
|
|
|
final height = MediaQuery.of(context).size.height;
|
2023-03-03 12:49:42 +01:00
|
|
|
PageProvider pageProvider = context.watch<PageProvider>();
|
|
|
|
TasksProvider tasksProvider = context.watch<TasksProvider>();
|
2023-03-04 17:58:04 +01:00
|
|
|
return Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
2023-03-03 12:49:42 +01:00
|
|
|
pageProvider.showForm
|
|
|
|
? Center(
|
|
|
|
child: ChangeNotifierProvider(
|
|
|
|
create: (context) => InputProvider(),
|
|
|
|
child: form,
|
|
|
|
))
|
2023-03-04 17:58:04 +01:00
|
|
|
: Center(child: view),
|
|
|
|
if (!pageProvider.showForm)
|
2023-03-05 17:33:27 +01:00
|
|
|
Container(
|
|
|
|
height: height / 8,
|
|
|
|
width: height / 8,
|
2023-03-05 17:44:10 +01:00
|
|
|
margin: EdgeInsets.only(bottom: height * 0.08),
|
2023-03-05 17:33:27 +01:00
|
|
|
child: RoundAddButton(
|
|
|
|
onPressed: tasksProvider.tasks[page] == true
|
|
|
|
? () => pageProvider.swap()
|
|
|
|
: () => showTaskDonePopup(context, page),
|
|
|
|
),
|
2023-03-04 17:58:04 +01:00
|
|
|
)
|
2023-03-03 12:49:42 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|