create user interface for QR-Code scanner settings

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
rodolfobacuinjr 2022-12-06 10:45:18 +08:00
parent f924111815
commit a2d7da5435
7 changed files with 265 additions and 3 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:toggle_switch/toggle_switch.dart';
class CostumToggleSwitch extends StatelessWidget {
final List<Color> activeBGColors;
final List<IconData> icons;
final int initialLabelIndex;
final void Function(int?)? onToggle;
final List<String> 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),
);
}
}

View File

@ -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<QRCodeScannerSettings> createState() => _QRCodeScannerSettingsState();
}
class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
bool _includeOtherInputs = false;
String scanMode = 'INCOMING';
String selectedLevel = '';
String selectedEstablishment = '';
String selectedArea = '';
final _formKey = GlobalKey<FormBuilderState>();
@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<String?>(
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<String?>(
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<String?>(
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<UserBloc>(context)
// .add(UserWebLogin(
// password: password,
// username: username));
// }
},
),
),
const SizedBox(
height: 8,
),
],
),
),
),
)),
);
}
}

View File

@ -0,0 +1,3 @@
List<String> levels = ['Establishments', 'Office'];
List<String> establishments = ['Provincial Government of Agusan del Norte'];
List <String> checkPointAreas = ['Agusan Up', 'Bids and Awards Committee','Cabadbaran District Hospital','Commision on Audit'];

View File

@ -6,7 +6,7 @@ const String numericValidator = "Please a number only";
const String mobile1 = "Mobile number 1"; const String mobile1 = "Mobile number 1";
const String mobile2 = "Mobile number 2"; const String mobile2 = "Mobile number 2";
const String currentLocation = "You current location"; const String currentLocation = "You current location";
const String noModule = "No Module Assigned"; const String noModule = "No Module Assign";
const String noModuleSubTitle = const String noModuleSubTitle =
"Please contact the admin if you want to access a module."; "Please contact the admin if you want to access a module.";
const String submit = "SUBMIT"; const String submit = "SUBMIT";
@ -18,6 +18,7 @@ const String unit2ModuleScreen = "uniT2 Modules";
const String welcome = "Welcome to!"; const String welcome = "Welcome to!";
const String unitApp = 'uniT-App'; const String unitApp = 'uniT-App';
const String loginToContinue = "Please login to continue."; 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 emergencyReponseLabel = " Request Emergency Response ";
const String requestSOS = "Request SOS"; const String requestSOS = "Request SOS";
const String qrScannerTitle = "QR-Code Scanner";

View File

@ -558,6 +558,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.12" 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: typed_data:
dependency: transitive dependency: transitive
description: description:

View File

@ -49,6 +49,7 @@ dependencies:
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0
animate_do: ^3.0.2 animate_do: ^3.0.2
flutter_spinkit: ^5.1.0 flutter_spinkit: ^5.1.0
toggle_switch: ^2.0.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: