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
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final width = size.width;
final height = size.height;
final cardWidth = width * 0.92;
final cardHeight = height * 0.15;
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 cardWidth = size.width * 0.90;
final cardHeight = size.height * 0.15;
final iconSize = size.width * 0.13;
final fontSize = size.width * 0.052;
final time = TimeOfDay.now().format(context);
// Palet warna
const greenPrimary = Color(0xFF1CB56B);
@ -58,28 +52,27 @@ class _DashboardPageState extends State<DashboardPage>
const blueHumidity = Color(0xFF0288D1);
const yellowBadge = Color(0xFFFFF9C4);
const cardShadow = Color(0x331CB56B);
const borderRadius = 24.0;
return Scaffold(
backgroundColor: greenBg,
body: LayoutBuilder(
builder: (context, constraints) {
return Column(
body: Column(
children: [
// Modern custom header
Container(
width: double.infinity,
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
decoration: BoxDecoration(
gradient: const LinearGradient(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [greenGradientStart, greenPrimary],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(width * 0.08),
bottomRight: Radius.circular(width * 0.08),
bottomLeft: Radius.circular(32),
bottomRight: Radius.circular(32),
),
boxShadow: const [
boxShadow: [
BoxShadow(
color: cardShadow,
blurRadius: 18,
@ -89,16 +82,16 @@ class _DashboardPageState extends State<DashboardPage>
),
child: Column(
children: [
SizedBox(height: height * 0.025),
SizedBox(height: size.height * 0.025),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: width * 0.12,
height: width * 0.12,
width: 44,
height: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(width * 0.035),
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
@ -107,48 +100,48 @@ class _DashboardPageState extends State<DashboardPage>
),
],
),
child: Icon(
child: const Icon(
Icons.eco,
color: greenPrimary,
size: width * 0.08,
size: 30,
),
),
SizedBox(width: width * 0.04),
const SizedBox(width: 14),
Text(
'Smart Farming',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: width * 0.065,
fontSize: size.width * 0.065,
letterSpacing: 1.2,
),
),
],
),
SizedBox(height: height * 0.012),
SizedBox(height: size.height * 0.012),
Container(
padding: EdgeInsets.symmetric(
horizontal: width * 0.045,
vertical: height * 0.008,
padding: const EdgeInsets.symmetric(
horizontal: 18,
vertical: 6,
),
decoration: BoxDecoration(
color: yellowBadge.withOpacity(0.85),
borderRadius: BorderRadius.circular(width * 0.04),
borderRadius: BorderRadius.circular(16),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
const Icon(
Icons.access_time,
color: greenPrimary,
size: width * 0.055,
size: 20,
),
SizedBox(width: width * 0.018),
const SizedBox(width: 7),
Text(
time,
style: TextStyle(
style: const TextStyle(
color: greenPrimary,
fontSize: width * 0.045,
fontSize: 18,
fontWeight: FontWeight.w600,
letterSpacing: 1.1,
),
@ -156,14 +149,12 @@ class _DashboardPageState extends State<DashboardPage>
],
),
),
SizedBox(height: height * 0.025),
SizedBox(height: size.height * 0.025),
],
),
),
SizedBox(height: height * 0.03),
Expanded(
child: Center(
child: FadeTransition(
const Spacer(flex: 2),
FadeTransition(
opacity: _fadeAnim,
child: Column(
mainAxisSize: MainAxisSize.min,
@ -172,7 +163,7 @@ class _DashboardPageState extends State<DashboardPage>
Container(
width: cardWidth,
height: cardHeight,
margin: EdgeInsets.only(bottom: height * 0.022),
margin: const EdgeInsets.only(bottom: 18),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(borderRadius),
@ -180,23 +171,23 @@ class _DashboardPageState extends State<DashboardPage>
BoxShadow(
color: cardShadow,
blurRadius: 18,
offset: Offset(0, 8),
offset: const Offset(0, 8),
),
],
),
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: width * 0.045),
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: Stack(
alignment: Alignment.topRight,
children: [
Container(
decoration: BoxDecoration(
color: blueTemp.withOpacity(0.15),
borderRadius: BorderRadius.circular(width * 0.045),
borderRadius: BorderRadius.circular(18),
),
padding: EdgeInsets.all(width * 0.038),
padding: const EdgeInsets.all(14),
child: Icon(
Icons.thermostat,
color: blueTemp,
@ -207,20 +198,20 @@ class _DashboardPageState extends State<DashboardPage>
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: width * 0.025,
vertical: height * 0.003,
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: blueTemp,
borderRadius: BorderRadius.circular(width * 0.03),
borderRadius: BorderRadius.circular(12),
),
child: Text(
child: const Text(
'°C',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: width * 0.032,
fontSize: 13,
),
),
),
@ -252,7 +243,7 @@ class _DashboardPageState extends State<DashboardPage>
],
),
),
SizedBox(width: width * 0.045),
const SizedBox(width: 18),
],
),
),
@ -260,7 +251,7 @@ class _DashboardPageState extends State<DashboardPage>
Container(
width: cardWidth,
height: cardHeight,
margin: EdgeInsets.only(bottom: height * 0.022),
margin: const EdgeInsets.only(bottom: 18),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(borderRadius),
@ -268,23 +259,23 @@ class _DashboardPageState extends State<DashboardPage>
BoxShadow(
color: cardShadow,
blurRadius: 18,
offset: Offset(0, 8),
offset: const Offset(0, 8),
),
],
),
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: width * 0.045),
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: Stack(
alignment: Alignment.topRight,
children: [
Container(
decoration: BoxDecoration(
color: blueHumidity.withOpacity(0.13),
borderRadius: BorderRadius.circular(width * 0.045),
borderRadius: BorderRadius.circular(18),
),
padding: EdgeInsets.all(width * 0.038),
padding: const EdgeInsets.all(14),
child: Icon(
Icons.water_drop,
color: blueHumidity,
@ -295,20 +286,20 @@ class _DashboardPageState extends State<DashboardPage>
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: width * 0.025,
vertical: height * 0.003,
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: blueHumidity,
borderRadius: BorderRadius.circular(width * 0.03),
borderRadius: BorderRadius.circular(12),
),
child: Text(
child: const Text(
'%',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: width * 0.032,
fontSize: 13,
),
),
),
@ -340,7 +331,7 @@ class _DashboardPageState extends State<DashboardPage>
],
),
),
SizedBox(width: width * 0.045),
const SizedBox(width: 18),
],
),
),
@ -357,30 +348,28 @@ class _DashboardPageState extends State<DashboardPage>
icon: Icon(
Icons.tornado,
color: fanOn ? Colors.white : greenPrimary,
size: width * 0.07,
),
label: Text(
fanOn ? 'Kipas ON' : 'Kipas OFF',
style: TextStyle(
color: fanOn ? Colors.white : greenPrimary,
fontWeight: FontWeight.bold,
fontSize: buttonFont,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: fanOn ? greenPrimary : Colors.white,
side: BorderSide(color: greenPrimary, width: width * 0.008),
side: const BorderSide(color: greenPrimary, width: 2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(width * 0.06),
borderRadius: BorderRadius.circular(22),
),
elevation: 0,
padding: EdgeInsets.symmetric(
horizontal: buttonPaddingH,
vertical: buttonPaddingV,
horizontal: size.width * 0.09,
vertical: size.height * 0.018,
),
),
),
SizedBox(width: width * 0.06),
SizedBox(width: size.width * 0.06),
ElevatedButton.icon(
onPressed: () {
setState(() {
@ -390,26 +379,24 @@ class _DashboardPageState extends State<DashboardPage>
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,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: pumpOn ? greenPrimary : Colors.white,
side: BorderSide(color: greenPrimary, width: width * 0.008),
side: const BorderSide(color: greenPrimary, width: 2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(width * 0.06),
borderRadius: BorderRadius.circular(22),
),
elevation: 0,
padding: EdgeInsets.symmetric(
horizontal: buttonPaddingH,
vertical: buttonPaddingV,
horizontal: size.width * 0.09,
vertical: size.height * 0.018,
),
),
),
@ -418,11 +405,8 @@ class _DashboardPageState extends State<DashboardPage>
],
),
),
),
),
const Spacer(flex: 3),
],
);
},
),
);
}