227 lines
7.2 KiB
Dart
227 lines
7.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class GreetingHeader extends StatelessWidget {
|
|
final String name;
|
|
final String role;
|
|
final String? desa;
|
|
final String? nip;
|
|
final String? profileImageUrl;
|
|
|
|
const GreetingHeader({
|
|
super.key,
|
|
required this.name,
|
|
required this.role,
|
|
this.desa,
|
|
this.nip,
|
|
this.profileImageUrl,
|
|
});
|
|
|
|
String _getGreeting() {
|
|
final hour = DateTime.now().hour;
|
|
if (hour < 12) {
|
|
return 'Selamat Pagi';
|
|
} else if (hour < 15) {
|
|
return 'Selamat Siang';
|
|
} else if (hour < 19) {
|
|
return 'Selamat Sore';
|
|
} else {
|
|
return 'Selamat Malam';
|
|
}
|
|
}
|
|
|
|
String _getCurrentDate() {
|
|
final now = DateTime.now();
|
|
return DateFormat('EEEE, d MMMM yyyy', 'id_ID').format(now);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Colors.blue.shade800,
|
|
Colors.blue.shade600,
|
|
],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.blue.withOpacity(0.3),
|
|
spreadRadius: 1,
|
|
blurRadius: 15,
|
|
offset: const Offset(0, 5),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.2),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Text(
|
|
_getGreeting(),
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
name,
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Container(
|
|
width: 50,
|
|
height: 50,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.2),
|
|
shape: BoxShape.circle,
|
|
border: Border.all(
|
|
color: Colors.white.withOpacity(0.3),
|
|
width: 2,
|
|
),
|
|
image: profileImageUrl != null && profileImageUrl!.isNotEmpty
|
|
? DecorationImage(
|
|
image: NetworkImage(profileImageUrl!),
|
|
fit: BoxFit.cover,
|
|
)
|
|
: null,
|
|
),
|
|
child: profileImageUrl == null || profileImageUrl!.isEmpty
|
|
? const Icon(
|
|
Icons.person,
|
|
size: 30,
|
|
color: Colors.white,
|
|
)
|
|
: null,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.15),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(
|
|
Icons.location_on,
|
|
size: 14,
|
|
color: Colors.white70,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Flexible(
|
|
child: Text(
|
|
desa != null && desa!.isNotEmpty
|
|
? '$role - Desa $desa'
|
|
: role,
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.white70,
|
|
),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (nip != null && nip!.isNotEmpty)
|
|
Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.15),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(
|
|
Icons.badge,
|
|
size: 14,
|
|
color: Colors.white70,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'NIP: $nip',
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.white70,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.15),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(
|
|
Icons.calendar_today,
|
|
size: 14,
|
|
color: Colors.white70,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
_getCurrentDate(),
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.white70,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|