Siopas Inventory PETI for ISTW Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

488 lines
15 KiB

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../models/user_model.dart';
import '../../providers/auth_provider.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
import '../../theme.dart';
class HomePage extends StatefulWidget {
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String? token;
// final items = ["Android", "iOS", "Desktop", "Web"];
// final items = ['assets/gps_samara.jpeg'];
final items = [
'https://mypertamina.id/uploads/posts/Survey-Bright-Cafe-2021-1024x576.jpg',
'https://grhaproperti.com/wp-content/uploads/2022/05/banner-survey-on-520.jpg',
'https://grhaproperti.com/wp-content/uploads/2022/05/banner-properti-agent-1-1.jpg'
];
// bool isLoading = true;
@override
void initState() {
super.initState();
initializeDateFormatting("id_ID", null); // Inisialisasi pustaka intl
_getUserToken();
}
void _getUserToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
if (mounted) {
setState(() {
token = prefs.getString('token');
// getInit(); // Panggil getInit jika token sudah didapatkan
});
}
}
@override
void dispose() {
// Memastikan untuk membatalkan timer saat widget di-dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
AuthProvider authProvider = Provider.of<AuthProvider>(context);
UserModel user = authProvider.user;
// String? token = authProvider.token;
Widget header() {
return Container(
margin: EdgeInsets.only(
top: defaultMargin,
left: 10,
right: 10,
bottom: 15.5,
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Hallo, ${user.email}',
style: primaryTextStyle.copyWith(
fontSize: 16,
fontWeight: semiBold,
),
),
Text(
'${user.email}',
style: subtitleTextStyle.copyWith(
fontSize: 14,
),
),
],
),
),
Stack(
children: [
GestureDetector(
onTap: () {
// Tambahkan aksi yang ingin Anda lakukan ketika ikon notifikasi diklik di sini
},
child: Icon(
Icons
.notifications, // Ubah ikon notifikasi sesuai kebutuhan
size: 30,
color: Colors.blue[700], // Ubah warna sesuai kebutuhan
),
),
Positioned(
right: 0,
top: 0,
child: Container(
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red, // Warna latar belakang notifikasi
),
child: Text(
'1', // Jumlah notifikasi (Anda dapat mengubahnya sesuai kebutuhan)
style: TextStyle(
color: Colors.white, // Warna teks notifikasi
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
],
),
);
}
Widget subHeader() {
return Card(
margin: EdgeInsets.only(
top: 10,
left: 10,
right: 10,
),
child: Container(
padding: EdgeInsets.all(15),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Pengumuman',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
Text(
DateFormat('dd MMMM yyyy', 'id_ID').format(DateTime.now()),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
],
),
SizedBox(height: 10),
Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec euismod, nisl eget aliquet ultricies, nunc nisl aliquam nisl, vitae aliquam nisl nisl eget nisl. Donec euismod, nisl eget aliquet ultricies, nunc nisl aliquam nisl, vitae aliquam nisl nisl eget nisl.',
style: TextStyle(
fontSize: 11.5,
),
),
],
),
),
);
}
Widget titleMenu() {
return Container(
margin: EdgeInsets.only(
top: 5,
left: 10,
right: 10,
bottom: 5,
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Menu Apps',
style: primaryTextStyle.copyWith(
fontSize: 16,
fontWeight: semiBold,
),
),
Text(
'See All',
style: TextStyle(fontSize: 12, color: Colors.blue[700]),
),
],
),
],
),
),
],
),
);
}
Widget cardMenuPeminjaman() {
return Container(
margin: EdgeInsets.all(10),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: InkWell(
onTap: () {
// Aksi ketika card diklik
Navigator.pushNamed(context, '/peminjaman-barang');
},
child: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.vertical_align_top,
size: 50,
color: Colors.greenAccent[700],
),
SizedBox(height: 10),
Text(
'Peminjaman',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
),
),
),
);
}
Widget cardMenuPengembalian() {
return Container(
margin: EdgeInsets.all(10),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: InkWell(
onTap: () {
// Aksi ketika card diklik
// Navigator.pushNamed(context, '/peminjaman-barang');
},
child: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.vertical_align_bottom,
size: 50,
color: Colors.blueAccent[700],
),
SizedBox(height: 10),
Text(
'Pengembalian',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
),
),
),
);
}
Widget cardTotal(String title, int total, IconData icon) {
return Expanded(
child: Card(
margin: EdgeInsets.all(5),
child: Container(
padding: EdgeInsets.all(5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
icon,
size: 20,
color: Colors.blue[700],
),
SizedBox(height: 2),
Text(
title,
style: TextStyle(
fontSize: 8,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
SizedBox(height: 2),
Text(
total.toString(),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.blue[700],
),
),
],
),
),
),
);
}
Widget cardRow() {
return Column(
children: [
Row(
children: [
cardTotal('PENGADAAN', 0, Icons.shopping_cart),
cardTotal('PEMINJAMAN', 0, Icons.shopping_basket),
],
),
SizedBox(height: 5),
Row(
children: [
cardTotal('PENGEMBALIAN', 0, Icons.reply),
cardTotal('REMINDER PENGEMBALIAN', 0, Icons.access_alarm),
],
),
],
);
}
Widget _buildDrawer() {
return SizedBox(
//membuat menu drawer
child: Drawer(
//membuat list,
//list digunakan untuk melakukan scrolling jika datanya terlalu panjang
child: ListView(
padding: EdgeInsets.zero,
//di dalam listview ini terdapat beberapa widget drawable
children: [
UserAccountsDrawerHeader(
//membuat gambar profil
currentAccountPicture: Image(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png")),
//membuat nama akun
accountName: Text("Sahretech"),
//membuat nama email
accountEmail: Text("ig: @sahretech"),
//memberikan background
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2016/04/24/20/52/laundry-1350593_960_720.jpg"),
fit: BoxFit.cover)),
),
//membuat list menu
ListTile(
leading: Icon(Icons.home),
title: Text("Beranda"),
onTap: () {},
),
ListTile(
leading: Icon(Icons.people),
title: Text("Pegawai"),
onTap: () {},
),
ListTile(
leading: Icon(Icons.money),
title: Text("Transaksi"),
onTap: () {},
),
Divider(),
ListTile(
leading: Icon(Icons.emoji_emotions),
title: Text("Profil"),
onTap: () {},
),
ListTile(
leading: Icon(Icons.info),
title: Text("Tentang"),
onTap: () {},
),
],
),
),
);
}
return Scaffold(
backgroundColor: Colors.grey[200],
appBar: AppBar(
elevation: 0,
automaticallyImplyLeading: false,
backgroundColor: Colors.indigo[700],
title: Row(
children: [
SizedBox(width: 10),
Expanded(
child: Center(
child: Column(
children: [
Text(
'Beranda',
textAlign: TextAlign.center,
),
Text(
'User Fullname',
style: TextStyle(
fontSize: 10,
),
),
],
),
),
),
],
),
// actions: [
// Align(
// alignment: Alignment.center,
// child: Stack(
// children: [
// GestureDetector(
// onTap: () {
// // Tambahkan aksi yang diinginkan saat ikon ditekan
// },
// child: Icon(
// Icons.notifications,
// color: Colors.white,
// size: 30,
// ),
// ),
// Positioned(
// right: 0,
// top: 0,
// child: Container(
// padding: EdgeInsets.all(4),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.red, // Warna latar belakang notifikasi
// ),
// child: Text(
// '5',
// style: TextStyle(
// color: Colors.white, // Warna teks notifikasi
// fontSize: 12,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// SizedBox(width: 10),
// ],
),
// drawer: _buildDrawer(),
body: ListView(
children: [
// header(),
// subHeader(),
// SizedBox(height: 10),
// cardRow(),
// titleMenu(),
GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: [
cardMenuPeminjaman(),
cardMenuPengembalian(),
],
),
],
),
);
}
}