1
0

settings_page.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:form_builder_validators/form_builder_validators.dart';
  4. import 'package:gap/gap.dart';
  5. import 'package:hive_flutter/hive_flutter.dart';
  6. import 'package:tp5/core/basic_page.dart';
  7. import 'package:flutter_form_builder/flutter_form_builder.dart';
  8. import 'package:tp5/fltinfo/widget/w_cadre.dart';
  9. class SettingsPage extends ConsumerStatefulWidget {
  10. const SettingsPage({super.key, required this.params});
  11. final SettingsParams params;
  12. @override
  13. ConsumerState<ConsumerStatefulWidget> createState() => _SettingsPageState();
  14. }
  15. class _SettingsPageState extends ConsumerState<SettingsPage> {
  16. final _formKey = GlobalKey<FormBuilderState>();
  17. @override
  18. Widget build(BuildContext context) {
  19. return BasicPage(
  20. title: "Settings & Profile",
  21. body: Column(
  22. mainAxisSize: MainAxisSize.min,
  23. children: [
  24. Padding(
  25. padding: const EdgeInsets.all(8.0),
  26. child: FormBuilder(
  27. key: _formKey,
  28. child: Column(
  29. children: [
  30. WCadre(
  31. title: "Crewlink Settings",
  32. child: Column(
  33. children: [
  34. FormBuilderTextField(
  35. name: 'crewlink_user',
  36. decoration: InputDecoration(
  37. labelText: 'Crewlink Username',
  38. )),
  39. FormBuilderTextField(
  40. name: 'crewlink_pass',
  41. decoration: InputDecoration(
  42. labelText: 'Crewlink Password',
  43. ),
  44. ),
  45. SizedBox(height: 20),
  46. Row(
  47. mainAxisAlignment: MainAxisAlignment.end,
  48. children: [
  49. ElevatedButton(
  50. onPressed: () {},
  51. child: Text(
  52. 'Test Connection to Crewlink',
  53. ),
  54. ),
  55. ElevatedButton(
  56. onPressed: () {},
  57. style: ElevatedButton.styleFrom(
  58. backgroundColor: Colors.red),
  59. child: Text("Delete"),
  60. )
  61. ],
  62. ),
  63. const Gap(10)
  64. ],
  65. ),
  66. ),
  67. const Gap(10),
  68. WCadre(
  69. title: "Lido Settings",
  70. child: Column(
  71. children: [
  72. FormBuilderTextField(
  73. name: 'lido_user',
  74. decoration: InputDecoration(
  75. labelText: 'Lido Username',
  76. )),
  77. FormBuilderTextField(
  78. name: 'lido_pass',
  79. decoration: InputDecoration(
  80. labelText: 'Lido Password',
  81. ),
  82. ),
  83. SizedBox(height: 20),
  84. Row(
  85. mainAxisAlignment: MainAxisAlignment.end,
  86. children: [
  87. ElevatedButton(
  88. onPressed: () {},
  89. child: Text(
  90. 'Test Connection to Lido',
  91. ),
  92. ),
  93. ElevatedButton(
  94. onPressed: () {},
  95. style: ElevatedButton.styleFrom(
  96. backgroundColor: Colors.red),
  97. child: Text("Delete"),
  98. )
  99. ],
  100. ),
  101. const Gap(10)
  102. ],
  103. ),
  104. ),
  105. ],
  106. ),
  107. ),
  108. ),
  109. Row(
  110. children: [
  111. Expanded(
  112. child: ElevatedButton(
  113. onPressed: () {
  114. if (_formKey.currentState!.saveAndValidate()) {
  115. print(_formKey.currentState!.value);
  116. } else {
  117. print('Validation failed');
  118. }
  119. },
  120. style: ElevatedButton.styleFrom(
  121. backgroundColor: Colors.green[800],
  122. foregroundColor: Colors.white,
  123. ),
  124. child: SizedBox(
  125. height: 44,
  126. child: Center(
  127. child: const Text(
  128. 'Save & Sync',
  129. style: TextStyle(color: Colors.white, fontSize: 22),
  130. ),
  131. ),
  132. ),
  133. ),
  134. ),
  135. ],
  136. ),
  137. ],
  138. ));
  139. }
  140. }
  141. class SettingsParams {
  142. const SettingsParams({
  143. this.crewlinkUser,
  144. this.crewlinkPass,
  145. this.lidoUser,
  146. this.lidoPass,
  147. this.userRole,
  148. });
  149. final String? crewlinkUser;
  150. final String? crewlinkPass;
  151. final String? lidoUser;
  152. final String? lidoPass;
  153. final String? userRole;
  154. }