diff --git a/unit2/assets/svgs/switch.svg b/unit2/assets/svgs/switch.svg new file mode 100644 index 0000000..68521a8 --- /dev/null +++ b/unit2/assets/svgs/switch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/unit2/lib/screen/unit2/roles/qr_code_scanner.dart/components/custom_switch.dart b/unit2/lib/screen/unit2/roles/qr_code_scanner.dart/components/custom_switch.dart new file mode 100644 index 0000000..907993f --- /dev/null +++ b/unit2/lib/screen/unit2/roles/qr_code_scanner.dart/components/custom_switch.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:toggle_switch/toggle_switch.dart'; + +class CostumToggleSwitch extends StatelessWidget { + final List activeBGColors; + final List icons; +final int initialLabelIndex; + final void Function(int?)? onToggle; + final List labels; + const CostumToggleSwitch( + {Key? key, + required this.activeBGColors, + required this.icons, + required this.onToggle, + required this.labels, + required this.initialLabelIndex + + }) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(15), + height: 80, + child: ToggleSwitch( + minWidth: 150.0, + cornerRadius: 25.0, + activeBgColors: [ + [Colors.green[800]!], + [Colors.red[800]!] + ], + activeFgColor: Colors.white, + inactiveBgColor: Colors.grey, + inactiveFgColor: Colors.white, + initialLabelIndex: initialLabelIndex, + totalSwitches: 2, + labels: labels, + icons: icons, + radiusStyle: false, + onToggle: onToggle), + ); + } +} diff --git a/unit2/lib/screen/unit2/roles/qr_code_scanner.dart/settings_screen.dart b/unit2/lib/screen/unit2/roles/qr_code_scanner.dart/settings_screen.dart new file mode 100644 index 0000000..5a79040 --- /dev/null +++ b/unit2/lib/screen/unit2/roles/qr_code_scanner.dart/settings_screen.dart @@ -0,0 +1,205 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:fluttericon/entypo_icons.dart'; +import 'package:fluttericon/modern_pictograms_icons.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:unit2/screen/unit2/roles/qr_code_scanner.dart/components/custom_switch.dart'; +import 'package:unit2/test_data.dart'; +import 'package:unit2/utils/text_container.dart'; +import '../../../../theme-data.dart/btn-style.dart'; +import '../../../../theme-data.dart/colors.dart'; +import '../../../../theme-data.dart/form-style.dart'; +import '../../../../utils/global.dart'; + +class QRCodeScannerSettings extends StatefulWidget { + const QRCodeScannerSettings({super.key}); + + @override + State createState() => _QRCodeScannerSettingsState(); +} + +class _QRCodeScannerSettingsState extends State { + bool _includeOtherInputs = false; + String scanMode = 'INCOMING'; + String selectedLevel = ''; + String selectedEstablishment = ''; + String selectedArea = ''; + final _formKey = GlobalKey(); + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: const Text(qrScannerTitle), + centerTitle: true, + backgroundColor: second, + ), + body: SingleChildScrollView( + child: Container( + height: screenHeight * .88, + padding: const EdgeInsets.symmetric(horizontal: 30), + child: FormBuilder( + key: _formKey, + child: Column( + children: [ + const SizedBox( + height: 32, + ), + SvgPicture.asset( + 'assets/svgs/switch.svg', + height: blockSizeVertical * 14, + allowDrawingOutsideViewBox: true, + ), + ListTile( + title: Text( + "Set QR Scanner Settings", + style: Theme.of(context) + .textTheme + .headline6! + .copyWith(color: third), + textAlign: TextAlign.center, + ), + ), + Text("Include other inputs?", + style: Theme.of(context).textTheme.subtitle1), + Text( + "inputs such as body temperature, etc.", + style: Theme.of(context).textTheme.caption, + ), + SizedBox( + child: FittedBox( + child: CostumToggleSwitch( + activeBGColors: [ + Colors.green[800]!, + Colors.red[800]! + ], + initialLabelIndex: _includeOtherInputs ? 0 : 1, + icons: const [Entypo.check, ModernPictograms.cancel], + labels: const ['YES', 'NO'], + onToggle: (value) { + value == 0 + ? _includeOtherInputs = true + : _includeOtherInputs = false; + }, + ), + ), + ), + // Incoming or outgoing + Text("Incoming or Outgoing? ", + style: Theme.of(context).textTheme.subtitle1), + Text( + "incoming for entrance outgoing for exit.", + style: Theme.of(context).textTheme.caption, + ), + FittedBox( + child: CostumToggleSwitch( + activeBGColors: [Colors.green[800]!, Colors.red[800]!], + initialLabelIndex: scanMode == 'INCOMING' ? 0 : 1, + icons: const [ + Entypo.down_bold, + Entypo.up_bold, + ], + labels: const ['INCOMING', 'OUTGOING'], + onToggle: (value) { + value == 0 + ? scanMode = 'INCOMING' + : scanMode = 'OUTGOING'; + }, + ), + ), + const SizedBox( + height: 10, + ), + + //SELECT LEVEL + + FormBuilderDropdown( + name: 'level', + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: normalTextFieldStyle("Select level", "level"), + items: levels + .map((level) => DropdownMenuItem( + child: Text(level), + value: level, + )) + .toList(), + // value: selectedLevel, + onChanged: (value) async { + selectedLevel = value!; + }, + ), + + const SizedBox( + height: 8, + ), + + FormBuilderDropdown( + name: 'establishment', + decoration: normalTextFieldStyle( + "Select establishment", "establishments"), + isExpanded: true, + items: establishments + .map((est) => DropdownMenuItem( + child: Text(est), + value: est, + )) + .toList(), + // value: selectedArea, + onChanged: (value) async { + selectedArea = value!; + }), + const SizedBox( + height: 8, + ), + DropdownButtonFormField( + decoration: normalTextFieldStyle( + "Select establishment", "establishments"), + isExpanded: true, + items: establishments + .map((est) => DropdownMenuItem( + child: Text(est), + value: est, + )) + .toList(), + // value: selectedArea, + onChanged: (value) async { + selectedArea = value!; + }), + const Expanded( + child: SizedBox(), + ), + SizedBox( + width: double.infinity, + height: screenHeight * .06, + child: ElevatedButton( + style: secondaryBtnStyle( + second, Colors.transparent, Colors.white54), + child: const Text( + submit, + style: TextStyle(color: Colors.white), + ), + onPressed: () { + // if (_formKey.currentState.validate()) { + // _formKey.currentState.save(); + // BlocProvider.of(context) + // .add(UserWebLogin( + // password: password, + // username: username)); + // } + }, + ), + ), + + const SizedBox( + height: 8, + ), + ], + ), + ), + ), + )), + ); + } +} diff --git a/unit2/lib/test_data.dart b/unit2/lib/test_data.dart new file mode 100644 index 0000000..57b6cd3 --- /dev/null +++ b/unit2/lib/test_data.dart @@ -0,0 +1,3 @@ +List levels = ['Establishments', 'Office']; +List establishments = ['Provincial Government of Agusan del Norte']; +List checkPointAreas = ['Agusan Up', 'Bids and Awards Committee','Cabadbaran District Hospital','Commision on Audit']; diff --git a/unit2/lib/utils/text_container.dart b/unit2/lib/utils/text_container.dart index a214c0b..1cb3b80 100644 --- a/unit2/lib/utils/text_container.dart +++ b/unit2/lib/utils/text_container.dart @@ -6,7 +6,7 @@ const String numericValidator = "Please a number only"; const String mobile1 = "Mobile number 1"; const String mobile2 = "Mobile number 2"; const String currentLocation = "You current location"; -const String noModule = "No Module Assigned"; +const String noModule = "No Module Assign"; const String noModuleSubTitle = "Please contact the admin if you want to access a module."; const String submit = "SUBMIT"; @@ -18,6 +18,7 @@ const String unit2ModuleScreen = "uniT2 Modules"; const String welcome = "Welcome to!"; const String unitApp = 'uniT-App'; const String loginToContinue = "Please login to continue."; -const String loginViaQr = "Login via QR code"; +const String loginViaQr = "Login via QR code"; const String emergencyReponseLabel = " Request Emergency Response "; -const String requestSOS = "Request SOS"; \ No newline at end of file +const String requestSOS = "Request SOS"; +const String qrScannerTitle = "QR-Code Scanner"; diff --git a/unit2/pubspec.lock b/unit2/pubspec.lock index 06adf03..93767ed 100644 --- a/unit2/pubspec.lock +++ b/unit2/pubspec.lock @@ -558,6 +558,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.12" + toggle_switch: + dependency: "direct main" + description: + name: toggle_switch + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" typed_data: dependency: transitive description: diff --git a/unit2/pubspec.yaml b/unit2/pubspec.yaml index af6129a..729c747 100644 --- a/unit2/pubspec.yaml +++ b/unit2/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: auto_size_text: ^3.0.0 animate_do: ^3.0.2 flutter_spinkit: ^5.1.0 + toggle_switch: ^2.0.1 dev_dependencies: flutter_test: