TKK_E32220429/lib/app/modules/home/views/home_view.dart

164 lines
5.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/home_controller.dart';
import 'package:intl/intl.dart'; // Untuk format tanggal
class HomeView extends GetView<HomeController> {
const HomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue[400],
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 20),
// Row untuk lokasi dan pengaturan
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Teks Selamat Datang dan Ikon Pengaturan
const Text(
'Selamat Datang!',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
IconButton(
icon: const Icon(Icons.settings, color: Colors.white, size: 25),
onPressed: () {
controller.goToSettings();
},
),
],
),
),
const SizedBox(height: 20),
// Lokasi pengguna dalam satu card
// Lokasi pengguna dalam satu card
// Lokasi pengguna dalam satu card
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 8,
shadowColor: Colors.black38,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center, // Menyelaraskan ikon dan teks di tengah
children: [
// Ikon lokasi
const Icon(
Icons.location_on,
color: Colors.blue,
size: 40, // Menyesuaikan ukuran ikon
),
const SizedBox(width: 15), // Jarak antara ikon dan teks
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, // Agar teks rata kiri
children: [
// Latitude dan Longitude
Obx(() => Text(
'Lat: ${controller.latitude.value}, Lon: ${controller.longitude.value}',
style: const TextStyle(
color: Colors.black87,
fontSize: 16,
fontWeight: FontWeight.w500, // Menebalkan teks agar lebih jelas
),
)),
const SizedBox(height: 5),
// Tanggal update
Obx(() {
String formattedDate = DateFormat('dd-MM-yy HH:mm:ss').format(controller.lastUpdate.value);
return Text(
'Last Update: $formattedDate',
style: const TextStyle(
color: Colors.black54,
fontSize: 14,
),
);
}),
],
),
),
],
),
),
),
),
const SizedBox(height: 30),
// Menempatkan card About Us dan Maps sejajar kiri dan kanan, di tengah halaman
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 80), // Jarak vertikal agar card berada di tengah halaman
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// About Us Card
GestureDetector(
onTap: controller.goToAboutUs,
child: _buildCard(Icons.person, 'About Us'),
),
// Maps Card
GestureDetector(
onTap: controller.goToMaps,
child: _buildCard(Icons.map, 'Maps'),
),
],
),
],
),
),
],
),
),
),
);
}
// Helper function untuk membuat card dengan ikon dan teks
Widget _buildCard(IconData icon, String label) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 8, // Membuat bayangan lebih kuat
shadowColor: Colors.black38, // Warna bayangan lebih lembut
child: Container(
width: 150, // Ukuran kartu lebih besar
height: 150, // Ukuran kartu lebih besar
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 60, color: Colors.blue), // Ikon lebih besar
const SizedBox(height: 10),
Text(label, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500)),
],
),
),
);
}
}