step 3 : buat screen splash screen

This commit is contained in:
sindhu
2025-02-15 12:01:35 +07:00
parent a3bb43c8fd
commit d70b20f5ff
9 changed files with 327 additions and 112 deletions

BIN
images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
images/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
images/splashatas.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
images/splashbawah.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

213
lib/app/constant.dart Normal file
View File

@@ -0,0 +1,213 @@
import 'package:flutter/material.dart';
class Constant {
// static double designHeight = 1024;
// static double designWidth = 1440;
// base url
static String baseURL = "http://devone.aplikasi.web.id/";
static String bearerName = "scan-ktp";
static double designHeightPhone = 844;
static double designWidthPhone = 390;
// color theme
static Color textTrueBlack = const Color(0xff000000);
static Color textBlack = const Color(0xff212B36);
static Color textLightGrey = const Color(0xff919EAB);
static Color textOrange = const Color(0xffF15A29);
static Color textDarkGrey = const Color(0xff637381);
static Color bgAddressPresensi = const Color.fromRGBO(241, 90, 41, 0.08);
static Color textWhite = Color(0xffFDFDFD);
static Color textRed = Color(0xffFF4842);
// background upload file
static Color bgUploadFile = Color.fromRGBO(207, 207, 207, 0.20);
// size convertion
static double getActualXPhone({
required BuildContext context,
required double x,
}) {
return x / designWidthPhone * MediaQuery.of(context).size.width;
}
static double getActualYPhone({
required BuildContext context,
required double y,
}) {
return y / designHeightPhone * MediaQuery.of(context).size.height;
}
// typography
static TextStyle titleH1_700({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 24),
fontWeight: FontWeight.w700,
);
}
static TextStyle titleH2_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 12),
fontWeight: FontWeight.w600,
);
}
static TextStyle logintitle_700({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 15),
fontWeight: FontWeight.w700,
);
}
static TextStyle titleH2_400_12({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 12),
fontWeight: FontWeight.w400,
fontFamily: 'Public Sans');
}
static TextStyle titleH2_600_14({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 14),
fontWeight: FontWeight.w600,
fontFamily: 'Public Sans');
}
static TextStyle titleH2_400_14({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 14),
fontWeight: FontWeight.w400,
fontFamily: 'Public Sans');
}
static TextStyle titleH1_500_18({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 18),
fontWeight: FontWeight.w500,
fontFamily: 'Public Sans');
}
static TextStyle titleH1_700_18({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 18),
fontWeight: FontWeight.w700,
fontFamily: 'Public Sans');
}
static TextStyle titleH2_700({required BuildContext context}) {
return TextStyle(
fontFamily: 'Quicksand',
fontSize: Constant.getActualYPhone(context: context, y: 14),
fontWeight: FontWeight.w700,
);
}
static TextStyle titleH3_700({required BuildContext context}) {
return TextStyle(
fontFamily: 'Quicksand',
fontSize: Constant.getActualYPhone(context: context, y: 16),
fontWeight: FontWeight.w700,
);
}
static TextStyle titleH2_500({required BuildContext context}) {
return TextStyle(
fontFamily: 'Quicksand',
fontSize: Constant.getActualYPhone(context: context, y: 12),
fontWeight: FontWeight.w500,
);
}
static TextStyle titleH2_400({required BuildContext context}) {
return TextStyle(
fontFamily: 'Public Sans',
fontSize: Constant.getActualYPhone(context: context, y: 12),
fontWeight: FontWeight.w400,
);
}
static TextStyle titlePresensiH2_700({required BuildContext context}) {
return TextStyle(
fontFamily: 'Quicksand',
fontSize: Constant.getActualYPhone(context: context, y: 24),
fontWeight: FontWeight.w700,
);
}
static TextStyle time_700({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 28),
fontWeight: FontWeight.w700,
fontFamily: 'Quicksand',
);
}
static TextStyle subtitle_600_14({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 14),
fontWeight: FontWeight.w700,
fontFamily: 'Public Sans',
);
}
static TextStyle subtitle_500_12({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 12),
fontWeight: FontWeight.w500,
fontFamily: 'Public Sans',
);
}
static TextStyle date_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 16),
fontWeight: FontWeight.w600,
fontFamily: 'Quicksand',
);
}
static TextStyle title_screen({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 24),
fontWeight: FontWeight.w600,
fontFamily: 'Public Sans',
);
}
static TextStyle body_16({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 16),
fontWeight: FontWeight.w600,
fontFamily: 'Public Sans',
);
}
static TextStyle body_14({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 14),
fontWeight: FontWeight.w600,
fontFamily: 'Public Sans',
);
}
static TextStyle body_12({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualYPhone(context: context, y: 12),
fontWeight: FontWeight.w600,
fontFamily: 'Public Sans',
);
}
static Color primaryBlue = const Color(0xff0C53B7);
static Color bgBlue = const Color(0xff1890FF).withOpacity(0.16);
static Color primaryOrange = const Color(0xffF15A29);
static Color bgOrange = const Color(0xffF15A29).withOpacity(0.16);
static Color secondaryBlue = const Color(0xff43ADA5);
static Color bgSecondaryBlue = const Color(0xff43ADA5).withOpacity(0.16);
static Color primaryGreen = const Color(0xff229A16);
static Color bgGreen = const Color(0xff54D62C).withOpacity(0.08);
static Color primaryRed = const Color(0xffB72136);
static Color bgRed = const Color(0xffFF4842).withOpacity(0.08);
}

28
lib/app/route.dart Normal file
View File

@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import '../screen/splash_screen.dart';
const splashRoute = "/splashRoute";
class AppRoute {
static Route<dynamic> generateRoute(RouteSettings settings) {
// splash screen
if (settings.name == splashRoute) {
return MaterialPageRoute(builder: (context) {
return MediaQuery(
data: MediaQuery.of(context)
.copyWith(textScaler: TextScaler.linear(1.0), padding: EdgeInsets.all(0)),
child: SplashScreen(),
);
});
}
return MaterialPageRoute(builder: (context) {
return MediaQuery(
data: MediaQuery.of(context)
.copyWith(padding: const EdgeInsets.all(0), textScaler: TextScaler.linear(1.0)),
child: SplashScreen(),
);
});
}
}

View File

@@ -1,125 +1,38 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:scanktpflutter/app/route.dart';
void main() {
runApp(const MyApp());
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitUp,
]).then((value) => runApp(const ProviderScope(child: MyApp())));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Scan KTP',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
scrollBehavior: const MaterialScrollBehavior().copyWith(
dragDevices: {
PointerDeviceKind.mouse,
PointerDeviceKind.touch,
PointerDeviceKind.stylus,
PointerDeviceKind.unknown,
},
),
debugShowCheckedModeBanner: false,
initialRoute: splashRoute,
onGenerateRoute: AppRoute.generateRoute,
);
}
}

View File

@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../app/constant.dart';
class SplashScreen extends HookConsumerWidget {
const SplashScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
SystemUiOverlay.bottom,
]);
return Scaffold(
backgroundColor: Constant.textWhite,
body: Column(
children: [
// atas
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
width: Constant.getActualXPhone(context: context, x: 246),
child: Image.asset(
'images/splashatas.png',
fit: BoxFit.fitWidth,
),
),
],
),
Spacer(),
// logo
Center(
child: Image.asset(
'images/logo.png',
width: Constant.getActualXPhone(context: context, x: 164),
),
),
Spacer(),
// bawah
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: Constant.getActualXPhone(context: context, x: 246),
child: Image.asset(
'images/splashbawah.png',
fit: BoxFit.fitWidth,
),
),
],
),
],
),
);
}
}

View File

@@ -67,9 +67,11 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- images/logo.png
- images/splash.png
- images/splashatas.png
- images/splashbawah.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images