💄 Optimize publisher page filter select date
This commit is contained in:
@@ -1317,5 +1317,6 @@
|
|||||||
"fromDate": "From Date",
|
"fromDate": "From Date",
|
||||||
"toDate": "To Date",
|
"toDate": "To Date",
|
||||||
"popularity": "Popularity",
|
"popularity": "Popularity",
|
||||||
"descendingOrder": "Descending Order"
|
"descendingOrder": "Descending Order",
|
||||||
|
"selectDate": "Select Date"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,10 +487,29 @@ class _PublisherCategoryTabWidget extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
final pickedDate = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate:
|
||||||
|
periodStart.value != null
|
||||||
|
? DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
periodStart.value! * 1000,
|
||||||
|
)
|
||||||
|
: DateTime.now(),
|
||||||
|
firstDate: DateTime(2000),
|
||||||
|
lastDate: DateTime.now().add(
|
||||||
|
const Duration(days: 365),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (pickedDate != null) {
|
||||||
|
periodStart.value =
|
||||||
|
pickedDate.millisecondsSinceEpoch ~/ 1000;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: InputDecorator(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'fromDate'.tr(),
|
labelText: 'fromDate'.tr(),
|
||||||
hintText: 'YYYY-MM-DD',
|
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
Radius.circular(12),
|
Radius.circular(12),
|
||||||
@@ -500,28 +519,43 @@ class _PublisherCategoryTabWidget extends StatelessWidget {
|
|||||||
horizontal: 12,
|
horizontal: 12,
|
||||||
vertical: 8,
|
vertical: 8,
|
||||||
),
|
),
|
||||||
|
suffixIcon: const Icon(Symbols.calendar_today),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
periodStart.value != null
|
||||||
|
? DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
periodStart.value! * 1000,
|
||||||
|
).toString().split(' ')[0]
|
||||||
|
: 'selectDate'.tr(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onChanged: (value) {
|
|
||||||
if (value.isEmpty) {
|
|
||||||
periodStart.value = null;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
final date = DateTime.parse(value);
|
|
||||||
periodStart.value =
|
|
||||||
date.millisecondsSinceEpoch ~/ 1000;
|
|
||||||
} catch (_) {
|
|
||||||
periodStart.value = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Gap(8),
|
const Gap(8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
final pickedDate = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate:
|
||||||
|
periodEnd.value != null
|
||||||
|
? DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
periodEnd.value! * 1000,
|
||||||
|
)
|
||||||
|
: DateTime.now(),
|
||||||
|
firstDate: DateTime(2000),
|
||||||
|
lastDate: DateTime.now().add(
|
||||||
|
const Duration(days: 365),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (pickedDate != null) {
|
||||||
|
periodEnd.value =
|
||||||
|
pickedDate.millisecondsSinceEpoch ~/ 1000;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: InputDecorator(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'toDate'.tr(),
|
labelText: 'toDate'.tr(),
|
||||||
hintText: 'YYYY-MM-DD',
|
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
Radius.circular(12),
|
Radius.circular(12),
|
||||||
@@ -531,20 +565,16 @@ class _PublisherCategoryTabWidget extends StatelessWidget {
|
|||||||
horizontal: 12,
|
horizontal: 12,
|
||||||
vertical: 8,
|
vertical: 8,
|
||||||
),
|
),
|
||||||
|
suffixIcon: const Icon(Symbols.calendar_today),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
periodEnd.value != null
|
||||||
|
? DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
periodEnd.value! * 1000,
|
||||||
|
).toString().split(' ')[0]
|
||||||
|
: 'selectDate'.tr(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onChanged: (value) {
|
|
||||||
if (value.isEmpty) {
|
|
||||||
periodEnd.value = null;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
final date = DateTime.parse(value);
|
|
||||||
periodEnd.value =
|
|
||||||
date.millisecondsSinceEpoch ~/ 1000;
|
|
||||||
} catch (_) {
|
|
||||||
periodEnd.value = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user