179 lines
5.8 KiB
Dart
179 lines
5.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:scanktpflutter/screen/home/card_riwayat_scan.dart';
|
|
|
|
import '../../app/constant.dart';
|
|
import '../../app/route.dart';
|
|
import '../../provider/current_user_provider.dart';
|
|
|
|
class HomeScreen extends HookConsumerWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
|
|
SystemUiOverlay.bottom,
|
|
]);
|
|
|
|
final currentUser = ref.watch(currentUserProvider);
|
|
|
|
useEffect(() {
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
final userID = currentUser?.model.userId ?? "0";
|
|
if (userID == "0") {
|
|
// not logged in
|
|
Navigator.of(context)
|
|
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
|
return;
|
|
}
|
|
});
|
|
return () {};
|
|
}, [currentUser]);
|
|
|
|
final username = currentUser?.model.username ?? "-";
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
FocusManager.instance.primaryFocus!.unfocus();
|
|
},
|
|
child: Scaffold(
|
|
resizeToAvoidBottomInset: true,
|
|
backgroundColor: Constant.bgGrey,
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// atas
|
|
Image.asset(
|
|
'images/vektoratas.png',
|
|
width: double.infinity,
|
|
fit: BoxFit.cover,
|
|
),
|
|
SizedBox(
|
|
height: Constant.getActualYPhone(
|
|
context: context,
|
|
y: 34,
|
|
),
|
|
),
|
|
// button scan ktp
|
|
Padding(
|
|
padding: EdgeInsets.only(
|
|
left: Constant.getActualXPhone(
|
|
context: context,
|
|
x: 20,
|
|
),
|
|
right: Constant.getActualXPhone(
|
|
context: context,
|
|
x: 20,
|
|
),
|
|
),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
height: Constant.getActualYPhone(
|
|
context: context,
|
|
y: 48,
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: () {},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Constant.bgButton,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
elevation: 8,
|
|
shadowColor: Constant.bgButton.withOpacity(0.24),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Image.asset(
|
|
'images/iconbarcode.png',
|
|
width: Constant.getActualXPhone(
|
|
context: context,
|
|
x: 20,
|
|
),
|
|
height: Constant.getActualYPhone(
|
|
context: context,
|
|
y: 20,
|
|
),
|
|
fit: BoxFit.cover,
|
|
),
|
|
SizedBox(
|
|
width: Constant.getActualXPhone(
|
|
context: context,
|
|
x: 10,
|
|
),
|
|
),
|
|
Text(
|
|
'SCAN KTP BARU',
|
|
style: Constant.titleButton500(context: context)
|
|
.copyWith(
|
|
color: Constant.textWhite,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: Constant.getActualYPhone(
|
|
context: context,
|
|
y: 56,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.only(
|
|
left: Constant.getActualXPhone(
|
|
context: context,
|
|
x: 20,
|
|
),
|
|
right: Constant.getActualXPhone(
|
|
context: context,
|
|
x: 20,
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Riwayat',
|
|
style:
|
|
Constant.titleRiwayat(context: context).copyWith(
|
|
color: Constant.textBlack,
|
|
),
|
|
),
|
|
Text(
|
|
'20 Scan Terakhir',
|
|
style: Constant.titleInputan500(context: context)
|
|
.copyWith(
|
|
color: Constant.inputanGrey,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: Constant.getActualYPhone(
|
|
context: context,
|
|
y: 24,
|
|
),
|
|
),
|
|
|
|
// card riwayat
|
|
CardRiwayatScan(),
|
|
// card riwayat
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|