Implement time-range filter
This commit is contained in:
parent
255fc9337c
commit
3e0c4845e9
@ -299,8 +299,8 @@ class APIClient {
|
|||||||
if (filter?.channelIDs != null) 'channel_id': filter!.channelIDs!,
|
if (filter?.channelIDs != null) 'channel_id': filter!.channelIDs!,
|
||||||
if (filter?.senderNames != null) 'sender': filter!.senderNames!,
|
if (filter?.senderNames != null) 'sender': filter!.senderNames!,
|
||||||
if (filter?.hasSenderName != null) 'has_sender': [filter!.hasSenderName!.toString()],
|
if (filter?.hasSenderName != null) 'has_sender': [filter!.hasSenderName!.toString()],
|
||||||
if (filter?.timeBefore != null) 'before': [filter!.timeBefore!.toIso8601String()],
|
if (filter?.timeBefore != null) 'before': [filter!.timeBefore!.toUtc().toIso8601String()],
|
||||||
if (filter?.timeAfter != null) 'after': [filter!.timeAfter!.toIso8601String()],
|
if (filter?.timeAfter != null) 'after': [filter!.timeAfter!.toUtc().toIso8601String()],
|
||||||
if (filter?.priority != null) 'priority': filter!.priority!.map((p) => p.toString()).toList(),
|
if (filter?.priority != null) 'priority': filter!.priority!.map((p) => p.toString()).toList(),
|
||||||
if (filter?.usedKeys != null) 'used_key': filter!.usedKeys!,
|
if (filter?.usedKeys != null) 'used_key': filter!.usedKeys!,
|
||||||
if (filter?.senderUserID != null) 'sender_user_id': filter!.senderUserID!,
|
if (filter?.senderUserID != null) 'sender_user_id': filter!.senderUserID!,
|
||||||
|
@ -5,8 +5,10 @@ import 'package:simplecloudnotifier/components/modals/filter_modal_keytoken.dart
|
|||||||
import 'package:simplecloudnotifier/components/modals/filter_modal_priority.dart';
|
import 'package:simplecloudnotifier/components/modals/filter_modal_priority.dart';
|
||||||
import 'package:simplecloudnotifier/components/modals/filter_modal_searchplain.dart';
|
import 'package:simplecloudnotifier/components/modals/filter_modal_searchplain.dart';
|
||||||
import 'package:simplecloudnotifier/components/modals/filter_modal_sendername.dart';
|
import 'package:simplecloudnotifier/components/modals/filter_modal_sendername.dart';
|
||||||
import 'package:simplecloudnotifier/components/modals/filter_modal_time.dart';
|
import 'package:simplecloudnotifier/pages/message_list/message_filter_chiplet.dart';
|
||||||
import 'package:simplecloudnotifier/state/app_bar_state.dart';
|
import 'package:simplecloudnotifier/state/app_bar_state.dart';
|
||||||
|
import 'package:simplecloudnotifier/state/app_events.dart';
|
||||||
|
import 'package:simplecloudnotifier/state/app_settings.dart';
|
||||||
import 'package:simplecloudnotifier/utils/navi.dart';
|
import 'package:simplecloudnotifier/utils/navi.dart';
|
||||||
|
|
||||||
class AppBarFilterDialog extends StatefulWidget {
|
class AppBarFilterDialog extends StatefulWidget {
|
||||||
@ -116,7 +118,21 @@ class _AppBarFilterDialogState extends State<AppBarFilterDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showTimeModal(BuildContext context) {
|
void _showTimeModal(BuildContext context) {
|
||||||
showDialog<void>(context: context, builder: (BuildContext context) => FilterModalTime());
|
final dateFormat = AppSettings().dateFormat.dateOnlyFormat();
|
||||||
|
|
||||||
|
final now = DateTime.now();
|
||||||
|
showDateRangePicker(context: context, firstDate: DateTime(2000), lastDate: DateTime(now.year, now.month, now.day + 7)).then((value) {
|
||||||
|
if (value != null) {
|
||||||
|
List<MessageFilterChiplet> chiplets = [];
|
||||||
|
chiplets.add(MessageFilterChiplet(
|
||||||
|
label: dateFormat.format(value.start) + ' - ' + dateFormat.format(value.end),
|
||||||
|
value: value,
|
||||||
|
type: MessageFilterChipletType.timeRange,
|
||||||
|
));
|
||||||
|
|
||||||
|
AppEvents().notifyFilterListeners([MessageFilterChipletType.plainSearch], chiplets);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showPlainSearchModal(BuildContext context) {
|
void _showPlainSearchModal(BuildContext context) {
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:simplecloudnotifier/utils/navi.dart';
|
|
||||||
|
|
||||||
class FilterModalTime extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
_FilterModalTimeState createState() => _FilterModalTimeState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FilterModalTimeState extends State<FilterModalTime> {
|
|
||||||
DateTime? _tsBefore = null;
|
|
||||||
DateTime? _tsAfter = null;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Timerange'),
|
|
||||||
content: Container(
|
|
||||||
width: 9000,
|
|
||||||
height: 9000,
|
|
||||||
child: Placeholder(),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
style: TextButton.styleFrom(textStyle: Theme.of(context).textTheme.labelLarge),
|
|
||||||
child: const Text('Apply'),
|
|
||||||
onPressed: () {
|
|
||||||
onOkay();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onOkay() {
|
|
||||||
Navi.popDialog(context);
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
}
|
|
@ -81,9 +81,9 @@ class _DebugRequestViewPageState extends State<DebugRequestViewPage> {
|
|||||||
UI.buttonIconOnly(
|
UI.buttonIconOnly(
|
||||||
iconSize: 14,
|
iconSize: 14,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Clipboard.setData(new ClipboardData(text: title));
|
Clipboard.setData(new ClipboardData(text: value));
|
||||||
Toaster.info("Clipboard", 'Copied text to Clipboard');
|
Toaster.info("Clipboard", 'Copied text to Clipboard');
|
||||||
print('================= [CLIPBOARD] =================\n${title}\n================= [/CLIPBOARD] =================');
|
print('================= [CLIPBOARD] =================\n${value}\n================= [/CLIPBOARD] =================');
|
||||||
},
|
},
|
||||||
icon: FontAwesomeIcons.copy,
|
icon: FontAwesomeIcons.copy,
|
||||||
),
|
),
|
||||||
|
@ -340,9 +340,14 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
|
|||||||
|
|
||||||
var chipletsTimeRange = _filterChiplets.where((p) => p.type == MessageFilterChipletType.timeRange).toList();
|
var chipletsTimeRange = _filterChiplets.where((p) => p.type == MessageFilterChipletType.timeRange).toList();
|
||||||
if (chipletsTimeRange.isNotEmpty) {
|
if (chipletsTimeRange.isNotEmpty) {
|
||||||
//TODO
|
var t0 = (chipletsTimeRange[0].value as DateTimeRange).start.toLocal();
|
||||||
//filter.timeAfter = chipletsTimeRange[0].value1 as DateTime;
|
var t1 = (chipletsTimeRange[0].value as DateTimeRange).end.toLocal();
|
||||||
//filter.timeBefore = chipletsTimeRange[0].value2 as DateTime;
|
|
||||||
|
t0 = DateTime(t0.year, t0.month, t0.day, 0, 0, 0, 0);
|
||||||
|
t1 = DateTime(t1.year, t1.month, t1.day, 23, 59, 59, 999);
|
||||||
|
|
||||||
|
filter.timeAfter = t0;
|
||||||
|
filter.timeBefore = t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
|
@ -2,7 +2,7 @@ name: simplecloudnotifier
|
|||||||
description: "Receive push messages"
|
description: "Receive push messages"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 2.0.0+479
|
version: 2.0.0+481
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.2.6 <4.0.0'
|
sdk: '>=3.2.6 <4.0.0'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user