151 lines
5.2 KiB
Dart
151 lines
5.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../controllers/notifikasi_controller.dart';
|
|
|
|
class NotifikasiView extends GetView<NotifikasiController> {
|
|
const NotifikasiView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
// === CUSTOM APPBAR MELENGKUNG ===
|
|
Container(
|
|
width: size.width,
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 30),
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xFF7EFAB7),
|
|
Color(0xFF4FB9E4),
|
|
],
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
),
|
|
borderRadius: BorderRadius.vertical(
|
|
bottom: Radius.circular(30),
|
|
),
|
|
),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
// Back button di kiri
|
|
Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: IconButton(
|
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
onPressed: () => Get.back(),
|
|
),
|
|
),
|
|
|
|
// Title di tengah
|
|
Text(
|
|
'Notifikasi',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
// === DAFTAR NOTIFIKASI ===
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
child: Obx(() {
|
|
final list = controller.notifikasiList;
|
|
if (list.isEmpty) {
|
|
return const Center(
|
|
child: Text(
|
|
"Belum ada notifikasi.",
|
|
style: TextStyle(fontSize: 16, color: Colors.grey),
|
|
),
|
|
);
|
|
}
|
|
|
|
return ListView.builder(
|
|
itemCount: list.length,
|
|
itemBuilder: (context, index) {
|
|
final item = list[index];
|
|
return Dismissible(
|
|
key: Key(item['waktu'] ?? 'key_$index'),
|
|
background: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
alignment: Alignment.centerLeft,
|
|
child: const Icon(Icons.delete, color: Colors.grey),
|
|
),
|
|
secondaryBackground: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
alignment: Alignment.centerRight,
|
|
child: const Icon(Icons.delete, color: Colors.grey),
|
|
),
|
|
onDismissed: (_) => controller.hapusNotifikasi(item['waktu'] ?? ''),
|
|
child: Card(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
color: Colors.white,
|
|
elevation: 3,
|
|
margin: const EdgeInsets.only(bottom: 15),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
item['judul'] ?? 'Tidak ada judul',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
item['deskripsi'] ?? 'Tidak ada deskripsi',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 14,
|
|
color: Colors.grey[700],
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Align(
|
|
alignment: Alignment.bottomRight,
|
|
child: Text(
|
|
item['waktu'] ?? '-',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 12,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|