[Homepage] 1. add homepage screen
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:app_petty_cash/screen/home/homepage_screen.dart';
|
||||
|
||||
import '../screen/change_company/change_company.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -98,7 +100,8 @@ class AppRoute {
|
||||
textScaleFactor: 1.0,
|
||||
padding: EdgeInsets.all(0),
|
||||
),
|
||||
child: HomeScreen(),
|
||||
// child: HomeScreen(),
|
||||
child: HomePageScreen(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,11 +38,12 @@ class MyApp extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
initialRoute: loginRoute,
|
||||
// initialRoute: loginRoute,
|
||||
// initialRoute: splashScreen,
|
||||
// initialRoute: transaksiRoute,
|
||||
// initialRoute: reportRoute,
|
||||
// initialRoute: testFilePickerRoute,
|
||||
initialRoute: homeRoute,
|
||||
onGenerateRoute: AppRoute.generateRoute,
|
||||
);
|
||||
}
|
||||
|
||||
220
app_petty_cash/lib/screen/home/homepage_screen.dart
Normal file
220
app_petty_cash/lib/screen/home/homepage_screen.dart
Normal file
@@ -0,0 +1,220 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../app/route.dart';
|
||||
import '../../provider/current_user_provider.dart';
|
||||
import '../../widget/custom_drawer.dart';
|
||||
|
||||
class HomePageScreen extends HookConsumerWidget {
|
||||
const HomePageScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
||||
if (userID == "0") {
|
||||
//not login
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
|
||||
|
||||
// Navigator.popAndPushNamed(context, loginRoute);
|
||||
return;
|
||||
}
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualYPhone(context: context, y: 30),
|
||||
),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'Home Screen',
|
||||
style: TextStyle(color: Constant.textWhite),
|
||||
),
|
||||
backgroundColor: Constant.pcBtnBackgroundColor,
|
||||
iconTheme: IconThemeData(
|
||||
color: Constant.textWhite,
|
||||
),
|
||||
),
|
||||
drawer: CustomDrawer(),
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: Constant.getActualXPhone(context: context, x: 390),
|
||||
height: Constant.getActualYPhone(context: context, y: 844),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: Constant.getActualYPhone(context: context, y: 36),
|
||||
),
|
||||
//Card
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
image: DecorationImage(
|
||||
image: AssetImage('images/background_card.png'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: Constant.getActualXPhone(context: context, x: 34),
|
||||
right:
|
||||
Constant.getActualXPhone(context: context, x: 34),
|
||||
),
|
||||
child: Container(
|
||||
width:
|
||||
Constant.getActualXPhone(context: context, x: 332),
|
||||
height:
|
||||
Constant.getActualYPhone(context: context, y: 173),
|
||||
|
||||
//Isi Card
|
||||
child: Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Text1 & Text2
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualYPhone(
|
||||
context: context, y: 17),
|
||||
left: Constant.getActualXPhone(
|
||||
context: context, x: 81),
|
||||
right: Constant.getActualXPhone(
|
||||
context: context, x: 81),
|
||||
),
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Account Balance'),
|
||||
Text('Rp. 1,440,000'),
|
||||
],
|
||||
)),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: Constant.getActualYPhone(
|
||||
context: context, y: 25),
|
||||
),
|
||||
|
||||
//Debit dan Kredit
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment
|
||||
.center, // Menengahkan secara horizontal
|
||||
children: [
|
||||
// Spasi di sebelah kiri "Check In"
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: Constant.getActualYPhone(
|
||||
context: context, y: 17),
|
||||
left: Constant.getActualXPhone(
|
||||
context: context, x: 20),
|
||||
),
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Debit'),
|
||||
Text('Rp. 2,000,000'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: Constant.getActualXPhone(
|
||||
context: context, x: 51),
|
||||
), // Jarak antara "Check In" dan "Check Out"
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: Constant.getActualYPhone(
|
||||
context: context, y: 17),
|
||||
right: Constant.getActualXPhone(
|
||||
context: context, x: 28),
|
||||
),
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Credit'),
|
||||
Text('Rp. 560,000'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualYPhone(
|
||||
context: context, y: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: Constant.getActualYPhone(context: context, y: 44),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: Constant.getActualXPhone(context: context, x: 20),
|
||||
right: Constant.getActualXPhone(context: context, x: 20),
|
||||
),
|
||||
child: Container(
|
||||
// color: Colors.amber,
|
||||
alignment: Alignment.centerLeft,
|
||||
|
||||
child: Column(children: [
|
||||
Text('Transaksi Terkini'),
|
||||
SizedBox(
|
||||
height:
|
||||
Constant.getActualYPhone(context: context, y: 24),
|
||||
),
|
||||
Container(
|
||||
width: Constant.getActualXPhone(
|
||||
context: context, x: 350),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Image(
|
||||
image:
|
||||
AssetImage('images/pizza_icon.png'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualXPhone(
|
||||
context: context, x: 12),
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user