127 lines
4.4 KiB
Dart
127 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import '../controllers/setting_controller.dart';
|
|
|
|
class SettingView extends GetView<SettingController> {
|
|
const SettingView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
// === APPBAR GRADIENT MELENGKUNG ===
|
|
Container(
|
|
width: size.width,
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 30),
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [Color(0xFF7AD6F0), Color(0xFF51C3E8)],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.vertical(bottom: Radius.circular(30)),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
onPressed: () => Get.back(),
|
|
),
|
|
Text(
|
|
'Pengaturan',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(width: 48), // Dummy agar rata tengah
|
|
],
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// === FORM SETTING ===
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
child: Form(
|
|
key: controller.formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
buildField("Interval (menit)", controller.intervalController),
|
|
const SizedBox(height: 16),
|
|
buildField("Suhu (°C)", controller.suhuController),
|
|
const SizedBox(height: 30),
|
|
|
|
// === TOMBOL SIMPAN ===
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFF51C3E8),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
),
|
|
onPressed: controller.simpanKeFirebase,
|
|
child: Text(
|
|
"Simpan",
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildField(String label, TextEditingController controller) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: GoogleFonts.poppins(fontSize: 14, fontWeight: FontWeight.w500),
|
|
),
|
|
const SizedBox(height: 8),
|
|
TextFormField(
|
|
controller: controller,
|
|
keyboardType: TextInputType.number,
|
|
decoration: InputDecoration(
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
|
filled: true,
|
|
fillColor: Colors.grey[100],
|
|
),
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) return 'Tidak boleh kosong';
|
|
return null;
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|