From c3d906653a91f117a3a5f72e0357ce7098a43518 Mon Sep 17 00:00:00 2001 From: sindhu Date: Sat, 15 Feb 2025 13:43:37 +0700 Subject: [PATCH] step 6 : slicing vektor atas home screen --- lib/app/route.dart | 30 ++++++++---- lib/main.dart | 3 +- lib/screen/home_screen.dart | 93 +++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 lib/screen/home_screen.dart diff --git a/lib/app/route.dart b/lib/app/route.dart index 6883603..f4368a1 100644 --- a/lib/app/route.dart +++ b/lib/app/route.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:scanktpflutter/screen/home_screen.dart'; import '../screen/login_screen.dart'; import '../screen/splash_screen.dart'; const splashRoute = "/splashRoute"; const loginRoute = "/loginRoute"; +const homeRoute = "/homeRoute"; class AppRoute { static Route generateRoute(RouteSettings settings) { @@ -12,8 +14,8 @@ class AppRoute { if (settings.name == splashRoute) { return MaterialPageRoute(builder: (context) { return MediaQuery( - data: MediaQuery.of(context) - .copyWith(textScaler: TextScaler.linear(1.0), padding: EdgeInsets.all(0)), + data: MediaQuery.of(context).copyWith( + textScaler: TextScaler.linear(1.0), padding: EdgeInsets.all(0)), child: SplashScreen(), ); }); @@ -23,19 +25,31 @@ class AppRoute { if (settings.name == loginRoute) { return MaterialPageRoute(builder: (context) { return MediaQuery( - data: MediaQuery.of(context) - .copyWith(textScaler: TextScaler.linear(1.0), padding: EdgeInsets.all(0)), + data: MediaQuery.of(context).copyWith( + textScaler: TextScaler.linear(1.0), padding: EdgeInsets.all(0)), child: LoginScreen(), ); }); } - + + // home screen + if (settings.name == homeRoute) { + return MaterialPageRoute(builder: (context) { + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaler: TextScaler.linear(1.0), padding: EdgeInsets.all(0)), + child: HomeScreen(), + ); + }); + } + return MaterialPageRoute(builder: (context) { return MediaQuery( - data: MediaQuery.of(context) - .copyWith(padding: const EdgeInsets.all(0), textScaler: TextScaler.linear(1.0)), + data: MediaQuery.of(context).copyWith( + padding: const EdgeInsets.all(0), + textScaler: TextScaler.linear(1.0)), child: SplashScreen(), ); }); } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index 550ba1b..dfa0e90 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,7 +32,8 @@ class MyApp extends StatelessWidget { ), debugShowCheckedModeBanner: false, // initialRoute: splashRoute, - initialRoute: loginRoute, + // initialRoute: loginRoute, + initialRoute: homeRoute, onGenerateRoute: AppRoute.generateRoute, ); } diff --git a/lib/screen/home_screen.dart b/lib/screen/home_screen.dart new file mode 100644 index 0000000..c8bb525 --- /dev/null +++ b/lib/screen/home_screen.dart @@ -0,0 +1,93 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +import '../app/constant.dart'; + +class HomeScreen extends HookConsumerWidget { + const HomeScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus!.unfocus(); + }, + child: Scaffold( + resizeToAvoidBottomInset: true, + backgroundColor: Constant.textWhite, + 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: [ + Icon( + Icons + .scanner, + color: Constant.textWhite, + size: 24, + ), + SizedBox( + width: + Constant.getActualXPhone(context: context, x: 10), + ), + Text( + 'SCAN KTP BARU', + style: Constant.titleButton500(context: context) + .copyWith( + color: Constant.textWhite, + ), + ), + ], + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +}