184 lines
7.3 KiB
Dart
184 lines
7.3 KiB
Dart
import 'package:agrilink_vocpro/core/constant/app_color.dart';
|
|
import 'package:agrilink_vocpro/core/constant/app_theme.dart';
|
|
import 'package:agrilink_vocpro/core/extension/extention.dart';
|
|
import 'package:agrilink_vocpro/core/route/app_route.dart';
|
|
import 'package:agrilink_vocpro/features/home/pages/soil_moisture/view/soil_moisture_screen.dart';
|
|
import 'package:agrilink_vocpro/features/home/pages/temperature/view/temperature_screen.dart';
|
|
import 'package:agrilink_vocpro/features/home/provider/home_provider.dart';
|
|
import 'package:agrilink_vocpro/features/home/widgets/data_display_widget.dart';
|
|
import 'package:agrilink_vocpro/features/home/pages/humidity/view/humidity_screen.dart';
|
|
import 'package:bootstrap_icons/bootstrap_icons.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class HomeScreen extends StatelessWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: SafeArea(
|
|
child: RefreshIndicator(
|
|
onRefresh: () async {
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
},
|
|
child: ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const CircleAvatar(
|
|
radius: 24,
|
|
backgroundColor: AppColor.primary,
|
|
child: Icon(
|
|
Icons.person,
|
|
color: Colors.white,
|
|
size: 24,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
getGreeting(DateTime.now().toString()),
|
|
style: AppTheme.titleMedium,
|
|
),
|
|
Text(
|
|
'Fikril Mahesaputra',
|
|
style: AppTheme.titleLarge,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 24),
|
|
Consumer<HomeProvider>(builder: (context, provider, child) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
height: MediaQuery.of(context).size.height * 0.17,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.secondary,
|
|
image: const DecorationImage(
|
|
image:
|
|
AssetImage('assets/images/green_house_image.jpg'),
|
|
fit: BoxFit.cover),
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: AppColor.ternary.withAlpha(200),
|
|
borderRadius: BorderRadius.circular(32),
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
vertical: 8, horizontal: 16),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text("Fikril's Greenhouse",
|
|
style: AppTheme.labelMedium
|
|
.copyWith(color: Colors.white)),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 12, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
color: AppColor.primary,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Text(
|
|
dateFormater(DateTime.now().toString()),
|
|
style: AppTheme.labelMedium
|
|
.copyWith(color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}),
|
|
const SizedBox(height: 16),
|
|
Text('Linked Device', style: AppTheme.titleMedium),
|
|
const SizedBox(height: 16),
|
|
GridView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2,
|
|
crossAxisSpacing: 16,
|
|
mainAxisSpacing: 16,
|
|
),
|
|
children: [
|
|
DataDisplayerWidget(
|
|
title: 'Humidity',
|
|
subtitle: 'kelembaban udara',
|
|
value: '60',
|
|
unit: '%',
|
|
icon: BootstrapIcons.droplet_half,
|
|
textColor: Colors.white,
|
|
color: AppColor.secondary,
|
|
iconColor: Colors.white,
|
|
onTap: () async {
|
|
context.push(AppRoute.humidity, extra: '60');
|
|
},
|
|
),
|
|
DataDisplayerWidget(
|
|
title: 'Temperature',
|
|
subtitle: 'suhu greenhouse',
|
|
value: '28',
|
|
unit: '°C',
|
|
icon: BootstrapIcons.thermometer_half,
|
|
color: Colors.white,
|
|
onTap: () async {
|
|
await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const TemperatureScreen()));
|
|
},
|
|
),
|
|
const DataDisplayerWidget(
|
|
title: 'Light',
|
|
subtitle: 'intensitas cahaya',
|
|
value: '1000',
|
|
unit: 'lux',
|
|
icon: BootstrapIcons.sun,
|
|
color: Colors.white,
|
|
),
|
|
DataDisplayerWidget(
|
|
title: 'Soil Moisture',
|
|
subtitle: 'kelembaban tanah',
|
|
value: '40',
|
|
unit: '%',
|
|
icon: Icons.water_outlined,
|
|
color: Colors.white,
|
|
onTap: () async {
|
|
await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const SoilMoistureScreen(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const DataDisplayerWidget(
|
|
title: 'Acid Level',
|
|
subtitle: 'tingkat keasaman',
|
|
value: '6.5',
|
|
unit: '',
|
|
icon: BootstrapIcons.pie_chart,
|
|
color: Colors.white,
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|