feat: lang

This commit is contained in:
efrilm
2025-08-20 13:52:49 +07:00
parent f07d07b3a8
commit 5a83bc4049
53 changed files with 3386 additions and 721 deletions
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
import '../../../common/extension/extension.dart';
class DateRangePickerBottomSheet {
static Future<DateRangePickerSelectionChangedArgs?> show({
required BuildContext context,
@@ -9,8 +11,8 @@ class DateRangePickerBottomSheet {
DateTime? initialEndDate,
DateTime? minDate,
DateTime? maxDate,
String confirmText = 'Pilih',
String cancelText = 'Batal',
String? confirmText,
String? cancelText,
Color primaryColor = Colors.blue,
Function(DateTime? startDate, DateTime? endDate)? onChanged,
}) async {
@@ -26,8 +28,8 @@ class DateRangePickerBottomSheet {
initialEndDate: initialEndDate,
minDate: minDate,
maxDate: maxDate,
confirmText: confirmText,
cancelText: cancelText,
confirmText: confirmText ?? context.lang.select,
cancelText: cancelText ?? context.lang.cancel,
primaryColor: primaryColor,
onChanged: onChanged,
),
@@ -104,7 +106,7 @@ class _DateRangePickerBottomSheetState
return _formatDate(range.startDate!);
}
}
return 'Belum ada tanggal dipilih';
return context.lang.no_date_selected;
}
String _formatDate(DateTime date) {
@@ -187,7 +189,7 @@ class _DateRangePickerBottomSheetState
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Tanggal Terpilih:',
'${context.lang.selected_date}:',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
import '../../../common/extension/extension.dart';
import '../../../common/theme/theme.dart';
import '../bottom_sheet/date_range_bottom_sheet.dart';
@@ -22,7 +23,7 @@ class DateRangePickerField extends StatefulWidget {
final double height;
const DateRangePickerField({
Key? key,
super.key,
this.label,
this.placeholder = 'Pilih rentang tanggal',
this.startDate,
@@ -38,7 +39,7 @@ class DateRangePickerField extends StatefulWidget {
this.placeholderStyle,
this.decoration,
this.height = 52.0,
}) : super(key: key);
});
@override
State<DateRangePickerField> createState() => _DateRangePickerFieldState();
@@ -83,7 +84,7 @@ class _DateRangePickerFieldState extends State<DateRangePickerField> {
final result = await DateRangePickerBottomSheet.show(
context: context,
title: widget.label ?? 'Pilih Rentang Tanggal',
title: widget.label ?? context.lang.select_date_range,
initialStartDate: widget.startDate,
initialEndDate: widget.endDate,
minDate: widget.minDate,
@@ -294,7 +295,7 @@ class _DateRangePickerFieldOutlinedState
final result = await DateRangePickerBottomSheet.show(
context: context,
title: widget.label ?? 'Pilih Rentang Tanggal',
title: widget.label ?? context.lang.select_date_range,
initialStartDate: widget.startDate,
initialEndDate: widget.endDate,
minDate: widget.minDate,
@@ -412,120 +413,3 @@ class _DateRangePickerFieldOutlinedState
);
}
}
// Usage Example Widget
class DateRangePickerExample extends StatefulWidget {
@override
_DateRangePickerExampleState createState() => _DateRangePickerExampleState();
}
class _DateRangePickerExampleState extends State<DateRangePickerExample> {
DateTime? _startDate;
DateTime? _endDate;
DateTime? _startDate2;
DateTime? _endDate2;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Date Range Picker Example'),
backgroundColor: AppColor.primary,
foregroundColor: AppColor.white,
),
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Default Style',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
const SizedBox(height: 16),
DateRangePickerField(
label: 'Periode Laporan',
placeholder: 'Pilih tanggal mulai - selesai',
startDate: _startDate,
endDate: _endDate,
primaryColor: AppColor.primary,
onChanged: (start, end) {
setState(() {
_startDate = start;
_endDate = end;
});
},
),
const SizedBox(height: 32),
Text(
'Outlined Style',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
const SizedBox(height: 16),
DateRangePickerFieldOutlined(
label: 'Rentang Waktu',
placeholder: 'Pilih rentang tanggal',
startDate: _startDate2,
endDate: _endDate2,
primaryColor: AppColor.secondary,
onChanged: (start, end) {
setState(() {
_startDate2 = start;
_endDate2 = end;
});
},
),
const SizedBox(height: 24),
// Display selected dates
if (_startDate != null ||
_endDate != null ||
_startDate2 != null ||
_endDate2 != null)
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColor.background,
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Selected Dates:',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
const SizedBox(height: 8),
if (_startDate != null)
Text(
'Default: ${_startDate!} - ${_endDate ?? 'Not selected'}',
),
if (_startDate2 != null)
Text(
'Outlined: ${_startDate2!} - ${_endDate2 ?? 'Not selected'}',
),
],
),
),
],
),
),
);
}
}