add costum alerts and finalize profile user interface

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
rodolfobacuinjr 2022-12-13 14:56:09 +08:00
parent cbca4ec97d
commit 8d5f713e52
13 changed files with 483 additions and 259 deletions

View File

@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.unit2"> package="com.example.unit2">
<uses-permission android:name="android.permission.CAMERA" />
<application <application
android:label="unit2" android:label="unit2"
android:name="${applicationName}" android:name="${applicationName}"

View File

@ -63,7 +63,7 @@ class _MenuScreenState extends State<MenuScreen> {
Expanded( Expanded(
child: Align( child: Align(
alignment: FractionalOffset.bottomLeft, alignment: FractionalOffset.bottomLeft,
child: getTile(WebSymbols.logout, "Logout", '/', context), child: getTile(WebSymbols.logout, "Logout", 'login', context),
)), )),
], ],
), ),

View File

@ -1,7 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart'; import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:cool_alert/cool_alert.dart';
import 'package:unit2/utils/alerts.dart';
import '../../../../theme-data.dart/colors.dart'; import '../../../../theme-data.dart/colors.dart';
Widget getTile( Widget getTile(
@ -17,9 +18,13 @@ Widget getTile(
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
), ),
onTap: () async { onTap: () async {
debugPrint(title); if (title.toLowerCase() == "logout") {
ZoomDrawer.of(context)!.toggle(); confirmAlert(context, () {
context.goNamed("login");
});
} else {
context.goNamed(route); context.goNamed(route);
}
}, },
); );
} }

View File

@ -1,10 +1,16 @@
import 'package:barcode_scan2/barcode_scan2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/scanner.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import '../../../widgets/wave.dart'; import '../../../widgets/wave.dart';
import '../../../utils/global.dart'; import '../../../utils/global.dart';
import '../../../theme-data.dart/colors.dart'; import '../../../theme-data.dart/colors.dart';
@ -29,7 +35,9 @@ class _UniT2LoginState extends State<UniT2Login> {
return WillPopScope( return WillPopScope(
onWillPop: pressAgainToExit, onWillPop: pressAgainToExit,
child: Scaffold( child: Scaffold(
body: SizedBox( body: ProgressHUD(
child: Builder(builder: (context) {
return SizedBox(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Stack( child: Stack(
children: [ children: [
@ -154,17 +162,27 @@ class _UniT2LoginState extends State<UniT2Login> {
child: SizedBox( child: SizedBox(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(second,
second, Colors.transparent, Colors.white54), Colors.transparent, Colors.white54),
child: const Text( child: const Text(
"LOGIN", login,
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
onPressed: () { onPressed: () {
if (_formKey.currentState! final progress = ProgressHUD.of(context);
.saveAndValidate()) { progress?.showWithText(
context.go(context.namedLocation('home')); 'Logging in...',
} );
Future.delayed(const Duration(seconds: 5),
() {
progress!.dismiss();
context.goNamed("home");
});
// if (_formKey.currentState!
// .saveAndValidate()) {
// context.go(context.namedLocation('home'));
// }
// if (_formKey.currentState.validate()) { // if (_formKey.currentState.validate()) {
// _formKey.currentState.save(); // _formKey.currentState.save();
@ -197,8 +215,13 @@ class _UniT2LoginState extends State<UniT2Login> {
style: TextStyle(color: second), style: TextStyle(color: second),
), ),
onPressed: () async { onPressed: () async {
context.go(context.namedLocation('home')); ScanResult result =
await QRCodeBarCodeScanner.instance
.scanner();
debugPrint(result.type.toString());
debugPrint(
result.rawContent.toString());
// BlocProvider.of<UserBloc>(context) // BlocProvider.of<UserBloc>(context)
// .add(QRCodelogin()); // .add(QRCodelogin());
}, },
@ -220,8 +243,8 @@ class _UniT2LoginState extends State<UniT2Login> {
FontAwesome5.life_ring, FontAwesome5.life_ring,
color: Colors.white, color: Colors.white,
), ),
style: mainBtnStyle( style: mainBtnStyle(third,
third, Colors.transparent, Colors.white38), Colors.transparent, Colors.white38),
onPressed: () { onPressed: () {
context.goNamed('add-mobile'); context.goNamed('add-mobile');
}, },
@ -238,6 +261,8 @@ class _UniT2LoginState extends State<UniT2Login> {
], ],
), ),
), ),
);
}),
), ),
), ),
); );

View File

@ -1,7 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:fluttericon/web_symbols_icons.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:unit2/test_data.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/utils/global.dart';
import '../../../theme-data.dart/colors.dart';
import './components/cover-image.dart'; import './components/cover-image.dart';
class Profile extends StatelessWidget { class Profile extends StatelessWidget {
@ -15,7 +21,9 @@ class Profile extends StatelessWidget {
}, },
child: SafeArea( child: SafeArea(
child: Scaffold( child: Scaffold(
body: Stack( body: SizedBox(
width: screenWidth,
child: Stack(
clipBehavior: Clip.none, clipBehavior: Clip.none,
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
@ -34,10 +42,22 @@ class Profile extends StatelessWidget {
color: Colors.white, color: Colors.white,
), ),
)), )),
Positioned(
top: 10,
right: 20,
child: IconButton(
onPressed: () {},
icon: const Icon(
Icons.edit,
size: 24,
color: Colors.white,
),
)),
], ],
), ),
), ),
), ),
),
); );
} }
} }
@ -46,10 +66,13 @@ class BuildInformation extends StatelessWidget {
const BuildInformation({super.key}); const BuildInformation({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Container(
padding: const EdgeInsets.symmetric(horizontal: 25),
width: screenWidth,
child: Column(
children: [ children: [
const SizedBox( const SizedBox(
height: 8, height: 25,
), ),
Text( Text(
"Rodolfo Bernales Acuin", "Rodolfo Bernales Acuin",
@ -58,23 +81,40 @@ class BuildInformation extends StatelessWidget {
.headline5! .headline5!
.copyWith(fontWeight: FontWeight.bold), .copyWith(fontWeight: FontWeight.bold),
), ),
Row(
children: [
Icon(
FontAwesome5.birthday_cake,
color: Colors.blueAccent,
),
const SizedBox( const SizedBox(
width: 20, height: 10,
), ),
Text( Text(
"july 14, 1994 | Male", "july 14, 1994 | Male",
style: style: Theme.of(context).textTheme.caption!.copyWith(fontSize: 18),
Theme.of(context).textTheme.caption!.copyWith(fontSize: 22), ),
const SizedBox(
height: 15,
),
QrImage(
data: uuid,
size: blockSizeVertical * 30,
),
SizedBox(
height: 25,
),
SizedBox(
height: blockSizeVertical * 6,
width: screenWidth * .60,
child: ElevatedButton.icon(
label: const Text("Signature pad"),
icon: const Icon(
FontAwesome5.signature,
),
style: mainBtnStyle(third, Colors.transparent, Colors.white54),
onPressed: () {},
),
),
const SizedBox(
height: 5,
), ),
], ],
), ),
],
); );
} }
} }
@ -89,12 +129,12 @@ class BuildProfileImage extends StatelessWidget {
Stack( Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
CircleAvatar( const CircleAvatar(
radius: 85, radius: 72,
backgroundColor: Colors.white, backgroundColor: Colors.white,
), ),
CircleAvatar( CircleAvatar(
radius: 80, radius: 69,
backgroundColor: Colors.grey.shade800, backgroundColor: Colors.grey.shade800,
child: SvgPicture.asset( child: SvgPicture.asset(
'assets/svgs/male.svg', 'assets/svgs/male.svg',

View File

@ -1,5 +1,5 @@
import 'package:azlistview/azlistview.dart'; import 'package:azlistview/azlistview.dart';
String uuid = 'f68c3142-b939-11ec-9acb-3939f0cc109a';
List<String> levels = ['Establishments', 'Office']; List<String> levels = ['Establishments', 'Office'];
List<String> establishments = ['Provincial Government of Agusan del Norte']; List<String> establishments = ['Provincial Government of Agusan del Norte'];
List<String> checkPointAreas = [ List<String> checkPointAreas = [

View File

@ -0,0 +1,29 @@
import 'package:cool_alert/cool_alert.dart';
import 'package:flutter/material.dart';
import 'package:unit2/theme-data.dart/colors.dart';
confirmAlert(context, Function() yes) {
CoolAlert.show(
loopAnimation: true,
context: context,
type: CoolAlertType.confirm,
title: 'LOGOUT!',
text: 'Are you sure you want to logout?',
cancelBtnText: 'No',
confirmBtnText: 'Yes',
confirmBtnColor: second,
showCancelBtn: true,
barrierDismissible: false,
onConfirmBtnTap: yes);
}
errorAlert(context) {
CoolAlert.show(
context: context,
type: CoolAlertType.error,
confirmBtnColor: second,
title: 'Login Failed!',
text: 'username or password is incorrect.',
loopAnimation: false,
);
}

View File

@ -13,7 +13,7 @@ final GoRouter goRouter = GoRouter(routes: <GoRoute>[
GoRoute( GoRoute(
path: '/', path: '/',
name: 'login', name: 'login',
builder: (context, state) => Register(), builder: (context, state) => UniT2Login(),
routes: [ routes: [
GoRoute( GoRoute(
name: 'home', name: 'home',

View File

@ -0,0 +1,36 @@
import 'package:barcode_scan2/barcode_scan2.dart';
class QRCodeBarCodeScanner {
static final QRCodeBarCodeScanner _instance = QRCodeBarCodeScanner();
static QRCodeBarCodeScanner get instance => _instance;
final _selectedCamera = -1;
final bool _useAutoFocus = true;
static final _possibleFormats = BarcodeFormat.values.toList()
..removeWhere((e) => e == BarcodeFormat.unknown);
ScanResult scanResult = ScanResult();
List<BarcodeFormat> selectedFormats = [..._possibleFormats];
Future<ScanResult> scanner() async {
ScanOptions options = ScanOptions(
strings: {
"cancel": "Back",
"flash_on": "Flash on",
"flash_off": "Flash off",
},
restrictFormat: selectedFormats,
useCamera: _selectedCamera,
// autoEnableFlash: _autoEnableFlash,
android: AndroidOptions(
// aspectTolerance: _aspectTolerance,
useAutoFocus: _useAutoFocus,
),
);
try {
scanResult = await BarcodeScanner.scan(options: options);
} on Error catch (e) {
throw (e.toString());
}
return scanResult;
}
}

View File

@ -8,6 +8,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.2" version: "3.0.2"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.5"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -29,6 +36,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
barcode_scan2:
dependency: "direct main"
description:
name: barcode_scan2
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -78,6 +92,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.16.0" version: "1.16.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.1"
convex_bottom_bar: convex_bottom_bar:
dependency: "direct main" dependency: "direct main"
description: description:
@ -85,6 +106,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.0+1" version: "3.1.0+1"
cool_alert:
dependency: "direct main"
description:
name: cool_alert
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -141,6 +169,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.1.4" version: "6.1.4"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
flare_flutter:
dependency: transitive
description:
name: flare_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -186,6 +228,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_progress_hud:
dependency: "direct main"
description:
name: flutter_progress_hud
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
flutter_spinkit: flutter_spinkit:
dependency: "direct main" dependency: "direct main"
description: description:
@ -301,6 +350,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
lottie:
dependency: transitive
description:
name: lottie
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.3"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -434,6 +490,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
pointycastle:
dependency: transitive
description:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.2"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -441,6 +504,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
protobuf:
dependency: transitive
description:
name: protobuf
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
provider: provider:
dependency: transitive dependency: transitive
description: description:
@ -448,6 +518,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.4" version: "6.0.4"
qr:
dependency: transitive
description:
name: qr
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
qr_flutter:
dependency: "direct main"
description:
name: qr_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
rxdart: rxdart:
dependency: transitive dependency: transitive
description: description:

View File

@ -54,6 +54,10 @@ dependencies:
azlistview: ^2.0.0 azlistview: ^2.0.0
intl: ^0.17.0 intl: ^0.17.0
date_time_picker: ^2.1.0 date_time_picker: ^2.1.0
flutter_progress_hud: ^2.0.2
barcode_scan2: ^4.2.1
cool_alert: ^1.1.0
qr_flutter: ^4.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: