140 lines
5.1 KiB
Dart
140 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '/flutter_flow/flutter_flow_icon_button.dart';
|
|
import '/flutter_flow/flutter_flow_theme.dart';
|
|
import '/flutter_flow/flutter_flow_util.dart';
|
|
import 'preferences_settings_model.dart';
|
|
|
|
class PreferencesPageWidget extends StatelessWidget {
|
|
const PreferencesPageWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider<PreferencesPageModel>(
|
|
create: (_) => PreferencesPageModel(),
|
|
child: Consumer<PreferencesPageModel>(
|
|
builder: (context, model, child) => GestureDetector(
|
|
onTap: () => model.unfocusNode.canRequestFocus
|
|
? FocusScope.of(context).requestFocus(model.unfocusNode)
|
|
: FocusScope.of(context).unfocus(),
|
|
child: Scaffold(
|
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
appBar: AppBar(
|
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
automaticallyImplyLeading: false,
|
|
forceMaterialTransparency: true,
|
|
leading: FlutterFlowIconButton(
|
|
borderColor: Colors.transparent,
|
|
borderRadius: 30.0,
|
|
borderWidth: 1.0,
|
|
buttonSize: 60.0,
|
|
icon: Icon(
|
|
Icons.keyboard_arrow_left,
|
|
color: FlutterFlowTheme.of(context).primaryText,
|
|
size: 30.0,
|
|
),
|
|
onPressed: () async {
|
|
context.pop();
|
|
},
|
|
),
|
|
title: Text(
|
|
FFLocalizations.of(context).getVariableText(
|
|
enText: 'Preferences',
|
|
ptText: 'Preferências',
|
|
),
|
|
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
|
fontFamily: 'Nunito',
|
|
color: FlutterFlowTheme.of(context).primaryText,
|
|
fontSize: 17.0,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
elevation: 0.0,
|
|
),
|
|
body: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Container(),
|
|
Expanded(
|
|
flex: 2,
|
|
child: GridView.builder(
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 3,
|
|
crossAxisSpacing: 12.0,
|
|
mainAxisSpacing: 12.0,
|
|
childAspectRatio: 1.0,
|
|
mainAxisExtent: 100.0,
|
|
),
|
|
itemCount: 6, // Assuming 4 items for simplicity
|
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return _buildIconButton(context, index, model);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildIconButton(BuildContext context, int index, PreferencesPageModel model) {
|
|
IconData icon;
|
|
Function() onPressed =() => {};
|
|
bool isEnabled;
|
|
|
|
switch (index) {
|
|
case 0:
|
|
icon = Icons.fingerprint;
|
|
onPressed = () => model.toggleFingerprint(context); // Desabilita se fingerprint for false
|
|
isEnabled = FFAppState().fingerprint;
|
|
break;
|
|
case 1:
|
|
icon = Icons.person;
|
|
onPressed = () => model.enablePerson(context);
|
|
isEnabled = FFAppState().person;
|
|
break;
|
|
case 2:
|
|
icon = Icons.notifications;
|
|
onPressed = model.toggleNotify;
|
|
isEnabled = FFAppState().notify;
|
|
break;
|
|
case 3:
|
|
icon = Icons.lock_clock_sharp;
|
|
// onLongPress = model.togglePass(context, model);
|
|
isEnabled = FFAppState().pass;
|
|
break;
|
|
case 4:
|
|
icon = Icons.landscape;
|
|
onPressed = model.localLogout;
|
|
isEnabled = false;
|
|
break;
|
|
case 5:
|
|
icon = Icons.delete;
|
|
onPressed = () => model.deleteAccount(context);
|
|
isEnabled = false;
|
|
break;
|
|
default:
|
|
throw Exception('Invalid index: $index');
|
|
}
|
|
|
|
return FlutterFlowIconButton(
|
|
icon: Icon(icon, color: isEnabled ? FlutterFlowTheme.of(context).primaryBackground : FlutterFlowTheme.of(context).primary, size: 40.0),
|
|
onPressed: index != 3 ? onPressed : () {model.togglePass(context);},
|
|
borderRadius: 20.0,
|
|
borderWidth: 1.0,
|
|
buttonSize: 40.0,
|
|
fillColor: isEnabled ? FlutterFlowTheme.of(context).primary : FlutterFlowTheme.of(context).alternate,
|
|
disabledColor: FlutterFlowTheme.of(context).alternate,
|
|
disabledIconColor: FlutterFlowTheme.of(context).primary,
|
|
);
|
|
}
|
|
} |