218 lines
7.4 KiB
Dart
218 lines
7.4 KiB
Dart
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'package:hub/commons/components/atoms/menu_button_item/widget.dart';
|
|
import 'package:hub/commons/components/molecules/menu_item/widget.dart';
|
|
import 'package:hub/commons/components/molecules/menu_list_view/widget.dart';
|
|
import 'package:hub/commons/components/molecules/menu_staggered_view/widget.dart';
|
|
import 'package:hub/commons/schema/enums/enums.dart';
|
|
|
|
import '/commons/widgets/flutter_flow_util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'model.dart';
|
|
export 'model.dart';
|
|
|
|
class MenuComponentWidget extends StatefulWidget {
|
|
const MenuComponentWidget({
|
|
Key? key,
|
|
required this.style,
|
|
required this.item,
|
|
required this.expandable,
|
|
required this.options,
|
|
});
|
|
final MenuView style;
|
|
final MenuItem item;
|
|
final bool expandable;
|
|
final List<MenuEntry> options;
|
|
|
|
@override
|
|
State<MenuComponentWidget> createState() => _MenuComponentWidgetState();
|
|
}
|
|
|
|
class _MenuComponentWidgetState extends State<MenuComponentWidget> {
|
|
late MenuComponentModel _model;
|
|
|
|
@override
|
|
void setState(VoidCallback callback) {
|
|
super.setState(callback);
|
|
_model.onUpdate();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model = createModel(context, () => MenuComponentModel());
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.maybeDispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
log('MenuComponentWidget: ${widget.options.toList().toString()}');
|
|
return Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0),
|
|
child: Builder(
|
|
builder: (context) {
|
|
if (widget.style == MenuView.list_grid && widget.expandable == true && widget.item == MenuItem.button) {
|
|
if (_model.isGrid == true) {
|
|
return wrapWithModel(
|
|
model: _model.menuListViewComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
updateOnChange: true,
|
|
child: MenuListViewComponentWidget(
|
|
options: widget.options,
|
|
expandable: widget.expandable,
|
|
item: widget.item,
|
|
|
|
|
|
changeMenuStyle: () async {
|
|
await _model.changeMenuStyle(context);
|
|
setState(() {});
|
|
},
|
|
registerVisitorOptAction: () async {
|
|
await _model.registerVisitorOptAction(context);
|
|
setState(() {});
|
|
},
|
|
scheduleVisitOptAction: () async {
|
|
await _model.scheduleVisitOptAction(context);
|
|
setState(() {});
|
|
},
|
|
peopleOnThePropertyOptAction: () async {
|
|
await _model.peopleOnThePropertyAction(context);
|
|
setState(() {});
|
|
},
|
|
preferencesSettings: () async {
|
|
await _model.preferencesSettings(context);
|
|
setState(() {});
|
|
},
|
|
liberationHistoryOptAction: () async {
|
|
await _model.liberationHistoryOptAction(context);
|
|
setState(() {});
|
|
},
|
|
accessQRCodeOptAction: () async {
|
|
await _model.accessQRCodeOptAction(context);
|
|
setState(() {});
|
|
},
|
|
messageHistoryAction: () async {
|
|
await _model.messageHistoryAction(context);
|
|
setState(() {});
|
|
},
|
|
|
|
),
|
|
);
|
|
} else {
|
|
return wrapWithModel(
|
|
model: _model.menuStaggeredViewComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
updateOnChange: true,
|
|
child: MenuStaggeredViewComponentWidget(
|
|
changeMenuStyleAction: () async {
|
|
await _model.changeMenuStyle(context);
|
|
setState(() {});
|
|
},
|
|
registerVisitorOptAction: () async {
|
|
await _model.registerVisitorOptAction(context);
|
|
setState(() {});
|
|
},
|
|
scheduleVisitOptAction: () async {
|
|
await _model.scheduleVisitOptAction(context);
|
|
setState(() {});
|
|
},
|
|
peopleOnThePropertyOptAction: () async {
|
|
await _model.peopleOnThePropertyAction(context);
|
|
setState(() {});
|
|
},
|
|
preferencesSettings: () async {
|
|
await _model.preferencesSettings(context);
|
|
setState(() {});
|
|
},
|
|
liberationHistoryOptAction: () async {
|
|
await _model.liberationHistoryOptAction(context);
|
|
setState(() {});
|
|
},
|
|
accessQRCodeOptAction: () async {
|
|
await _model.accessQRCodeOptAction(context);
|
|
setState(() {});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
if (widget.style == MenuView.list && widget.expandable == false && widget.item == MenuItem.card){
|
|
return wrapWithModel(
|
|
model: _model.menuListViewComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
updateOnChange: true,
|
|
child: MenuListViewComponentWidget(
|
|
expandable: widget.expandable,
|
|
item: widget.item,
|
|
options: widget.options,
|
|
messageHistoryAction: () async {
|
|
await _model.messageHistoryAction(context);
|
|
setState(() {});
|
|
},
|
|
|
|
|
|
changeMenuStyle: () async {
|
|
await _model.changeMenuStyle(context);
|
|
setState(() {});
|
|
},
|
|
registerVisitorOptAction: () async {
|
|
await _model.registerVisitorOptAction(context);
|
|
setState(() {});
|
|
},
|
|
scheduleVisitOptAction: () async {
|
|
await _model.scheduleVisitOptAction(context);
|
|
setState(() {});
|
|
},
|
|
peopleOnThePropertyOptAction: () async {
|
|
await _model.peopleOnThePropertyAction(context);
|
|
setState(() {});
|
|
},
|
|
preferencesSettings: () async {
|
|
await _model.preferencesSettings(context);
|
|
setState(() {});
|
|
},
|
|
liberationHistoryOptAction: () async {
|
|
await _model.liberationHistoryOptAction(context);
|
|
setState(() {});
|
|
},
|
|
accessQRCodeOptAction: () async {
|
|
await _model.accessQRCodeOptAction(context);
|
|
setState(() {});
|
|
},
|
|
|
|
|
|
),
|
|
);
|
|
}
|
|
return const SizedBox();
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Future accessQRCodeOptAction(BuildContext context) async {
|
|
context.pushNamed(
|
|
'qrCodePage',
|
|
extra: <String, dynamic>{
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.scale,
|
|
alignment: Alignment.bottomCenter,
|
|
),
|
|
},
|
|
);
|
|
}
|
|
|
|
|
|
}
|