This commit is contained in:
aarsyah0 2025-06-17 22:40:33 +07:00
parent 13e2655343
commit b8dcc027ca
1 changed files with 332 additions and 348 deletions

View File

@ -39,16 +39,10 @@ class _DashboardPageState extends State<DashboardPage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final size = MediaQuery.of(context).size; final size = MediaQuery.of(context).size;
final width = size.width; final cardWidth = size.width * 0.90;
final height = size.height; final cardHeight = size.height * 0.15;
final cardWidth = width * 0.92; final iconSize = size.width * 0.13;
final cardHeight = height * 0.15; final fontSize = size.width * 0.052;
final iconSize = width * 0.13;
final fontSize = width * 0.052;
final borderRadius = width * 0.06;
final buttonFont = width * 0.045;
final buttonPaddingH = width * 0.09;
final buttonPaddingV = height * 0.018;
final time = TimeOfDay.now().format(context); final time = TimeOfDay.now().format(context);
// Palet warna // Palet warna
const greenPrimary = Color(0xFF1CB56B); const greenPrimary = Color(0xFF1CB56B);
@ -58,371 +52,361 @@ class _DashboardPageState extends State<DashboardPage>
const blueHumidity = Color(0xFF0288D1); const blueHumidity = Color(0xFF0288D1);
const yellowBadge = Color(0xFFFFF9C4); const yellowBadge = Color(0xFFFFF9C4);
const cardShadow = Color(0x331CB56B); const cardShadow = Color(0x331CB56B);
const borderRadius = 24.0;
return Scaffold( return Scaffold(
backgroundColor: greenBg, backgroundColor: greenBg,
body: LayoutBuilder( body: Column(
builder: (context, constraints) { children: [
return Column( // Modern custom header
children: [ Container(
// Modern custom header width: double.infinity,
Container( padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
width: double.infinity, decoration: const BoxDecoration(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), gradient: LinearGradient(
decoration: BoxDecoration( colors: [greenGradientStart, greenPrimary],
gradient: const LinearGradient( begin: Alignment.topLeft,
colors: [greenGradientStart, greenPrimary], end: Alignment.bottomRight,
begin: Alignment.topLeft, ),
end: Alignment.bottomRight, borderRadius: BorderRadius.only(
), bottomLeft: Radius.circular(32),
borderRadius: BorderRadius.only( bottomRight: Radius.circular(32),
bottomLeft: Radius.circular(width * 0.08), ),
bottomRight: Radius.circular(width * 0.08), boxShadow: [
), BoxShadow(
boxShadow: const [ color: cardShadow,
BoxShadow( blurRadius: 18,
color: cardShadow, offset: Offset(0, 8),
blurRadius: 18,
offset: Offset(0, 8),
),
],
), ),
child: Column( ],
),
child: Column(
children: [
SizedBox(height: size.height * 0.025),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
SizedBox(height: height * 0.025),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: width * 0.12,
height: width * 0.12,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(width * 0.035),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Icon(
Icons.eco,
color: greenPrimary,
size: width * 0.08,
),
),
SizedBox(width: width * 0.04),
Text(
'Smart Farming',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: width * 0.065,
letterSpacing: 1.2,
),
),
],
),
SizedBox(height: height * 0.012),
Container( Container(
padding: EdgeInsets.symmetric( width: 44,
horizontal: width * 0.045, height: 44,
vertical: height * 0.008,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: yellowBadge.withOpacity(0.85), color: Colors.white,
borderRadius: BorderRadius.circular(width * 0.04), borderRadius: BorderRadius.circular(12),
), boxShadow: [
child: Row( BoxShadow(
mainAxisSize: MainAxisSize.min, color: Colors.black.withOpacity(0.06),
children: [ blurRadius: 8,
Icon( offset: const Offset(0, 2),
Icons.access_time,
color: greenPrimary,
size: width * 0.055,
),
SizedBox(width: width * 0.018),
Text(
time,
style: TextStyle(
color: greenPrimary,
fontSize: width * 0.045,
fontWeight: FontWeight.w600,
letterSpacing: 1.1,
),
), ),
], ],
), ),
child: const Icon(
Icons.eco,
color: greenPrimary,
size: 30,
),
),
const SizedBox(width: 14),
Text(
'Smart Farming',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: size.width * 0.065,
letterSpacing: 1.2,
),
), ),
SizedBox(height: height * 0.025),
], ],
), ),
), SizedBox(height: size.height * 0.012),
SizedBox(height: height * 0.03), Container(
Expanded( padding: const EdgeInsets.symmetric(
child: Center( horizontal: 18,
child: FadeTransition( vertical: 6,
opacity: _fadeAnim, ),
child: Column( decoration: BoxDecoration(
mainAxisSize: MainAxisSize.min, color: yellowBadge.withOpacity(0.85),
children: [ borderRadius: BorderRadius.circular(16),
// Card suhu ),
Container( child: Row(
width: cardWidth, mainAxisSize: MainAxisSize.min,
height: cardHeight, children: [
margin: EdgeInsets.only(bottom: height * 0.022), const Icon(
decoration: BoxDecoration( Icons.access_time,
color: Colors.white, color: greenPrimary,
borderRadius: BorderRadius.circular(borderRadius), size: 20,
boxShadow: [ ),
BoxShadow( const SizedBox(width: 7),
color: cardShadow, Text(
blurRadius: 18, time,
offset: Offset(0, 8), style: const TextStyle(
), color: greenPrimary,
], fontSize: 18,
), fontWeight: FontWeight.w600,
child: Row( letterSpacing: 1.1,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: width * 0.045),
child: Stack(
alignment: Alignment.topRight,
children: [
Container(
decoration: BoxDecoration(
color: blueTemp.withOpacity(0.15),
borderRadius: BorderRadius.circular(width * 0.045),
),
padding: EdgeInsets.all(width * 0.038),
child: Icon(
Icons.thermostat,
color: blueTemp,
size: iconSize,
),
),
Positioned(
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: width * 0.025,
vertical: height * 0.003,
),
decoration: BoxDecoration(
color: blueTemp,
borderRadius: BorderRadius.circular(width * 0.03),
),
child: Text(
'°C',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: width * 0.032,
),
),
),
),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Temperature',
style: TextStyle(
color: blueTemp,
fontSize: fontSize * 0.95,
fontWeight: FontWeight.w600,
),
),
Text(
'${temperature.toStringAsFixed(1)}',
style: TextStyle(
color: blueTemp,
fontSize: fontSize * 1.35,
fontWeight: FontWeight.bold,
),
),
],
),
),
SizedBox(width: width * 0.045),
],
),
), ),
// Card kelembapan ),
Container( ],
width: cardWidth, ),
height: cardHeight, ),
margin: EdgeInsets.only(bottom: height * 0.022), SizedBox(height: size.height * 0.025),
decoration: BoxDecoration( ],
color: Colors.white, ),
borderRadius: BorderRadius.circular(borderRadius), ),
boxShadow: [ const Spacer(flex: 2),
BoxShadow( FadeTransition(
color: cardShadow, opacity: _fadeAnim,
blurRadius: 18, child: Column(
offset: Offset(0, 8), mainAxisSize: MainAxisSize.min,
), children: [
], // Card suhu
), Container(
child: Row( width: cardWidth,
children: [ height: cardHeight,
Padding( margin: const EdgeInsets.only(bottom: 18),
padding: EdgeInsets.symmetric(horizontal: width * 0.045), decoration: BoxDecoration(
child: Stack( color: Colors.white,
alignment: Alignment.topRight, borderRadius: BorderRadius.circular(borderRadius),
children: [ boxShadow: [
Container( BoxShadow(
decoration: BoxDecoration( color: cardShadow,
color: blueHumidity.withOpacity(0.13), blurRadius: 18,
borderRadius: BorderRadius.circular(width * 0.045), offset: const Offset(0, 8),
), ),
padding: EdgeInsets.all(width * 0.038), ],
child: Icon( ),
Icons.water_drop, child: Row(
color: blueHumidity, children: [
size: iconSize, Padding(
), padding: const EdgeInsets.symmetric(horizontal: 18.0),
), child: Stack(
Positioned( alignment: Alignment.topRight,
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: width * 0.025,
vertical: height * 0.003,
),
decoration: BoxDecoration(
color: blueHumidity,
borderRadius: BorderRadius.circular(width * 0.03),
),
child: Text(
'%',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: width * 0.032,
),
),
),
),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Humidity',
style: TextStyle(
color: blueHumidity,
fontSize: fontSize * 0.95,
fontWeight: FontWeight.w600,
),
),
Text(
'${humidity.toStringAsFixed(1)}',
style: TextStyle(
color: blueHumidity,
fontSize: fontSize * 1.35,
fontWeight: FontWeight.bold,
),
),
],
),
),
SizedBox(width: width * 0.045),
],
),
),
// Tombol
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
ElevatedButton.icon( Container(
onPressed: () { decoration: BoxDecoration(
setState(() { color: blueTemp.withOpacity(0.15),
fanOn = !fanOn; borderRadius: BorderRadius.circular(18),
});
},
icon: Icon(
Icons.tornado,
color: fanOn ? Colors.white : greenPrimary,
size: width * 0.07,
), ),
label: Text( padding: const EdgeInsets.all(14),
fanOn ? 'Kipas ON' : 'Kipas OFF', child: Icon(
style: TextStyle( Icons.thermostat,
color: fanOn ? Colors.white : greenPrimary, color: blueTemp,
fontWeight: FontWeight.bold, size: iconSize,
fontSize: buttonFont,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: fanOn ? greenPrimary : Colors.white,
side: BorderSide(color: greenPrimary, width: width * 0.008),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(width * 0.06),
),
elevation: 0,
padding: EdgeInsets.symmetric(
horizontal: buttonPaddingH,
vertical: buttonPaddingV,
),
), ),
), ),
SizedBox(width: width * 0.06), Positioned(
ElevatedButton.icon( top: 0,
onPressed: () { right: 0,
setState(() { child: Container(
pumpOn = !pumpOn; padding: const EdgeInsets.symmetric(
}); horizontal: 8,
}, vertical: 2,
icon: Icon(
Icons.water,
color: pumpOn ? Colors.white : greenPrimary,
size: width * 0.07,
),
label: Text(
pumpOn ? 'Pompa ON' : 'Pompa OFF',
style: TextStyle(
color: pumpOn ? Colors.white : greenPrimary,
fontWeight: FontWeight.bold,
fontSize: buttonFont,
), ),
), decoration: BoxDecoration(
style: ElevatedButton.styleFrom( color: blueTemp,
backgroundColor: pumpOn ? greenPrimary : Colors.white, borderRadius: BorderRadius.circular(12),
side: BorderSide(color: greenPrimary, width: width * 0.008),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(width * 0.06),
), ),
elevation: 0, child: const Text(
padding: EdgeInsets.symmetric( '°C',
horizontal: buttonPaddingH, style: TextStyle(
vertical: buttonPaddingV, color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 13,
),
), ),
), ),
), ),
], ],
), ),
], ),
), Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Temperature',
style: TextStyle(
color: blueTemp,
fontSize: fontSize * 0.95,
fontWeight: FontWeight.w600,
),
),
Text(
'${temperature.toStringAsFixed(1)}',
style: TextStyle(
color: blueTemp,
fontSize: fontSize * 1.35,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(width: 18),
],
), ),
), ),
), // Card kelembapan
], Container(
); width: cardWidth,
}, height: cardHeight,
margin: const EdgeInsets.only(bottom: 18),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(borderRadius),
boxShadow: [
BoxShadow(
color: cardShadow,
blurRadius: 18,
offset: const Offset(0, 8),
),
],
),
child: Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: Stack(
alignment: Alignment.topRight,
children: [
Container(
decoration: BoxDecoration(
color: blueHumidity.withOpacity(0.13),
borderRadius: BorderRadius.circular(18),
),
padding: const EdgeInsets.all(14),
child: Icon(
Icons.water_drop,
color: blueHumidity,
size: iconSize,
),
),
Positioned(
top: 0,
right: 0,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: blueHumidity,
borderRadius: BorderRadius.circular(12),
),
child: const Text(
'%',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
),
),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Humidity',
style: TextStyle(
color: blueHumidity,
fontSize: fontSize * 0.95,
fontWeight: FontWeight.w600,
),
),
Text(
'${humidity.toStringAsFixed(1)}',
style: TextStyle(
color: blueHumidity,
fontSize: fontSize * 1.35,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(width: 18),
],
),
),
// Tombol
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() {
fanOn = !fanOn;
});
},
icon: Icon(
Icons.tornado,
color: fanOn ? Colors.white : greenPrimary,
),
label: Text(
fanOn ? 'Kipas ON' : 'Kipas OFF',
style: TextStyle(
color: fanOn ? Colors.white : greenPrimary,
fontWeight: FontWeight.bold,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: fanOn ? greenPrimary : Colors.white,
side: const BorderSide(color: greenPrimary, width: 2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(22),
),
elevation: 0,
padding: EdgeInsets.symmetric(
horizontal: size.width * 0.09,
vertical: size.height * 0.018,
),
),
),
SizedBox(width: size.width * 0.06),
ElevatedButton.icon(
onPressed: () {
setState(() {
pumpOn = !pumpOn;
});
},
icon: Icon(
Icons.water,
color: pumpOn ? Colors.white : greenPrimary,
),
label: Text(
pumpOn ? 'Pompa ON' : 'Pompa OFF',
style: TextStyle(
color: pumpOn ? Colors.white : greenPrimary,
fontWeight: FontWeight.bold,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: pumpOn ? greenPrimary : Colors.white,
side: const BorderSide(color: greenPrimary, width: 2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(22),
),
elevation: 0,
padding: EdgeInsets.symmetric(
horizontal: size.width * 0.09,
vertical: size.height * 0.018,
),
),
),
],
),
],
),
),
const Spacer(flex: 3),
],
), ),
); );
} }