import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:gap/gap.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:tp5/core/basic_page.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:tp5/fltinfo/widget/w_cadre.dart'; class SettingsPage extends ConsumerStatefulWidget { const SettingsPage({super.key, required this.params}); final SettingsParams params; @override ConsumerState createState() => _SettingsPageState(); } class _SettingsPageState extends ConsumerState { final _formKey = GlobalKey(); @override Widget build(BuildContext context) { return BasicPage( title: "Settings & Profile", body: Column( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(8.0), child: FormBuilder( key: _formKey, child: Column( children: [ WCadre( title: "Crewlink Settings", child: Column( children: [ FormBuilderTextField( name: 'crewlink_user', decoration: InputDecoration( labelText: 'Crewlink Username', )), FormBuilderTextField( name: 'crewlink_pass', decoration: InputDecoration( labelText: 'Crewlink Password', ), ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ ElevatedButton( onPressed: () {}, child: Text( 'Test Connection to Crewlink', ), ), ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( backgroundColor: Colors.red), child: Text("Delete"), ) ], ), const Gap(10) ], ), ), const Gap(10), WCadre( title: "Lido Settings", child: Column( children: [ FormBuilderTextField( name: 'lido_user', decoration: InputDecoration( labelText: 'Lido Username', )), FormBuilderTextField( name: 'lido_pass', decoration: InputDecoration( labelText: 'Lido Password', ), ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ ElevatedButton( onPressed: () {}, child: Text( 'Test Connection to Lido', ), ), ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( backgroundColor: Colors.red), child: Text("Delete"), ) ], ), const Gap(10) ], ), ), ], ), ), ), Row( children: [ Expanded( child: ElevatedButton( onPressed: () { if (_formKey.currentState!.saveAndValidate()) { print(_formKey.currentState!.value); } else { print('Validation failed'); } }, style: ElevatedButton.styleFrom( backgroundColor: Colors.green[800], foregroundColor: Colors.white, ), child: SizedBox( height: 44, child: Center( child: const Text( 'Save & Sync', style: TextStyle(color: Colors.white, fontSize: 22), ), ), ), ), ), ], ), ], )); } } class SettingsParams { const SettingsParams({ this.crewlinkUser, this.crewlinkPass, this.lidoUser, this.lidoPass, this.userRole, }); final String? crewlinkUser; final String? crewlinkPass; final String? lidoUser; final String? lidoPass; final String? userRole; }