import 'dart:developer'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/backend/notifications/firebase_messaging_service.dart'; import 'package:hub/backend/schema/enums/enums.dart'; import 'package:hub/components/organism_components/local_profile_component/local_profile_component_widget.dart'; import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/pages/home_page/home_page_model.dart'; import 'package:hub/shared/helpers/db_helper.dart'; import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart'; class HomePageWidget extends StatefulWidget { const HomePageWidget({Key? key}) : super(key: key); @override State createState() => _HomePageWidgetState(); } class _HomePageWidgetState extends State { late HomePageModel _model; final scaffoldKey = GlobalKey(); late LocalProfileComponentWidget _localProfileComponentWidget; final DatabaseHelper db = DatabaseHelper(); _HomePageWidgetState() { _localProfileComponentWidget = LocalProfileComponentWidget(); } @override void dispose() { super.dispose(); _model.dispose(); } @override void initState() { super.initState(); _model = createModel(context, () => HomePageModel()); _model.updateOnChange = true; FirebaseMessagingService().updateDeviceToken(); _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); } @override Widget build(BuildContext context) { AppState().context = context; return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, // drawer: buildDrawer(context), drawerEnableOpenDragGesture: true, drawerDragStartBehavior: DragStartBehavior.start, drawer: CustomDrawer(model: _model), appBar: AppBar( backgroundColor: FlutterFlowTheme.of(context).primary, automaticallyImplyLeading: false, leading: FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, buttonSize: 40.0, fillColor: FlutterFlowTheme.of(context).primary, icon: const Icon( Icons.menu_rounded, color: Colors.white, size: 28.0, ), onPressed: () async { scaffoldKey.currentState!.openDrawer(); }, ), title: Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.asset( 'assets/images/logo.png', width: 15.0, height: 15.0, fit: BoxFit.cover, ), ), Text( 'FRE ACCESS', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ].divide(const SizedBox(width: 8.0)), ), actions: const [], centerTitle: true, elevation: 0.0, ), body: buildPage(context), ), ); } Container buildPage(BuildContext context) { return Container( decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primary, ), child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [ Wrap( spacing: 0.0, runSpacing: 0.0, alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, direction: Axis.horizontal, runAlignment: WrapAlignment.start, verticalDirection: VerticalDirection.down, clipBehavior: Clip.none, children: [ buildLocal(), buildBody(), ], ), ], ), ), ); } Widget buildBody() { return Container( color: FlutterFlowTheme.of(context).primaryBackground, child: wrapWithModel( model: _model.menuComponentModel, updateCallback: () => setState(() {}), child: const Padding( padding: EdgeInsets.only(bottom: 40), child: MenuComponentWidget( expandable: true, style: MenuView.list_grid, item: MenuItem.button, ), ), ), ); } Widget buildLocal() { return wrapWithModel( model: _model.localComponentModel, updateCallback: () => safeSetState(() {}), child: _localProfileComponentWidget, ); } }