improve dateFormat a bit, and fix some buttons
Some checks failed
Build Docker and Deploy / Build Docker Container (push) Successful in 49s
Build Docker and Deploy / Run Unit-Tests (push) Failing after 11m13s
Build Docker and Deploy / Deploy to Server (push) Has been skipped

This commit is contained in:
Mike Schwörer 2025-04-22 00:35:32 +02:00
parent b91ddc172d
commit d5e9c6ecc3
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
7 changed files with 20 additions and 9 deletions

View File

@ -62,7 +62,7 @@ class _ChannelListItemState extends State<ChannelListItem> {
@override
Widget build(BuildContext context) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return Card.filled(
margin: EdgeInsets.fromLTRB(0, 4, 0, 4),

View File

@ -19,7 +19,7 @@ class ClientListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return Card.filled(
margin: EdgeInsets.fromLTRB(0, 4, 0, 4),

View File

@ -24,7 +24,7 @@ class KeyTokenListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return Card.filled(
margin: EdgeInsets.fromLTRB(0, 4, 0, 4),

View File

@ -202,14 +202,14 @@ class _MessageViewPageState extends State<MessageViewPage> {
icon: FontAwesomeIcons.solidUser,
title: 'User',
values: [user?.userID ?? message.senderUserID, user?.username ?? ''],
mainAction: () => FilteredMessageViewPage(title: user?.username ?? message.senderUserID, filter: MessageFilter(senderUserID: [message.senderUserID])),
mainAction: () => Navi.push(context, () => FilteredMessageViewPage(title: user?.username ?? message.senderUserID, filter: MessageFilter(senderUserID: [message.senderUserID]))),
),
UI.metaCard(
context: context,
icon: FontAwesomeIcons.solidBolt,
title: 'Priority',
values: [_prettyPrintPriority(message.priority)],
mainAction: () => FilteredMessageViewPage(title: "Priority ${message.priority}", filter: MessageFilter(priority: [message.priority])),
mainAction: () => Navi.push(context, () => FilteredMessageViewPage(title: "Priority ${message.priority}", filter: MessageFilter(priority: [message.priority]))),
),
if (message.senderUserID == userAccUserID) UI.button(text: "Delete Message", onPressed: () {/*TODO*/}, color: Colors.red[900]),
],

View File

@ -22,7 +22,7 @@ class SenderListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return Card.filled(
margin: EdgeInsets.fromLTRB(0, 4, 0, 4),

View File

@ -160,7 +160,7 @@ class _SubscriptionViewPageState extends State<SubscriptionViewPage> {
}
Widget _buildOwnedSubscriptionView(BuildContext context, Subscription subscription) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return SingleChildScrollView(
child: Padding(
@ -193,7 +193,7 @@ class _SubscriptionViewPageState extends State<SubscriptionViewPage> {
}
Widget _buildIncomingSubscriptionView(BuildContext context, Subscription subscription) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return SingleChildScrollView(
child: Padding(
@ -228,7 +228,7 @@ class _SubscriptionViewPageState extends State<SubscriptionViewPage> {
}
Widget _buildOutgoingSubscriptionView(BuildContext context, Subscription subscription) {
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateFormat();
final dateFormat = context.select<AppSettings, AppSettingsDateFormat>((v) => v.dateFormat).dateOnlyFormat();
return SingleChildScrollView(
child: Padding(

View File

@ -30,6 +30,17 @@ enum AppSettingsDateFormat {
}
}
DateFormat dateOnlyFormat() {
switch (this) {
case AppSettingsDateFormat.ISO:
return DateFormat('yyyy-MM-dd');
case AppSettingsDateFormat.German:
return DateFormat('dd.MM.yyyy');
case AppSettingsDateFormat.US:
return DateFormat('MM/dd/yyyy');
}
}
static AppSettingsDateFormat? parse(String? string) {
if (string == null) return null;
return values.firstWhere((e) => e.key == string, orElse: null);