From 5a7432e3307dd1fe8e2bf15830dccbf94a949444 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 19 Jul 2024 23:38:25 +0800 Subject: [PATCH] :arrow_up: Support new notification APIs --- .github/workflows/nightly.yml | 20 +-------- lib/models/notification.dart | 60 +++++++++------------------ lib/screens/account/notification.dart | 27 ++---------- 3 files changed, 25 insertions(+), 82 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9f1821d..aa47d2b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -59,22 +59,4 @@ jobs: uses: actions/upload-artifact@v4 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 \ No newline at end of file + path: build/windows/x64/runner/Release \ No newline at end of file diff --git a/lib/models/notification.dart b/lib/models/notification.dart index f08e81e..63774dc 100755 --- a/lib/models/notification.dart +++ b/lib/models/notification.dart @@ -3,10 +3,11 @@ class Notification { DateTime createdAt; DateTime updatedAt; DateTime? deletedAt; - String subject; - String content; - List? 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.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.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 json) => Link( - label: json['label'], - url: json['url'], - ); - - Map toJson() => { - 'label': label, - 'url': url, - }; -} diff --git a/lib/screens/account/notification.dart b/lib/screens/account/notification.dart index 98fd172..afe0b2f 100644 --- a/lib/screens/account/notification.dart +++ b/lib/screens/account/notification.dart @@ -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 { 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), ], ), ),