import 'package:flutter/material.dart'; import 'package:isipiringku/pages/home/beranda/detail.dart'; import 'package:isipiringku/pages/home/kalori/kalori_harian.dart'; import 'package:isipiringku/pages/home/kalori/kalori_tab.dart'; import 'package:isipiringku/pages/home/tambahdarah/kalender_tab.dart'; import 'package:isipiringku/pages/login/login_page.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { runApp(BerandaTab()); } class BerandaTab extends StatefulWidget { @override State createState() => _BerandaTabState(); } class _BerandaTabState extends State { late SharedPreferences logindata; String username = ''; @override void initState() { super.initState(); initial(); } void initial() async { logindata = await SharedPreferences.getInstance(); setState(() { username = logindata.getString('username') ?? ''; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( toolbarHeight: 20, elevation: 0, backgroundColor: Colors.deepOrange, ), body: ListView( children: [ Container( height: 170.0, width: double.infinity, decoration: BoxDecoration( color: Colors.deepOrange, ), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.only(left: 24), child: Text( 'Hi, $username', style: TextStyle( color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, ), ), ), Container( margin: EdgeInsets.only(right: 24), child: Transform.scale( scale: 1.5, child: Icon( Icons.notifications, color: Colors.yellow, ), ), ), ], ), Padding( padding: const EdgeInsets.only( left: 15, right: 15, top: 25, ), child: Container( height: 100, width: 320, decoration: BoxDecoration( color: Colors.brown.withOpacity(0.75), borderRadius: BorderRadius.circular(15.0), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Icon( Icons.transgender_rounded, size: 60.0, ), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Umur', style: TextStyle( color: Colors.white, fontSize: 14, ), textAlign: TextAlign.center, ), SizedBox( height: 10.0, ), Text( '15 Tahun', style: TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ], ), VerticalDivider( color: Colors.white, thickness: 1.0, indent: 10.0, endIndent: 10.0, ), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Tinggi\nBadan', style: TextStyle( color: Colors.white, fontSize: 14, ), textAlign: TextAlign.center, ), SizedBox( height: 10.0, ), Text( '165 cm', style: TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ], ), VerticalDivider( color: Colors.white, thickness: 1.0, indent: 10.0, endIndent: 10.0, ), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Berat\nBadan', style: TextStyle( color: Colors.white, fontSize: 14, ), textAlign: TextAlign.center, ), SizedBox( height: 10.0, ), Text( '76 kg', style: TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ], ), ], ), ), ), ], ), ), SizedBox( height: 10, ), Container( height: 150, width: 300, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Colors.orange, Colors.white], ), borderRadius: BorderRadius.circular(15.0), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Rata-rata \nKalori Makanan', style: TextStyle( color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), Stack( alignment: Alignment.center, children: [ Container( width: 130, height: 100, decoration: BoxDecoration( color: Colors.yellow, borderRadius: BorderRadius.circular(15.0), ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 100, height: 30, alignment: Alignment.topCenter, decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(15.0), ), padding: EdgeInsets.all( 3.0), // Mengatur padding ke semua sisi sebesar 8.0 child: Center( child: Text( 'Bulan Lalu', style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), Positioned( child: Padding( padding: EdgeInsets.all( 30.0), // Atur padding sesuai kebutuhan Anda child: Text( '1130 Kkal', style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold, ), ), ), ), ], ), SizedBox( height: 10.0, ), ], ), VerticalDivider( color: Colors.white, thickness: 1.0, indent: 10.0, endIndent: 10.0, ), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Rata-rata \nKalori Makanan', style: TextStyle( color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), Container( width: 130, height: 100, decoration: BoxDecoration( color: Colors.yellow, borderRadius: BorderRadius.circular(15.0), ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 100, height: 30, alignment: Alignment.topCenter, decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(15.0), ), child: Center( child: Text( 'Bulan Ini', style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), Positioned( child: Padding( padding: EdgeInsets.all( 10.0), // Atur padding sesuai kebutuhan Anda child: Text( '1500 Kkal', style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), SizedBox( height: 10.0, ), ], ), ], ), ), SizedBox( height: 10, width: 16, ), Text( " Pengingat", style: TextStyle( color: Colors.red, fontSize: 15, fontWeight: FontWeight.bold, ), textAlign: TextAlign.left, ), SizedBox( height: 15, ), GestureDetector( onTap: () { // Arahkan ke class KaloriTab di sini Navigator.push( context, MaterialPageRoute( builder: (context) => KaloriTab()), // Ganti dengan rute yang sesuai ); }, child: Container( height: 30, width: 80, decoration: BoxDecoration( color: Color.fromARGB(255, 253, 207, 207), borderRadius: BorderRadius.circular(15.0), ), child: Center( child: Text( 'Anda Belum Melakukan Pengisian Konsumsi Kegiatan Hari Ini!', style: TextStyle( color: Colors.red, fontSize: 12, ), textAlign: TextAlign.left, ), ), ), ), SizedBox( height: 15, ), GestureDetector( onTap: () { // Arahkan ke class KalenderTab di sini Navigator.push( context, MaterialPageRoute( builder: (context) => KalenderTab()), // Ganti dengan rute yang sesuai ); }, child: Container( height: 30, width: 100, decoration: BoxDecoration( color: Colors.yellow, borderRadius: BorderRadius.circular(15.0), ), child: Center( child: Text( 'Anda Belum Melakukan Pengisian Tambah Darah', style: TextStyle( color: Colors.red, fontSize: 12, ), textAlign: TextAlign.left, ), ), ), ), ElevatedButton( onPressed: () { logindata.setBool('login', true); Navigator.pushReplacement(context, new MaterialPageRoute(builder: (context) => LoginPage())); }, child: Text('Log Out'), ), SizedBox(height: 20), Text( " Informasi Gizi & Kesehatan", style: TextStyle( color: Colors.red, fontSize: 15, fontWeight: FontWeight.bold, ), textAlign: TextAlign.left, ), Column( children: [ //arah ke detail kalori Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ //icon Container( height: 80, padding: EdgeInsets.all(12), decoration: BoxDecoration( // color: Colors.red, borderRadius: BorderRadius.circular(12), ), // child: Image.asset('assets/image/sayur.png'), ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Isi Piringku', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), SizedBox( height: 12, ), Text( 'Makanan ini mengandung salmon', style: TextStyle( fontSize: 16, color: Colors.grey, ), ), ], ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => Detail()), ); }, child: Icon(Icons.arrow_forward_ios), ) ], ), //transaction ], ), Column( children: [ //arah ke detail kalori Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ //icon Container( height: 80, padding: EdgeInsets.all(12), decoration: BoxDecoration( // color: Colors.red, borderRadius: BorderRadius.circular(12), ), // child: Image.asset('assets/image/sayur.png'), ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Isi Piringku', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), SizedBox( height: 12, ), Text( 'Makanan ini mengandung salmon', style: TextStyle( fontSize: 16, color: Colors.grey, ), ), ], ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => Detail()), ); }, child: Icon(Icons.arrow_forward_ios), ) ], ), //transaction ], ), Column( children: [ //arah ke detail kalori Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ //icon Container( height: 80, padding: EdgeInsets.all(12), decoration: BoxDecoration( // color: Colors.red, borderRadius: BorderRadius.circular(12), ), // child: Image.asset('assets/image/sayur.png'), ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Isi Piringku', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), SizedBox( height: 12, ), Text( 'Makanan ini mengandung salmon', style: TextStyle( fontSize: 16, color: Colors.grey, ), ), ], ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => KaloriHarian()), ); }, child: Icon(Icons.arrow_forward_ios), ) ], ), //transaction ], ), Column( children: [ //arah ke detail kalori Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ //icon Container( height: 80, padding: EdgeInsets.all(12), decoration: BoxDecoration( // color: Colors.red, borderRadius: BorderRadius.circular(12), ), // child: Image.asset('assets/image/sayur.png'), ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Isi Piringku', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), SizedBox( height: 12, ), Text( 'Makanan ini mengandung salmon', style: TextStyle( fontSize: 16, color: Colors.grey, ), ), ], ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => KalenderTab()), ); }, child: Icon(Icons.arrow_forward_ios), ), ], ), //transaction ], ), ], ), ); } }