⬆️ Support new notification APIs

This commit is contained in:
LittleSheep 2024-07-19 23:38:25 +08:00
parent 6811d8e9b1
commit 5a7432e330
3 changed files with 25 additions and 82 deletions

View File

@ -60,21 +60,3 @@ jobs:
with:
name: build-output-windows
path: build/windows/x64/runner/Release
build-linux:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev libsqlite3-0 libsqlite3-dev
- run: flutter build linux
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: build-output-windows
path: build/linux/x64/release/bundle

View File

@ -3,10 +3,11 @@ class Notification {
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String subject;
String content;
List<Link>? links;
DateTime? readAt;
String title;
String? subtitle;
String body;
String? avatar;
String? picture;
int? senderId;
int recipientId;
@ -15,10 +16,11 @@ class Notification {
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.subject,
required this.content,
required this.links,
required this.readAt,
required this.title,
required this.subtitle,
required this.body,
required this.avatar,
required this.picture,
required this.senderId,
required this.recipientId,
});
@ -32,12 +34,11 @@ class Notification {
? DateTime.now()
: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
subject: json['subject'],
content: json['content'],
links: json['links'] != null
? List<Link>.from(json['links'].map((x) => Link.fromJson(x)))
: List.empty(),
readAt: json['read_at'],
title: json['title'],
subtitle: json['subtitle'],
body: json['body'],
avatar: json['avatar'],
picture: json['picture'],
senderId: json['sender_id'],
recipientId: json['recipient_id'],
);
@ -47,33 +48,12 @@ class Notification {
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'subject': subject,
'content': content,
'links': links != null
? List<dynamic>.from(links!.map((x) => x.toJson()))
: List.empty(),
'read_at': readAt,
'title': title,
'subtitle': subtitle,
'body': body,
'avatar': avatar,
'picture': picture,
'sender_id': senderId,
'recipient_id': recipientId,
};
}
class Link {
String label;
String url;
Link({
required this.label,
required this.url,
});
factory Link.fromJson(Map<String, dynamic> json) => Link(
label: json['label'],
url: json['url'],
);
Map<String, dynamic> toJson() => {
'label': label,
'url': url,
};
}

View File

@ -4,7 +4,6 @@ import 'package:get/get.dart';
import 'package:solian/providers/websocket.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/models/notification.dart' as notify;
import 'package:url_launcher/url_launcher_string.dart';
import 'package:uuid/uuid.dart';
class NotificationScreen extends StatefulWidget {
@ -126,31 +125,13 @@ class _NotificationScreenState extends State<NotificationScreen> {
horizontal: 24,
vertical: 8,
),
title: Text(element.subject),
title: Text(element.title),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(element.content),
if (element.links != null)
Row(
children: element.links!
.map((e) => InkWell(
child: Text(
e.label,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
decoration:
TextDecoration.underline,
),
),
onTap: () {
launchUrlString(e.url);
},
).paddingOnly(right: 5))
.toList(),
),
if (element.subtitle != null)
Text(element.subtitle!),
Text(element.body),
],
),
),