246 lines
7.6 KiB
Dart
246 lines
7.6 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:hub/actions/actions.dart';
|
|
import 'package:hub/backend/api_requests/api_calls.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/utils/dialog_util.dart';
|
|
import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class HomePageWidget extends StatefulWidget {
|
|
const HomePageWidget({super.key});
|
|
|
|
@override
|
|
State<HomePageWidget> createState() => _HomePageWidgetState();
|
|
}
|
|
|
|
class _HomePageWidgetState extends State<HomePageWidget> {
|
|
late HomePageModel _model;
|
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
void checkData() async {
|
|
final response = await PhpGroup.getDadosCall.call(
|
|
devUUID: AppState().devUUID,
|
|
userUUID: AppState().userUUID,
|
|
cliUUID: AppState().cliUUID,
|
|
atividade: 'getDados',
|
|
);
|
|
|
|
switch (response.statusCode) {
|
|
case 200:
|
|
if (response.jsonBody['error'] == false) {
|
|
AppState().whatsapp = response.jsonBody['whatsapp'];
|
|
AppState().provisional = response.jsonBody['provisional'];
|
|
AppState().name = response.jsonBody['visitado']['VDO_NOME'];
|
|
} else {
|
|
if (response.jsonBody['error_msg'] !=
|
|
r'''Usuario nao possui vinculo ativo com esse condominio''') {
|
|
log(response.jsonBody['error_msg']);
|
|
await DialogUtil.warningDefault(context)
|
|
.whenComplete(() => checkData());
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
await DialogUtil.warningDefault(context)
|
|
.whenComplete(() => checkData());
|
|
|
|
safeSetState(() {});
|
|
break;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model = createModel(context, () => HomePageModel());
|
|
|
|
AppState().context = context;
|
|
|
|
() async {
|
|
await FirebaseMessagingService().updateDeviceToken();
|
|
}();
|
|
|
|
checkLocals(
|
|
context: context,
|
|
model: _model,
|
|
).then((_) => checkData());
|
|
|
|
_model.textController ??= TextEditingController();
|
|
_model.textFieldFocusNode ??= FocusNode();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.dispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
context.watch<AppState>();
|
|
return GestureDetector(
|
|
onTap: () => _model.unfocusNode.canRequestFocus
|
|
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
|
: FocusScope.of(context).unfocus(),
|
|
child: Scaffold(
|
|
key: scaffoldKey,
|
|
backgroundColor: FlutterFlowTheme.of(context).secondaryBackground,
|
|
// drawer: buildDrawer(context),
|
|
drawerEnableOpenDragGesture: true,
|
|
drawerDragStartBehavior: DragStartBehavior.start,
|
|
drawer: CustomDrawer(model: _model),
|
|
body: buildPage(context),
|
|
),
|
|
);
|
|
}
|
|
|
|
Container buildPage(BuildContext context) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
),
|
|
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: [
|
|
createHeader(context),
|
|
createLocal(),
|
|
createBody(),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget createHeader(BuildContext context) {
|
|
return Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: MediaQuery.of(context).size.height * 0.1,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFF1AAB5F),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: 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();
|
|
},
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
child: Image.asset(
|
|
'assets/images/logo.png',
|
|
width: 15.0,
|
|
height: 15.0,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
const SizedBox(width: 8.0),
|
|
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),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 60.0),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Wrap createBody() {
|
|
return 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: [
|
|
wrapWithModel(
|
|
model: _model.menuComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
child: const MenuComponentWidget(
|
|
expandable: true,
|
|
style: MenuView.list_grid,
|
|
item: MenuItem.button,
|
|
),
|
|
),
|
|
// Align(
|
|
// alignment: const AlignmentDirectional(0.0, 0.0),
|
|
// child: Provider<MessageWellNotifier>(
|
|
// create: (_) => MessageWellNotifier(),
|
|
// child: wrapWithModel(
|
|
// model: _model.messageWellComponentModel,
|
|
// updateCallback: () => setState(() {}),
|
|
// child: const MessageWellComponentWidget(),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
//footer
|
|
const SizedBox(
|
|
height: 100,
|
|
width: double.infinity,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget createLocal() {
|
|
return wrapWithModel(
|
|
model: _model.localComponentModel,
|
|
updateCallback: () => safeSetState(() {}),
|
|
child: const LocalProfileComponentWidget(),
|
|
);
|
|
}
|
|
}
|