Compare commits

..

25 Commits

Author SHA1 Message Date
fb51d2076f 🗑️ Remove pfp decoration test code 2025-12-10 23:12:02 +08:00
d8485954fa Profile decoration 2025-12-10 23:11:46 +08:00
d7746d14e4 🚀 Launch 3.5.0+151 2025-12-06 21:52:30 +08:00
648d5225f6 🐛 Ensure mobile site management request permission 2025-12-06 21:48:16 +08:00
9d4d0f2e48 🐛 Fix inconsistence alert 2025-12-06 21:44:43 +08:00
fe386163f4 💄 Optimize designs in developer hub 2025-12-06 21:39:50 +08:00
ac2cee10e5 💄 Hub now shows loading stautus of publishers / developers 2025-12-06 21:28:19 +08:00
9c370647dd 🐛 Fix some bugs in creator hub 2025-12-06 21:26:00 +08:00
7516e197fe 💄 Fix post replies skeleton inconststent 2025-12-06 21:15:32 +08:00
71c372ab6c Prefer auto dispose riverpods 2025-12-06 21:13:25 +08:00
25f23f7f93 🐛 Fix serval bugs during the changes 2025-12-06 21:05:29 +08:00
51853698b9 🐛 Fix serval bugs 2025-12-06 20:53:24 +08:00
39ed5393ab 💄 Dedicated notification skeleton 2025-12-06 20:49:54 +08:00
782b3f1b08 🐛 Fix article edit shows the post edit sheet 2025-12-06 20:45:47 +08:00
3ef2f13dd3 💄 Redesign the post tags and categories page 2025-12-06 20:40:28 +08:00
36b0f55a47 🐛 Fix inconsistent of margin in post silver list 2025-12-06 20:24:54 +08:00
bc7a6e865e 🐛 Fix some issues 2025-12-06 20:20:54 +08:00
2ff60fc4ff 💫 List loading state switch animation 2025-12-06 19:54:34 +08:00
ea93aa144e 🐛 Fix some bugs in post search UI 2025-12-06 19:47:36 +08:00
e4cd0c99df 💄 Optimize skeleton effect 2025-12-06 19:01:40 +08:00
dff84dde58 Post list now supports initial filter to prevent some mismatch 2025-12-06 18:47:50 +08:00
16c7b7e764 ♻️ Refactored post loading 2025-12-06 18:20:47 +08:00
240509ceff 🚚 Update files layout of pods 2025-12-06 17:31:12 +08:00
91da9768c1 💄 Adjust the style of the post reply preview 2025-12-06 15:26:23 +08:00
60b8e2bcad 💄 Optimize post reply preview 2025-12-06 13:53:22 +08:00
108 changed files with 7237 additions and 6904 deletions

View File

@@ -12,6 +12,8 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

View File

@@ -618,6 +618,7 @@
"tagsHint": "Enter tags, separated by commas",
"categories": "Categories",
"categoriesHint": "Enter categories, separated by commas",
"categoriesAndTags": "Categories & Tags",
"chatNotJoined": "You have not joined this chat yet.",
"chatUnableJoin": "You can't join this chat due to it's access control settings.",
"chatJoin": "Join the Chat",

View File

@@ -1489,5 +1489,6 @@
"accountActivationAlert": "请记住激活您的账户",
"accountActivationAlertHint": "未激活的账户可能会导致各种权限问题,请点击我们发送到您邮箱收件箱的链接来激活您的账户。",
"accountActivationResendHint": "没收到?请尝试点击下方按钮重新发送。如果您在账户未激活期间需要更新邮箱,请随时联系我们的客服。",
"accountActivationResend": "重新发送"
"accountActivationResend": "重新发送",
"noFurtherData": "已经到底了"
}

View File

@@ -257,6 +257,8 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.3.0):
- Flutter
- pointer_interceptor_ios (0.0.1):
- Flutter
- PromisesObjC (2.4.0)
@@ -351,6 +353,7 @@ DEPENDENCIES:
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- pasteboard (from `.symlinks/plugins/pasteboard/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`)
- protocol_handler_ios (from `.symlinks/plugins/protocol_handler_ios/ios`)
- receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`)
@@ -458,6 +461,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/pasteboard/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
pointer_interceptor_ios:
:path: ".symlinks/plugins/pointer_interceptor_ios/ios"
protocol_handler_ios:
@@ -539,6 +544,7 @@ SPEC CHECKSUMS:
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
pasteboard: 49088aeb6119d51f976a421db60d8e1ab079b63c
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
pointer_interceptor_ios: da06a662d5bfd329602b45b2ab41bc0fb5fdb0f0
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851

View File

@@ -264,8 +264,7 @@ class $ChatRoomsTable extends ChatRooms
ChatRoom map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return ChatRoom(
id:
attachedDatabase.typeMapping.read(
id: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}id'],
)!,
@@ -277,8 +276,7 @@ class $ChatRoomsTable extends ChatRooms
DriftSqlType.string,
data['${effectivePrefix}description'],
),
type:
attachedDatabase.typeMapping.read(
type: attachedDatabase.typeMapping.read(
DriftSqlType.int,
data['${effectivePrefix}type'],
)!,
@@ -310,13 +308,11 @@ class $ChatRoomsTable extends ChatRooms
DriftSqlType.string,
data['${effectivePrefix}account_id'],
),
createdAt:
attachedDatabase.typeMapping.read(
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
)!,
updatedAt:
attachedDatabase.typeMapping.read(
updatedAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}updated_at'],
)!,
@@ -416,39 +412,31 @@ class ChatRoom extends DataClass implements Insertable<ChatRoom> {
return ChatRoomsCompanion(
id: Value(id),
name: name == null && nullToAbsent ? const Value.absent() : Value(name),
description:
description == null && nullToAbsent
description: description == null && nullToAbsent
? const Value.absent()
: Value(description),
type: Value(type),
isPublic:
isPublic == null && nullToAbsent
isPublic: isPublic == null && nullToAbsent
? const Value.absent()
: Value(isPublic),
isCommunity:
isCommunity == null && nullToAbsent
isCommunity: isCommunity == null && nullToAbsent
? const Value.absent()
: Value(isCommunity),
picture:
picture == null && nullToAbsent
picture: picture == null && nullToAbsent
? const Value.absent()
: Value(picture),
background:
background == null && nullToAbsent
background: background == null && nullToAbsent
? const Value.absent()
: Value(background),
realmId:
realmId == null && nullToAbsent
realmId: realmId == null && nullToAbsent
? const Value.absent()
: Value(realmId),
accountId:
accountId == null && nullToAbsent
accountId: accountId == null && nullToAbsent
? const Value.absent()
: Value(accountId),
createdAt: Value(createdAt),
updatedAt: Value(updatedAt),
deletedAt:
deletedAt == null && nullToAbsent
deletedAt: deletedAt == null && nullToAbsent
? const Value.absent()
: Value(deletedAt),
);
@@ -530,15 +518,18 @@ class ChatRoom extends DataClass implements Insertable<ChatRoom> {
return ChatRoom(
id: data.id.present ? data.id.value : this.id,
name: data.name.present ? data.name.value : this.name,
description:
data.description.present ? data.description.value : this.description,
description: data.description.present
? data.description.value
: this.description,
type: data.type.present ? data.type.value : this.type,
isPublic: data.isPublic.present ? data.isPublic.value : this.isPublic,
isCommunity:
data.isCommunity.present ? data.isCommunity.value : this.isCommunity,
isCommunity: data.isCommunity.present
? data.isCommunity.value
: this.isCommunity,
picture: data.picture.present ? data.picture.value : this.picture,
background:
data.background.present ? data.background.value : this.background,
background: data.background.present
? data.background.value
: this.background,
realmId: data.realmId.present ? data.realmId.value : this.realmId,
accountId: data.accountId.present ? data.accountId.value : this.accountId,
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
@@ -1044,18 +1035,15 @@ class $ChatMembersTable extends ChatMembers
ChatMember map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return ChatMember(
id:
attachedDatabase.typeMapping.read(
id: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}id'],
)!,
chatRoomId:
attachedDatabase.typeMapping.read(
chatRoomId: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}chat_room_id'],
)!,
accountId:
attachedDatabase.typeMapping.read(
accountId: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}account_id'],
)!,
@@ -1069,8 +1057,7 @@ class $ChatMembersTable extends ChatMembers
DriftSqlType.string,
data['${effectivePrefix}nick'],
),
notify:
attachedDatabase.typeMapping.read(
notify: attachedDatabase.typeMapping.read(
DriftSqlType.int,
data['${effectivePrefix}notify'],
)!,
@@ -1086,13 +1073,11 @@ class $ChatMembersTable extends ChatMembers
DriftSqlType.dateTime,
data['${effectivePrefix}timeout_until'],
),
createdAt:
attachedDatabase.typeMapping.read(
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
)!,
updatedAt:
attachedDatabase.typeMapping.read(
updatedAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}updated_at'],
)!,
@@ -1179,22 +1164,18 @@ class ChatMember extends DataClass implements Insertable<ChatMember> {
account: Value(account),
nick: nick == null && nullToAbsent ? const Value.absent() : Value(nick),
notify: Value(notify),
joinedAt:
joinedAt == null && nullToAbsent
joinedAt: joinedAt == null && nullToAbsent
? const Value.absent()
: Value(joinedAt),
breakUntil:
breakUntil == null && nullToAbsent
breakUntil: breakUntil == null && nullToAbsent
? const Value.absent()
: Value(breakUntil),
timeoutUntil:
timeoutUntil == null && nullToAbsent
timeoutUntil: timeoutUntil == null && nullToAbsent
? const Value.absent()
: Value(timeoutUntil),
createdAt: Value(createdAt),
updatedAt: Value(updatedAt),
deletedAt:
deletedAt == null && nullToAbsent
deletedAt: deletedAt == null && nullToAbsent
? const Value.absent()
: Value(deletedAt),
);
@@ -1269,17 +1250,18 @@ class ChatMember extends DataClass implements Insertable<ChatMember> {
ChatMember copyWithCompanion(ChatMembersCompanion data) {
return ChatMember(
id: data.id.present ? data.id.value : this.id,
chatRoomId:
data.chatRoomId.present ? data.chatRoomId.value : this.chatRoomId,
chatRoomId: data.chatRoomId.present
? data.chatRoomId.value
: this.chatRoomId,
accountId: data.accountId.present ? data.accountId.value : this.accountId,
account: data.account.present ? data.account.value : this.account,
nick: data.nick.present ? data.nick.value : this.nick,
notify: data.notify.present ? data.notify.value : this.notify,
joinedAt: data.joinedAt.present ? data.joinedAt.value : this.joinedAt,
breakUntil:
data.breakUntil.present ? data.breakUntil.value : this.breakUntil,
timeoutUntil:
data.timeoutUntil.present
breakUntil: data.breakUntil.present
? data.breakUntil.value
: this.breakUntil,
timeoutUntil: data.timeoutUntil.present
? data.timeoutUntil.value
: this.timeoutUntil,
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
@@ -1695,7 +1677,8 @@ class $ChatMessagesTable extends ChatMessages
List<Map<String, dynamic>>,
String
>
attachments = GeneratedColumn<String>(
attachments =
GeneratedColumn<String>(
'attachments',
aliasedName,
false,
@@ -1710,7 +1693,8 @@ class $ChatMessagesTable extends ChatMessages
List<Map<String, dynamic>>,
String
>
reactions = GeneratedColumn<String>(
reactions =
GeneratedColumn<String>(
'reactions',
aliasedName,
false,
@@ -1882,18 +1866,15 @@ class $ChatMessagesTable extends ChatMessages
ChatMessage map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return ChatMessage(
id:
attachedDatabase.typeMapping.read(
id: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}id'],
)!,
roomId:
attachedDatabase.typeMapping.read(
roomId: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}room_id'],
)!,
senderId:
attachedDatabase.typeMapping.read(
senderId: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}sender_id'],
)!,
@@ -1905,13 +1886,11 @@ class $ChatMessagesTable extends ChatMessages
DriftSqlType.string,
data['${effectivePrefix}nonce'],
),
data:
attachedDatabase.typeMapping.read(
data: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}data'],
)!,
createdAt:
attachedDatabase.typeMapping.read(
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
)!,
@@ -1933,8 +1912,7 @@ class $ChatMessagesTable extends ChatMessages
DriftSqlType.dateTime,
data['${effectivePrefix}deleted_at'],
),
type:
attachedDatabase.typeMapping.read(
type: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}type'],
)!,
@@ -2101,42 +2079,36 @@ class ChatMessage extends DataClass implements Insertable<ChatMessage> {
id: Value(id),
roomId: Value(roomId),
senderId: Value(senderId),
content:
content == null && nullToAbsent
content: content == null && nullToAbsent
? const Value.absent()
: Value(content),
nonce:
nonce == null && nullToAbsent ? const Value.absent() : Value(nonce),
nonce: nonce == null && nullToAbsent
? const Value.absent()
: Value(nonce),
data: Value(data),
createdAt: Value(createdAt),
status: Value(status),
isDeleted:
isDeleted == null && nullToAbsent
isDeleted: isDeleted == null && nullToAbsent
? const Value.absent()
: Value(isDeleted),
updatedAt:
updatedAt == null && nullToAbsent
updatedAt: updatedAt == null && nullToAbsent
? const Value.absent()
: Value(updatedAt),
deletedAt:
deletedAt == null && nullToAbsent
deletedAt: deletedAt == null && nullToAbsent
? const Value.absent()
: Value(deletedAt),
type: Value(type),
meta: Value(meta),
membersMentioned: Value(membersMentioned),
editedAt:
editedAt == null && nullToAbsent
editedAt: editedAt == null && nullToAbsent
? const Value.absent()
: Value(editedAt),
attachments: Value(attachments),
reactions: Value(reactions),
repliedMessageId:
repliedMessageId == null && nullToAbsent
repliedMessageId: repliedMessageId == null && nullToAbsent
? const Value.absent()
: Value(repliedMessageId),
forwardedMessageId:
forwardedMessageId == null && nullToAbsent
forwardedMessageId: forwardedMessageId == null && nullToAbsent
? const Value.absent()
: Value(forwardedMessageId),
);
@@ -2245,12 +2217,10 @@ class ChatMessage extends DataClass implements Insertable<ChatMessage> {
editedAt: editedAt.present ? editedAt.value : this.editedAt,
attachments: attachments ?? this.attachments,
reactions: reactions ?? this.reactions,
repliedMessageId:
repliedMessageId.present
repliedMessageId: repliedMessageId.present
? repliedMessageId.value
: this.repliedMessageId,
forwardedMessageId:
forwardedMessageId.present
forwardedMessageId: forwardedMessageId.present
? forwardedMessageId.value
: this.forwardedMessageId,
);
@@ -2269,20 +2239,18 @@ class ChatMessage extends DataClass implements Insertable<ChatMessage> {
deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt,
type: data.type.present ? data.type.value : this.type,
meta: data.meta.present ? data.meta.value : this.meta,
membersMentioned:
data.membersMentioned.present
membersMentioned: data.membersMentioned.present
? data.membersMentioned.value
: this.membersMentioned,
editedAt: data.editedAt.present ? data.editedAt.value : this.editedAt,
attachments:
data.attachments.present ? data.attachments.value : this.attachments,
attachments: data.attachments.present
? data.attachments.value
: this.attachments,
reactions: data.reactions.present ? data.reactions.value : this.reactions,
repliedMessageId:
data.repliedMessageId.present
repliedMessageId: data.repliedMessageId.present
? data.repliedMessageId.value
: this.repliedMessageId,
forwardedMessageId:
data.forwardedMessageId.present
forwardedMessageId: data.forwardedMessageId.present
? data.forwardedMessageId.value
: this.forwardedMessageId,
);
@@ -2809,8 +2777,7 @@ class $PostDraftsTable extends PostDrafts
PostDraft map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return PostDraft(
id:
attachedDatabase.typeMapping.read(
id: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}id'],
)!,
@@ -2826,23 +2793,19 @@ class $PostDraftsTable extends PostDrafts
DriftSqlType.string,
data['${effectivePrefix}content'],
),
visibility:
attachedDatabase.typeMapping.read(
visibility: attachedDatabase.typeMapping.read(
DriftSqlType.int,
data['${effectivePrefix}visibility'],
)!,
type:
attachedDatabase.typeMapping.read(
type: attachedDatabase.typeMapping.read(
DriftSqlType.int,
data['${effectivePrefix}type'],
)!,
lastModified:
attachedDatabase.typeMapping.read(
lastModified: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}last_modified'],
)!,
postData:
attachedDatabase.typeMapping.read(
postData: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}post_data'],
)!,
@@ -2897,14 +2860,13 @@ class PostDraft extends DataClass implements Insertable<PostDraft> {
PostDraftsCompanion toCompanion(bool nullToAbsent) {
return PostDraftsCompanion(
id: Value(id),
title:
title == null && nullToAbsent ? const Value.absent() : Value(title),
description:
description == null && nullToAbsent
title: title == null && nullToAbsent
? const Value.absent()
: Value(title),
description: description == null && nullToAbsent
? const Value.absent()
: Value(description),
content:
content == null && nullToAbsent
content: content == null && nullToAbsent
? const Value.absent()
: Value(content),
visibility: Value(visibility),
@@ -2968,14 +2930,15 @@ class PostDraft extends DataClass implements Insertable<PostDraft> {
return PostDraft(
id: data.id.present ? data.id.value : this.id,
title: data.title.present ? data.title.value : this.title,
description:
data.description.present ? data.description.value : this.description,
description: data.description.present
? data.description.value
: this.description,
content: data.content.present ? data.content.value : this.content,
visibility:
data.visibility.present ? data.visibility.value : this.visibility,
visibility: data.visibility.present
? data.visibility.value
: this.visibility,
type: data.type.present ? data.type.value : this.type,
lastModified:
data.lastModified.present
lastModified: data.lastModified.present
? data.lastModified.value
: this.lastModified,
postData: data.postData.present ? data.postData.value : this.postData,
@@ -3585,12 +3548,12 @@ class $$ChatRoomsTableTableManager
TableManagerState(
db: db,
table: table,
createFilteringComposer:
() => $$ChatRoomsTableFilterComposer($db: db, $table: table),
createOrderingComposer:
() => $$ChatRoomsTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer:
() => $$ChatRoomsTableAnnotationComposer($db: db, $table: table),
createFilteringComposer: () =>
$$ChatRoomsTableFilterComposer($db: db, $table: table),
createOrderingComposer: () =>
$$ChatRoomsTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer: () =>
$$ChatRoomsTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback:
({
Value<String> id = const Value.absent(),
@@ -3655,9 +3618,7 @@ class $$ChatRoomsTableTableManager
deletedAt: deletedAt,
rowid: rowid,
),
withReferenceMapper:
(p0) =>
p0
withReferenceMapper: (p0) => p0
.map(
(e) => (
e.readTable(table),
@@ -3665,10 +3626,8 @@ class $$ChatRoomsTableTableManager
),
)
.toList(),
prefetchHooksCallback: ({
chatMembersRefs = false,
chatMessagesRefs = false,
}) {
prefetchHooksCallback:
({chatMembersRefs = false, chatMessagesRefs = false}) {
return PrefetchHooks(
db: db,
explicitlyWatchedTables: [
@@ -3687,8 +3646,7 @@ class $$ChatRoomsTableTableManager
currentTable: table,
referencedTable: $$ChatRoomsTableReferences
._chatMembersRefsTable(db),
managerFromTypedResult:
(p0) =>
managerFromTypedResult: (p0) =>
$$ChatRoomsTableReferences(
db,
table,
@@ -3709,16 +3667,16 @@ class $$ChatRoomsTableTableManager
currentTable: table,
referencedTable: $$ChatRoomsTableReferences
._chatMessagesRefsTable(db),
managerFromTypedResult:
(p0) =>
managerFromTypedResult: (p0) =>
$$ChatRoomsTableReferences(
db,
table,
p0,
).chatMessagesRefs,
referencedItemsForCurrentItem:
(item, referencedItems) =>
referencedItems.where((e) => e.roomId == item.id),
(item, referencedItems) => referencedItems.where(
(e) => e.roomId == item.id,
),
typedResults: items,
),
];
@@ -4142,12 +4100,11 @@ class $$ChatMembersTableTableManager
TableManagerState(
db: db,
table: table,
createFilteringComposer:
() => $$ChatMembersTableFilterComposer($db: db, $table: table),
createOrderingComposer:
() => $$ChatMembersTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer:
() =>
createFilteringComposer: () =>
$$ChatMembersTableFilterComposer($db: db, $table: table),
createOrderingComposer: () =>
$$ChatMembersTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer: () =>
$$ChatMembersTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback:
({
@@ -4209,9 +4166,7 @@ class $$ChatMembersTableTableManager
deletedAt: deletedAt,
rowid: rowid,
),
withReferenceMapper:
(p0) =>
p0
withReferenceMapper: (p0) => p0
.map(
(e) => (
e.readTable(table),
@@ -4219,14 +4174,15 @@ class $$ChatMembersTableTableManager
),
)
.toList(),
prefetchHooksCallback: ({
chatRoomId = false,
chatMessagesRefs = false,
}) {
prefetchHooksCallback:
({chatRoomId = false, chatMessagesRefs = false}) {
return PrefetchHooks(
db: db,
explicitlyWatchedTables: [if (chatMessagesRefs) db.chatMessages],
addJoins: <
explicitlyWatchedTables: [
if (chatMessagesRefs) db.chatMessages,
],
addJoins:
<
T extends TableManagerState<
dynamic,
dynamic,
@@ -4246,7 +4202,8 @@ class $$ChatMembersTableTableManager
state.withJoin(
currentTable: table,
currentColumn: table.chatRoomId,
referencedTable: $$ChatMembersTableReferences
referencedTable:
$$ChatMembersTableReferences
._chatRoomIdTable(db),
referencedColumn:
$$ChatMembersTableReferences
@@ -4269,8 +4226,7 @@ class $$ChatMembersTableTableManager
currentTable: table,
referencedTable: $$ChatMembersTableReferences
._chatMessagesRefsTable(db),
managerFromTypedResult:
(p0) =>
managerFromTypedResult: (p0) =>
$$ChatMembersTableReferences(
db,
table,
@@ -4831,12 +4787,11 @@ class $$ChatMessagesTableTableManager
TableManagerState(
db: db,
table: table,
createFilteringComposer:
() => $$ChatMessagesTableFilterComposer($db: db, $table: table),
createOrderingComposer:
() => $$ChatMessagesTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer:
() =>
createFilteringComposer: () =>
$$ChatMessagesTableFilterComposer($db: db, $table: table),
createOrderingComposer: () =>
$$ChatMessagesTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer: () =>
$$ChatMessagesTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback:
({
@@ -4930,9 +4885,7 @@ class $$ChatMessagesTableTableManager
forwardedMessageId: forwardedMessageId,
rowid: rowid,
),
withReferenceMapper:
(p0) =>
p0
withReferenceMapper: (p0) => p0
.map(
(e) => (
e.readTable(table),
@@ -4944,7 +4897,8 @@ class $$ChatMessagesTableTableManager
return PrefetchHooks(
db: db,
explicitlyWatchedTables: [],
addJoins: <
addJoins:
<
T extends TableManagerState<
dynamic,
dynamic,
@@ -4966,8 +4920,7 @@ class $$ChatMessagesTableTableManager
currentColumn: table.roomId,
referencedTable: $$ChatMessagesTableReferences
._roomIdTable(db),
referencedColumn:
$$ChatMessagesTableReferences
referencedColumn: $$ChatMessagesTableReferences
._roomIdTable(db)
.id,
)
@@ -4980,8 +4933,7 @@ class $$ChatMessagesTableTableManager
currentColumn: table.senderId,
referencedTable: $$ChatMessagesTableReferences
._senderIdTable(db),
referencedColumn:
$$ChatMessagesTableReferences
referencedColumn: $$ChatMessagesTableReferences
._senderIdTable(db)
.id,
)
@@ -5201,12 +5153,12 @@ class $$PostDraftsTableTableManager
TableManagerState(
db: db,
table: table,
createFilteringComposer:
() => $$PostDraftsTableFilterComposer($db: db, $table: table),
createOrderingComposer:
() => $$PostDraftsTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer:
() => $$PostDraftsTableAnnotationComposer($db: db, $table: table),
createFilteringComposer: () =>
$$PostDraftsTableFilterComposer($db: db, $table: table),
createOrderingComposer: () =>
$$PostDraftsTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer: () =>
$$PostDraftsTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback:
({
Value<String> id = const Value.absent(),
@@ -5251,15 +5203,8 @@ class $$PostDraftsTableTableManager
postData: postData,
rowid: rowid,
),
withReferenceMapper:
(p0) =>
p0
.map(
(e) => (
e.readTable(table),
BaseReferences(db, table, e),
),
)
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), BaseReferences(db, table, e)))
.toList(),
prefetchHooksCallback: null,
),

View File

@@ -12,16 +12,14 @@ _SnAbuseReport _$SnAbuseReportFromJson(Map<String, dynamic> json) =>
resourceIdentifier: json['resource_identifier'] as String,
type: (json['type'] as num).toInt(),
reason: json['reason'] as String,
resolvedAt:
json['resolved_at'] == null
resolvedAt: json['resolved_at'] == null
? null
: DateTime.parse(json['resolved_at'] as String),
resolution: json['resolution'] as String?,
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -15,8 +15,7 @@ _SnAccount _$SnAccountFromJson(Map<String, dynamic> json) => _SnAccount(
isSuperuser: json['is_superuser'] as bool,
automatedId: json['automated_id'] as String?,
profile: SnAccountProfile.fromJson(json['profile'] as Map<String, dynamic>),
perkSubscription:
json['perk_subscription'] == null
perkSubscription: json['perk_subscription'] == null
? null
: SnWalletSubscriptionRef.fromJson(
json['perk_subscription'] as Map<String, dynamic>,
@@ -31,14 +30,12 @@ _SnAccount _$SnAccountFromJson(Map<String, dynamic> json) => _SnAccount(
?.map((e) => SnContactMethod.fromJson(e as Map<String, dynamic>))
.toList() ??
const [],
activatedAt:
json['activated_at'] == null
activatedAt: json['activated_at'] == null
? null
: DateTime.parse(json['activated_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -73,8 +70,9 @@ _UsernameColor _$UsernameColorFromJson(Map<String, dynamic> json) =>
type: json['type'] as String? ?? 'plain',
value: json['value'] as String?,
direction: json['direction'] as String?,
colors:
(json['colors'] as List<dynamic>?)?.map((e) => e as String).toList(),
colors: (json['colors'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
);
Map<String, dynamic> _$UsernameColorToJson(_UsernameColor instance) =>
@@ -85,8 +83,9 @@ Map<String, dynamic> _$UsernameColorToJson(_UsernameColor instance) =>
'colors': instance.colors,
};
_SnAccountProfile _$SnAccountProfileFromJson(Map<String, dynamic> json) =>
_SnAccountProfile(
_SnAccountProfile _$SnAccountProfileFromJson(
Map<String, dynamic> json,
) => _SnAccountProfile(
id: json['id'] as String,
firstName: json['first_name'] as String? ?? '',
middleName: json['middle_name'] as String? ?? '',
@@ -96,58 +95,43 @@ _SnAccountProfile _$SnAccountProfileFromJson(Map<String, dynamic> json) =>
pronouns: json['pronouns'] as String? ?? '',
location: json['location'] as String? ?? '',
timeZone: json['time_zone'] as String? ?? '',
birthday:
json['birthday'] == null
birthday: json['birthday'] == null
? null
: DateTime.parse(json['birthday'] as String),
links:
json['links'] == null
links: json['links'] == null
? const []
: const ProfileLinkConverter().fromJson(json['links']),
lastSeenAt:
json['last_seen_at'] == null
lastSeenAt: json['last_seen_at'] == null
? null
: DateTime.parse(json['last_seen_at'] as String),
activeBadge:
json['active_badge'] == null
activeBadge: json['active_badge'] == null
? null
: SnAccountBadge.fromJson(
json['active_badge'] as Map<String, dynamic>,
),
: SnAccountBadge.fromJson(json['active_badge'] as Map<String, dynamic>),
experience: (json['experience'] as num).toInt(),
level: (json['level'] as num).toInt(),
socialCredits: (json['social_credits'] as num?)?.toDouble() ?? 100,
socialCreditsLevel: (json['social_credits_level'] as num?)?.toInt() ?? 0,
levelingProgress: (json['leveling_progress'] as num).toDouble(),
picture:
json['picture'] == null
picture: json['picture'] == null
? null
: SnCloudFile.fromJson(json['picture'] as Map<String, dynamic>),
background:
json['background'] == null
background: json['background'] == null
? null
: SnCloudFile.fromJson(
json['background'] as Map<String, dynamic>,
),
verification:
json['verification'] == null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
verification: json['verification'] == null
? null
: SnVerificationMark.fromJson(
json['verification'] as Map<String, dynamic>,
),
usernameColor:
json['username_color'] == null
usernameColor: json['username_color'] == null
? null
: UsernameColor.fromJson(
json['username_color'] as Map<String, dynamic>,
),
: UsernameColor.fromJson(json['username_color'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
);
Map<String, dynamic> _$SnAccountProfileToJson(_SnAccountProfile instance) =>
<String, dynamic>{
@@ -188,15 +172,13 @@ _SnAccountStatus _$SnAccountStatusFromJson(Map<String, dynamic> json) =>
isCustomized: json['is_customized'] as bool,
label: json['label'] as String? ?? "",
meta: json['meta'] as Map<String, dynamic>?,
clearedAt:
json['cleared_at'] == null
clearedAt: json['cleared_at'] == null
? null
: DateTime.parse(json['cleared_at'] as String),
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -225,19 +207,16 @@ _SnAccountBadge _$SnAccountBadgeFromJson(Map<String, dynamic> json) =>
label: json['label'] as String?,
caption: json['caption'] as String?,
meta: json['meta'] as Map<String, dynamic>,
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
activatedAt:
json['activated_at'] == null
activatedAt: json['activated_at'] == null
? null
: DateTime.parse(json['activated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -261,8 +240,7 @@ _SnContactMethod _$SnContactMethodFromJson(Map<String, dynamic> json) =>
_SnContactMethod(
id: json['id'] as String,
type: (json['type'] as num).toInt(),
verifiedAt:
json['verified_at'] == null
verifiedAt: json['verified_at'] == null
? null
: DateTime.parse(json['verified_at'] as String),
isPrimary: json['is_primary'] as bool,
@@ -271,8 +249,7 @@ _SnContactMethod _$SnContactMethodFromJson(Map<String, dynamic> json) =>
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -295,8 +272,7 @@ _SnNotification _$SnNotificationFromJson(Map<String, dynamic> json) =>
_SnNotification(
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
id: json['id'] as String,
@@ -306,8 +282,7 @@ _SnNotification _$SnNotificationFromJson(Map<String, dynamic> json) =>
content: json['content'] as String,
meta: json['meta'] as Map<String, dynamic>? ?? const {},
priority: (json['priority'] as num).toInt(),
viewedAt:
json['viewed_at'] == null
viewedAt: json['viewed_at'] == null
? null
: DateTime.parse(json['viewed_at'] as String),
accountId: json['account_id'] as String,
@@ -376,8 +351,7 @@ _SnAuthDeviceWithSessione _$SnAuthDeviceWithSessioneFromJson(
deviceLabel: json['device_label'] as String?,
accountId: json['account_id'] as String,
platform: (json['platform'] as num).toInt(),
sessions:
(json['sessions'] as List<dynamic>)
sessions: (json['sessions'] as List<dynamic>)
.map((e) => SnAuthSession.fromJson(e as Map<String, dynamic>))
.toList(),
isCurrent: json['is_current'] as bool? ?? false,
@@ -405,8 +379,7 @@ _SnExperienceRecord _$SnExperienceRecordFromJson(Map<String, dynamic> json) =>
bonusMultiplier: (json['bonus_multiplier'] as num?)?.toDouble() ?? 1.0,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -430,14 +403,12 @@ _SnSocialCreditRecord _$SnSocialCreditRecordFromJson(
delta: (json['delta'] as num).toDouble(),
reasonType: json['reason_type'] as String,
reason: json['reason'] as String,
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -460,8 +431,7 @@ _SnFriendOverviewItem _$SnFriendOverviewItemFromJson(
) => _SnFriendOverviewItem(
account: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
status: SnAccountStatus.fromJson(json['status'] as Map<String, dynamic>),
activities:
(json['activities'] as List<dynamic>)
activities: (json['activities'] as List<dynamic>)
.map((e) => SnPresenceActivity.fromJson(e as Map<String, dynamic>))
.toList(),
);

View File

@@ -12,8 +12,7 @@ _SnNotableDay _$SnNotableDayFromJson(Map<String, dynamic> json) =>
localName: json['local_name'] as String,
globalName: json['global_name'] as String,
countryCode: json['country_code'] as String,
holidays:
(json['holidays'] as List<dynamic>)
holidays: (json['holidays'] as List<dynamic>)
.map((e) => (e as num).toInt())
.toList(),
);
@@ -35,8 +34,7 @@ _SnTimelineEvent _$SnTimelineEventFromJson(Map<String, dynamic> json) =>
data: json['data'],
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -56,19 +54,16 @@ _SnCheckInResult _$SnCheckInResultFromJson(Map<String, dynamic> json) =>
_SnCheckInResult(
id: json['id'] as String,
level: (json['level'] as num).toInt(),
tips:
(json['tips'] as List<dynamic>)
tips: (json['tips'] as List<dynamic>)
.map((e) => SnFortuneTip.fromJson(e as Map<String, dynamic>))
.toList(),
accountId: json['account_id'] as String,
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -103,14 +98,12 @@ _SnEventCalendarEntry _$SnEventCalendarEntryFromJson(
Map<String, dynamic> json,
) => _SnEventCalendarEntry(
date: DateTime.parse(json['date'] as String),
checkInResult:
json['check_in_result'] == null
checkInResult: json['check_in_result'] == null
? null
: SnCheckInResult.fromJson(
json['check_in_result'] as Map<String, dynamic>,
),
statuses:
(json['statuses'] as List<dynamic>)
statuses: (json['statuses'] as List<dynamic>)
.map((e) => SnAccountStatus.fromJson(e as Map<String, dynamic>))
.toList(),
);
@@ -141,8 +134,7 @@ _SnPresenceActivity _$SnPresenceActivityFromJson(Map<String, dynamic> json) =>
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -34,15 +34,13 @@ Map<String, dynamic> _$GeoIpLocationToJson(_GeoIpLocation instance) =>
_SnAuthChallenge _$SnAuthChallengeFromJson(Map<String, dynamic> json) =>
_SnAuthChallenge(
id: json['id'] as String,
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
stepRemain: (json['step_remain'] as num).toInt(),
stepTotal: (json['step_total'] as num).toInt(),
failedAttempts: (json['failed_attempts'] as num).toInt(),
blacklistFactors:
(json['blacklist_factors'] as List<dynamic>)
blacklistFactors: (json['blacklist_factors'] as List<dynamic>)
.map((e) => e as String)
.toList(),
audiences: json['audiences'] as List<dynamic>,
@@ -50,17 +48,13 @@ _SnAuthChallenge _$SnAuthChallengeFromJson(Map<String, dynamic> json) =>
ipAddress: json['ip_address'] as String,
userAgent: json['user_agent'] as String,
nonce: json['nonce'] as String?,
location:
json['location'] == null
location: json['location'] == null
? null
: GeoIpLocation.fromJson(
json['location'] as Map<String, dynamic>,
),
: GeoIpLocation.fromJson(json['location'] as Map<String, dynamic>),
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -90,26 +84,21 @@ _SnAuthSession _$SnAuthSessionFromJson(Map<String, dynamic> json) =>
id: json['id'] as String,
label: json['label'] as String?,
lastGrantedAt: DateTime.parse(json['last_granted_at'] as String),
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
audiences: json['audiences'] as List<dynamic>,
scopes: json['scopes'] as List<dynamic>,
ipAddress: json['ip_address'] as String?,
userAgent: json['user_agent'] as String?,
location:
json['location'] == null
location: json['location'] == null
? null
: GeoIpLocation.fromJson(
json['location'] as Map<String, dynamic>,
),
: GeoIpLocation.fromJson(json['location'] as Map<String, dynamic>),
type: (json['type'] as num).toInt(),
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -138,16 +127,13 @@ _SnAuthFactor _$SnAuthFactorFromJson(Map<String, dynamic> json) =>
type: (json['type'] as num).toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
enabledAt:
json['enabled_at'] == null
enabledAt: json['enabled_at'] == null
? null
: DateTime.parse(json['enabled_at'] as String),
trustworthy: (json['trustworthy'] as num).toInt(),
@@ -177,8 +163,7 @@ _SnAccountConnection _$SnAccountConnectionFromJson(Map<String, dynamic> json) =>
lastUsedAt: DateTime.parse(json['last_used_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -10,8 +10,7 @@ AutoCompletionAccountResponse _$AutoCompletionAccountResponseFromJson(
Map<String, dynamic> json,
) => AutoCompletionAccountResponse(
type: json['type'] as String,
items:
(json['items'] as List<dynamic>)
items: (json['items'] as List<dynamic>)
.map((e) => AutoCompletionItem.fromJson(e as Map<String, dynamic>))
.toList(),
$type: json['runtimeType'] as String?,
@@ -29,8 +28,7 @@ AutoCompletionStickerResponse _$AutoCompletionStickerResponseFromJson(
Map<String, dynamic> json,
) => AutoCompletionStickerResponse(
type: json['type'] as String,
items:
(json['items'] as List<dynamic>)
items: (json['items'] as List<dynamic>)
.map((e) => AutoCompletionItem.fromJson(e as Map<String, dynamic>))
.toList(),
$type: json['runtimeType'] as String?,

View File

@@ -14,8 +14,7 @@ _Bot _$BotFromJson(Map<String, dynamic> json) => _Bot(
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
account: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
developer:
json['developer'] == null
developer: json['developer'] == null
? null
: SnDeveloper.fromJson(json['developer'] as Map<String, dynamic>),
);
@@ -74,8 +73,7 @@ _BotSecret _$BotSecretFromJson(Map<String, dynamic> json) => _BotSecret(
id: json['id'] as String? ?? '',
secret: json['secret'] as String? ?? '',
description: json['description'] as String?,
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
botId: json['bot_id'] as String? ?? '',

View File

@@ -13,28 +13,23 @@ _SnChatRoom _$SnChatRoomFromJson(Map<String, dynamic> json) => _SnChatRoom(
type: (json['type'] as num).toInt(),
isPublic: json['is_public'] as bool? ?? false,
isCommunity: json['is_community'] as bool? ?? false,
picture:
json['picture'] == null
picture: json['picture'] == null
? null
: SnCloudFile.fromJson(json['picture'] as Map<String, dynamic>),
background:
json['background'] == null
background: json['background'] == null
? null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
realmId: json['realm_id'] as String?,
accountId: json['account_id'] as String?,
realm:
json['realm'] == null
realm: json['realm'] == null
? null
: SnRealm.fromJson(json['realm'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
members:
(json['members'] as List<dynamic>?)
members: (json['members'] as List<dynamic>?)
?.map((e) => SnChatMember.fromJson(e as Map<String, dynamic>))
.toList(),
);
@@ -62,8 +57,7 @@ _SnChatMessage _$SnChatMessageFromJson(Map<String, dynamic> json) =>
_SnChatMessage(
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
id: json['id'] as String,
@@ -76,8 +70,7 @@ _SnChatMessage _$SnChatMessageFromJson(Map<String, dynamic> json) =>
?.map((e) => e as String)
.toList() ??
const [],
editedAt:
json['edited_at'] == null
editedAt: json['edited_at'] == null
? null
: DateTime.parse(json['edited_at'] as String),
attachments:
@@ -122,8 +115,7 @@ _SnChatReaction _$SnChatReactionFromJson(Map<String, dynamic> json) =>
_SnChatReaction(
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
id: json['id'] as String,
@@ -151,40 +143,31 @@ _SnChatMember _$SnChatMemberFromJson(Map<String, dynamic> json) =>
_SnChatMember(
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
id: json['id'] as String,
chatRoomId: json['chat_room_id'] as String,
chatRoom:
json['chat_room'] == null
chatRoom: json['chat_room'] == null
? null
: SnChatRoom.fromJson(json['chat_room'] as Map<String, dynamic>),
accountId: json['account_id'] as String,
account: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
nick: json['nick'] as String?,
notify: (json['notify'] as num).toInt(),
joinedAt:
json['joined_at'] == null
joinedAt: json['joined_at'] == null
? null
: DateTime.parse(json['joined_at'] as String),
breakUntil:
json['break_until'] == null
breakUntil: json['break_until'] == null
? null
: DateTime.parse(json['break_until'] as String),
timeoutUntil:
json['timeout_until'] == null
timeoutUntil: json['timeout_until'] == null
? null
: DateTime.parse(json['timeout_until'] as String),
status:
json['status'] == null
status: json['status'] == null
? null
: SnAccountStatus.fromJson(
json['status'] as Map<String, dynamic>,
),
lastTyped:
json['last_typed'] == null
: SnAccountStatus.fromJson(json['status'] as Map<String, dynamic>),
lastTyped: json['last_typed'] == null
? null
: DateTime.parse(json['last_typed'] as String),
);
@@ -211,8 +194,7 @@ Map<String, dynamic> _$SnChatMemberToJson(_SnChatMember instance) =>
_SnChatSummary _$SnChatSummaryFromJson(Map<String, dynamic> json) =>
_SnChatSummary(
unreadCount: (json['unread_count'] as num).toInt(),
lastMessage:
json['last_message'] == null
lastMessage: json['last_message'] == null
? null
: SnChatMessage.fromJson(
json['last_message'] as Map<String, dynamic>,
@@ -251,8 +233,7 @@ _ChatRealtimeJoinResponse _$ChatRealtimeJoinResponseFromJson(
callId: json['call_id'] as String,
roomName: json['room_name'] as String,
isAdmin: json['is_admin'] as bool,
participants:
(json['participants'] as List<dynamic>)
participants: (json['participants'] as List<dynamic>)
.map((e) => CallParticipant.fromJson(e as Map<String, dynamic>))
.toList(),
);
@@ -288,12 +269,10 @@ _SnRealtimeCall _$SnRealtimeCallFromJson(Map<String, dynamic> json) =>
id: json['id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
endedAt:
json['ended_at'] == null
endedAt: json['ended_at'] == null
? null
: DateTime.parse(json['ended_at'] as String),
senderId: json['sender_id'] as String,

View File

@@ -12,28 +12,23 @@ _CustomApp _$CustomAppFromJson(Map<String, dynamic> json) => _CustomApp(
name: json['name'] as String? ?? '',
description: json['description'] as String?,
status: (json['status'] as num?)?.toInt() ?? 0,
picture:
json['picture'] == null
picture: json['picture'] == null
? null
: SnCloudFile.fromJson(json['picture'] as Map<String, dynamic>),
background:
json['background'] == null
background: json['background'] == null
? null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
verification:
json['verification'] == null
verification: json['verification'] == null
? null
: SnVerificationMark.fromJson(
json['verification'] as Map<String, dynamic>,
),
oauthConfig:
json['oauth_config'] == null
oauthConfig: json['oauth_config'] == null
? null
: CustomAppOauthConfig.fromJson(
json['oauth_config'] as Map<String, dynamic>,
),
links:
json['links'] == null
links: json['links'] == null
? null
: CustomAppLinks.fromJson(json['links'] as Map<String, dynamic>),
secrets:
@@ -83,8 +78,7 @@ _CustomAppOauthConfig _$CustomAppOauthConfigFromJson(
?.map((e) => e as String)
.toList() ??
const [],
postLogoutRedirectUris:
(json['post_logout_redirect_uris'] as List<dynamic>?)
postLogoutRedirectUris: (json['post_logout_redirect_uris'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
allowedScopes:
@@ -118,8 +112,7 @@ _CustomAppSecret _$CustomAppSecretFromJson(Map<String, dynamic> json) =>
id: json['id'] as String? ?? '',
secret: json['secret'] as String? ?? '',
description: json['description'] as String?,
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
isOidc: json['is_oidc'] as bool? ?? false,

View File

@@ -9,8 +9,7 @@ part of 'developer.dart';
_SnDeveloper _$SnDeveloperFromJson(Map<String, dynamic> json) => _SnDeveloper(
id: json['id'] as String,
publisherId: json['publisher_id'] as String,
publisher:
json['publisher'] == null
publisher: json['publisher'] == null
? null
: SnPublisher.fromJson(json['publisher'] as Map<String, dynamic>),
);

View File

@@ -22,8 +22,7 @@ _DriveTask _$DriveTaskFromJson(Map<String, dynamic> json) => _DriveTask(
transmissionProgress: (json['transmission_progress'] as num?)?.toDouble(),
errorMessage: json['error_message'] as String?,
statusMessage: json['status_message'] as String?,
result:
json['result'] == null
result: json['result'] == null
? null
: SnCloudFile.fromJson(json['result'] as Map<String, dynamic>),
poolId: json['pool_id'] as String?,

View File

@@ -17,8 +17,7 @@ _SnScrappedLink _$SnScrappedLinkFromJson(Map<String, dynamic> json) =>
siteName: json['site_name'] as String?,
contentType: json['content_type'] as String?,
author: json['author'] as String?,
publishedDate:
json['published_date'] == null
publishedDate: json['published_date'] == null
? null
: DateTime.parse(json['published_date'] as String),
);

View File

@@ -35,8 +35,7 @@ _SnCloudFile _$SnCloudFileFromJson(Map<String, dynamic> json) => _SnCloudFile(
description: json['description'] as String?,
fileMeta: json['file_meta'] as Map<String, dynamic>?,
userMeta: json['user_meta'] as Map<String, dynamic>?,
pool:
json['pool'] == null
pool: json['pool'] == null
? null
: SnFilePool.fromJson(json['pool'] as Map<String, dynamic>),
sensitiveMarks:
@@ -47,15 +46,13 @@ _SnCloudFile _$SnCloudFileFromJson(Map<String, dynamic> json) => _SnCloudFile(
mimeType: json['mime_type'] as String?,
hash: json['hash'] as String?,
size: (json['size'] as num).toInt(),
uploadedAt:
json['uploaded_at'] == null
uploadedAt: json['uploaded_at'] == null
? null
: DateTime.parse(json['uploaded_at'] as String),
uploadedTo: json['uploaded_to'] as String?,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -87,8 +84,7 @@ _SnCloudFileIndex _$SnCloudFileIndexFromJson(Map<String, dynamic> json) =>
file: SnCloudFile.fromJson(json['file'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -16,16 +16,13 @@ _SnFilePool _$SnFilePoolFromJson(Map<String, dynamic> json) => _SnFilePool(
isHidden: json['is_hidden'] as bool?,
accountId: json['account_id'] as String?,
resourceIdentifier: json['resource_identifier'] as String?,
createdAt:
json['created_at'] == null
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt:
json['updated_at'] == null
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -10,8 +10,7 @@ _SnHeatmap _$SnHeatmapFromJson(Map<String, dynamic> json) => _SnHeatmap(
unit: json['unit'] as String,
periodStart: DateTime.parse(json['period_start'] as String),
periodEnd: DateTime.parse(json['period_end'] as String),
items:
(json['items'] as List<dynamic>)
items: (json['items'] as List<dynamic>)
.map((e) => SnHeatmapItem.fromJson(e as Map<String, dynamic>))
.toList(),
);

View File

@@ -8,29 +8,23 @@ part of 'poll.dart';
_SnPollWithStats _$SnPollWithStatsFromJson(Map<String, dynamic> json) =>
_SnPollWithStats(
userAnswer:
json['user_answer'] == null
userAnswer: json['user_answer'] == null
? null
: SnPollAnswer.fromJson(
json['user_answer'] as Map<String, dynamic>,
),
: SnPollAnswer.fromJson(json['user_answer'] as Map<String, dynamic>),
stats: json['stats'] as Map<String, dynamic>? ?? const {},
id: json['id'] as String,
questions:
(json['questions'] as List<dynamic>)
questions: (json['questions'] as List<dynamic>)
.map((e) => SnPollQuestion.fromJson(e as Map<String, dynamic>))
.toList(),
title: json['title'] as String?,
description: json['description'] as String?,
endedAt:
json['ended_at'] == null
endedAt: json['ended_at'] == null
? null
: DateTime.parse(json['ended_at'] as String),
publisherId: json['publisher_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -52,25 +46,21 @@ Map<String, dynamic> _$SnPollWithStatsToJson(_SnPollWithStats instance) =>
_SnPoll _$SnPollFromJson(Map<String, dynamic> json) => _SnPoll(
id: json['id'] as String,
questions:
(json['questions'] as List<dynamic>)
questions: (json['questions'] as List<dynamic>)
.map((e) => SnPollQuestion.fromJson(e as Map<String, dynamic>))
.toList(),
title: json['title'] as String?,
description: json['description'] as String?,
endedAt:
json['ended_at'] == null
endedAt: json['ended_at'] == null
? null
: DateTime.parse(json['ended_at'] as String),
publisherId: json['publisher_id'] as String,
publisher:
json['publisher'] == null
publisher: json['publisher'] == null
? null
: SnPublisher.fromJson(json['publisher'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -92,8 +82,7 @@ _SnPollQuestion _$SnPollQuestionFromJson(Map<String, dynamic> json) =>
_SnPollQuestion(
id: json['id'] as String,
type: $enumDecode(_$SnPollQuestionTypeEnumMap, json['type']),
options:
(json['options'] as List<dynamic>?)
options: (json['options'] as List<dynamic>?)
?.map((e) => SnPollOption.fromJson(e as Map<String, dynamic>))
.toList(),
title: json['title'] as String,
@@ -145,12 +134,10 @@ _SnPollAnswer _$SnPollAnswerFromJson(Map<String, dynamic> json) =>
pollId: json['poll_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
);

View File

@@ -11,12 +11,10 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
title: json['title'] as String?,
description: json['description'] as String?,
language: json['language'] as String?,
editedAt:
json['edited_at'] == null
editedAt: json['edited_at'] == null
? null
: DateTime.parse(json['edited_at'] as String),
publishedAt:
json['published_at'] == null
publishedAt: json['published_at'] == null
? null
: DateTime.parse(json['published_at'] as String),
visibility: (json['visibility'] as num?)?.toInt() ?? 0,
@@ -24,12 +22,9 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
slug: json['slug'] as String?,
type: (json['type'] as num?)?.toInt() ?? 0,
meta: json['meta'] as Map<String, dynamic>?,
embedView:
json['embed_view'] == null
embedView: json['embed_view'] == null
? null
: SnPostEmbedView.fromJson(
json['embed_view'] as Map<String, dynamic>,
),
: SnPostEmbedView.fromJson(json['embed_view'] as Map<String, dynamic>),
viewsUnique: (json['views_unique'] as num?)?.toInt() ?? 0,
viewsTotal: (json['views_total'] as num?)?.toInt() ?? 0,
upvotes: (json['upvotes'] as num?)?.toInt() ?? 0,
@@ -38,23 +33,19 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
awardedScore: (json['awarded_score'] as num?)?.toInt() ?? 0,
pinMode: (json['pin_mode'] as num?)?.toInt(),
threadedPostId: json['threaded_post_id'] as String?,
threadedPost:
json['threaded_post'] == null
threadedPost: json['threaded_post'] == null
? null
: SnPost.fromJson(json['threaded_post'] as Map<String, dynamic>),
repliedPostId: json['replied_post_id'] as String?,
repliedPost:
json['replied_post'] == null
repliedPost: json['replied_post'] == null
? null
: SnPost.fromJson(json['replied_post'] as Map<String, dynamic>),
forwardedPostId: json['forwarded_post_id'] as String?,
forwardedPost:
json['forwarded_post'] == null
forwardedPost: json['forwarded_post'] == null
? null
: SnPost.fromJson(json['forwarded_post'] as Map<String, dynamic>),
realmId: json['realm_id'] as String?,
realm:
json['realm'] == null
realm: json['realm'] == null
? null
: SnRealm.fromJson(json['realm'] as Map<String, dynamic>),
attachments:
@@ -90,16 +81,13 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
?.map((e) => SnPostFeaturedRecord.fromJson(e as Map<String, dynamic>))
.toList() ??
const [],
createdAt:
json['created_at'] == null
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt:
json['updated_at'] == null
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
repliedGone: json['replied_gone'] as bool? ?? false,
@@ -214,16 +202,13 @@ _SnPostAward _$SnPostAwardFromJson(Map<String, dynamic> json) => _SnPostAward(
message: json['message'] as String?,
postId: json['post_id'] as String,
accountId: json['account_id'] as String,
createdAt:
json['created_at'] == null
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt:
json['updated_at'] == null
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -250,12 +235,10 @@ _SnPostReaction _$SnPostReactionFromJson(Map<String, dynamic> json) =>
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -278,15 +261,13 @@ _SnPostFeaturedRecord _$SnPostFeaturedRecordFromJson(
) => _SnPostFeaturedRecord(
id: json['id'] as String,
postId: json['post_id'] as String,
featuredAt:
json['featured_at'] == null
featuredAt: json['featured_at'] == null
? null
: DateTime.parse(json['featured_at'] as String),
socialCredits: (json['social_credits'] as num).toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -17,8 +17,7 @@ _SnPublicationSite _$SnPublicationSiteFromJson(Map<String, dynamic> json) =>
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
pages:
(json['pages'] as List<dynamic>)
pages: (json['pages'] as List<dynamic>)
.map((e) => SnPublicationPage.fromJson(e as Map<String, dynamic>))
.toList(),
);

View File

@@ -12,34 +12,27 @@ _SnPublisher _$SnPublisherFromJson(Map<String, dynamic> json) => _SnPublisher(
name: json['name'] as String? ?? '',
nick: json['nick'] as String? ?? '',
bio: json['bio'] as String? ?? '',
picture:
json['picture'] == null
picture: json['picture'] == null
? null
: SnCloudFile.fromJson(json['picture'] as Map<String, dynamic>),
background:
json['background'] == null
background: json['background'] == null
? null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
accountId: json['account_id'] as String?,
createdAt:
json['created_at'] == null
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt:
json['updated_at'] == null
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
realmId: json['realm_id'] as String?,
verification:
json['verification'] == null
verification: json['verification'] == null
? null
: SnVerificationMark.fromJson(
json['verification'] as Map<String, dynamic>,
@@ -67,24 +60,20 @@ Map<String, dynamic> _$SnPublisherToJson(_SnPublisher instance) =>
_SnPublisherMember _$SnPublisherMemberFromJson(Map<String, dynamic> json) =>
_SnPublisherMember(
publisherId: json['publisher_id'] as String,
publisher:
json['publisher'] == null
publisher: json['publisher'] == null
? null
: SnPublisher.fromJson(json['publisher'] as Map<String, dynamic>),
accountId: json['account_id'] as String,
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
role: (json['role'] as num).toInt(),
joinedAt:
json['joined_at'] == null
joinedAt: json['joined_at'] == null
? null
: DateTime.parse(json['joined_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -12,25 +12,21 @@ _SnRealm _$SnRealmFromJson(Map<String, dynamic> json) => _SnRealm(
name: json['name'] as String? ?? '',
description: json['description'] as String? ?? '',
verifiedAs: json['verified_as'] as String?,
verifiedAt:
json['verified_at'] == null
verifiedAt: json['verified_at'] == null
? null
: DateTime.parse(json['verified_at'] as String),
isCommunity: json['is_community'] as bool,
isPublic: json['is_public'] as bool,
picture:
json['picture'] == null
picture: json['picture'] == null
? null
: SnCloudFile.fromJson(json['picture'] as Map<String, dynamic>),
background:
json['background'] == null
background: json['background'] == null
? null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -55,32 +51,25 @@ Map<String, dynamic> _$SnRealmToJson(_SnRealm instance) => <String, dynamic>{
_SnRealmMember _$SnRealmMemberFromJson(Map<String, dynamic> json) =>
_SnRealmMember(
realmId: json['realm_id'] as String,
realm:
json['realm'] == null
realm: json['realm'] == null
? null
: SnRealm.fromJson(json['realm'] as Map<String, dynamic>),
accountId: json['account_id'] as String,
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
role: (json['role'] as num).toInt(),
joinedAt:
json['joined_at'] == null
joinedAt: json['joined_at'] == null
? null
: DateTime.parse(json['joined_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
status:
json['status'] == null
status: json['status'] == null
? null
: SnAccountStatus.fromJson(
json['status'] as Map<String, dynamic>,
),
: SnAccountStatus.fromJson(json['status'] as Map<String, dynamic>),
);
Map<String, dynamic> _$SnRealmMemberToJson(_SnRealmMember instance) =>

View File

@@ -9,20 +9,17 @@ part of 'reference.dart';
_Reference _$ReferenceFromJson(Map<String, dynamic> json) => _Reference(
id: json['id'] as String,
fileId: json['file_id'] as String,
file:
json['file'] == null
file: json['file'] == null
? null
: SnCloudFile.fromJson(json['file'] as Map<String, dynamic>),
usage: json['usage'] as String,
resourceId: json['resource_id'] as String,
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -8,24 +8,20 @@ part of 'relationship.dart';
_SnRelationship _$SnRelationshipFromJson(Map<String, dynamic> json) =>
_SnRelationship(
createdAt:
json['created_at'] == null
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt:
json['updated_at'] == null
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
accountId: json['account_id'] as String,
account: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
relatedId: json['related_id'] as String,
related: SnAccount.fromJson(json['related'] as Map<String, dynamic>),
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
status: (json['status'] as num).toInt(),

View File

@@ -11,14 +11,12 @@ _SnSticker _$SnStickerFromJson(Map<String, dynamic> json) => _SnSticker(
slug: json['slug'] as String,
image: SnCloudFile.fromJson(json['image'] as Map<String, dynamic>),
packId: json['pack_id'] as String,
pack:
json['pack'] == null
pack: json['pack'] == null
? null
: SnStickerPack.fromJson(json['pack'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -42,18 +40,15 @@ _SnStickerPack _$SnStickerPackFromJson(Map<String, dynamic> json) =>
description: json['description'] as String,
prefix: json['prefix'] as String,
publisherId: json['publisher_id'] as String,
icon:
json['icon'] == null
icon: json['icon'] == null
? null
: SnCloudFile.fromJson(json['icon'] as Map<String, dynamic>),
publisher:
json['publisher'] == null
publisher: json['publisher'] == null
? null
: SnPublisher.fromJson(json['publisher'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
stickers:

View File

@@ -16,12 +16,10 @@ _StreamThinkingRequest _$StreamThinkingRequestFromJson(
?.map((e) => e as String)
.toList() ??
const [],
attachedPosts:
(json['attached_posts'] as List<dynamic>?)
attachedPosts: (json['attached_posts'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
attachedMessages:
(json['attached_messages'] as List<dynamic>?)
attachedMessages: (json['attached_messages'] as List<dynamic>?)
?.map((e) => e as Map<String, dynamic>)
.toList(),
serviceId: json['service_id'] as String?,
@@ -87,14 +85,10 @@ _SnThinkingMessagePart _$SnThinkingMessagePartFromJson(
(json['type'] as num).toInt(),
),
text: json['text'] as String?,
functionCall:
json['function_call'] == null
functionCall: json['function_call'] == null
? null
: SnFunctionCall.fromJson(
json['function_call'] as Map<String, dynamic>,
),
functionResult:
json['function_result'] == null
: SnFunctionCall.fromJson(json['function_call'] as Map<String, dynamic>),
functionResult: json['function_result'] == null
? null
: SnFunctionResult.fromJson(
json['function_result'] as Map<String, dynamic>,
@@ -119,8 +113,7 @@ _SnThinkingSequence _$SnThinkingSequenceFromJson(Map<String, dynamic> json) =>
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -159,16 +152,14 @@ _SnThinkingThought _$SnThinkingThoughtFromJson(Map<String, dynamic> json) =>
tokenCount: (json['token_count'] as num?)?.toInt(),
modelName: json['model_name'] as String?,
sequenceId: json['sequence_id'] as String,
sequence:
json['sequence'] == null
sequence: json['sequence'] == null
? null
: SnThinkingSequence.fromJson(
json['sequence'] as Map<String, dynamic>,
),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -206,8 +197,7 @@ _ThoughtServicesResponse _$ThoughtServicesResponseFromJson(
Map<String, dynamic> json,
) => _ThoughtServicesResponse(
defaultService: json['default_service'] as String,
services:
(json['services'] as List<dynamic>)
services: (json['services'] as List<dynamic>)
.map((e) => ThoughtService.fromJson(e as Map<String, dynamic>))
.toList(),
);

View File

@@ -8,19 +8,16 @@ part of 'wallet.dart';
_SnWallet _$SnWalletFromJson(Map<String, dynamic> json) => _SnWallet(
id: json['id'] as String,
pockets:
(json['pockets'] as List<dynamic>)
pockets: (json['pockets'] as List<dynamic>)
.map((e) => SnWalletPocket.fromJson(e as Map<String, dynamic>))
.toList(),
accountId: json['account_id'] as String,
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -77,8 +74,7 @@ _SnWalletPocket _$SnWalletPocketFromJson(Map<String, dynamic> json) =>
walletId: json['wallet_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -102,19 +98,16 @@ _SnTransaction _$SnTransactionFromJson(Map<String, dynamic> json) =>
remarks: json['remarks'] as String?,
type: (json['type'] as num).toInt(),
payerWalletId: json['payer_wallet_id'] as String?,
payerWallet:
json['payer_wallet'] == null
payerWallet: json['payer_wallet'] == null
? null
: SnWallet.fromJson(json['payer_wallet'] as Map<String, dynamic>),
payeeWalletId: json['payee_wallet_id'] as String?,
payeeWallet:
json['payee_wallet'] == null
payeeWallet: json['payee_wallet'] == null
? null
: SnWallet.fromJson(json['payee_wallet'] as Map<String, dynamic>),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -140,8 +133,7 @@ _SnWalletSubscription _$SnWalletSubscriptionFromJson(
) => _SnWalletSubscription(
id: json['id'] as String,
begunAt: DateTime.parse(json['begun_at'] as String),
endedAt:
json['ended_at'] == null
endedAt: json['ended_at'] == null
? null
: DateTime.parse(json['ended_at'] as String),
identifier: json['identifier'] as String,
@@ -153,21 +145,18 @@ _SnWalletSubscription _$SnWalletSubscriptionFromJson(
basePrice: (json['base_price'] as num?)?.toDouble(),
couponId: json['coupon_id'] as String?,
coupon: json['coupon'],
renewalAt:
json['renewal_at'] == null
renewalAt: json['renewal_at'] == null
? null
: DateTime.parse(json['renewal_at'] as String),
accountId: json['account_id'] as String,
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
isAvailable: json['is_available'] as bool? ?? true,
finalPrice: (json['final_price'] as num?)?.toDouble(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -204,8 +193,7 @@ _SnWalletSubscriptionRef _$SnWalletSubscriptionRefFromJson(
isActive: json['is_active'] as bool,
accountId: json['account_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
@@ -239,8 +227,7 @@ _SnWalletOrder _$SnWalletOrderFromJson(Map<String, dynamic> json) =>
issuerAppId: json['issuer_app_id'] as String?,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -269,41 +256,34 @@ _SnWalletGift _$SnWalletGiftFromJson(Map<String, dynamic> json) =>
giftCode: json['gift_code'] as String,
subscriptionIdentifier: json['subscription_identifier'] as String,
recipientId: json['recipient_id'] as String?,
recipient:
json['recipient'] == null
recipient: json['recipient'] == null
? null
: SnAccount.fromJson(json['recipient'] as Map<String, dynamic>),
gifterId: json['gifter_id'] as String,
gifter:
json['gifter'] == null
gifter: json['gifter'] == null
? null
: SnAccount.fromJson(json['gifter'] as Map<String, dynamic>),
redeemerId: json['redeemer_id'] as String?,
redeemer:
json['redeemer'] == null
redeemer: json['redeemer'] == null
? null
: SnAccount.fromJson(json['redeemer'] as Map<String, dynamic>),
message: json['message'] as String?,
status: (json['status'] as num).toInt(),
redeemedAt:
json['redeemed_at'] == null
redeemedAt: json['redeemed_at'] == null
? null
: DateTime.parse(json['redeemed_at'] as String),
expiredAt:
json['expired_at'] == null
expiredAt: json['expired_at'] == null
? null
: DateTime.parse(json['expired_at'] as String),
subscriptionId: json['subscription_id'] as String?,
subscription:
json['subscription'] == null
subscription: json['subscription'] == null
? null
: SnWalletSubscription.fromJson(
json['subscription'] as Map<String, dynamic>,
),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -330,9 +310,8 @@ Map<String, dynamic> _$SnWalletGiftToJson(_SnWalletGift instance) =>
'deleted_at': instance.deletedAt?.toIso8601String(),
};
_SnWalletFund _$SnWalletFundFromJson(
Map<String, dynamic> json,
) => _SnWalletFund(
_SnWalletFund _$SnWalletFundFromJson(Map<String, dynamic> json) =>
_SnWalletFund(
id: json['id'] as String,
currency: json['currency'] as String,
totalAmount: (json['total_amount'] as num).toDouble(),
@@ -342,23 +321,20 @@ _SnWalletFund _$SnWalletFundFromJson(
status: (json['status'] as num).toInt(),
message: json['message'] as String?,
creatorAccountId: json['creator_account_id'] as String,
creatorAccount:
json['creator_account'] == null
creatorAccount: json['creator_account'] == null
? null
: SnAccount.fromJson(json['creator_account'] as Map<String, dynamic>),
expiredAt: DateTime.parse(json['expired_at'] as String),
recipients:
(json['recipients'] as List<dynamic>)
recipients: (json['recipients'] as List<dynamic>)
.map((e) => SnWalletFundRecipient.fromJson(e as Map<String, dynamic>))
.toList(),
isOpen: json['is_open'] as bool,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
);
Map<String, dynamic> _$SnWalletFundToJson(_SnWalletFund instance) =>
<String, dynamic>{
@@ -386,22 +362,17 @@ _SnWalletFundRecipient _$SnWalletFundRecipientFromJson(
id: json['id'] as String,
fundId: json['fund_id'] as String,
recipientAccountId: json['recipient_account_id'] as String,
recipientAccount:
json['recipient_account'] == null
recipientAccount: json['recipient_account'] == null
? null
: SnAccount.fromJson(
json['recipient_account'] as Map<String, dynamic>,
),
: SnAccount.fromJson(json['recipient_account'] as Map<String, dynamic>),
amount: (json['amount'] as num).toDouble(),
isReceived: json['is_received'] as bool,
receivedAt:
json['received_at'] == null
receivedAt: json['received_at'] == null
? null
: DateTime.parse(json['received_at'] as String),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -425,31 +396,27 @@ _SnLotteryTicket _$SnLotteryTicketFromJson(Map<String, dynamic> json) =>
_SnLotteryTicket(
id: json['id'] as String,
accountId: json['account_id'] as String,
account:
json['account'] == null
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
regionOneNumbers:
(json['region_one_numbers'] as List<dynamic>)
regionOneNumbers: (json['region_one_numbers'] as List<dynamic>)
.map((e) => (e as num).toInt())
.toList(),
regionTwoNumber: (json['region_two_number'] as num).toInt(),
multiplier: (json['multiplier'] as num).toInt(),
drawStatus: (json['draw_status'] as num).toInt(),
drawDate:
json['draw_date'] == null
drawDate: json['draw_date'] == null
? null
: DateTime.parse(json['draw_date'] as String),
matchedRegionOneNumbers:
(json['matched_region_one_numbers'] as List<dynamic>?)
?.map((e) => (e as num).toInt())
.toList(),
matchedRegionTwoNumber:
(json['matched_region_two_number'] as num?)?.toInt(),
matchedRegionTwoNumber: (json['matched_region_two_number'] as num?)
?.toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -471,26 +438,24 @@ Map<String, dynamic> _$SnLotteryTicketToJson(_SnLotteryTicket instance) =>
'deleted_at': instance.deletedAt?.toIso8601String(),
};
_SnLotteryRecord _$SnLotteryRecordFromJson(Map<String, dynamic> json) =>
_SnLotteryRecord(
_SnLotteryRecord _$SnLotteryRecordFromJson(
Map<String, dynamic> json,
) => _SnLotteryRecord(
id: json['id'] as String,
drawDate: DateTime.parse(json['draw_date'] as String),
winningRegionOneNumbers:
(json['winning_region_one_numbers'] as List<dynamic>)
winningRegionOneNumbers: (json['winning_region_one_numbers'] as List<dynamic>)
.map((e) => (e as num).toInt())
.toList(),
winningRegionTwoNumber:
(json['winning_region_two_number'] as num).toInt(),
winningRegionTwoNumber: (json['winning_region_two_number'] as num).toInt(),
totalTickets: (json['total_tickets'] as num).toInt(),
totalPrizesAwarded: (json['total_prizes_awarded'] as num).toInt(),
totalPrizeAmount: (json['total_prize_amount'] as num).toDouble(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
);
Map<String, dynamic> _$SnLotteryRecordToJson(_SnLotteryRecord instance) =>
<String, dynamic>{

View File

@@ -17,12 +17,10 @@ _SnWebFeed _$SnWebFeedFromJson(Map<String, dynamic> json) => _SnWebFeed(
url: json['url'] as String,
title: json['title'] as String,
description: json['description'] as String?,
preview:
json['preview'] == null
preview: json['preview'] == null
? null
: SnScrappedLink.fromJson(json['preview'] as Map<String, dynamic>),
config:
json['config'] == null
config: json['config'] == null
? const SnWebFeedConfig()
: SnWebFeedConfig.fromJson(json['config'] as Map<String, dynamic>),
publisherId: json['publisher_id'] as String,
@@ -33,8 +31,7 @@ _SnWebFeed _$SnWebFeedFromJson(Map<String, dynamic> json) => _SnWebFeed(
const [],
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);
@@ -61,26 +58,20 @@ _SnWebArticle _$SnWebArticleFromJson(Map<String, dynamic> json) =>
url: json['url'] as String,
author: json['author'] as String?,
meta: json['meta'] as Map<String, dynamic>?,
preview:
json['preview'] == null
preview: json['preview'] == null
? null
: SnScrappedLink.fromJson(
json['preview'] as Map<String, dynamic>,
),
feed:
json['feed'] == null
: SnScrappedLink.fromJson(json['preview'] as Map<String, dynamic>),
feed: json['feed'] == null
? null
: SnWebFeed.fromJson(json['feed'] as Map<String, dynamic>),
content: json['content'] as String?,
publishedAt:
json['published_at'] == null
publishedAt: json['published_at'] == null
? null
: DateTime.parse(json['published_at'] as String),
feedId: json['feed_id'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt:
json['deleted_at'] == null
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
);

View File

@@ -1 +0,0 @@

View File

@@ -14,7 +14,7 @@ Future<Map<String, dynamic>?> billingUsage(Ref ref) async {
return response.data;
}
final indexedCloudFileListProvider = AsyncNotifierProvider(
final indexedCloudFileListProvider = AsyncNotifierProvider.autoDispose(
IndexedCloudFileListNotifier.new,
);
@@ -76,10 +76,10 @@ class IndexedCloudFileListNotifier extends AsyncNotifier<List<FileListItem>>
queryParameters: queryParameters,
);
final List<String> folders =
(response.data['folders'] as List).map((e) => e as String).toList();
final List<SnCloudFileIndex> files =
(response.data['files'] as List)
final List<String> folders = (response.data['folders'] as List)
.map((e) => e as String)
.toList();
final List<SnCloudFileIndex> files = (response.data['files'] as List)
.map((e) => SnCloudFileIndex.fromJson(e as Map<String, dynamic>))
.toList();
@@ -92,7 +92,7 @@ class IndexedCloudFileListNotifier extends AsyncNotifier<List<FileListItem>>
}
}
final unindexedFileListProvider = AsyncNotifierProvider(
final unindexedFileListProvider = AsyncNotifierProvider.autoDispose(
UnindexedFileListNotifier.new,
);
@@ -165,13 +165,13 @@ class UnindexedFileListNotifier extends AsyncNotifier<List<FileListItem>>
totalCount = int.tryParse(response.headers.value('x-total') ?? '0') ?? 0;
final List<SnCloudFile> files =
(response.data as List)
final List<SnCloudFile> files = (response.data as List)
.map((e) => SnCloudFile.fromJson(e as Map<String, dynamic>))
.toList();
final List<FileListItem> items =
files.map((file) => FileListItem.unindexedFile(file)).toList();
final List<FileListItem> items = files
.map((file) => FileListItem.unindexedFile(file))
.toList();
return items;
}

View File

@@ -7,6 +7,7 @@ abstract class PaginationController<T> {
int get fetchedCount;
bool get fetchedAll;
bool get isLoading;
FutureOr<List<T>> fetch();
@@ -32,11 +33,15 @@ mixin AsyncPaginationController<T> on AsyncNotifier<List<T>>
@override
bool get fetchedAll => totalCount != null && fetchedCount >= totalCount!;
@override
bool isLoading = false;
@override
FutureOr<List<T>> build() async => fetch();
@override
Future<void> refresh() async {
isLoading = true;
totalCount = null;
state = AsyncData<List<T>>([]);
@@ -44,12 +49,14 @@ mixin AsyncPaginationController<T> on AsyncNotifier<List<T>>
return await fetch();
});
state = newState;
isLoading = false;
}
@override
Future<void> fetchFurther() async {
if (fetchedAll) return;
isLoading = true;
state = AsyncLoading<List<T>>();
final newState = await AsyncValue.guard<List<T>>(() async {
@@ -58,6 +65,7 @@ mixin AsyncPaginationController<T> on AsyncNotifier<List<T>>
});
state = newState;
isLoading = false;
}
}
@@ -67,6 +75,7 @@ mixin AsyncPaginationFilter<F, T> on AsyncPaginationController<T>
Future<void> applyFilter(F filter) async {
if (currentFilter == filter) return;
// Reset the data
isLoading = true;
totalCount = null;
state = AsyncData<List<T>>([]);
currentFilter = filter;
@@ -75,5 +84,6 @@ mixin AsyncPaginationFilter<F, T> on AsyncPaginationController<T>
return await fetch();
});
state = newState;
isLoading = false;
}
}

View File

@@ -0,0 +1,52 @@
// Post Categories Notifier
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post_category.dart';
import 'package:island/models/post_tag.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
final postCategoriesProvider =
AsyncNotifierProvider.autoDispose<
PostCategoriesNotifier,
List<SnPostCategory>
>(PostCategoriesNotifier.new);
class PostCategoriesNotifier extends AsyncNotifier<List<SnPostCategory>>
with AsyncPaginationController<SnPostCategory> {
@override
Future<List<SnPostCategory>> fetch() async {
final client = ref.read(apiClientProvider);
final response = await client.get(
'/sphere/posts/categories',
queryParameters: {'offset': fetchedCount, 'take': 20, 'order': 'usage'},
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final data = response.data as List;
return data.map((json) => SnPostCategory.fromJson(json)).toList();
}
}
// Post Tags Notifier
final postTagsProvider =
AsyncNotifierProvider.autoDispose<PostTagsNotifier, List<SnPostTag>>(
PostTagsNotifier.new,
);
class PostTagsNotifier extends AsyncNotifier<List<SnPostTag>>
with AsyncPaginationController<SnPostTag> {
@override
Future<List<SnPostTag>> fetch() async {
final client = ref.read(apiClientProvider);
final response = await client.get(
'/sphere/posts/tags',
queryParameters: {'offset': fetchedCount, 'take': 20, 'order': 'usage'},
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final data = response.data as List;
return data.map((json) => SnPostTag.fromJson(json)).toList();
}
}

View File

@@ -0,0 +1,95 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
part 'post_list.freezed.dart';
@freezed
sealed class PostListQuery with _$PostListQuery {
const factory PostListQuery({
String? pubName,
String? realm,
int? type,
List<String>? categories,
List<String>? tags,
bool? pinned,
@Default(false) bool shuffle,
bool? includeReplies,
bool? mediaOnly,
String? queryTerm,
String? order,
int? periodStart,
int? periodEnd,
@Default(true) bool orderDesc,
}) = _PostListQuery;
}
@freezed
sealed class PostListQueryConfig with _$PostListQueryConfig {
const factory PostListQueryConfig({
String? id,
@Default(PostListQuery()) PostListQuery initialFilter,
}) = _PostListQueryConfig;
}
final postListProvider = AsyncNotifierProvider.autoDispose.family(
PostListNotifier.new,
);
class PostListNotifier extends AsyncNotifier<List<SnPost>>
with
AsyncPaginationController<SnPost>,
AsyncPaginationFilter<PostListQuery, SnPost> {
static const int pageSize = 20;
final String? id;
final PostListQueryConfig config;
PostListNotifier(this.config) : id = config.id;
@override
late PostListQuery currentFilter;
@override
Future<List<SnPost>> build() async {
currentFilter = config.initialFilter;
return fetch();
}
@override
Future<List<SnPost>> fetch() async {
final client = ref.read(apiClientProvider);
final queryParams = {
'offset': fetchedCount,
'take': pageSize,
'replies': currentFilter.includeReplies,
'orderDesc': currentFilter.orderDesc,
if (currentFilter.shuffle) 'shuffle': currentFilter.shuffle,
if (currentFilter.pubName != null) 'pub': currentFilter.pubName,
if (currentFilter.realm != null) 'realm': currentFilter.realm,
if (currentFilter.type != null) 'type': currentFilter.type,
if (currentFilter.tags != null) 'tags': currentFilter.tags,
if (currentFilter.categories != null)
'categories': currentFilter.categories,
if (currentFilter.pinned != null) 'pinned': currentFilter.pinned,
if (currentFilter.order != null) 'order': currentFilter.order,
if (currentFilter.periodStart != null)
'periodStart': currentFilter.periodStart,
if (currentFilter.periodEnd != null) 'periodEnd': currentFilter.periodEnd,
if (currentFilter.queryTerm != null) 'query': currentFilter.queryTerm,
if (currentFilter.mediaOnly != null) 'media': currentFilter.mediaOnly,
};
final response = await client.get(
'/sphere/posts',
queryParameters: queryParams,
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
return response.data
.map((json) => SnPost.fromJson(json))
.cast<SnPost>()
.toList();
}
}

View File

@@ -317,4 +317,276 @@ as bool,
}
/// @nodoc
mixin _$PostListQueryConfig {
String? get id; PostListQuery get initialFilter;
/// Create a copy of PostListQueryConfig
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$PostListQueryConfigCopyWith<PostListQueryConfig> get copyWith => _$PostListQueryConfigCopyWithImpl<PostListQueryConfig>(this as PostListQueryConfig, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PostListQueryConfig&&(identical(other.id, id) || other.id == id)&&(identical(other.initialFilter, initialFilter) || other.initialFilter == initialFilter));
}
@override
int get hashCode => Object.hash(runtimeType,id,initialFilter);
@override
String toString() {
return 'PostListQueryConfig(id: $id, initialFilter: $initialFilter)';
}
}
/// @nodoc
abstract mixin class $PostListQueryConfigCopyWith<$Res> {
factory $PostListQueryConfigCopyWith(PostListQueryConfig value, $Res Function(PostListQueryConfig) _then) = _$PostListQueryConfigCopyWithImpl;
@useResult
$Res call({
String? id, PostListQuery initialFilter
});
$PostListQueryCopyWith<$Res> get initialFilter;
}
/// @nodoc
class _$PostListQueryConfigCopyWithImpl<$Res>
implements $PostListQueryConfigCopyWith<$Res> {
_$PostListQueryConfigCopyWithImpl(this._self, this._then);
final PostListQueryConfig _self;
final $Res Function(PostListQueryConfig) _then;
/// Create a copy of PostListQueryConfig
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? initialFilter = null,}) {
return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,initialFilter: null == initialFilter ? _self.initialFilter : initialFilter // ignore: cast_nullable_to_non_nullable
as PostListQuery,
));
}
/// Create a copy of PostListQueryConfig
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$PostListQueryCopyWith<$Res> get initialFilter {
return $PostListQueryCopyWith<$Res>(_self.initialFilter, (value) {
return _then(_self.copyWith(initialFilter: value));
});
}
}
/// Adds pattern-matching-related methods to [PostListQueryConfig].
extension PostListQueryConfigPatterns on PostListQueryConfig {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PostListQueryConfig value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _PostListQueryConfig() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PostListQueryConfig value) $default,){
final _that = this;
switch (_that) {
case _PostListQueryConfig():
return $default(_that);}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PostListQueryConfig value)? $default,){
final _that = this;
switch (_that) {
case _PostListQueryConfig() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? id, PostListQuery initialFilter)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PostListQueryConfig() when $default != null:
return $default(_that.id,_that.initialFilter);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? id, PostListQuery initialFilter) $default,) {final _that = this;
switch (_that) {
case _PostListQueryConfig():
return $default(_that.id,_that.initialFilter);}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? id, PostListQuery initialFilter)? $default,) {final _that = this;
switch (_that) {
case _PostListQueryConfig() when $default != null:
return $default(_that.id,_that.initialFilter);case _:
return null;
}
}
}
/// @nodoc
class _PostListQueryConfig implements PostListQueryConfig {
const _PostListQueryConfig({this.id, this.initialFilter = const PostListQuery()});
@override final String? id;
@override@JsonKey() final PostListQuery initialFilter;
/// Create a copy of PostListQueryConfig
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$PostListQueryConfigCopyWith<_PostListQueryConfig> get copyWith => __$PostListQueryConfigCopyWithImpl<_PostListQueryConfig>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PostListQueryConfig&&(identical(other.id, id) || other.id == id)&&(identical(other.initialFilter, initialFilter) || other.initialFilter == initialFilter));
}
@override
int get hashCode => Object.hash(runtimeType,id,initialFilter);
@override
String toString() {
return 'PostListQueryConfig(id: $id, initialFilter: $initialFilter)';
}
}
/// @nodoc
abstract mixin class _$PostListQueryConfigCopyWith<$Res> implements $PostListQueryConfigCopyWith<$Res> {
factory _$PostListQueryConfigCopyWith(_PostListQueryConfig value, $Res Function(_PostListQueryConfig) _then) = __$PostListQueryConfigCopyWithImpl;
@override @useResult
$Res call({
String? id, PostListQuery initialFilter
});
@override $PostListQueryCopyWith<$Res> get initialFilter;
}
/// @nodoc
class __$PostListQueryConfigCopyWithImpl<$Res>
implements _$PostListQueryConfigCopyWith<$Res> {
__$PostListQueryConfigCopyWithImpl(this._self, this._then);
final _PostListQueryConfig _self;
final $Res Function(_PostListQueryConfig) _then;
/// Create a copy of PostListQueryConfig
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? initialFilter = null,}) {
return _then(_PostListQueryConfig(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,initialFilter: null == initialFilter ? _self.initialFilter : initialFilter // ignore: cast_nullable_to_non_nullable
as PostListQuery,
));
}
/// Create a copy of PostListQueryConfig
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$PostListQueryCopyWith<$Res> get initialFilter {
return $PostListQueryCopyWith<$Res>(_self.initialFilter, (value) {
return _then(_self.copyWith(initialFilter: value));
});
}
}
// dart format on

View File

@@ -1,13 +1,11 @@
import 'package:flutter/foundation.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/activity.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
final activityListProvider =
AsyncNotifierProvider<ActivityListNotifier, List<SnTimelineEvent>>(
final activityListProvider = AsyncNotifierProvider.autoDispose(
ActivityListNotifier.new,
);
);
class ActivityListNotifier extends AsyncNotifier<List<SnTimelineEvent>>
with
@@ -28,8 +26,6 @@ class ActivityListNotifier extends AsyncNotifier<List<SnTimelineEvent>>
if (cursor != null) 'cursor': cursor,
'take': pageSize,
if (currentFilter != null) 'filter': currentFilter,
if (kDebugMode)
'debugInclude': 'realms,publishers,articles,shuffledPosts',
};
final response = await client.get(
@@ -37,8 +33,7 @@ class ActivityListNotifier extends AsyncNotifier<List<SnTimelineEvent>>
queryParameters: queryParameters,
);
final List<SnTimelineEvent> items =
(response.data as List)
final List<SnTimelineEvent> items = (response.data as List)
.map((e) => SnTimelineEvent.fromJson(e as Map<String, dynamic>))
.toList();

View File

@@ -5,16 +5,14 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:island/models/webfeed.dart';
import 'package:island/pods/network.dart';
final webFeedListProvider = FutureProvider.family<List<SnWebFeed>, String>((
ref,
pubName,
) async {
final webFeedListProvider = FutureProvider.autoDispose
.family<List<SnWebFeed>, String>((ref, pubName) async {
final client = ref.watch(apiClientProvider);
final response = await client.get('/sphere/publishers/$pubName/feeds');
return (response.data as List)
.map((json) => SnWebFeed.fromJson(json))
.toList();
});
});
class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
final ({String pubName, String? feedId}) arg;
@@ -51,8 +49,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
final client = ref.read(apiClientProvider);
final url = '/sphere/publishers/${feed.publisherId}/feeds';
final response =
feed.id.isEmpty
final response = feed.id.isEmpty
? await client.post(url, data: feed.toJson())
: await client.patch('$url/${feed.id}', data: feed.toJson());

View File

@@ -105,8 +105,7 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'articleCompose',
path: '/articles/compose',
builder:
(context, state) => ArticleComposeScreen(
builder: (context, state) => ArticleComposeScreen(
initialState: state.extra as PostComposeInitialState?,
),
),
@@ -190,8 +189,7 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'explore',
path: '/',
pageBuilder:
(context, state) => CustomTransitionPage(
pageBuilder: (context, state) => CustomTransitionPage(
key: const ValueKey('explore'),
child: const ExploreScreen(),
transitionsBuilder: _tabPagesTransitionBuilder,
@@ -220,11 +218,6 @@ final routerProvider = Provider<GoRouter>((ref) {
return PostCategoryDetailScreen(slug: slug, isCategory: true);
},
),
GoRoute(
name: 'postTags',
path: '/posts/tags',
builder: (context, state) => const PostTagsListScreen(),
),
GoRoute(
name: 'postTagDetail',
path: '/posts/tags/:slug',
@@ -260,8 +253,7 @@ final routerProvider = Provider<GoRouter>((ref) {
// Chat tab
ShellRoute(
pageBuilder:
(context, state, child) => CustomTransitionPage(
pageBuilder: (context, state, child) => CustomTransitionPage(
key: const ValueKey('chat'),
child: ChatShellScreen(child: child),
transitionsBuilder: _tabPagesTransitionBuilder,
@@ -303,8 +295,7 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'realmList',
path: '/realms',
pageBuilder:
(context, state) => CustomTransitionPage(
pageBuilder: (context, state) => CustomTransitionPage(
key: const ValueKey('realms'),
child: const RealmListScreen(),
transitionsBuilder: _tabPagesTransitionBuilder,
@@ -336,8 +327,7 @@ final routerProvider = Provider<GoRouter>((ref) {
// Account tab
ShellRoute(
pageBuilder:
(context, state, child) => CustomTransitionPage(
pageBuilder: (context, state, child) => CustomTransitionPage(
key: const ValueKey('account'),
child: AccountShellScreen(child: child),
transitionsBuilder: _tabPagesTransitionBuilder,
@@ -352,8 +342,8 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'stickerMarketplace',
path: '/stickers',
builder:
(context, state) => const MarketplaceStickersScreen(),
builder: (context, state) =>
const MarketplaceStickersScreen(),
routes: [
GoRoute(
name: 'stickerPackDetail',
@@ -368,8 +358,8 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'webFeedMarketplace',
path: '/feeds',
builder:
(context, state) => const MarketplaceWebFeedsScreen(),
builder: (context, state) =>
const MarketplaceWebFeedsScreen(),
routes: [
GoRoute(
name: 'webFeedDetail',
@@ -516,26 +506,22 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'developerHub',
path: '/developers',
builder:
(context, state) => DeveloperHubScreen(
initialPublisherName:
state.uri.queryParameters['publisher'],
builder: (context, state) => DeveloperHubScreen(
initialPublisherName: state.uri.queryParameters['publisher'],
initialProjectId: state.uri.queryParameters['project'],
),
routes: [
GoRoute(
name: 'developerProjectNew',
path: ':name/projects/new',
builder:
(context, state) => NewProjectScreen(
builder: (context, state) => NewProjectScreen(
publisherName: state.pathParameters['name']!,
),
),
GoRoute(
name: 'developerProjectEdit',
path: ':name/projects/:id/edit',
builder:
(context, state) => EditProjectScreen(
builder: (context, state) => EditProjectScreen(
publisherName: state.pathParameters['name']!,
id: state.pathParameters['id']!,
),
@@ -558,8 +544,7 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'developerAppDetail',
path: 'apps/:appId',
builder:
(context, state) => AppDetailScreen(
builder: (context, state) => AppDetailScreen(
publisherName: state.pathParameters['name']!,
projectId: state.pathParameters['projectId']!,
appId: state.pathParameters['appId']!,
@@ -568,8 +553,7 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
name: 'developerBotDetail',
path: 'bots/:botId',
builder:
(context, state) => BotDetailScreen(
builder: (context, state) => BotDetailScreen(
publisherName: state.pathParameters['name']!,
projectId: state.pathParameters['projectId']!,
botId: state.pathParameters['botId']!,

View File

@@ -331,8 +331,7 @@ class AccountScreen extends HookConsumerWidget {
if (availableWidth > totalMin) {
return Row(
spacing: 8,
children:
children
children: children
.map((child) => Expanded(child: child))
.toList(),
).padding(horizontal: 12).height(48);
@@ -341,8 +340,7 @@ class AccountScreen extends HookConsumerWidget {
scrollDirection: Axis.horizontal,
child: Row(
spacing: 8,
children:
children
children: children
.map(
(child) =>
SizedBox(width: minWidth, child: child),
@@ -495,8 +493,7 @@ class _UnauthorizedAccountScreen extends StatelessWidget {
Widget build(BuildContext context) {
return AppScaffold(
appBar: AppBar(title: const Text('account').tr()),
body:
ConstrainedBox(
body: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,

View File

@@ -23,7 +23,7 @@ Future<double> socialCredits(Ref ref) async {
return response.data?.toDouble() ?? 0.0;
}
final socialCreditHistoryNotifierProvider = AsyncNotifierProvider(
final socialCreditHistoryNotifierProvider = AsyncNotifierProvider.autoDispose(
SocialCreditHistoryNotifier.new,
);
@@ -45,8 +45,7 @@ class SocialCreditHistoryNotifier
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final records =
response.data
final records = response.data
.map((json) => SnSocialCreditRecord.fromJson(json))
.cast<SnSocialCreditRecord>()
.toList();
@@ -68,8 +67,7 @@ class SocialCreditsTab extends HookConsumerWidget {
margin: const EdgeInsets.only(left: 16, right: 16, top: 8),
child: socialCredits
.when(
data:
(credits) => Stack(
data: (credits) => Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -83,9 +81,7 @@ class SocialCreditsTab extends HookConsumerWidget {
? 'socialCreditsLevelGood'.tr()
: 'socialCreditsLevelExcellent'.tr(),
).tr().bold().fontSize(20),
Text(
'${credits.toStringAsFixed(2)} pts',
).fontSize(14),
Text('${credits.toStringAsFixed(2)} pts').fontSize(14),
const Gap(8),
LinearProgressIndicator(value: credits / 200),
],
@@ -119,8 +115,7 @@ class SocialCreditsTab extends HookConsumerWidget {
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
title: Text(
record.reason,
style:
isExpired
style: isExpired
? TextStyle(
decoration: TextDecoration.lineThrough,
color: Theme.of(

View File

@@ -14,7 +14,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:styled_widget/styled_widget.dart';
final levelingHistoryNotifierProvider = AsyncNotifierProvider(
final levelingHistoryNotifierProvider = AsyncNotifierProvider.autoDispose(
LevelingHistoryNotifier.new,
);
@@ -35,8 +35,7 @@ class LevelingHistoryNotifier extends AsyncNotifier<List<SnExperienceRecord>>
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final List<SnExperienceRecord> records =
response.data
final List<SnExperienceRecord> records = response.data
.map((json) => SnExperienceRecord.fromJson(json))
.cast<SnExperienceRecord>()
.toList();
@@ -162,8 +161,9 @@ class LevelingScreen extends HookConsumerWidget {
stopIndicatorRadius: 0,
trackGap: 0,
color: Theme.of(context).colorScheme.primary,
backgroundColor:
Theme.of(context).colorScheme.surfaceContainerHigh,
backgroundColor: Theme.of(
context,
).colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(32),
),
],
@@ -186,8 +186,7 @@ class LevelingScreen extends HookConsumerWidget {
notifier: levelingHistoryNotifierProvider.notifier,
isRefreshable: false,
isSliver: true,
itemBuilder:
(context, idx, record) => ListTile(
itemBuilder: (context, idx, record) => ListTile(
title: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -208,9 +207,7 @@ class LevelingScreen extends HookConsumerWidget {
subtitle: Row(
spacing: 8,
children: [
Text(
'${record.delta > 0 ? '+' : ''}${record.delta} EXP',
),
Text('${record.delta > 0 ? '+' : ''}${record.delta} EXP'),
if (record.bonusMultiplier != 1.0)
Text('x${record.bonusMultiplier}'),
],
@@ -249,8 +246,7 @@ class LevelStairsPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint =
Paint()
final paint = Paint()
..color = surfaceColor.withOpacity(0.2)
..strokeWidth = 1.5
..style = PaintingStyle.stroke;

View File

@@ -29,7 +29,7 @@ Future<List<SnRelationship>> sentFriendRequest(Ref ref) async {
.toList();
}
final relationshipListNotifierProvider = AsyncNotifierProvider(
final relationshipListNotifierProvider = AsyncNotifierProvider.autoDispose(
RelationshipListNotifier.new,
);
@@ -45,8 +45,7 @@ class RelationshipListNotifier extends AsyncNotifier<List<SnRelationship>>
queryParameters: {'offset': fetchedCount.toString(), 'take': take},
);
final List<SnRelationship> items =
(response.data as List)
final List<SnRelationship> items = (response.data as List)
.map((e) => SnRelationship.fromJson(e as Map<String, dynamic>))
.cast<SnRelationship>()
.toList();
@@ -83,8 +82,9 @@ class RelationshipListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final account =
showRelatedAccount ? relationship.related : relationship.account;
final account = showRelatedAccount
? relationship.related
: relationship.account;
final isPending =
relationship.status == 0 && relationship.relatedId == currentUserId;
final isWaiting =
@@ -138,8 +138,7 @@ class RelationshipListTile extends StatelessWidget {
],
),
subtitle: Text('@${account.name}'),
trailing:
showActions
trailing: showActions
? Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -165,8 +164,7 @@ class RelationshipListTile extends StatelessWidget {
PopupMenuButton(
padding: EdgeInsets.zero,
icon: const Icon(Symbols.more_vert),
itemBuilder:
(context) => [
itemBuilder: (context) => [
if (relationship.status >= 100) // If friend
PopupMenuItem(
child: ListTile(
@@ -174,11 +172,7 @@ class RelationshipListTile extends StatelessWidget {
title: Text('blockUser').tr(),
contentPadding: EdgeInsets.zero,
),
onTap:
() => onUpdateStatus?.call(
relationship,
-100,
),
onTap: () => onUpdateStatus?.call(relationship, -100),
)
else if (relationship.status <= -100) // If blocked
PopupMenuItem(
@@ -187,9 +181,7 @@ class RelationshipListTile extends StatelessWidget {
title: Text('unblockUser').tr(),
contentPadding: EdgeInsets.zero,
),
onTap:
() =>
onUpdateStatus?.call(relationship, 100),
onTap: () => onUpdateStatus?.call(relationship, 100),
),
],
),
@@ -299,6 +291,7 @@ class RelationshipScreen extends HookConsumerWidget {
const Divider(height: 1),
Expanded(
child: PaginationList(
padding: EdgeInsets.zero,
provider: relationshipListNotifierProvider,
notifier: relationshipListNotifierProvider.notifier,
itemBuilder: (context, index, relationship) {
@@ -380,9 +373,7 @@ class _SentFriendRequestsSheet extends HookConsumerWidget {
const Divider(height: 1),
Expanded(
child: requests.when(
data:
(items) =>
items.isEmpty
data: (items) => items.isEmpty
? Center(
child: Text(
'friendSentRequestEmpty'.tr(),

View File

@@ -20,6 +20,7 @@ import 'package:island/widgets/navigation/fab_menu.dart';
import 'package:island/widgets/response.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:relative_time/relative_time.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:super_sliver_list/super_sliver_list.dart';
import 'package:island/pods/chat/chat_room.dart';
@@ -50,8 +51,7 @@ class ChatRoomListTile extends HookConsumerWidget {
if (validMembers.isNotEmpty) {
final userInfo = ref.watch(userInfoProvider);
if (userInfo.value != null) {
validMembers =
validMembers
validMembers = validMembers
.where((e) => e.accountId != userInfo.value!.id)
.toList();
}
@@ -60,37 +60,60 @@ class ChatRoomListTile extends HookConsumerWidget {
Widget buildSubtitle() {
if (subtitle != null) return subtitle!;
return summary.when(
data: (data) {
if (data == null) {
return isDirect && room.description == null
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
layoutBuilder: (currentChild, previousChildren) => Stack(
alignment: Alignment.centerLeft,
children: [
...previousChildren,
if (currentChild != null) currentChild,
],
),
child: summary.when(
data: (data) => Container(
key: const ValueKey('data'),
child: data == null
? isDirect && room.description == null
? Text(
validMembers.map((e) => '@${e.account.name}').join(', '),
validMembers
.map((e) => '@${e.account.name}')
.join(', '),
maxLines: 1,
)
: Text(room.description ?? 'descriptionNone'.tr(), maxLines: 1);
}
return Column(
: Text(
room.description ?? 'descriptionNone'.tr(),
maxLines: 1,
)
: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (data.unreadCount > 0)
Text(
'unreadMessages'.plural(data.unreadCount),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(context).colorScheme.primary,
),
),
if (data.lastMessage == null)
Text(room.description ?? 'descriptionNone'.tr(), maxLines: 1)
Text(
room.description ?? 'descriptionNone'.tr(),
maxLines: 1,
)
else
Row(
spacing: 4,
children: [
Badge(
label: Text(data.lastMessage!.sender.account.nick),
textColor: Theme.of(context).colorScheme.onPrimary,
backgroundColor: Theme.of(context).colorScheme.primary,
label: Text(
data.lastMessage!.sender.account.nick,
),
textColor: Theme.of(
context,
).colorScheme.onPrimary,
backgroundColor: Theme.of(
context,
).colorScheme.primary,
),
Expanded(
child: Text(
@@ -114,19 +137,37 @@ class ChatRoomListTile extends HookConsumerWidget {
],
),
],
),
),
loading: () => Container(
key: const ValueKey('loading'),
child: Builder(
builder: (context) {
final seed = DateTime.now().microsecondsSinceEpoch;
final len = 4 + (seed % 17); // 4..20 inclusive
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
var s = seed;
final buffer = StringBuffer();
for (var i = 0; i < len; i++) {
s = (s * 1103515245 + 12345) & 0x7fffffff;
buffer.write(chars[s % chars.length]);
}
return Skeletonizer(
enabled: true,
child: Text(buffer.toString()),
);
},
loading: () => const SizedBox.shrink(),
error:
(_, _) =>
isDirect && room.description == null
),
),
error: (_, _) => Container(
key: const ValueKey('error'),
child: isDirect && room.description == null
? Text(
validMembers.map((e) => '@${e.account.name}').join(', '),
maxLines: 1,
)
: Text(
room.description ?? 'descriptionNone'.tr(),
maxLines: 1,
: Text(room.description ?? 'descriptionNone'.tr(), maxLines: 1),
),
),
);
}
@@ -149,11 +190,9 @@ class ChatRoomListTile extends HookConsumerWidget {
loading: () => false,
error: (_, _) => false,
),
child:
(isDirect && room.picture?.id == null)
child: (isDirect && room.picture?.id == null)
? SplitAvatarWidget(
filesId:
validMembers
filesId: validMembers
.map((e) => e.account.profile.picture?.id)
.toList(),
)
@@ -199,8 +238,7 @@ class ChatListBodyWidget extends HookConsumerWidget {
builder: (context, ref, _) {
final summaryState = ref.watch(chatSummaryProvider);
return summaryState.maybeWhen(
loading:
() => const LinearProgressIndicator(
loading: () => const LinearProgressIndicator(
minHeight: 2,
borderRadius: BorderRadius.zero,
),
@@ -210,16 +248,13 @@ class ChatListBodyWidget extends HookConsumerWidget {
),
Expanded(
child: chats.when(
data:
(items) => RefreshIndicator(
onRefresh:
() => Future.sync(() {
data: (items) => RefreshIndicator(
onRefresh: () => Future.sync(() {
ref.invalidate(chatRoomJoinedProvider);
}),
child: SuperListView.builder(
padding: EdgeInsets.only(bottom: 96),
itemCount:
items
itemCount: items
.where(
(item) =>
selectedTab.value == 0 ||
@@ -228,13 +263,11 @@ class ChatListBodyWidget extends HookConsumerWidget {
)
.length,
itemBuilder: (context, index) {
final filteredItems =
items
final filteredItems = items
.where(
(item) =>
selectedTab.value == 0 ||
(selectedTab.value == 1 &&
item.type == 1) ||
(selectedTab.value == 1 && item.type == 1) ||
(selectedTab.value == 2 && item.type != 1),
)
.toList();
@@ -260,8 +293,7 @@ class ChatListBodyWidget extends HookConsumerWidget {
),
),
loading: () => const Center(child: CircularProgressIndicator()),
error:
(error, stack) => ResponseErrorWidget(
error: (error, stack) => ResponseErrorWidget(
error: error,
onRetry: () {
ref.invalidate(chatRoomJoinedProvider);
@@ -552,15 +584,9 @@ class _ChatInvitesSheet extends HookConsumerWidget {
),
],
child: invites.when(
data:
(items) =>
items.isEmpty
data: (items) => items.isEmpty
? Center(
child:
Text(
'invitesEmpty',
textAlign: TextAlign.center,
).tr(),
child: Text('invitesEmpty', textAlign: TextAlign.center).tr(),
)
: ListView.builder(
shrinkWrap: true,
@@ -576,10 +602,10 @@ class _ChatInvitesSheet extends HookConsumerWidget {
if (invite.chatRoom!.type == 1)
Badge(
label: const Text('directMessage').tr(),
backgroundColor:
Theme.of(context).colorScheme.primary,
textColor:
Theme.of(context).colorScheme.onPrimary,
backgroundColor: Theme.of(
context,
).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary,
),
],
),

View File

@@ -98,8 +98,7 @@ class PublisherMemberListNotifier extends AsyncNotifier<List<SnPublisherMember>>
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final members =
response.data
final members = response.data
.map((e) => SnPublisherMember.fromJson(e))
.cast<SnPublisherMember>()
.toList();
@@ -173,12 +172,10 @@ class PublisherSelector extends StatelessWidget {
iconStyleData: IconStyleData(
icon: Icon(Icons.arrow_drop_down),
iconSize: 19,
iconEnabledColor:
isWideScreen(context)
iconEnabledColor: isWideScreen(context)
? null
: Theme.of(context).appBarTheme.foregroundColor!,
iconDisabledColor:
isWideScreen(context)
iconDisabledColor: isWideScreen(context)
? null
: Theme.of(context).appBarTheme.foregroundColor!,
),
@@ -204,6 +201,13 @@ class _PublisherUnselectedWidget extends HookConsumerWidget {
child: Column(
children: [
if (!hasPublishers) ...[
if (publishers.isLoading)
Padding(
padding: const EdgeInsets.all(8),
child: const CircularProgressIndicator(),
)
else
...([
const Icon(
Symbols.info,
fill: 1,
@@ -214,6 +218,7 @@ class _PublisherUnselectedWidget extends HookConsumerWidget {
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
).tr(),
]),
const Gap(24),
],
if (hasPublishers)
@@ -288,14 +293,14 @@ class CreatorHubScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) =>
builder: (context) =>
EditPublisherScreen(name: currentPublisher.value!.name),
).then((value) async {
if (value == null) return;
final data = await ref.refresh(publishersManagedProvider.future);
currentPublisher.value =
data.where((e) => e.id == currentPublisher.value!.id).firstOrNull;
currentPublisher.value = data
.where((e) => e.id == currentPublisher.value!.id)
.firstOrNull;
});
}
@@ -315,9 +320,7 @@ class CreatorHubScreen extends HookConsumerWidget {
}
final List<DropdownMenuItem<SnPublisher>> publishersMenu = publishers.when(
data:
(data) =>
data
data: (data) => data
.map(
(item) => DropdownMenuItem<SnPublisher>(
value: item,
@@ -329,8 +332,7 @@ class CreatorHubScreen extends HookConsumerWidget {
),
title: Text(item.nick),
subtitle: Text('@${item.name}'),
trailing:
currentPublisher.value?.id == item.id
trailing: currentPublisher.value?.id == item.id
? const Icon(Icons.check)
: null,
contentPadding: EdgeInsets.symmetric(horizontal: 8),
@@ -443,8 +445,7 @@ class CreatorHubScreen extends HookConsumerWidget {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder:
(context) => _PublisherMemberListSheet(
builder: (context) => _PublisherMemberListSheet(
publisherUname: currentPublisher.value!.name,
),
);
@@ -567,11 +568,9 @@ class CreatorHubScreen extends HookConsumerWidget {
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: publisherStats.when(
data:
(stats) => SingleChildScrollView(
data: (stats) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 24),
child:
currentPublisher.value == null
child: currentPublisher.value == null
? ConstrainedBox(
constraints: BoxConstraints(maxWidth: 640),
child: _PublisherUnselectedWidget(
@@ -876,8 +875,7 @@ class _PublisherMemberListSheet extends HookConsumerWidget {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder:
(context) => _PublisherMemberRoleSheet(
builder: (context) => _PublisherMemberRoleSheet(
publisherUname: publisherUname,
member: member,
),
@@ -991,12 +989,8 @@ class _PublisherMemberRoleSheet extends HookConsumerWidget {
onSelected: (int selection) {
roleController.text = selection.toString();
},
fieldViewBuilder: (
context,
controller,
focusNode,
onFieldSubmitted,
) {
fieldViewBuilder:
(context, controller, focusNode, onFieldSubmitted) {
return TextField(
controller: controller,
focusNode: focusNode,
@@ -1085,15 +1079,9 @@ class _PublisherInviteSheet extends HookConsumerWidget {
),
],
child: invites.when(
data:
(items) =>
items.isEmpty
data: (items) => items.isEmpty
? Center(
child:
Text(
'invitesEmpty',
textAlign: TextAlign.center,
).tr(),
child: Text('invitesEmpty', textAlign: TextAlign.center).tr(),
)
: ListView.builder(
shrinkWrap: true,
@@ -1106,8 +1094,7 @@ class _PublisherInviteSheet extends HookConsumerWidget {
fallbackIcon: Symbols.group,
),
title: Text(invite.publisher!.nick),
subtitle:
Text(
subtitle: Text(
invite.role >= 100
? 'permissionOwner'
: invite.role >= 50
@@ -1131,8 +1118,7 @@ class _PublisherInviteSheet extends HookConsumerWidget {
},
),
loading: () => const Center(child: CircularProgressIndicator()),
error:
(error, _) => ResponseErrorWidget(
error: (error, _) => ResponseErrorWidget(
error: error,
onRetry: () => ref.invalidate(publisherInvitesProvider),
),

View File

@@ -44,8 +44,7 @@ class PollListNotifier extends AsyncNotifier<List<SnPollWithStats>>
queryParameters: queryParams,
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final items =
response.data
final items = response.data
.map((json) => SnPollWithStats.fromJson(json))
.cast<SnPollWithStats>()
.toList();
@@ -91,6 +90,7 @@ class CreatorPollListScreen extends HookConsumerWidget {
body: ExtendedRefreshIndicator(
onRefresh: () => ref.refresh(pollListNotifierProvider(pubName).future),
child: PaginationList(
footerSkeletonMaxWidth: 640,
provider: pollListNotifierProvider(pubName),
notifier: pollListNotifierProvider(pubName).notifier,
padding: const EdgeInsets.only(top: 12),
@@ -119,8 +119,7 @@ class _CreatorPollItem extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final theme = Theme.of(context);
final ended = pollWithStats.endedAt;
final endedText =
ended == null
final endedText = ended == null
? 'No end'
: MaterialLocalizations.of(context).formatFullDate(ended);
@@ -152,8 +151,7 @@ class _CreatorPollItem extends HookConsumerWidget {
],
),
trailing: PopupMenuButton<String>(
itemBuilder:
(context) => [
itemBuilder: (context) => [
PopupMenuItem(
child: Row(
children: [
@@ -167,8 +165,7 @@ class _CreatorPollItem extends HookConsumerWidget {
context: context,
isScrollControlled: true,
isDismissible: false,
builder:
(context) => PollEditorScreen(
builder: (context) => PollEditorScreen(
initialPublisher: pubName,
initialPollId: pollWithStats.id,
),
@@ -189,21 +186,16 @@ class _CreatorPollItem extends HookConsumerWidget {
onTap: () async {
final confirmed = await showDialog<bool>(
context: context,
builder:
(context) => AlertDialog(
builder: (context) => AlertDialog(
title: Text('Delete Poll'),
content: Text(
'Are you sure you want to delete this poll?',
),
content: Text('Are you sure you want to delete this poll?'),
actions: [
TextButton(
onPressed:
() => Navigator.of(context).pop(false),
onPressed: () => Navigator.of(context).pop(false),
child: Text('Cancel'),
),
TextButton(
onPressed:
() => Navigator.of(context).pop(true),
onPressed: () => Navigator.of(context).pop(true),
child: Text('Delete'),
),
],
@@ -212,9 +204,7 @@ class _CreatorPollItem extends HookConsumerWidget {
if (confirmed == true) {
try {
final client = ref.read(apiClientProvider);
await client.delete(
'/sphere/polls/${pollWithStats.id}',
);
await client.delete('/sphere/polls/${pollWithStats.id}');
ref.invalidate(pollListNotifierProvider(pubName));
showSnackBar('Poll deleted successfully');
} catch (e) {

View File

@@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/post/post_list.dart';
@@ -20,7 +21,7 @@ class CreatorPostListScreen extends HookConsumerWidget {
key: ValueKey(refreshKey.value),
slivers: [
SliverPostList(
pubName: pubName,
query: PostListQuery(pubName: pubName),
itemType: PostItemType.creator,
maxWidth: 640,
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,

View File

@@ -12,7 +12,6 @@ import 'package:island/widgets/alert.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:island/widgets/extended_refresh_indicator.dart';
import 'package:styled_widget/styled_widget.dart';
final siteListNotifierProvider = AsyncNotifierProvider.family.autoDispose(
@@ -38,8 +37,7 @@ class SiteListNotifier extends AsyncNotifier<List<SnPublicationSite>>
queryParameters: queryParams,
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final items =
response.data
final items = response.data
.map((json) => SnPublicationSite.fromJson(json))
.cast<SnPublicationSite>()
.toList();
@@ -70,14 +68,11 @@ class CreatorSiteListScreen extends HookConsumerWidget {
onPressed: () => _createSite(context),
child: Icon(Icons.add),
),
body: ExtendedRefreshIndicator(
onRefresh: () => ref.refresh(siteListNotifierProvider(pubName).future),
child: CustomScrollView(
slivers: [
const SliverGap(8),
PaginationList(
body: PaginationList(
footerSkeletonMaxWidth: 640,
provider: siteListNotifierProvider(pubName),
notifier: siteListNotifierProvider(pubName).notifier,
padding: const EdgeInsets.only(top: 12),
itemBuilder: (context, index, site) {
return ConstrainedBox(
constraints: BoxConstraints(maxWidth: 640),
@@ -85,9 +80,6 @@ class CreatorSiteListScreen extends HookConsumerWidget {
).center();
},
),
],
),
),
);
}
}
@@ -148,8 +140,7 @@ class _CreatorSiteItem extends HookConsumerWidget {
),
),
PopupMenuButton<String>(
itemBuilder:
(context) => [
itemBuilder: (context) => [
PopupMenuItem(
child: Row(
children: [
@@ -162,11 +153,8 @@ class _CreatorSiteItem extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SiteForm(
pubName: pubName,
siteSlug: site.slug,
),
builder: (context) =>
SiteForm(pubName: pubName, siteSlug: site.slug),
);
},
),
@@ -179,26 +167,10 @@ class _CreatorSiteItem extends HookConsumerWidget {
],
),
onTap: () async {
final confirmed = await showDialog<bool>(
context: context,
builder:
(context) => AlertDialog(
title: Text('deleteSite'.tr()),
content: Text('deleteSiteConfirm'.tr()),
actions: [
TextButton(
onPressed:
() =>
Navigator.of(context).pop(false),
child: Text('cancel'.tr()),
),
TextButton(
onPressed:
() => Navigator.of(context).pop(true),
child: Text('delete'.tr()),
),
],
),
final confirmed = await showConfirmAlert(
'publicationSiteDeleteConfirm'.tr(),
'deleteSite'.tr(),
isDanger: true,
);
if (confirmed == true) {
try {

View File

@@ -41,8 +41,7 @@ class StickersScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createStickerPack'.tr(),
child: StickerPackForm(pubName: pubName),
),
@@ -54,8 +53,7 @@ class StickersScreen extends HookConsumerWidget {
},
child: const Icon(Symbols.add),
),
body:
isWideScreen(context)
body: isWideScreen(context)
? Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 640),
@@ -83,6 +81,7 @@ class SliverStickerPacksList extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
return PaginationList(
padding: EdgeInsets.zero,
provider: stickerPacksProvider(pubName),
notifier: stickerPacksProvider(pubName).notifier,
itemBuilder: (context, index, sticker) {
@@ -97,8 +96,7 @@ class SliverStickerPacksList extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: sticker.name,
actions: [
IconButton(
@@ -108,8 +106,7 @@ class SliverStickerPacksList extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createSticker'.tr(),
child: StickerForm(packId: id),
),
@@ -165,8 +162,7 @@ class StickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final stickers =
response.data
final stickers = response.data
.map((e) => SnStickerPack.fromJson(e))
.cast<SnStickerPack>()
.toList();
@@ -262,8 +258,7 @@ class StickerPackForm extends HookConsumerWidget {
color: Theme.of(context).colorScheme.surfaceContainer,
borderRadius: BorderRadius.all(Radius.circular(8)),
),
child:
(icon.value?.isEmpty ?? true)
child: (icon.value?.isEmpty ?? true)
? const SizedBox.shrink()
: CloudImageWidget(fileId: icon.value!),
),
@@ -273,8 +268,7 @@ class StickerPackForm extends HookConsumerWidget {
onPressed: () {
showModalBottomSheet(
context: context,
builder:
(context) => CloudFilePicker(
builder: (context) => CloudFilePicker(
allowedTypes: {UniversalFileType.image},
),
).then((value) {
@@ -300,8 +294,8 @@ class StickerPackForm extends HookConsumerWidget {
}
return null;
},
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
TextFormField(
controller: descriptionController,
@@ -314,8 +308,8 @@ class StickerPackForm extends HookConsumerWidget {
),
minLines: 3,
maxLines: null,
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
TextFormField(
controller: prefixController,
@@ -332,8 +326,8 @@ class StickerPackForm extends HookConsumerWidget {
}
return null;
},
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
],
),

View File

@@ -39,8 +39,7 @@ class AppDetailScreen extends HookConsumerWidget {
actions: [
IconButton(
icon: const Icon(Symbols.edit),
onPressed:
appData.value == null
onPressed: appData.value == null
? null
: () {
context.pushNamed(
@@ -85,21 +84,31 @@ class AppDetailScreen extends HookConsumerWidget {
controller: tabController,
physics: const NeverScrollableScrollPhysics(),
children: [
_AppOverview(app: app),
AppSecretsScreen(
Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: _AppOverview(app: app),
),
),
Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: AppSecretsScreen(
publisherName: publisherName,
projectId: projectId,
appId: appId,
),
),
),
],
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry:
() => ref.invalidate(
onRetry: () => ref.invalidate(
customAppProvider(publisherName, projectId, appId),
),
),
@@ -115,6 +124,7 @@ class _AppOverview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
padding: EdgeInsets.zero,
child: Column(
children: [
AspectRatio(
@@ -125,8 +135,7 @@ class _AppOverview extends StatelessWidget {
children: [
Container(
color: Theme.of(context).colorScheme.surfaceContainer,
child:
app.background != null
child: app.background != null
? CloudFileWidget(
item: app.background!,
fit: BoxFit.cover,

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/custom_app_secret.dart';
import 'package:island/pods/network.dart';
@@ -53,8 +54,7 @@ class AppSecretsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'newSecretGenerated'.tr(),
child: Padding(
padding: const EdgeInsets.all(20.0),
@@ -114,23 +114,39 @@ class AppSecretsScreen extends HookConsumerWidget {
controller: descriptionController,
decoration: InputDecoration(
labelText: 'description'.tr(),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
Radius.circular(12),
),
),
),
autofocus: true,
),
const SizedBox(height: 20),
const Gap(16),
TextFormField(
controller: expiresInController,
decoration: InputDecoration(
labelText: 'expiresIn'.tr(),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
Radius.circular(12),
),
),
),
keyboardType: TextInputType.number,
),
const SizedBox(height: 20),
SwitchListTile(
const Gap(16),
Card(
margin: EdgeInsets.zero,
child: SwitchListTile(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
title: Text('isOidc'.tr()),
value: isOidc.value,
onChanged: (value) => isOidc.value = value,
),
),
const SizedBox(height: 20),
FilledButton.icon(
onPressed: () async {
@@ -175,13 +191,8 @@ class AppSecretsScreen extends HookConsumerWidget {
return secrets.when(
data: (data) {
return RefreshIndicator(
onRefresh:
() => ref.refresh(
customAppSecretsProvider(
publisherName,
projectId,
appId,
).future,
onRefresh: () => ref.refresh(
customAppSecretsProvider(publisherName, projectId, appId).future,
),
child: Column(
children: [
@@ -240,11 +251,9 @@ class AppSecretsScreen extends HookConsumerWidget {
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry:
() => ref.invalidate(
onRetry: () => ref.invalidate(
customAppSecretsProvider(publisherName, projectId, appId),
),
),

View File

@@ -76,8 +76,7 @@ class CustomAppsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createCustomApp'.tr(),
child: NewCustomAppScreen(
publisherName: publisherName,
@@ -95,10 +94,8 @@ class CustomAppsScreen extends HookConsumerWidget {
);
}
return ExtendedRefreshIndicator(
onRefresh:
() => ref.refresh(
customAppsProvider(publisherName, projectId).future,
),
onRefresh: () =>
ref.refresh(customAppsProvider(publisherName, projectId).future),
child: Column(
children: [
const Gap(8),
@@ -110,8 +107,7 @@ class CustomAppsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createCustomApp'.tr(),
child: NewCustomAppScreen(
publisherName: publisherName,
@@ -145,32 +141,21 @@ class CustomAppsScreen extends HookConsumerWidget {
);
},
child: Column(
children: [
SizedBox(
height: 150,
child: Stack(
fit: StackFit.expand,
children: [
if (app.background != null)
CloudFileWidget(
AspectRatio(
aspectRatio: 16 / 7,
child: CloudFileWidget(
item: app.background!,
fit: BoxFit.cover,
).clipRRect(topLeft: 8, topRight: 8),
if (app.picture != null)
Positioned(
left: 16,
bottom: 16,
child: ProfilePictureWidget(
fileId: app.picture!.id,
radius: 40,
fallbackIcon: Symbols.apps,
),
),
],
),
),
ListTile(
title: Text(app.name),
leading: ProfilePictureWidget(
fileId: app.picture?.id,
fallbackIcon: Symbols.apps,
),
subtitle: Text(
app.slug,
style: GoogleFonts.robotoMono(fontSize: 12),
@@ -180,8 +165,7 @@ class CustomAppsScreen extends HookConsumerWidget {
right: 12,
),
trailing: PopupMenuButton(
itemBuilder:
(context) => [
itemBuilder: (context) => [
PopupMenuItem(
value: 'edit',
child: Row(
@@ -203,9 +187,7 @@ class CustomAppsScreen extends HookConsumerWidget {
const SizedBox(width: 12),
Text(
'delete',
style: TextStyle(
color: Colors.red,
),
style: TextStyle(color: Colors.red),
).tr(),
],
),
@@ -216,8 +198,7 @@ class CustomAppsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'editCustomApp'.tr(),
child: EditAppScreen(
publisherName: publisherName,
@@ -264,13 +245,10 @@ class CustomAppsScreen extends HookConsumerWidget {
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry:
() => ref.invalidate(
customAppsProvider(publisherName, projectId),
),
onRetry: () =>
ref.invalidate(customAppsProvider(publisherName, projectId)),
),
);
}

View File

@@ -36,8 +36,7 @@ class BotDetailScreen extends HookConsumerWidget {
actions: [
IconButton(
icon: const Icon(Symbols.edit),
onPressed:
botData.value == null
onPressed: botData.value == null
? null
: () {
context.pushNamed(
@@ -84,23 +83,32 @@ class BotDetailScreen extends HookConsumerWidget {
controller: tabController,
physics: const NeverScrollableScrollPhysics(),
children: [
_BotOverview(bot: bot),
BotKeysScreen(
Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: _BotOverview(bot: bot),
),
),
Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: BotKeysScreen(
publisherName: publisherName,
projectId: projectId,
botId: botId,
),
),
),
],
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry:
() => ref.invalidate(
botProvider(publisherName, projectId, botId),
),
onRetry: () =>
ref.invalidate(botProvider(publisherName, projectId, botId)),
),
),
);
@@ -124,8 +132,7 @@ class _BotOverview extends StatelessWidget {
children: [
Container(
color: Theme.of(context).colorScheme.surfaceContainer,
child:
bot.account.profile.background != null
child: bot.account.profile.background != null
? CloudFileWidget(
item: bot.account.profile.background!,
fit: BoxFit.cover,

View File

@@ -53,8 +53,7 @@ class BotKeysScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'newKeyGenerated'.tr(),
child: Padding(
padding: const EdgeInsets.all(20.0),
@@ -94,8 +93,8 @@ class BotKeysScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
heightFactor: 0.7,
titleText: 'newBotKey'.tr(),
child: Padding(
padding: const EdgeInsets.all(20.0),
@@ -105,7 +104,12 @@ class BotKeysScreen extends HookConsumerWidget {
children: [
TextFormField(
controller: keyNameController,
decoration: InputDecoration(labelText: 'keyName'.tr()),
decoration: InputDecoration(
labelText: 'keyName'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
),
autofocus: true,
),
const SizedBox(height: 20),
@@ -189,22 +193,15 @@ class BotKeysScreen extends HookConsumerWidget {
ListTile(
leading: const Icon(Symbols.add),
title: Text('newBotKey'.tr()),
trailing: const Icon(Symbols.chevron_right),
onTap: createKey,
),
const Divider(height: 1),
Expanded(
child:
data.isEmpty
child: data.isEmpty
? Center(child: Text('noBotKeys'.tr()))
: RefreshIndicator(
onRefresh:
() => ref.refresh(
botKeysProvider(
publisherName,
projectId,
botId,
).future,
onRefresh: () => ref.refresh(
botKeysProvider(publisherName, projectId, botId).future,
),
child: ListView.builder(
padding: EdgeInsets.zero,
@@ -219,8 +216,7 @@ class BotKeysScreen extends HookConsumerWidget {
right: 12,
),
trailing: PopupMenuButton(
itemBuilder:
(context) => [
itemBuilder: (context) => [
PopupMenuItem(
value: 'rotate',
child: Row(
@@ -242,9 +238,7 @@ class BotKeysScreen extends HookConsumerWidget {
const Gap(12),
Text(
'revoke'.tr(),
style: TextStyle(
color: Colors.red,
),
style: TextStyle(color: Colors.red),
),
],
),
@@ -267,13 +261,10 @@ class BotKeysScreen extends HookConsumerWidget {
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry:
() => ref.invalidate(
botKeysProvider(publisherName, projectId, botId),
),
onRetry: () =>
ref.invalidate(botKeysProvider(publisherName, projectId, botId)),
),
);
}

View File

@@ -54,8 +54,7 @@ class BotsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createBot'.tr(),
child: NewBotScreen(
publisherName: publisherName,
@@ -73,8 +72,8 @@ class BotsScreen extends HookConsumerWidget {
);
}
return ExtendedRefreshIndicator(
onRefresh:
() => ref.refresh(botsProvider(publisherName, projectId).future),
onRefresh: () =>
ref.refresh(botsProvider(publisherName, projectId).future),
child: Column(
children: [
const Gap(8),
@@ -86,8 +85,7 @@ class BotsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createBot'.tr(),
child: NewBotScreen(
publisherName: publisherName,
@@ -108,23 +106,30 @@ class BotsScreen extends HookConsumerWidget {
itemBuilder: (context, index) {
final bot = data[index];
return Card(
child: ListTile(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
child: Column(
children: [
if (bot.account.profile.background != null)
AspectRatio(
aspectRatio: 16 / 7,
child: CloudFileWidget(
item: bot.account.profile.background!,
fit: BoxFit.cover,
).clipRRect(topLeft: 8, topRight: 8),
),
leading: CircleAvatar(
child:
bot.account.profile.picture != null
? ProfilePictureWidget(
file: bot.account.profile.picture!,
)
: const Icon(Symbols.smart_toy),
ListTile(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
leading: ProfilePictureWidget(
fallbackIcon: Symbols.smart_toy,
file: bot.account.profile.picture,
),
title: Text(bot.account.nick),
subtitle: Text(bot.account.name),
trailing: PopupMenuButton(
itemBuilder:
(context) => [
itemBuilder: (context) => [
PopupMenuItem(
value: 'edit',
child: Row(
@@ -157,8 +162,7 @@ class BotsScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'editBot'.tr(),
child: EditBotScreen(
publisherName: publisherName,
@@ -175,7 +179,9 @@ class BotsScreen extends HookConsumerWidget {
isDanger: true,
).then((confirm) {
if (confirm) {
final client = ref.read(apiClientProvider);
final client = ref.read(
apiClientProvider,
);
client.delete(
'/develop/developers/$publisherName/projects/$projectId/bots/${bot.id}',
);
@@ -198,6 +204,8 @@ class BotsScreen extends HookConsumerWidget {
);
},
),
],
),
);
},
),
@@ -207,11 +215,9 @@ class BotsScreen extends HookConsumerWidget {
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry:
() => ref.invalidate(botsProvider(publisherName, projectId)),
onRetry: () => ref.invalidate(botsProvider(publisherName, projectId)),
),
);
}

View File

@@ -68,8 +68,7 @@ class DeveloperHubScreen extends HookConsumerWidget {
developers.value?.firstOrNull,
);
final projects =
currentDeveloper.value?.publisher?.name != null
final projects = currentDeveloper.value?.publisher?.name != null
? ref.watch(
devProjectsProvider(currentDeveloper.value!.publisher!.name),
)
@@ -126,8 +125,7 @@ class DeveloperHubScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'createProject'.tr(),
child: ProjectForm(
publisherName:
@@ -211,9 +209,7 @@ class _MainContentSection extends HookConsumerWidget {
return Container(
padding: const EdgeInsets.all(8),
child: developerStats.when(
data:
(stats) =>
currentDeveloper == null
data: (stats) => currentDeveloper == null
? ConstrainedBox(
constraints: BoxConstraints(maxWidth: 640),
child: _DeveloperUnselectedWidget(
@@ -229,9 +225,7 @@ class _MainContentSection extends HookConsumerWidget {
if (stats != null) ...[
Text(
'Overview',
style: Theme.of(
context,
).textTheme.titleLarge?.copyWith(
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
),
@@ -245,11 +239,9 @@ class _MainContentSection extends HookConsumerWidget {
children: [
Text(
'Projects',
style: Theme.of(
context,
).textTheme.titleLarge?.copyWith(
color:
Theme.of(context).colorScheme.onSurface,
style: Theme.of(context).textTheme.titleLarge
?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
),
const Spacer(),
@@ -273,17 +265,13 @@ class _MainContentSection extends HookConsumerWidget {
// Projects List
projects.value?.isNotEmpty ?? false
? Column(
children:
projects.value!
children: projects.value!
.map(
(project) => _ProjectListTile(
project: project,
publisherName:
currentDeveloper!
.publisher!
.name,
onProjectSelected:
onProjectSelected,
currentDeveloper!.publisher!.name,
onProjectSelected: onProjectSelected,
),
)
.toList(),
@@ -294,8 +282,7 @@ class _MainContentSection extends HookConsumerWidget {
child: Text(
'No projects available',
style: TextStyle(
color:
Theme.of(context).colorScheme.onSurface,
color: Theme.of(context).colorScheme.onSurface,
fontSize: 16,
),
),
@@ -304,8 +291,7 @@ class _MainContentSection extends HookConsumerWidget {
),
),
loading: () => const Center(child: CircularProgressIndicator()),
error:
(err, stack) => ResponseErrorWidget(
error: (err, stack) => ResponseErrorWidget(
error: err,
onRetry: () {
ref.invalidate(
@@ -335,9 +321,7 @@ class DeveloperSelector extends HookConsumerWidget {
final developers = ref.watch(developersProvider);
final List<DropdownMenuItem<SnDeveloper>> developersMenu = developers.when(
data:
(data) =>
data
data: (data) => data
.map(
(item) => DropdownMenuItem<SnDeveloper>(
value: item,
@@ -349,8 +333,7 @@ class DeveloperSelector extends HookConsumerWidget {
),
title: Text(item.publisher!.nick),
subtitle: Text('@${item.publisher!.name}'),
trailing:
currentDeveloper?.id == item.id
trailing: currentDeveloper?.id == item.id
? const Icon(Icons.check)
: null,
contentPadding: EdgeInsets.symmetric(horizontal: 8),
@@ -446,8 +429,7 @@ class ProjectSelector extends HookConsumerWidget {
return const SizedBox.shrink();
}
final List<DropdownMenuItem<DevProject>> projectsMenu =
projects.value!
final List<DropdownMenuItem<DevProject>> projectsMenu = projects.value!
.map(
(item) => DropdownMenuItem<DevProject>(
value: item,
@@ -469,8 +451,7 @@ class ProjectSelector extends HookConsumerWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
trailing:
currentProject?.id == item.id
trailing: currentProject?.id == item.id
? const Icon(Icons.check)
: null,
contentPadding: EdgeInsets.symmetric(horizontal: 8),
@@ -496,22 +477,21 @@ class ProjectSelector extends HookConsumerWidget {
final isWider = isWiderScreen(context);
return projectsMenu
.map(
(e) =>
isWider
(e) => isWider
? Row(
mainAxisSize: MainAxisSize.min,
children: [
CircleAvatar(
radius: 16,
backgroundColor:
Theme.of(context).colorScheme.primary,
backgroundColor: Theme.of(
context,
).colorScheme.primary,
child: Text(
e.value?.name.isNotEmpty ?? false
? e.value!.name[0].toUpperCase()
: '?',
style: TextStyle(
color:
Theme.of(context).colorScheme.onPrimary,
color: Theme.of(context).colorScheme.onPrimary,
),
),
),
@@ -519,8 +499,7 @@ class ProjectSelector extends HookConsumerWidget {
Text(
e.value?.name ?? '?',
style: TextStyle(
color:
Theme.of(
color: Theme.of(
context,
).appBarTheme.foregroundColor,
),
@@ -529,8 +508,7 @@ class ProjectSelector extends HookConsumerWidget {
).padding(right: 8)
: CircleAvatar(
radius: 16,
backgroundColor:
Theme.of(context).colorScheme.primary,
backgroundColor: Theme.of(context).colorScheme.primary,
child: Text(
e.value?.name.isNotEmpty ?? false
? e.value!.name[0].toUpperCase()
@@ -590,8 +568,7 @@ class _ProjectListTile extends HookConsumerWidget {
subtitle: Text(project.description ?? ''),
contentPadding: const EdgeInsets.only(left: 16, right: 17),
trailing: PopupMenuButton(
itemBuilder:
(context) => [
itemBuilder: (context) => [
PopupMenuItem(
value: 'edit',
child: Row(
@@ -608,10 +585,7 @@ class _ProjectListTile extends HookConsumerWidget {
children: [
const Icon(Symbols.delete, color: Colors.red),
const SizedBox(width: 12),
Text(
'delete',
style: const TextStyle(color: Colors.red),
).tr(),
Text('delete', style: const TextStyle(color: Colors.red)).tr(),
],
),
),
@@ -621,8 +595,7 @@ class _ProjectListTile extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'editProject'.tr(),
child: ProjectForm(
publisherName: publisherName,
@@ -735,6 +708,13 @@ class _DeveloperUnselectedWidget extends HookConsumerWidget {
mainAxisSize: MainAxisSize.min,
children: [
if (!hasDevelopers) ...[
if (developers.isLoading)
Padding(
padding: const EdgeInsets.all(8),
child: const CircularProgressIndicator(),
)
else
...([
const Icon(
Symbols.info,
fill: 1,
@@ -745,6 +725,7 @@ class _DeveloperUnselectedWidget extends HookConsumerWidget {
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
).tr(),
]),
const Gap(24),
],
if (hasDevelopers)
@@ -818,8 +799,7 @@ class ProjectForm extends HookConsumerWidget {
'description': descriptionController.text,
};
final resp =
isEditing
final resp = isEditing
? await client.put(
'/develop/developers/$publisherName/projects/${project!.id}',
data: data,
@@ -860,8 +840,8 @@ class ProjectForm extends HookConsumerWidget {
}
return null;
},
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
TextFormField(
controller: slugController,
@@ -878,8 +858,8 @@ class ProjectForm extends HookConsumerWidget {
}
return null;
},
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
TextFormField(
controller: descriptionController,
@@ -892,8 +872,8 @@ class ProjectForm extends HookConsumerWidget {
),
minLines: 3,
maxLines: null,
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
],
),
@@ -934,12 +914,9 @@ class _DeveloperEnrollmentSheet extends HookConsumerWidget {
return SheetScaffold(
titleText: 'enrollDeveloper'.tr(),
child: publishers.when(
data:
(items) =>
items.isEmpty
data: (items) => items.isEmpty
? Center(
child:
Text(
child: Text(
'noDevelopersToEnroll',
textAlign: TextAlign.center,
).tr(),
@@ -961,8 +938,7 @@ class _DeveloperEnrollmentSheet extends HookConsumerWidget {
},
),
loading: () => const Center(child: CircularProgressIndicator()),
error:
(error, _) => ResponseErrorWidget(
error: (error, _) => ResponseErrorWidget(
error: error,
onRetry: () => ref.invalidate(publishersManagedProvider),
),

View File

@@ -24,6 +24,16 @@ class ProjectDetailView extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final tabController = useTabController(initialLength: 2);
final currentDest = useState(0);
useEffect(() {
tabController.addListener(() {
if (tabController.indexIsChanging) {
currentDest.value = tabController.index;
}
});
return null;
});
final isWide = isWideScreen(context);
@@ -38,14 +48,13 @@ class ProjectDetailView extends HookConsumerWidget {
child: NavigationRail(
extended: isWiderScreen(context),
scrollable: true,
labelType:
isWiderScreen(context)
labelType: isWiderScreen(context)
? null
: NavigationRailLabelType.selected,
backgroundColor: Colors.transparent,
selectedIndex: tabController.index,
onDestinationSelected:
(index) => tabController.animateTo(index),
selectedIndex: currentDest.value,
onDestinationSelected: (index) =>
tabController.animateTo(index),
destinations: [
NavigationRailDestination(
icon: Icon(Icons.apps),

View File

@@ -33,7 +33,12 @@ class ArticlesListNotifier extends AsyncNotifier<List<SnWebArticle>>
Future<List<SnWebArticle>> fetch() async {
final client = ref.read(apiClientProvider);
final queryParams = {'limit': pageSize, 'offset': fetchedCount.toString()};
final queryParams = {
'limit': pageSize,
'offset': fetchedCount.toString(),
'feedId': arg.feedId,
'publisherId': arg.publisherId,
}..removeWhere((key, value) => value == null);
try {
final response = await client.get(
@@ -41,11 +46,8 @@ class ArticlesListNotifier extends AsyncNotifier<List<SnWebArticle>>
queryParameters: queryParams,
);
final articles =
response.data
.map(
(json) => SnWebArticle.fromJson(json as Map<String, dynamic>),
)
final articles = response.data
.map((json) => SnWebArticle.fromJson(json as Map<String, dynamic>))
.cast<SnWebArticle>()
.toList();
@@ -81,6 +83,7 @@ class SliverArticlesList extends ConsumerWidget {
ArticleListQuery(feedId: feedId, publisherId: publisherId),
);
return PaginationList(
spacing: 12,
provider: provider,
notifier: provider.notifier,
isRefreshable: false,
@@ -184,14 +187,12 @@ class ArticlesScreen extends ConsumerWidget {
),
);
},
loading:
() => AppScaffold(
loading: () => AppScaffold(
isNoBackground: false,
appBar: AppBar(title: const Text('Articles')),
body: const Center(child: CircularProgressIndicator()),
),
error:
(err, stack) => AppScaffold(
error: (err, stack) => AppScaffold(
isNoBackground: false,
appBar: AppBar(title: const Text('Articles')),
body: Center(child: Text('Error: $err')),

View File

@@ -44,8 +44,7 @@ class MarketplaceWebFeedContentNotifier
queryParameters: queryParams,
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final articles =
response.data
final articles = response.data
.map((json) => SnWebArticle.fromJson(json))
.cast<SnWebArticle>()
.toList();
@@ -116,8 +115,7 @@ class MarketplaceWebFeedDetailScreen extends HookConsumerWidget {
// Feed meta
feed
.when(
data:
(data) => Column(
data: (data) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(data.description ?? 'descriptionNone'.tr()),
@@ -149,10 +147,12 @@ class MarketplaceWebFeedDetailScreen extends HookConsumerWidget {
// Articles list
Expanded(
child: PaginationList(
spacing: 8,
padding: EdgeInsets.symmetric(vertical: 8),
provider: marketplaceWebFeedContentNotifierProvider(id),
notifier: marketplaceWebFeedContentNotifierProvider(id).notifier,
itemBuilder: (context, index, article) {
return WebArticleCard(article: article);
return WebArticleCard(article: article).padding(horizontal: 12);
},
),
),
@@ -165,10 +165,8 @@ class MarketplaceWebFeedDetailScreen extends HookConsumerWidget {
),
color: Theme.of(context).colorScheme.surfaceContainer,
child: subscribed.when(
data:
(isSubscribed) => FilledButton.icon(
onPressed:
isSubscribed ? unsubscribeFromFeed : subscribeToFeed,
data: (isSubscribed) => FilledButton.icon(
onPressed: isSubscribed ? unsubscribeFromFeed : subscribeToFeed,
icon: Icon(
isSubscribed ? Symbols.remove_circle : Symbols.add_circle,
),
@@ -176,14 +174,12 @@ class MarketplaceWebFeedDetailScreen extends HookConsumerWidget {
isSubscribed ? 'unsubscribe'.tr() : 'subscribe'.tr(),
),
),
loading:
() => const SizedBox(
loading: () => const SizedBox(
height: 32,
width: 32,
child: CircularProgressIndicator(strokeWidth: 2),
),
error:
(_, _) => OutlinedButton.icon(
).center(),
error: (_, _) => OutlinedButton.icon(
onPressed: subscribeToFeed,
icon: const Icon(Symbols.add_circle),
label: Text('subscribe').tr(),

View File

@@ -12,7 +12,7 @@ import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:material_symbols_icons/symbols.dart';
final marketplaceWebFeedsNotifierProvider = AsyncNotifierProvider(
final marketplaceWebFeedsNotifierProvider = AsyncNotifierProvider.autoDispose(
MarketplaceWebFeedsNotifier.new,
);
@@ -38,8 +38,7 @@ class MarketplaceWebFeedsNotifier extends AsyncNotifier<List<SnWebFeed>>
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final feeds =
response.data
final feeds = response.data
.map((e) => SnWebFeed.fromJson(e))
.cast<SnWebFeed>()
.toList();
@@ -92,8 +91,8 @@ class MarketplaceWebFeedsScreen extends HookConsumerWidget {
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(horizontal: 24),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
trailing: [
if (query.value != null && query.value!.isNotEmpty)
IconButton(
@@ -128,6 +127,7 @@ class MarketplaceWebFeedsScreen extends HookConsumerWidget {
padding: EdgeInsets.zero,
itemBuilder: (context, index, feed) {
return ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
title: Text(feed.title),
subtitle: Text(feed.description ?? ''),
trailing: const Icon(Symbols.chevron_right),

View File

@@ -23,7 +23,7 @@ class DiscoveryRealmsScreen extends HookConsumerWidget {
children: [
CustomScrollView(
slivers: [
SliverGap(80),
SliverGap(88),
SliverRealmList(
query: currentQuery.value,
key: ValueKey(currentQuery.value),

View File

@@ -102,7 +102,7 @@ class ExploreScreen extends HookConsumerWidget {
// Listen for post creation events to refresh activities
useEffect(() {
final subscription = eventBus.on<PostCreatedEvent>().listen((event) {
ref.invalidate(activityListProvider);
ref.read(activityListProvider.notifier).refresh();
});
return subscription.cancel;
}, []);
@@ -183,25 +183,13 @@ class ExploreScreen extends HookConsumerWidget {
children: [
const Icon(Symbols.category),
const Gap(12),
Text('categories').tr(),
Text('categoriesAndTags').tr(),
],
),
onTap: () {
context.pushNamed('postCategories');
},
),
PopupMenuItem(
child: Row(
children: [
const Icon(Symbols.label),
const Gap(12),
Text('tags').tr(),
],
),
onTap: () {
context.pushNamed('postTags');
},
),
PopupMenuItem(
child: Row(
children: [
@@ -490,25 +478,13 @@ class ExploreScreen extends HookConsumerWidget {
children: [
const Icon(Symbols.category),
const Gap(12),
Text('categories').tr(),
Text('categoriesAndTags').tr(),
],
),
onTap: () {
context.pushNamed('postCategories');
},
),
PopupMenuItem(
child: Row(
children: [
const Icon(Symbols.label),
const Gap(12),
Text('tags').tr(),
],
),
onTap: () {
context.pushNamed('postTags');
},
),
PopupMenuItem(
child: Row(
children: [

View File

@@ -10,9 +10,9 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/file.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/file_references.dart';
import 'package:island/pods/drive/file_references.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/upload_tasks.dart';
import 'package:island/pods/drive/upload_tasks.dart';
import 'package:island/models/drive_task.dart';
import 'package:island/services/responsive.dart';
import 'package:island/services/time.dart';
@@ -120,8 +120,9 @@ class FileDetailScreen extends HookConsumerWidget {
child: SizedBox(
width: 400,
child: Material(
color:
Theme.of(context).colorScheme.surfaceContainer,
color: Theme.of(
context,
).colorScheme.surfaceContainer,
elevation: 8,
child: FileInfoSheet(
item: item,
@@ -176,13 +177,11 @@ class FileDetailScreen extends HookConsumerWidget {
actions.add(
IconButton(
icon: Icon(Icons.link),
onPressed:
() => showModalBottomSheet(
onPressed: () => showModalBottomSheet(
useRootNavigator: true,
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'File References',
child: ReferencesList(fileId: item.id),
),
@@ -300,8 +299,7 @@ class ReferencesList extends ConsumerWidget {
final asyncReferences = ref.watch(fileReferencesProvider(fileId));
return asyncReferences.when(
data:
(references) => ListView.builder(
data: (references) => ListView.builder(
itemCount: references.length,
itemBuilder: (context, index) {
final reference = references[index];
@@ -317,10 +315,7 @@ class ReferencesList extends ConsumerWidget {
fontSize: 13,
),
),
Text(
reference.id,
style: GoogleFonts.robotoMono(fontSize: 13),
),
Text(reference.id, style: GoogleFonts.robotoMono(fontSize: 13)),
],
),
subtitle: Row(
@@ -335,8 +330,8 @@ class ReferencesList extends ConsumerWidget {
},
),
loading: () => const Center(child: CircularProgressIndicator()),
error:
(error, _) => Center(child: Text('Error loading references: $error')),
error: (error, _) =>
Center(child: Text('Error loading references: $error')),
);
}
}

View File

@@ -7,7 +7,7 @@ import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/file.dart';
import 'package:island/models/file_pool.dart';
import 'package:island/pods/file_list.dart';
import 'package:island/pods/drive/file_list.dart';
import 'package:island/services/file_uploader.dart';
import 'package:island/widgets/alert.dart';
import 'package:island/widgets/app_scaffold.dart';
@@ -40,27 +40,20 @@ class FileListScreen extends HookConsumerWidget {
actions: [
IconButton(
icon: const Icon(Symbols.bar_chart),
onPressed:
() => _showUsageSheet(
context,
usageAsync.value,
quotaAsync.value,
),
onPressed: () =>
_showUsageSheet(context, usageAsync.value, quotaAsync.value),
),
const Gap(8),
],
),
body: usageAsync.when(
data:
(usage) => quotaAsync.when(
data:
(quota) => FileListView(
data: (usage) => quotaAsync.when(
data: (quota) => FileListView(
usage: usage,
quota: quota,
currentPath: currentPath,
selectedPool: selectedPool,
onPickAndUpload:
() => _pickAndUploadFile(
onPickAndUpload: () => _pickAndUploadFile(
ref,
currentPath.value,
selectedPool.value?.id,
@@ -158,8 +151,7 @@ class FileListScreen extends HookConsumerWidget {
await showDialog(
context: context,
builder:
(context) => AlertDialog(
builder: (context) => AlertDialog(
title: const Text('Navigate to Directory'),
content: Column(
mainAxisSize: MainAxisSize.min,
@@ -207,8 +199,7 @@ class FileListScreen extends HookConsumerWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'Usage Overview',
child: UsageOverviewWidget(
usage: usage,

View File

@@ -18,11 +18,92 @@ import 'package:island/widgets/paging/pagination_list.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
import 'package:relative_time/relative_time.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:url_launcher/url_launcher_string.dart';
part 'notification.g.dart';
class SkeletonNotificationTile extends StatelessWidget {
const SkeletonNotificationTile({super.key});
@override
Widget build(BuildContext context) {
const fakeTitle = 'New notification';
const fakeSubtitle = 'You have a new message from someone';
const fakeContent =
'This is a preview of the notification content. It may contain formatted text.';
const List<String> fakeImageIds = []; // Empty list for no images
const String? fakePfp = null; // No profile picture
return ListTile(
isThreeLine: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
leading: fakePfp != null
? ProfilePictureWidget(fileId: fakePfp, radius: 20)
: CircleAvatar(
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
child: Icon(
Symbols.notifications,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
title: const Text(fakeTitle),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(fakeSubtitle).bold(),
Row(
spacing: 6,
children: [
Text('Loading...').fontSize(11),
Skeleton.ignore(child: Text('·').fontSize(11).bold()),
Text('Now').fontSize(11),
],
).opacity(0.75).padding(bottom: 4),
MarkdownTextContent(
content: fakeContent,
textStyle: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
),
),
if (fakeImageIds.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 8),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: fakeImageIds.map((imageId) {
return SizedBox(
width: 80,
height: 80,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: CloudImageWidget(
fileId: imageId,
aspectRatio: 1,
fit: BoxFit.cover,
),
),
);
}).toList(),
),
),
],
),
trailing: Container(
width: 12,
height: 12,
decoration: const BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
),
onTap: () {},
);
}
}
@riverpod
class NotificationUnreadCountNotifier
extends _$NotificationUnreadCountNotifier {
@@ -82,7 +163,7 @@ class NotificationUnreadCountNotifier
}
}
final notificationListProvider = AsyncNotifierProvider(
final notificationListProvider = AsyncNotifierProvider.autoDispose(
NotificationListNotifier.new,
);
@@ -182,6 +263,7 @@ class NotificationSheet extends HookConsumerWidget {
child: PaginationList(
provider: notificationListProvider,
notifier: notificationListProvider.notifier,
footerSkeletonChild: const SkeletonNotificationTile(),
itemBuilder: (context, index, notification) {
final pfp = notification.meta['pfp'] as String?;
final images = notification.meta['images'] as List?;

View File

@@ -18,12 +18,10 @@ _PostComposeInitialState _$PostComposeInitialStateFromJson(
.toList() ??
const [],
visibility: (json['visibility'] as num?)?.toInt(),
replyingTo:
json['replying_to'] == null
replyingTo: json['replying_to'] == null
? null
: SnPost.fromJson(json['replying_to'] as Map<String, dynamic>),
forwardingTo:
json['forwarding_to'] == null
forwardingTo: json['forwarding_to'] == null
? null
: SnPost.fromJson(json['forwarding_to'] as Map<String, dynamic>),
);

View File

@@ -2,73 +2,64 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post_category.dart';
import 'package:island/models/post_tag.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
import 'package:island/pods/post/post_categories.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:material_symbols_icons/symbols.dart';
// Post Categories Notifier
final postCategoriesProvider = AsyncNotifierProvider.autoDispose<
PostCategoriesNotifier,
List<SnPostCategory>
>(PostCategoriesNotifier.new);
class PostCategoriesNotifier extends AsyncNotifier<List<SnPostCategory>>
with AsyncPaginationController<SnPostCategory> {
@override
Future<List<SnPostCategory>> fetch() async {
final client = ref.read(apiClientProvider);
final response = await client.get(
'/sphere/posts/categories',
queryParameters: {'offset': fetchedCount, 'take': 20, 'order': 'usage'},
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final data = response.data as List;
return data.map((json) => SnPostCategory.fromJson(json)).toList();
}
}
// Post Tags Notifier
final postTagsProvider =
AsyncNotifierProvider.autoDispose<PostTagsNotifier, List<SnPostTag>>(
PostTagsNotifier.new,
);
class PostTagsNotifier extends AsyncNotifier<List<SnPostTag>>
with AsyncPaginationController<SnPostTag> {
@override
Future<List<SnPostTag>> fetch() async {
final client = ref.read(apiClientProvider);
final response = await client.get(
'/sphere/posts/tags',
queryParameters: {'offset': fetchedCount, 'take': 20, 'order': 'usage'},
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final data = response.data as List;
return data.map((json) => SnPostTag.fromJson(json)).toList();
}
}
class PostCategoriesListScreen extends ConsumerWidget {
class PostCategoriesListScreen extends HookConsumerWidget {
const PostCategoriesListScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return AppScaffold(
appBar: AppBar(title: const Text('categories').tr()),
body: PaginationList(
return DefaultTabController(
length: 2,
child: AppScaffold(
isNoBackground: false,
appBar: AppBar(
title: const Text('categoriesAndTags').tr(),
bottom: TabBar(
tabs: [
Tab(
child: Text(
'categories'.tr(),
style: TextStyle(
color: Theme.of(context).appBarTheme.foregroundColor,
),
),
),
Tab(
child: Text(
'tags'.tr(),
style: TextStyle(
color: Theme.of(context).appBarTheme.foregroundColor,
),
),
),
],
),
),
body: const TabBarView(children: [_CategoriesTab(), _TagsTab()]),
),
);
}
}
class _CategoriesTab extends ConsumerWidget {
const _CategoriesTab();
@override
Widget build(BuildContext context, WidgetRef ref) {
return PaginationList(
provider: postCategoriesProvider,
notifier: postCategoriesProvider.notifier,
footerSkeletonMaxWidth: 640,
padding: EdgeInsets.zero,
itemBuilder: (context, index, category) {
return ListTile(
return Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: ListTile(
leading: const Icon(Symbols.category),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
trailing: const Icon(Symbols.chevron_right),
@@ -80,26 +71,29 @@ class PostCategoriesListScreen extends ConsumerWidget {
pathParameters: {'slug': category.slug},
);
},
),
),
);
},
),
);
}
}
class PostTagsListScreen extends ConsumerWidget {
const PostTagsListScreen({super.key});
class _TagsTab extends ConsumerWidget {
const _TagsTab();
@override
Widget build(BuildContext context, WidgetRef ref) {
return AppScaffold(
appBar: AppBar(title: const Text('tags').tr()),
body: PaginationList(
return PaginationList(
provider: postTagsProvider,
notifier: postTagsProvider.notifier,
footerSkeletonMaxWidth: 640,
padding: EdgeInsets.zero,
itemBuilder: (context, index, tag) {
return ListTile(
return Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: ListTile(
title: Text(tag.name ?? '#${tag.slug}'),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
leading: const Icon(Symbols.label),
@@ -111,9 +105,10 @@ class PostTagsListScreen extends ConsumerWidget {
pathParameters: {'slug': tag.slug},
);
},
),
),
);
},
),
);
}
}

View File

@@ -5,6 +5,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post_category.dart';
import 'package:island/models/post_tag.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/post/post_list.dart';
import 'package:island/widgets/response.dart';
@@ -82,15 +83,15 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final postCategory =
isCategory ? ref.watch(postCategoryProvider(slug)) : null;
final postCategory = isCategory
? ref.watch(postCategoryProvider(slug))
: null;
final postTag = isCategory ? null : ref.watch(postTagProvider(slug));
final subscriptionStatus = ref.watch(
postCategorySubscriptionStatusProvider(slug, isCategory),
);
final postFilterTitle =
isCategory
final postFilterTitle = isCategory
? postCategory?.value?.categoryDisplayTitle ?? 'loading'
: postTag?.value?.name ?? postTag?.value?.slug ?? 'loading';
@@ -108,8 +109,7 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
child: Card(
margin: EdgeInsets.only(top: 8),
child: postCategory!.when(
data:
(category) => Column(
data: (category) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
@@ -118,9 +118,7 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
Text('A category'),
const Gap(8),
subscriptionStatus.when(
data:
(isSubscribed) =>
isSubscribed
data: (isSubscribed) => isSubscribed
? FilledButton.icon(
onPressed: () async {
await _unsubscribeFromCategoryOrTag(
@@ -129,9 +127,7 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
isCategory: isCategory,
);
},
icon: const Icon(
Symbols.remove_circle,
),
icon: const Icon(Symbols.remove_circle),
label: Text('unsubscribe'.tr()),
)
: FilledButton.icon(
@@ -142,28 +138,20 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
isCategory: isCategory,
);
},
icon: const Icon(
Symbols.add_circle,
),
icon: const Icon(Symbols.add_circle),
label: Text('subscribe'.tr()),
),
error:
(error, _) => Text(
'Error loading subscription status',
),
loading:
() =>
error: (error, _) =>
Text('Error loading subscription status'),
loading: () =>
CircularProgressIndicator().center(),
),
],
).padding(horizontal: 24, vertical: 16),
error:
(error, _) => ResponseErrorWidget(
error: (error, _) => ResponseErrorWidget(
error: error,
onRetry:
() => ref.invalidate(
postCategoryProvider(slug),
),
onRetry: () =>
ref.invalidate(postCategoryProvider(slug)),
),
loading: () => ResponseLoadingWidget(),
),
@@ -179,8 +167,7 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
child: Card(
margin: EdgeInsets.only(top: 8),
child: postTag!.when(
data:
(tag) => Column(
data: (tag) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
@@ -189,9 +176,7 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
Text('A tag'),
const Gap(8),
subscriptionStatus.when(
data:
(isSubscribed) =>
isSubscribed
data: (isSubscribed) => isSubscribed
? FilledButton.icon(
onPressed: () async {
await _unsubscribeFromCategoryOrTag(
@@ -200,9 +185,7 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
isCategory: isCategory,
);
},
icon: const Icon(
Symbols.remove_circle,
),
icon: const Icon(Symbols.remove_circle),
label: Text('unsubscribe'.tr()),
)
: FilledButton.icon(
@@ -213,26 +196,19 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
isCategory: isCategory,
);
},
icon: const Icon(
Symbols.add_circle,
),
icon: const Icon(Symbols.add_circle),
label: Text('subscribe'.tr()),
),
error:
(error, _) => Text(
'Error loading subscription status',
),
loading:
() =>
error: (error, _) =>
Text('Error loading subscription status'),
loading: () =>
CircularProgressIndicator().center(),
),
],
).padding(horizontal: 24, vertical: 16),
error:
(error, _) => ResponseErrorWidget(
error: (error, _) => ResponseErrorWidget(
error: error,
onRetry:
() => ref.invalidate(postTagProvider(slug)),
onRetry: () => ref.invalidate(postTagProvider(slug)),
),
loading: () => ResponseLoadingWidget(),
),
@@ -242,8 +218,11 @@ class PostCategoryDetailScreen extends HookConsumerWidget {
),
const SliverGap(4),
SliverPostList(
query: PostListQuery(
categories: isCategory ? [slug] : null,
tags: isCategory ? null : [slug],
),
maxWidth: 540 + 16,
),
SliverGap(MediaQuery.of(context).padding.bottom + 8),

View File

@@ -3,102 +3,19 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post.dart';
import 'package:island/pods/network.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/extended_refresh_indicator.dart';
import 'package:island/widgets/post/post_item.dart';
import 'package:island/pods/paging.dart';
import 'package:island/widgets/post/post_item_skeleton.dart';
import 'package:island/widgets/posts/post_filter.dart';
import 'package:gap/gap.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/services/responsive.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart';
final postSearchProvider = AsyncNotifierProvider.autoDispose(
PostSearchNotifier.new,
);
class PostSearchNotifier extends AsyncNotifier<List<SnPost>>
with AsyncPaginationController<SnPost> {
static const int _pageSize = 20;
String _currentQuery = '';
String? _pubName;
String? _realm;
int? _type;
List<String>? _categories;
List<String>? _tags;
bool _shuffle = false;
bool? _pinned;
@override
FutureOr<List<SnPost>> build() async {
// Initial state is empty if no query/filters, or fetch if needed
// But original logic allowed initial empty state.
// Let's replicate original logic: return empty list initially if no query.
return [];
}
Future<void> search(
String query, {
String? pubName,
String? realm,
int? type,
List<String>? categories,
List<String>? tags,
bool shuffle = false,
bool? pinned,
}) async {
_currentQuery = query.trim();
_pubName = pubName;
_realm = realm;
_type = type;
_categories = categories;
_tags = tags;
_shuffle = shuffle;
_pinned = pinned;
final hasFilters =
pubName != null ||
realm != null ||
type != null ||
categories != null ||
tags != null ||
shuffle ||
pinned != null;
if (_currentQuery.isEmpty && !hasFilters) {
state = const AsyncData([]);
totalCount = null;
return;
}
await refresh();
}
@override
Future<List<SnPost>> fetch() async {
final client = ref.read(apiClientProvider);
final response = await client.get(
'/sphere/posts',
queryParameters: {
'query': _currentQuery,
'offset': fetchedCount,
'take': _pageSize,
'vector': false,
if (_pubName != null) 'pub': _pubName,
if (_realm != null) 'realm': _realm,
if (_type != null) 'type': _type,
if (_tags != null) 'tags': _tags,
if (_categories != null) 'categories': _categories,
if (_shuffle) 'shuffle': true,
if (_pinned != null) 'pinned': _pinned,
},
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final data = response.data as List;
return data.map((json) => SnPost.fromJson(json)).toList();
}
}
const kSearchPostListId = 'search';
class PostSearchScreen extends HookConsumerWidget {
const PostSearchScreen({super.key});
@@ -111,11 +28,16 @@ class PostSearchScreen extends HookConsumerWidget {
final showFilters = useState(false);
final pubNameController = useTextEditingController();
final realmController = useTextEditingController();
final typeValue = useState<int?>(null);
final selectedCategories = useState<List<String>>([]);
final selectedTags = useState<List<String>>([]);
final shuffleValue = useState(false);
final pinnedValue = useState<bool?>(null);
// State variables for PostFilterWidget
final categoryTabController = useTabController(initialLength: 3);
// Single query state
final queryState = useState(const PostListQuery());
final noti = ref.read(
postListProvider(PostListQueryConfig(id: kSearchPostListId)).notifier,
);
useEffect(() {
return () {
@@ -126,186 +48,208 @@ class PostSearchScreen extends HookConsumerWidget {
};
}, []);
void onSearchChanged(String query) {
if (debounceTimer.value?.isActive ?? false) debounceTimer.value!.cancel();
void onSearchChanged(String query, {bool skipDebounce = false}) {
queryState.value = queryState.value.copyWith(queryTerm: query);
if (skipDebounce) {
noti.applyFilter(queryState.value);
return;
}
if (debounceTimer.value?.isActive ?? false) debounceTimer.value!.cancel();
debounceTimer.value = Timer(debounce, () {
ref.read(postSearchProvider.notifier).search(query);
noti.applyFilter(queryState.value);
});
}
void onSearchWithFilters(String query) {
if (debounceTimer.value?.isActive ?? false) debounceTimer.value!.cancel();
debounceTimer.value = Timer(debounce, () {
ref
.read(postSearchProvider.notifier)
.search(
query,
pubName:
pubNameController.text.isNotEmpty
? pubNameController.text
: null,
realm:
realmController.text.isNotEmpty ? realmController.text : null,
type: typeValue.value,
categories:
selectedCategories.value.isNotEmpty
? selectedCategories.value
: null,
tags: selectedTags.value.isNotEmpty ? selectedTags.value : null,
shuffle: shuffleValue.value,
pinned: pinnedValue.value,
);
});
}
void toggleFilters() {
void toggleFilterDisplay() {
showFilters.value = !showFilters.value;
}
void applyFilters() {
onSearchWithFilters(searchController.text);
}
void clearFilters() {
pubNameController.clear();
realmController.clear();
typeValue.value = null;
selectedCategories.value = [];
selectedTags.value = [];
shuffleValue.value = false;
pinnedValue.value = null;
onSearchChanged(searchController.text);
}
Widget buildFilterPanel() {
return Card(
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'filters'.tr(),
style: Theme.of(context).textTheme.titleMedium,
).padding(left: 4),
Row(
children: [
TextButton(
onPressed: applyFilters,
child: Text('apply'.tr()),
),
TextButton(
onPressed: clearFilters,
child: Text('clear'.tr()),
),
],
),
],
),
SizedBox(height: 16),
TextField(
controller: pubNameController,
decoration: InputDecoration(
labelText: 'pubName'.tr(),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(12)),
),
),
onChanged:
(value) => onSearchWithFilters(searchController.text),
),
SizedBox(height: 8),
TextField(
controller: realmController,
decoration: InputDecoration(
labelText: 'realm'.tr(),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(12)),
),
),
onChanged:
(value) => onSearchWithFilters(searchController.text),
),
SizedBox(height: 8),
Row(
children: [
Checkbox(
value: shuffleValue.value,
onChanged: (value) {
shuffleValue.value = value ?? false;
onSearchWithFilters(searchController.text);
return PostFilterWidget(
categoryTabController: categoryTabController,
initialQuery: queryState.value,
onQueryChanged: (newQuery) {
queryState.value = newQuery;
noti.applyFilter(newQuery);
},
),
Text('shuffle'.tr()),
],
),
Row(
children: [
Checkbox(
value: pinnedValue.value ?? false,
onChanged: (value) {
pinnedValue.value = value;
onSearchWithFilters(searchController.text);
},
),
Text('pinned'.tr()),
],
),
],
),
),
hideSearch: true,
);
}
return AppScaffold(
isNoBackground: false,
appBar: AppBar(
title: Row(
children: [
Expanded(
child: TextField(
controller: searchController,
decoration: InputDecoration(
hintText: 'search'.tr(),
border: InputBorder.none,
hintStyle: TextStyle(
color: Theme.of(context).appBarTheme.foregroundColor,
),
),
style: TextStyle(
color: Theme.of(context).appBarTheme.foregroundColor,
),
onChanged: onSearchChanged,
onSubmitted: (value) {
onSearchWithFilters(value);
},
autofocus: true,
),
),
title: Text('searchPosts'.tr()),
actions: [
if (!isWideScreen(context))
IconButton(
icon: Icon(
showFilters.value
? Icons.filter_alt
: Icons.filter_alt_outlined,
),
onPressed: toggleFilters,
onPressed: toggleFilterDisplay,
tooltip: 'toggleFilters'.tr(),
),
],
),
),
body: Consumer(
builder: (context, ref, child) {
final searchState = ref.watch(postSearchProvider);
final searchState = ref.watch(
postListProvider(PostListQueryConfig(id: kSearchPostListId)),
);
return CustomScrollView(
return isWideScreen(context)
? Row(
children: [
Flexible(
flex: 4,
child: ExtendedRefreshIndicator(
onRefresh: noti.refresh,
child: CustomScrollView(
slivers: [
SliverGap(16),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
),
child: SearchBar(
elevation: WidgetStateProperty.all(4),
controller: searchController,
hintText: 'search'.tr(),
leading: const Icon(Icons.search),
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(horizontal: 24),
),
onChanged: onSearchChanged,
onSubmitted: (value) {
onSearchChanged(value, skipDebounce: true);
},
),
),
),
const SliverGap(12),
PaginationList(
provider: postListProvider(
PostListQueryConfig(id: kSearchPostListId),
),
notifier: postListProvider(
PostListQueryConfig(id: kSearchPostListId),
).notifier,
isSliver: true,
isRefreshable: false,
footerSkeletonChild: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
),
child: const PostItemSkeleton(),
),
itemBuilder: (context, index, post) {
return Card(
margin: EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
child: PostActionableItem(
item: post,
borderRadius: 8,
),
);
},
),
if (searchState.value?.isEmpty == true &&
searchController.text.isNotEmpty &&
!searchState.isLoading)
SliverFillRemaining(
child: Center(
child: Text('noResultsFound'.tr()),
),
),
SliverGap(
MediaQuery.of(context).padding.bottom + 16,
),
],
).padding(left: 8),
),
),
Flexible(
flex: 3,
child: Align(
alignment: Alignment.topLeft,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Gap(16),
Card(
margin: EdgeInsets.symmetric(horizontal: 8),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
child: Row(
children: [
const Icon(
Symbols.tune,
).padding(horizontal: 8),
Expanded(
child: Text(
'filters'.tr(),
style: Theme.of(
context,
).textTheme.bodyLarge,
),
),
IconButton(
icon: Icon(
Symbols.filter_alt,
fill: showFilters.value ? 1 : null,
),
onPressed: toggleFilterDisplay,
tooltip: 'toggleFilters'.tr(),
),
const Gap(4),
],
),
),
),
const Gap(8),
if (showFilters.value) buildFilterPanel(),
],
),
),
),
),
],
)
: CustomScrollView(
slivers: [
const SliverGap(4),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
child: SearchBar(
elevation: WidgetStateProperty.all(4),
controller: searchController,
hintText: 'search'.tr(),
leading: const Icon(Icons.search),
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(horizontal: 24),
),
onChanged: onSearchChanged,
onSubmitted: (value) {
onSearchChanged(value, skipDebounce: true);
},
),
),
),
if (showFilters.value)
SliverToBoxAdapter(
child: Center(
@@ -315,13 +259,19 @@ class PostSearchScreen extends HookConsumerWidget {
),
),
),
// Use PaginationList with isSliver=true
PaginationList(
provider: postSearchProvider,
notifier: postSearchProvider.notifier,
provider: postListProvider(
PostListQueryConfig(id: kSearchPostListId),
),
notifier: postListProvider(
PostListQueryConfig(id: kSearchPostListId),
).notifier,
isSliver: true,
isRefreshable:
false, // CustomScrollView handles refreshing usually, but here we don't have PullToRefresh
isRefreshable: false,
footerSkeletonChild: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: const PostItemSkeleton(),
),
itemBuilder: (context, index, post) {
return Center(
child: ConstrainedBox(
@@ -331,7 +281,10 @@ class PostSearchScreen extends HookConsumerWidget {
horizontal: 8,
vertical: 4,
),
child: PostActionableItem(item: post, borderRadius: 8),
child: PostActionableItem(
item: post,
borderRadius: 8,
),
),
),
);

View File

@@ -11,6 +11,7 @@ import 'package:island/models/account.dart';
import 'package:island/models/heatmap.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/services/color.dart';
import 'package:island/services/responsive.dart';
import 'package:island/widgets/account/account_name.dart';
@@ -22,6 +23,7 @@ import 'package:island/widgets/content/cloud_files.dart';
import 'package:island/widgets/content/markdown.dart';
import 'package:island/widgets/post/post_list.dart';
import 'package:island/widgets/activity_heatmap.dart';
import 'package:island/widgets/posts/post_filter.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:island/services/color_extraction.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -82,8 +84,9 @@ class _PublisherBasisWidget extends StatelessWidget {
size: 12,
color: Theme.of(context).colorScheme.onPrimary,
),
backgroundColor:
Theme.of(context).colorScheme.primary,
backgroundColor: Theme.of(
context,
).colorScheme.primary,
offset: Offset(0, 48),
child: ProfilePictureWidget(
file: data.picture,
@@ -121,8 +124,9 @@ class _PublisherBasisWidget extends StatelessWidget {
size: 16,
color: Theme.of(context).colorScheme.onPrimary,
),
backgroundColor:
Theme.of(context).colorScheme.primary,
backgroundColor: Theme.of(
context,
).colorScheme.primary,
offset: Offset(0, 48),
child: ProfilePictureWidget(
file: data.picture,
@@ -201,10 +205,8 @@ class _PublisherBasisWidget extends StatelessWidget {
),
subStatus
.when(
data:
(status) => FilledButton.icon(
onPressed:
subscribing.value
data: (status) => FilledButton.icon(
onPressed: subscribing.value
? null
: (status.isSubscribed
? unsubscribe
@@ -214,8 +216,7 @@ class _PublisherBasisWidget extends StatelessWidget {
? Symbols.remove_circle
: Symbols.add_circle,
),
label:
Text(
label: Text(
status.isSubscribed
? 'unsubscribe'
: 'subscribe',
@@ -227,8 +228,7 @@ class _PublisherBasisWidget extends StatelessWidget {
),
),
error: (_, _) => const SizedBox(),
loading:
() => const SizedBox(
loading: () => const SizedBox(
height: 36,
child: Center(
child: SizedBox(
@@ -333,9 +333,7 @@ class _PublisherHeatmapWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return heatmap.when(
data:
(data) =>
data != null
data: (data) => data != null
? ActivityHeatmapWidget(
heatmap: data,
forceDense: forceDense,
@@ -347,271 +345,6 @@ class _PublisherHeatmapWidget extends StatelessWidget {
}
}
class _PublisherCategoryTabWidget extends StatelessWidget {
final TabController categoryTabController;
final ValueNotifier<bool?> includeReplies;
final ValueNotifier<bool> mediaOnly;
final ValueNotifier<String?> queryTerm;
final ValueNotifier<String?> order;
final ValueNotifier<bool> orderDesc;
final ValueNotifier<int?> periodStart;
final ValueNotifier<int?> periodEnd;
final ValueNotifier<bool> showAdvancedFilters;
const _PublisherCategoryTabWidget({
required this.categoryTabController,
required this.includeReplies,
required this.mediaOnly,
required this.queryTerm,
required this.order,
required this.orderDesc,
required this.periodStart,
required this.periodEnd,
required this.showAdvancedFilters,
});
@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
children: [
TabBar(
controller: categoryTabController,
dividerColor: Colors.transparent,
splashBorderRadius: const BorderRadius.all(Radius.circular(8)),
tabs: [
Tab(text: 'all'.tr()),
Tab(text: 'postTypePost'.tr()),
Tab(text: 'postArticle'.tr()),
],
),
const Divider(height: 1),
Column(
children: [
Row(
children: [
Expanded(
child: CheckboxListTile(
title: Text('reply'.tr()),
value: includeReplies.value,
tristate: true,
onChanged: (value) {
// Cycle through: null -> false -> true -> null
if (includeReplies.value == null) {
includeReplies.value = false;
} else if (includeReplies.value == false) {
includeReplies.value = true;
} else {
includeReplies.value = null;
}
},
dense: true,
controlAffinity: ListTileControlAffinity.leading,
secondary: const Icon(Symbols.reply),
),
),
Expanded(
child: CheckboxListTile(
title: Text('attachments'.tr()),
value: mediaOnly.value,
onChanged: (value) {
if (value != null) {
mediaOnly.value = value;
}
},
dense: true,
controlAffinity: ListTileControlAffinity.leading,
secondary: const Icon(Symbols.attachment),
),
),
],
),
CheckboxListTile(
title: Text('descendingOrder'.tr()),
value: orderDesc.value,
onChanged: (value) {
if (value != null) {
orderDesc.value = value;
}
},
dense: true,
controlAffinity: ListTileControlAffinity.leading,
secondary: const Icon(Symbols.sort),
),
],
),
const Divider(height: 1),
ListTile(
title: Text('advancedFilters'.tr()),
leading: const Icon(Symbols.filter_list),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(const Radius.circular(8)),
),
trailing: Icon(
showAdvancedFilters.value
? Symbols.expand_less
: Symbols.expand_more,
),
onTap: () {
showAdvancedFilters.value = !showAdvancedFilters.value;
},
),
if (showAdvancedFilters.value) ...[
const Divider(height: 1),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
decoration: InputDecoration(
labelText: 'search'.tr(),
hintText: 'searchPosts'.tr(),
prefixIcon: const Icon(Symbols.search),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
),
onChanged: (value) {
queryTerm.value = value.isEmpty ? null : value;
},
),
const Gap(12),
DropdownButtonFormField<String>(
decoration: InputDecoration(
labelText: 'sortBy'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
),
value: order.value,
items: [
DropdownMenuItem(value: 'date', child: Text('date'.tr())),
DropdownMenuItem(
value: 'popularity',
child: Text('popularity'.tr()),
),
],
onChanged: (value) {
order.value = value;
},
),
const Gap(12),
Row(
children: [
Expanded(
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(
labelText: 'fromDate'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
suffixIcon: const Icon(Symbols.calendar_today),
),
child: Text(
periodStart.value != null
? DateTime.fromMillisecondsSinceEpoch(
periodStart.value! * 1000,
).toString().split(' ')[0]
: 'selectDate'.tr(),
),
),
),
),
const Gap(8),
Expanded(
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(
labelText: 'toDate'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
suffixIcon: const Icon(Symbols.calendar_today),
),
child: Text(
periodEnd.value != null
? DateTime.fromMillisecondsSinceEpoch(
periodEnd.value! * 1000,
).toString().split(' ')[0]
: 'selectDate'.tr(),
),
),
),
),
],
),
],
),
),
],
],
),
);
}
}
@riverpod
Future<SnPublisher> publisher(Ref ref, String uname) async {
final apiClient = ref.watch(apiClientProvider);
@@ -683,24 +416,22 @@ class PublisherProfileScreen extends HookConsumerWidget {
);
final categoryTabController = useTabController(initialLength: 3);
final categoryTab = useState(0);
categoryTabController.addListener(() {
categoryTab.value = categoryTabController.index;
});
final includeReplies = useState<bool?>(null);
final mediaOnly = useState(false);
final queryTerm = useState<String?>(null);
final order = useState<String?>('date'); // 'popularity' or 'date'
final orderDesc = useState(
true,
); // true for descending, false for ascending
final periodStart = useState<int?>(null);
final periodEnd = useState<int?>(null);
final showAdvancedFilters = useState(false);
final queryState = useState(PostListQuery(pubName: name));
final subscribing = useState(false);
final isPinnedExpanded = useState(true);
useEffect(() {
final index = switch (queryState.value.type) {
0 => 1,
1 => 2,
_ => 0,
};
categoryTabController.index = index;
return null;
}, []);
Future<void> subscribe() async {
final apiClient = ref.watch(apiClientProvider);
subscribing.value = true;
@@ -739,11 +470,9 @@ class PublisherProfileScreen extends HookConsumerWidget {
);
return publisher.when(
data:
(data) => AppScaffold(
data: (data) => AppScaffold(
isNoBackground: false,
appBar:
isWideScreen(context)
appBar: isWideScreen(context)
? AppBar(
foregroundColor: appbarColor.value,
leading: PageBackButton(
@@ -761,8 +490,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
),
)
: null,
body:
isWideScreen(context)
body: isWideScreen(context)
? Row(
children: [
Flexible(
@@ -789,51 +517,31 @@ class PublisherProfileScreen extends HookConsumerWidget {
? Symbols.expand_less
: Symbols.expand_more,
),
onTap:
() =>
isPinnedExpanded.value =
onTap: () => isPinnedExpanded.value =
!isPinnedExpanded.value,
),
),
),
...[
if (isPinnedExpanded.value)
SliverPostList(pubName: name, pinned: true),
SliverPostList(
query: PostListQuery(pubName: name, pinned: true),
queryKey: 'publisher-$name-pinned',
),
],
SliverToBoxAdapter(
child: _PublisherCategoryTabWidget(
child: PostFilterWidget(
categoryTabController: categoryTabController,
includeReplies: includeReplies,
mediaOnly: mediaOnly,
queryTerm: queryTerm,
order: order,
orderDesc: orderDesc,
periodStart: periodStart,
periodEnd: periodEnd,
showAdvancedFilters: showAdvancedFilters,
initialQuery: queryState.value,
onQueryChanged: (newQuery) =>
queryState.value = newQuery,
),
),
SliverPostList(
key: ValueKey(
'${categoryTab.value}-${includeReplies.value}-${mediaOnly.value}-${queryTerm.value}-${order.value}-${orderDesc.value}-${periodStart.value}-${periodEnd.value}',
),
pubName: name,
pinned: false,
type:
categoryTab.value == 1
? 0
: (categoryTab.value == 2 ? 1 : null),
includeReplies: includeReplies.value,
mediaOnly: mediaOnly.value,
queryTerm: queryTerm.value,
order: order.value,
orderDesc: orderDesc.value,
periodStart: periodStart.value,
periodEnd: periodEnd.value,
),
SliverGap(
MediaQuery.of(context).padding.bottom + 16,
query: queryState.value,
queryKey: 'publisher-$name',
),
SliverGap(MediaQuery.of(context).padding.bottom + 16),
],
).padding(left: 8),
),
@@ -852,10 +560,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
subscribe: subscribe,
unsubscribe: unsubscribe,
).padding(horizontal: 4, top: 20),
_PublisherBadgesWidget(
data: data,
badges: badges,
),
_PublisherBadgesWidget(data: data, badges: badges),
_PublisherVerificationWidget(data: data),
_PublisherBioWidget(data: data),
_PublisherHeatmapWidget(
@@ -882,14 +587,10 @@ class PublisherProfileScreen extends HookConsumerWidget {
flexibleSpace: Stack(
children: [
Positioned.fill(
child:
data.background?.id != null
? CloudImageWidget(
file: data.background,
)
child: data.background?.id != null
? CloudImageWidget(file: data.background)
: Container(
color:
Theme.of(
color: Theme.of(
context,
).appBarTheme.backgroundColor,
),
@@ -900,9 +601,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
style: TextStyle(
color:
appbarColor.value ??
Theme.of(
context,
).appBarTheme.foregroundColor,
Theme.of(context).appBarTheme.foregroundColor,
shadows: [appbarShadow],
),
),
@@ -922,17 +621,12 @@ class PublisherProfileScreen extends HookConsumerWidget {
).padding(horizontal: 4, top: 8),
),
SliverToBoxAdapter(
child: _PublisherBadgesWidget(
data: data,
badges: badges,
),
child: _PublisherBadgesWidget(data: data, badges: badges),
),
SliverToBoxAdapter(
child: _PublisherVerificationWidget(data: data),
),
SliverToBoxAdapter(
child: _PublisherBioWidget(data: data),
),
SliverToBoxAdapter(child: _PublisherBioWidget(data: data)),
SliverToBoxAdapter(
child: _PublisherHeatmapWidget(
heatmap: heatmap,
@@ -940,10 +634,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
),
SliverToBoxAdapter(
child: Card(
margin: EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: ListTile(
title: Text('pinnedPosts'.tr()),
trailing: Icon(
@@ -951,60 +642,40 @@ class PublisherProfileScreen extends HookConsumerWidget {
? Symbols.expand_less
: Symbols.expand_more,
),
onTap:
() =>
isPinnedExpanded.value =
!isPinnedExpanded.value,
onTap: () =>
isPinnedExpanded.value = !isPinnedExpanded.value,
),
),
),
...[
if (isPinnedExpanded.value)
SliverPostList(pubName: name, pinned: true),
SliverPostList(
query: PostListQuery(pubName: name, pinned: true),
queryKey: 'publisher-$name-pinned',
),
],
SliverToBoxAdapter(
child: _PublisherCategoryTabWidget(
child: PostFilterWidget(
categoryTabController: categoryTabController,
includeReplies: includeReplies,
mediaOnly: mediaOnly,
queryTerm: queryTerm,
order: order,
orderDesc: orderDesc,
periodStart: periodStart,
periodEnd: periodEnd,
showAdvancedFilters: showAdvancedFilters,
initialQuery: queryState.value,
onQueryChanged: (newQuery) => queryState.value = newQuery,
),
),
SliverPostList(
key: ValueKey(
'${categoryTab.value}-${includeReplies.value}-${mediaOnly.value}-${queryTerm.value}-${order.value}-${orderDesc.value}-${periodStart.value}-${periodEnd.value}',
),
pubName: name,
pinned: false,
type:
categoryTab.value == 1
? 0
: (categoryTab.value == 2 ? 1 : null),
includeReplies: includeReplies.value,
mediaOnly: mediaOnly.value,
queryTerm: queryTerm.value,
order: order.value,
orderDesc: orderDesc.value,
periodStart: periodStart.value,
periodEnd: periodEnd.value,
key: ValueKey(queryState.value),
query: queryState.value,
queryKey: 'publisher-$name',
),
SliverGap(MediaQuery.of(context).padding.bottom + 16),
],
),
),
error:
(error, stackTrace) => AppScaffold(
error: (error, stackTrace) => AppScaffold(
isNoBackground: false,
appBar: AppBar(leading: const PageBackButton()),
body: Center(child: Text(error.toString())),
),
loading:
() => AppScaffold(
loading: () => AppScaffold(
isNoBackground: false,
appBar: AppBar(leading: const PageBackButton()),
body: Center(child: CircularProgressIndicator()),

View File

@@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/screens/chat/chat.dart';
import 'package:flutter/material.dart';
import 'package:island/models/chat.dart';
@@ -171,11 +172,9 @@ class RealmDetailScreen extends HookConsumerWidget {
return AppScaffold(
isNoBackground: false,
appBar:
isWideScreen(context)
appBar: isWideScreen(context)
? realmState.when(
data:
(realm) => AppBar(
data: (realm) => AppBar(
foregroundColor: appbarColor.value,
leading: PageBackButton(
color: appbarColor.value,
@@ -184,14 +183,10 @@ class RealmDetailScreen extends HookConsumerWidget {
flexibleSpace: Stack(
children: [
Positioned.fill(
child:
realm!.background?.id != null
? CloudImageWidget(
fileId: realm.background!.id,
)
child: realm!.background?.id != null
? CloudImageWidget(fileId: realm.background!.id)
: Container(
color:
Theme.of(
color: Theme.of(
context,
).appBarTheme.backgroundColor,
),
@@ -202,9 +197,7 @@ class RealmDetailScreen extends HookConsumerWidget {
style: TextStyle(
color:
appbarColor.value ??
Theme.of(
context,
).appBarTheme.foregroundColor,
Theme.of(context).appBarTheme.foregroundColor,
shadows: [iconShadow],
),
),
@@ -219,16 +212,12 @@ class RealmDetailScreen extends HookConsumerWidget {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder:
(context) =>
builder: (context) =>
_RealmMemberListSheet(realmSlug: slug),
);
},
),
_RealmActionMenu(
realmSlug: slug,
iconShadow: iconShadow,
),
_RealmActionMenu(realmSlug: slug, iconShadow: iconShadow),
const Gap(8),
],
),
@@ -239,17 +228,19 @@ class RealmDetailScreen extends HookConsumerWidget {
body: realmState.when(
loading: () => const Center(child: CircularProgressIndicator()),
error: (error, _) => Center(child: Text('Error: $error')),
data:
(realm) =>
isWideScreen(context)
data: (realm) => isWideScreen(context)
? Row(
children: [
Flexible(
flex: 3,
child: CustomScrollView(
slivers: [
SliverPostList(realm: slug, pinned: true),
SliverPostList(realm: slug, pinned: false),
SliverPostList(
query: PostListQuery(realm: slug, pinned: true),
),
SliverPostList(
query: PostListQuery(realm: slug, pinned: false),
),
],
),
),
@@ -260,14 +251,11 @@ class RealmDetailScreen extends HookConsumerWidget {
realmIdentity.when(
loading: () => const SizedBox.shrink(),
error: (_, _) => const SizedBox.shrink(),
data:
(identity) => Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
data: (identity) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
realmDescriptionWidget(realm!),
if (identity == null &&
realm.isCommunity)
if (identity == null && realm.isCommunity)
realmActionWidget(realm)
else
const SizedBox.shrink(),
@@ -293,14 +281,10 @@ class RealmDetailScreen extends HookConsumerWidget {
flexibleSpace: Stack(
children: [
Positioned.fill(
child:
realm!.background?.id != null
? CloudImageWidget(
fileId: realm.background!.id,
)
child: realm!.background?.id != null
? CloudImageWidget(fileId: realm.background!.id)
: Container(
color:
Theme.of(
color: Theme.of(
context,
).appBarTheme.backgroundColor,
),
@@ -311,9 +295,7 @@ class RealmDetailScreen extends HookConsumerWidget {
style: TextStyle(
color:
appbarColor.value ??
Theme.of(
context,
).appBarTheme.foregroundColor,
Theme.of(context).appBarTheme.foregroundColor,
shadows: [iconShadow],
),
),
@@ -329,17 +311,12 @@ class RealmDetailScreen extends HookConsumerWidget {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder:
(context) => _RealmMemberListSheet(
realmSlug: slug,
),
builder: (context) =>
_RealmMemberListSheet(realmSlug: slug),
);
},
),
_RealmActionMenu(
realmSlug: slug,
iconShadow: iconShadow,
),
_RealmActionMenu(realmSlug: slug, iconShadow: iconShadow),
const Gap(8),
],
),
@@ -348,10 +325,8 @@ class RealmDetailScreen extends HookConsumerWidget {
child: realmIdentity.when(
loading: () => const SizedBox.shrink(),
error: (_, _) => const SizedBox.shrink(),
data:
(identity) => Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
data: (identity) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
realmDescriptionWidget(realm),
if (identity == null && realm.isCommunity)
@@ -362,11 +337,13 @@ class RealmDetailScreen extends HookConsumerWidget {
),
),
),
SliverToBoxAdapter(
child: realmChatRoomListWidget(realm),
SliverToBoxAdapter(child: realmChatRoomListWidget(realm)),
SliverPostList(
query: PostListQuery(realm: slug, pinned: true),
),
SliverPostList(
query: PostListQuery(realm: slug, pinned: false),
),
SliverPostList(realm: slug, pinned: true),
SliverPostList(realm: slug, pinned: false),
],
),
),
@@ -391,8 +368,7 @@ class _RealmActionMenu extends HookConsumerWidget {
return PopupMenuButton(
icon: Icon(Icons.more_vert, shadows: [iconShadow]),
itemBuilder:
(context) => [
itemBuilder: (context) => [
if (isModerator)
PopupMenuItem(
onTap: () {
@@ -413,9 +389,7 @@ class _RealmActionMenu extends HookConsumerWidget {
),
),
realmIdentity.when(
data:
(identity) =>
(identity?.role ?? 0) >= 100
data: (identity) => (identity?.role ?? 0) >= 100
? PopupMenuItem(
child: Row(
children: [
@@ -478,13 +452,11 @@ class _RealmActionMenu extends HookConsumerWidget {
});
},
),
loading:
() => const PopupMenuItem(
loading: () => const PopupMenuItem(
enabled: false,
child: Center(child: CircularProgressIndicator()),
),
error:
(_, _) => PopupMenuItem(
error: (_, _) => PopupMenuItem(
child: Row(
children: [
Icon(
@@ -494,22 +466,17 @@ class _RealmActionMenu extends HookConsumerWidget {
const Gap(12),
Text(
'leaveRealm',
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
style: TextStyle(color: Theme.of(context).colorScheme.error),
).tr(),
],
),
onTap: () {
showConfirmAlert(
'leaveRealmHint'.tr(),
'leaveRealm'.tr(),
).then((confirm) async {
showConfirmAlert('leaveRealmHint'.tr(), 'leaveRealm'.tr()).then((
confirm,
) async {
if (confirm) {
final client = ref.watch(apiClientProvider);
await client.delete(
'/pass/realms/$realmSlug/members/me',
);
await client.delete('/pass/realms/$realmSlug/members/me');
ref.invalidate(realmsJoinedProvider);
if (context.mounted) {
context.pop(true);
@@ -684,8 +651,7 @@ class _RealmMemberListSheet extends HookConsumerWidget {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder:
(context) => _RealmMemberRoleSheet(
builder: (context) => _RealmMemberRoleSheet(
realmSlug: realmSlug,
member: member,
),
@@ -809,12 +775,8 @@ class _RealmMemberRoleSheet extends HookConsumerWidget {
onSelected: (int selection) {
roleController.text = selection.toString();
},
fieldViewBuilder: (
context,
controller,
focusNode,
onFieldSubmitted,
) {
fieldViewBuilder:
(context, controller, focusNode, onFieldSubmitted) {
return TextField(
controller: controller,
focusNode: focusNode,

View File

@@ -21,7 +21,7 @@ import 'package:material_symbols_icons/symbols.dart';
import 'package:path_provider/path_provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/file_pool.dart';
import 'package:island/pods/drive/file_pool.dart';
class SettingsScreen extends HookConsumerWidget {
const SettingsScreen({super.key});
@@ -249,8 +249,7 @@ class SettingsScreen extends HookConsumerWidget {
showDialog(
context: context,
builder: (context) {
Color selectedColor =
settings.appColorScheme != null
Color selectedColor = settings.appColorScheme != null
? Color(settings.appColorScheme!)
: Colors.indigo;
@@ -292,8 +291,7 @@ class SettingsScreen extends HookConsumerWidget {
height: 24,
margin: EdgeInsets.symmetric(horizontal: 2, vertical: 8),
decoration: BoxDecoration(
color:
settings.appColorScheme != null
color: settings.appColorScheme != null
? Color(settings.appColorScheme!)
: Colors.indigo,
shape: BoxShape.circle,
@@ -310,8 +308,7 @@ class SettingsScreen extends HookConsumerWidget {
// Custom colors section
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
child:
Text(
child: Text(
'Custom Colors',
style: Theme.of(context).textTheme.titleMedium,
).bold(),
@@ -319,8 +316,7 @@ class SettingsScreen extends HookConsumerWidget {
// Primary color
_ColorPickerTile(
title: 'Primary',
color:
settings.customColors?.primary != null
color: settings.customColors?.primary != null
? Color(settings.customColors!.primary!)
: null,
onColorChanged: (color) {
@@ -333,8 +329,7 @@ class SettingsScreen extends HookConsumerWidget {
// Secondary
_ColorPickerTile(
title: 'Secondary',
color:
settings.customColors?.secondary != null
color: settings.customColors?.secondary != null
? Color(settings.customColors!.secondary!)
: null,
onColorChanged: (color) {
@@ -347,8 +342,7 @@ class SettingsScreen extends HookConsumerWidget {
// Tertiary
_ColorPickerTile(
title: 'Tertiary',
color:
settings.customColors?.tertiary != null
color: settings.customColors?.tertiary != null
? Color(settings.customColors!.tertiary!)
: null,
onColorChanged: (color) {
@@ -361,8 +355,7 @@ class SettingsScreen extends HookConsumerWidget {
// Surface
_ColorPickerTile(
title: 'Surface',
color:
settings.customColors?.surface != null
color: settings.customColors?.surface != null
? Color(settings.customColors!.surface!)
: null,
onColorChanged: (color) {
@@ -375,8 +368,7 @@ class SettingsScreen extends HookConsumerWidget {
// Background
_ColorPickerTile(
title: 'Background',
color:
settings.customColors?.background != null
color: settings.customColors?.background != null
? Color(settings.customColors!.background!)
: null,
onColorChanged: (color) {
@@ -391,8 +383,7 @@ class SettingsScreen extends HookConsumerWidget {
// Error
_ColorPickerTile(
title: 'Error',
color:
settings.customColors?.error != null
color: settings.customColors?.error != null
? Color(settings.customColors!.error!)
: null,
onColorChanged: (color) {
@@ -509,8 +500,9 @@ class SettingsScreen extends HookConsumerWidget {
// Background image enabled
if (!kIsWeb && docBasepath.value != null)
FutureBuilder<bool>(
future:
File('${docBasepath.value}/$kAppBackgroundImagePath').exists(),
future: File(
'${docBasepath.value}/$kAppBackgroundImagePath',
).exists(),
builder: (context, snapshot) {
if (!snapshot.hasData || !snapshot.data!) {
return const SizedBox.shrink();
@@ -536,8 +528,9 @@ class SettingsScreen extends HookConsumerWidget {
// Clear background image option
if (!kIsWeb && docBasepath.value != null)
FutureBuilder<bool>(
future:
File('${docBasepath.value}/$kAppBackgroundImagePath').exists(),
future: File(
'${docBasepath.value}/$kAppBackgroundImagePath',
).exists(),
builder: (context, snapshot) {
if (!snapshot.hasData || !snapshot.data!) {
return const SizedBox.shrink();
@@ -565,8 +558,9 @@ class SettingsScreen extends HookConsumerWidget {
if (!kIsWeb && docBasepath.value != null)
FutureBuilder(
future:
File('${docBasepath.value}/$kAppBackgroundImagePath').exists(),
future: File(
'${docBasepath.value}/$kAppBackgroundImagePath',
).exists(),
builder: (context, snapshot) {
if (!snapshot.hasData || !snapshot.data!) {
return const SizedBox.shrink();
@@ -674,8 +668,7 @@ class SettingsScreen extends HookConsumerWidget {
trailing: DropdownButtonHideUnderline(
child: DropdownButton2<String>(
isExpanded: true,
items:
validPools.map((p) {
items: validPools.map((p) {
return DropdownMenuItem<String>(
value: p.id,
child: Tooltip(
@@ -705,14 +698,12 @@ class SettingsScreen extends HookConsumerWidget {
),
);
},
loading:
() => const ListTile(
loading: () => const ListTile(
minLeadingWidth: 48,
title: Text('Loading pools...'),
leading: CircularProgressIndicator(),
),
error:
(err, st) => ListTile(
error: (err, st) => ListTile(
minLeadingWidth: 48,
title: Text('settingsDefaultPool').tr(),
subtitle: Text('Error: $err'),
@@ -767,8 +758,7 @@ class SettingsScreen extends HookConsumerWidget {
ListTile(
minLeadingWidth: 48,
title: Text('settingsEnterToSend').tr(),
subtitle:
isDesktop
subtitle: isDesktop
? Text('settingsEnterToSendDesktopHint').tr().fontSize(12)
: null,
contentPadding: const EdgeInsets.only(left: 24, right: 17),
@@ -823,8 +813,7 @@ class SettingsScreen extends HookConsumerWidget {
];
// Desktop-specific settings
final desktopSettings =
!isDesktop
final desktopSettings = !isDesktop
? <Widget>[]
: [
ListTile(

View File

@@ -127,13 +127,9 @@ class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
// Stickers grid
Expanded(
child: packContent.when(
data:
(stickers) => RefreshIndicator(
onRefresh:
() => ref.refresh(
marketplaceStickerPackContentProvider(
packId: id,
).future,
data: (stickers) => RefreshIndicator(
onRefresh: () => ref.refresh(
marketplaceStickerPackContentProvider(packId: id).future,
),
child: GridView.builder(
padding: const EdgeInsets.symmetric(
@@ -157,8 +153,7 @@ class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
),
child: Container(
decoration: BoxDecoration(
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.surfaceContainer,
borderRadius: const BorderRadius.all(
@@ -178,9 +173,7 @@ class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
},
),
),
error:
(err, _) =>
Text(
error: (err, _) => Text(
'Error: $err',
).textAlignment(TextAlign.center).center(),
loading: () => const CircularProgressIndicator().center(),
@@ -189,27 +182,21 @@ class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8),
child: owned.when(
data:
(isOwned) => FilledButton.icon(
onPressed:
isOwned
data: (isOwned) => FilledButton.icon(
onPressed: isOwned
? removePackFromMyCollection
: addPackToMyCollection,
icon: Icon(
isOwned ? Symbols.remove_circle : Symbols.add_circle,
),
label: Text(
isOwned ? 'removePack'.tr() : 'addPack'.tr(),
label: Text(isOwned ? 'removePack'.tr() : 'addPack'.tr()),
),
),
loading:
() => const SizedBox(
loading: () => const SizedBox(
height: 32,
width: 32,
child: CircularProgressIndicator(strokeWidth: 2),
),
error:
(_, _) => OutlinedButton.icon(
).center(),
error: (_, _) => OutlinedButton.icon(
onPressed: addPackToMyCollection,
icon: const Icon(Symbols.add_circle),
label: Text('addPack').tr(),
@@ -220,8 +207,7 @@ class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
],
);
},
error:
(err, _) =>
error: (err, _) =>
Text('Error: $err').textAlignment(TextAlign.center).center(),
loading: () => const CircularProgressIndicator().center(),
),

View File

@@ -28,9 +28,8 @@ sealed class MarketplaceStickerQuery with _$MarketplaceStickerQuery {
}) = _MarketplaceStickerQuery;
}
final marketplaceStickerPacksNotifierProvider = AsyncNotifierProvider(
MarketplaceStickerPacksNotifier.new,
);
final marketplaceStickerPacksNotifierProvider =
AsyncNotifierProvider.autoDispose(MarketplaceStickerPacksNotifier.new);
class MarketplaceStickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
with
@@ -60,8 +59,7 @@ class MarketplaceStickerPacksNotifier extends AsyncNotifier<List<SnStickerPack>>
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final stickers =
response.data
final stickers = response.data
.map((e) => SnStickerPack.fromJson(e))
.cast<SnStickerPack>()
.toList();
@@ -112,12 +110,10 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
onPressed: () {
query.value = query.value.copyWith(byUsage: !query.value.byUsage);
},
icon:
query.value.byUsage
icon: query.value.byUsage
? const Icon(Symbols.local_fire_department)
: const Icon(Symbols.access_time),
tooltip:
query.value.byUsage
tooltip: query.value.byUsage
? 'orderByPopularity'.tr()
: 'orderByReleaseDate'.tr(),
),
@@ -137,8 +133,8 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(horizontal: 24),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
trailing: [
if (query.value.query != null && query.value.query!.isNotEmpty)
IconButton(
@@ -171,14 +167,13 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
padding: EdgeInsets.only(top: 8),
provider: marketplaceStickerPacksNotifierProvider,
notifier: marketplaceStickerPacksNotifierProvider.notifier,
itemBuilder:
(context, idx, pack) => Card(
itemBuilder: (context, idx, pack) => Card(
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
child: Column(
children: [
if (pack.stickers.isNotEmpty)
Container(
color:
Theme.of(context).colorScheme.secondaryContainer,
color: Theme.of(context).colorScheme.secondaryContainer,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
@@ -200,11 +195,8 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
maxWidth: 80,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
8,
),
color:
Theme.of(
borderRadius: BorderRadius.circular(8),
color: Theme.of(
context,
).colorScheme.tertiaryContainer,
),
@@ -234,14 +226,12 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
borderRadius: BorderRadius.circular(
8,
),
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.tertiaryContainer,
),
child: CloudImageWidget(
file:
pack.stickers[index + 4].image,
file: pack.stickers[index + 4].image,
),
).clipRRect(all: 8),
),
@@ -254,8 +244,7 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
ListTile(
leading: Container(
decoration: BoxDecoration(
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.tertiaryContainer,
borderRadius: const BorderRadius.all(
@@ -263,7 +252,7 @@ class MarketplaceStickersScreen extends HookConsumerWidget {
),
),
child: CloudImageWidget(
file: pack.icon ?? pack.stickers.first.image,
file: pack.icon ?? pack.stickers.firstOrNull?.image,
),
).width(40).height(40).clipRRect(all: 8),
shape: RoundedRectangleBorder(

View File

@@ -112,8 +112,8 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
),
),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const Gap(16),
@@ -137,8 +137,7 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
),
),
),
items:
kCurrencyIconData.keys.map((currency) {
items: kCurrencyIconData.keys.map((currency) {
return DropdownMenuItem(
value: currency,
child: Row(
@@ -178,8 +177,7 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
labelText: 'enterNumberOfSplits'.tr(),
hintText:
selectedRecipients.isNotEmpty
hintText: selectedRecipients.isNotEmpty
? selectedRecipients.length.toString()
: '1',
border: OutlineInputBorder(
@@ -188,12 +186,12 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
),
),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
onChanged: (value) {
if (value.isEmpty && selectedRecipients.isNotEmpty) {
splitsController.text =
selectedRecipients.length.toString();
splitsController.text = selectedRecipients.length
.toString();
}
},
),
@@ -261,8 +259,7 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
).colorScheme.outline.withOpacity(0.2),
),
),
child:
selectedRecipients.isNotEmpty
child: selectedRecipients.isNotEmpty
? Column(
children: [
...selectedRecipients.map((recipient) {
@@ -283,26 +280,23 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
),
subtitle: Text(
'selectedRecipient'.tr(),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
trailing: IconButton(
onPressed:
() => setState(
() => selectedRecipients.remove(
recipient,
),
onPressed: () => setState(
() =>
selectedRecipients.remove(recipient),
),
icon: Icon(
Icons.clear,
color:
Theme.of(context).colorScheme.error,
color: Theme.of(
context,
).colorScheme.error,
),
tooltip: 'Remove recipient',
),
@@ -316,19 +310,16 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
Icon(
Icons.person_add_outlined,
size: 48,
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
const Gap(8),
Text(
'noRecipientsSelected'.tr(),
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
color:
Theme.of(
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
@@ -336,11 +327,9 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
const Gap(4),
Text(
'selectRecipientsToSendFund'.tr(),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
@@ -399,8 +388,8 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
),
),
maxLines: 3,
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
],
),
@@ -441,13 +430,10 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
isScrollControlled: true,
backgroundColor: Colors.transparent,
useSafeArea: true,
builder:
(context) => Container(
builder: (context) => Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(16),
),
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Padding(
padding: EdgeInsets.only(
@@ -473,10 +459,10 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
const Gap(24),
OtpTextField(
numberOfFields: 6,
borderColor:
Theme.of(context).colorScheme.outline,
focusedBorderColor:
Theme.of(context).colorScheme.primary,
borderColor: Theme.of(context).colorScheme.outline,
focusedBorderColor: Theme.of(
context,
).colorScheme.primary,
showFieldAsBox: true,
obscureText: true,
keyboardType: TextInputType.number,
@@ -484,9 +470,7 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
fieldHeight: 56,
borderRadius: BorderRadius.circular(8),
borderWidth: 1,
textStyle: Theme.of(context)
.textTheme
.headlineSmall
textStyle: Theme.of(context).textTheme.headlineSmall
?.copyWith(fontWeight: FontWeight.w600),
onSubmit: (pin) {
enteredPin = pin;
@@ -552,8 +536,7 @@ class _CreateFundSheetState extends State<CreateFundSheet> {
'split_type': selectedSplitType,
'amount_of_splits': splits,
'recipient_account_ids': selectedRecipients.map((r) => r.id).toList(),
'message':
messageController.text.trim().isEmpty
'message': messageController.text.trim().isEmpty
? null
: messageController.text.trim(),
'pin_code': '', // Will be filled by PIN verification
@@ -632,8 +615,8 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
),
),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const Gap(16),
@@ -657,8 +640,7 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
),
),
),
items:
kCurrencyIconData.keys.map((currency) {
items: kCurrencyIconData.keys.map((currency) {
return DropdownMenuItem(
value: currency,
child: Row(
@@ -702,8 +684,7 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
).colorScheme.outline.withOpacity(0.2),
),
),
child:
selectedPayee != null
child: selectedPayee != null
? ListTile(
contentPadding: const EdgeInsets.only(
left: 20,
@@ -721,18 +702,16 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
),
subtitle: Text(
'selectedPayee'.tr(),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
),
trailing: IconButton(
onPressed:
() => setState(() => selectedPayee = null),
onPressed: () =>
setState(() => selectedPayee = null),
icon: Icon(
Icons.clear,
color: Theme.of(context).colorScheme.error,
@@ -746,19 +725,16 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
Icon(
Icons.person_add_outlined,
size: 48,
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
const Gap(8),
Text(
'noPayeeSelected'.tr(),
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
color:
Theme.of(
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
@@ -766,11 +742,9 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
const Gap(4),
Text(
'selectPayeeToTransfer'.tr(),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
@@ -824,8 +798,8 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
),
),
maxLines: 3,
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
],
),
@@ -866,13 +840,10 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
isScrollControlled: true,
backgroundColor: Colors.transparent,
useSafeArea: true,
builder:
(context) => Container(
builder: (context) => Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(16),
),
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Padding(
padding: EdgeInsets.only(
@@ -898,10 +869,10 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
const Gap(24),
OtpTextField(
numberOfFields: 6,
borderColor:
Theme.of(context).colorScheme.outline,
focusedBorderColor:
Theme.of(context).colorScheme.primary,
borderColor: Theme.of(context).colorScheme.outline,
focusedBorderColor: Theme.of(
context,
).colorScheme.primary,
showFieldAsBox: true,
obscureText: true,
keyboardType: TextInputType.number,
@@ -909,9 +880,7 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
fieldHeight: 56,
borderRadius: BorderRadius.circular(8),
borderWidth: 1,
textStyle: Theme.of(context)
.textTheme
.headlineSmall
textStyle: Theme.of(context).textTheme.headlineSmall
?.copyWith(fontWeight: FontWeight.w600),
onSubmit: (pin) {
enteredPin = pin;
@@ -974,8 +943,7 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
'amount': amount,
'currency': selectedCurrency,
'payee_account_id': selectedPayee!.id,
'remark':
remarkController.text.trim().isEmpty
'remark': remarkController.text.trim().isEmpty
? null
: remarkController.text.trim(),
};
@@ -991,7 +959,7 @@ class _CreateTransferSheetState extends State<CreateTransferSheet> {
}
}
final transactionListProvider = AsyncNotifierProvider(
final transactionListProvider = AsyncNotifierProvider.autoDispose(
TransactionListNotifier.new,
);
@@ -1012,14 +980,17 @@ class TransactionListNotifier extends AsyncNotifier<List<SnTransaction>>
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final List<dynamic> data = response.data;
final transactions =
data.map((json) => SnTransaction.fromJson(json)).toList();
final transactions = data
.map((json) => SnTransaction.fromJson(json))
.toList();
return transactions;
}
}
final walletFundsProvider = AsyncNotifierProvider(WalletFundsNotifier.new);
final walletFundsProvider = AsyncNotifierProvider.autoDispose(
WalletFundsNotifier.new,
);
class WalletFundsNotifier extends AsyncNotifier<List<SnWalletFund>>
with AsyncPaginationController<SnWalletFund> {
@@ -1034,8 +1005,9 @@ class WalletFundsNotifier extends AsyncNotifier<List<SnWalletFund>>
'/pass/wallets/funds?offset=$offset&take=$pageSize',
);
// Assuming total count header is present or we just check if list is empty
final list =
(response.data as List).map((e) => SnWalletFund.fromJson(e)).toList();
final list = (response.data as List)
.map((e) => SnWalletFund.fromJson(e))
.toList();
if (list.length < pageSize) {
totalCount = fetchedCount + list.length;
}
@@ -1043,7 +1015,7 @@ class WalletFundsNotifier extends AsyncNotifier<List<SnWalletFund>>
}
}
final walletFundRecipientsProvider = AsyncNotifierProvider(
final walletFundRecipientsProvider = AsyncNotifierProvider.autoDispose(
WalletFundRecipientsNotifier.new,
);
@@ -1060,8 +1032,7 @@ class WalletFundRecipientsNotifier
final response = await client.get(
'/pass/wallets/funds/recipients?offset=$offset&take=$_pageSize',
);
final list =
(response.data as List)
final list = (response.data as List)
.map((e) => SnWalletFundRecipient.fromJson(e))
.toList();
@@ -1312,8 +1283,7 @@ class WalletScreen extends HookConsumerWidget {
return allCurrencies.map((currency) {
final existingPocket = pockets.firstWhere(
(p) => p.currency == currency,
orElse:
() => SnWalletPocket(
orElse: () => SnWalletPocket(
id: '',
currency: currency,
amount: 0.0,
@@ -1338,10 +1308,10 @@ class WalletScreen extends HookConsumerWidget {
? Symbols.money_bag
: Symbols.swap_horiz,
),
onPressed:
currentTabIndex.value == 1 ? createFund : createTransfer,
tooltip:
currentTabIndex.value == 1
onPressed: currentTabIndex.value == 1
? createFund
: createTransfer,
tooltip: currentTabIndex.value == 1
? 'createFund'.tr()
: 'createTransfer'.tr(),
),
@@ -1368,8 +1338,7 @@ class WalletScreen extends HookConsumerWidget {
}
return NestedScrollView(
headerSliverBuilder:
(context, innerBoxIsScrolled) => [
headerSliverBuilder: (context, innerBoxIsScrolled) => [
// Wallet Overview
SliverToBoxAdapter(
child: Column(
@@ -1388,11 +1357,8 @@ class WalletScreen extends HookConsumerWidget {
kCurrencyIconData[pocket.currency] ??
Symbols.universal_currency_alt,
),
title:
Text(
getCurrencyTranslationKey(
pocket.currency,
),
title: Text(
getCurrencyTranslationKey(pocket.currency),
).tr(),
subtitle: Text(
'${pocket.amount.toStringAsFixed(2)} ${getCurrencyTranslationKey(pocket.currency, isShort: true).tr()}',
@@ -1438,10 +1404,8 @@ class WalletScreen extends HookConsumerWidget {
context: context,
useRootNavigator: true,
isScrollControlled: true,
builder:
(context) => TransactionDetailSheet(
transaction: transaction,
),
builder: (context) =>
TransactionDetailSheet(transaction: transaction),
);
},
child: ListTile(
@@ -1479,8 +1443,7 @@ class WalletScreen extends HookConsumerWidget {
),
);
},
error:
(error, stackTrace) => ResponseErrorWidget(
error: (error, stackTrace) => ResponseErrorWidget(
error: error,
onRetry: () => ref.invalidate(walletCurrentProvider),
),
@@ -1554,8 +1517,9 @@ class WalletScreen extends HookConsumerWidget {
itemCount: fundList.length,
itemBuilder: (context, index) {
final fund = fundList[index];
final claimedCount =
fund.recipients.where((r) => r.isReceived).length;
final claimedCount = fund.recipients
.where((r) => r.isReceived)
.length;
final totalRecipients = fund.recipients.length;
return Card(
@@ -1724,16 +1688,14 @@ class WalletScreen extends HookConsumerWidget {
),
);
},
loading:
() => Card(
loading: () => Card(
margin: EdgeInsets.zero,
child: const Padding(
padding: EdgeInsets.all(16),
child: Center(child: CircularProgressIndicator()),
),
),
error:
(error, stack) => Card(
error: (error, stack) => Card(
margin: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.all(16),

View File

@@ -7,7 +7,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:island/models/file.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/upload_tasks.dart';
import 'package:island/pods/drive/upload_tasks.dart';
import 'package:mime/mime.dart';
import 'package:native_exif/native_exif.dart';
import 'package:path/path.dart' show extension;
@@ -211,8 +211,9 @@ class FileUploader {
// Use old way for Uint8List
final chunks = <Uint8List>[];
for (int i = 0; i < fileData.length; i += chunkSize) {
final end =
i + chunkSize > fileData.length ? fileData.length : i + chunkSize;
final end = i + chunkSize > fileData.length
? fileData.length
: i + chunkSize;
chunks.add(Uint8List.fromList(fileData.sublist(i, end)));
}

View File

@@ -1 +0,0 @@

View File

@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/file.dart';
import 'package:island/models/file_pool.dart';
import 'package:island/pods/file_pool.dart';
import 'package:island/pods/drive/file_pool.dart';
import 'package:island/widgets/content/attachment_preview.dart';
import 'package:island/widgets/content/sheet.dart';
import 'package:island/widgets/post/compose_shared.dart';
@@ -79,8 +79,7 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
children: [
DropdownButtonFormField<String>(
value: selectedPoolId,
items:
pools.map((pool) {
items: pools.map((pool) {
return DropdownMenuItem<String>(
value: pool.id,
child: Text(pool.name),
@@ -140,8 +139,7 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.errorContainer,
borderRadius: BorderRadius.circular(8),
@@ -155,19 +153,18 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
Icon(
Symbols.warning,
size: 18,
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.error,
),
const Gap(8),
Text(
'uploadConstraints'.tr(),
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
color:
Theme.of(
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: Theme.of(
context,
).colorScheme.error,
fontWeight: FontWeight.w600,
@@ -183,11 +180,11 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
_formatFileSize(maxFileSize),
],
),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.error,
),
@@ -197,11 +194,11 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
const Gap(4),
Text(
'fileTypeNotAccepted'.tr(),
style: Theme.of(
context,
).textTheme.bodySmall?.copyWith(
color:
Theme.of(
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(
color: Theme.of(
context,
).colorScheme.error,
),
@@ -229,8 +226,7 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
),
],
),
style:
Theme.of(
style: Theme.of(
context,
).textTheme.bodyMedium,
).fontSize(13),
@@ -300,8 +296,8 @@ class _AttachmentUploaderSheetState extends State<AttachmentUploaderSheet> {
final maxFileSize = selectedPool.policyConfig?['max_file_size'] as int?;
final fileSizeExceeded = maxFileSize != null && fileSize > maxFileSize;
final acceptTypes =
(selectedPool.policyConfig?['accept_types'] as List?)?.cast<String>();
final acceptTypes = (selectedPool.policyConfig?['accept_types'] as List?)
?.cast<String>();
final mimeType =
attachment.data.mimeType ??
ComposeLogic.getMimeTypeFromFileType(attachment.type);

View File

@@ -9,8 +9,11 @@ import 'package:island/models/file.dart';
import 'package:island/pods/config.dart';
import 'package:island/services/time.dart';
import 'package:island/utils/format.dart';
import 'package:island/widgets/content/profile_decoration.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart';
import 'dart:math' as math;
import 'dart:ui' as ui;
import 'package:island/widgets/data_saving_gate.dart';
import 'file_viewer_contents.dart';
@@ -258,15 +261,13 @@ class CloudFileWidget extends HookConsumerWidget {
var content = switch (item.mimeType?.split('/').firstOrNull) {
'image' => AspectRatio(
aspectRatio: ratio,
child:
(useInternalGate && dataSaving && !unlocked.value)
child: (useInternalGate && dataSaving && !unlocked.value)
? dataPlaceHolder(Symbols.image)
: cloudImage(),
),
'video' => AspectRatio(
aspectRatio: ratio,
child:
(useInternalGate && dataSaving && !unlocked.value)
child: (useInternalGate && dataSaving && !unlocked.value)
? dataPlaceHolder(Symbols.play_arrow)
: cloudVideo(),
),
@@ -383,8 +384,7 @@ class CloudVideoWidget extends HookConsumerWidget {
final serverUrl = ref.watch(serverUrlProvider);
final uri = '$serverUrl/drive/files/${item.id}';
var ratio =
item.fileMeta?['ratio'] is num
var ratio = item.fileMeta?['ratio'] is num
? item.fileMeta!['ratio'].toDouble()
: 1.0;
if (ratio == 0) ratio = 1.0;
@@ -533,8 +533,7 @@ class CloudImageWidget extends ConsumerWidget {
return AspectRatio(
aspectRatio: aspectRatio,
child:
file != null
child: file != null
? CloudFileWidget(item: file!, fit: fit)
: UniversalImage(uri: uri, blurHash: blurHash, fit: fit),
);
@@ -545,8 +544,7 @@ class CloudImageWidget extends ConsumerWidget {
required String serverUrl,
bool original = false,
}) {
final uri =
original
final uri = original
? '$serverUrl/drive/files/$fileId?original=true'
: '$serverUrl/drive/files/$fileId';
return CachedNetworkImageProvider(uri);
@@ -560,6 +558,7 @@ class ProfilePictureWidget extends ConsumerWidget {
final double? borderRadius;
final IconData? fallbackIcon;
final Color? fallbackColor;
final ProfileDecoration? decoration;
const ProfilePictureWidget({
super.key,
this.fileId,
@@ -568,6 +567,7 @@ class ProfilePictureWidget extends ConsumerWidget {
this.borderRadius,
this.fallbackIcon,
this.fallbackColor,
this.decoration,
});
@override
@@ -575,36 +575,49 @@ class ProfilePictureWidget extends ConsumerWidget {
final serverUrl = ref.watch(serverUrlProvider);
final String? id = file?.id ?? fileId;
final fallback =
Icon(
final fallback = Icon(
fallbackIcon ?? Symbols.account_circle,
size: radius,
color:
fallbackColor ?? Theme.of(context).colorScheme.onPrimaryContainer,
color: fallbackColor ?? Theme.of(context).colorScheme.onPrimaryContainer,
).center();
return ClipRRect(
borderRadius:
borderRadius == null
? BorderRadius.all(Radius.circular(radius))
: BorderRadius.all(Radius.circular(borderRadius!)),
child: Container(
width: radius * 2,
height: radius * 2,
color: Theme.of(context).colorScheme.primaryContainer,
child:
id == null
final image = id == null
? fallback
: DataSavingGate(
bypass: true,
placeholder: fallback,
content:
() => UniversalImage(
content: () => UniversalImage(
uri: '$serverUrl/drive/files/$id',
fit: BoxFit.cover,
),
);
Widget content = Container(
width: radius * 2,
height: radius * 2,
color: Theme.of(context).colorScheme.primaryContainer,
child: decoration != null
? Stack(
fit: StackFit.expand,
children: [
image,
CustomPaint(
painter: _ProfileDecorationPainter(
text: decoration!.text,
color: decoration!.color,
textColor: decoration!.textColor ?? Colors.white,
),
),
],
)
: image,
);
return ClipRRect(
borderRadius: borderRadius == null
? BorderRadius.all(Radius.circular(radius))
: BorderRadius.all(Radius.circular(borderRadius!)),
child: content,
);
}
}
@@ -716,11 +729,9 @@ class SplitAvatarWidget extends ConsumerWidget {
),
),
Expanded(
child:
filesId.length > 4
child: filesId.length > 4
? Container(
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.primaryContainer,
child: Center(
@@ -728,8 +739,7 @@ class SplitAvatarWidget extends ConsumerWidget {
'+${filesId.length - 3}',
style: TextStyle(
fontSize: radius * 0.4,
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.onPrimaryContainer,
),
@@ -765,13 +775,11 @@ class SplitAvatarWidget extends ConsumerWidget {
width: radius,
height: radius,
color: Theme.of(context).colorScheme.primaryContainer,
child:
Icon(
child: Icon(
fallbackIcon,
size: radius * 0.6,
color:
fallbackColor ??
Theme.of(context).colorScheme.onPrimaryContainer,
fallbackColor ?? Theme.of(context).colorScheme.onPrimaryContainer,
).center(),
);
}
@@ -786,3 +794,106 @@ class SplitAvatarWidget extends ConsumerWidget {
);
}
}
class _ProfileDecorationPainter extends CustomPainter {
final String text;
final Color color;
final Color textColor;
_ProfileDecorationPainter({
required this.text,
required this.color,
required this.textColor,
});
@override
void paint(Canvas canvas, Size size) {
if (text.isEmpty) return;
final radius = size.width / 2;
final center = Offset(size.width / 2, size.height / 2);
final strokeWidth = radius * 0.4; // Increased thickness
final centerAngle = 3 * math.pi / 4;
final sweepAngle = math.pi / 1;
final startAngle = centerAngle - (sweepAngle / 2);
final arcRadius = radius - (strokeWidth / 2);
final rect = Rect.fromCircle(center: center, radius: arcRadius);
final paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = strokeWidth
..shader = SweepGradient(
startAngle: startAngle,
endAngle: startAngle + sweepAngle,
colors: [color.withOpacity(0), color, color, color.withOpacity(0)],
stops: const [0.0, 0.25, 0.75, 1.0],
).createShader(rect);
canvas.drawArc(rect, startAngle, sweepAngle, false, paint);
_drawTextOnArc(canvas, center, arcRadius, text, centerAngle);
}
void _drawTextOnArc(
Canvas canvas,
Offset center,
double radius,
String text,
double centerAngle,
) {
final textStyle = TextStyle(
color: textColor,
fontSize: radius * 0.28,
fontWeight: FontWeight.bold,
);
double totalAngle = 0;
List<double> charAngles = [];
// Calculate total angle occupied by text
for (int i = 0; i < text.length; i++) {
final char = text[i];
final span = TextSpan(text: char, style: textStyle);
final tp = TextPainter(text: span, textDirection: ui.TextDirection.ltr);
tp.layout();
final charWidth = tp.width;
final angle = charWidth / radius;
charAngles.add(angle);
totalAngle += angle;
}
// Start from "Left" of the center (High angle)
// We want to traverse from centerAngle + total/2 to centerAngle - total/2
double currentAngle = centerAngle + (totalAngle / 2);
for (int i = 0; i < text.length; i++) {
final char = text[i];
final span = TextSpan(text: char, style: textStyle);
final tp = TextPainter(text: span, textDirection: ui.TextDirection.ltr);
tp.layout();
final charAngle = charAngles[i];
final midCharAngle = currentAngle - charAngle / 2;
final x = center.dx + radius * math.cos(midCharAngle);
final y = center.dy + radius * math.sin(midCharAngle);
canvas.save();
canvas.translate(x, y);
canvas.rotate(midCharAngle - math.pi / 2);
tp.paint(canvas, Offset(-tp.width / 2, -tp.height / 2));
canvas.restore();
currentAngle -= charAngle;
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return true;
}
}

View File

@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'profile_decoration.freezed.dart';
@freezed
sealed class ProfileDecoration with _$ProfileDecoration {
const factory ProfileDecoration({
required String text,
required Color color,
Color? textColor,
}) = _ProfileDecoration;
}

View File

@@ -0,0 +1,277 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'profile_decoration.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ProfileDecoration {
String get text; Color get color; Color? get textColor;
/// Create a copy of ProfileDecoration
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ProfileDecorationCopyWith<ProfileDecoration> get copyWith => _$ProfileDecorationCopyWithImpl<ProfileDecoration>(this as ProfileDecoration, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ProfileDecoration&&(identical(other.text, text) || other.text == text)&&(identical(other.color, color) || other.color == color)&&(identical(other.textColor, textColor) || other.textColor == textColor));
}
@override
int get hashCode => Object.hash(runtimeType,text,color,textColor);
@override
String toString() {
return 'ProfileDecoration(text: $text, color: $color, textColor: $textColor)';
}
}
/// @nodoc
abstract mixin class $ProfileDecorationCopyWith<$Res> {
factory $ProfileDecorationCopyWith(ProfileDecoration value, $Res Function(ProfileDecoration) _then) = _$ProfileDecorationCopyWithImpl;
@useResult
$Res call({
String text, Color color, Color? textColor
});
}
/// @nodoc
class _$ProfileDecorationCopyWithImpl<$Res>
implements $ProfileDecorationCopyWith<$Res> {
_$ProfileDecorationCopyWithImpl(this._self, this._then);
final ProfileDecoration _self;
final $Res Function(ProfileDecoration) _then;
/// Create a copy of ProfileDecoration
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? text = null,Object? color = null,Object? textColor = freezed,}) {
return _then(_self.copyWith(
text: null == text ? _self.text : text // ignore: cast_nullable_to_non_nullable
as String,color: null == color ? _self.color : color // ignore: cast_nullable_to_non_nullable
as Color,textColor: freezed == textColor ? _self.textColor : textColor // ignore: cast_nullable_to_non_nullable
as Color?,
));
}
}
/// Adds pattern-matching-related methods to [ProfileDecoration].
extension ProfileDecorationPatterns on ProfileDecoration {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ProfileDecoration value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ProfileDecoration() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ProfileDecoration value) $default,){
final _that = this;
switch (_that) {
case _ProfileDecoration():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ProfileDecoration value)? $default,){
final _that = this;
switch (_that) {
case _ProfileDecoration() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String text, Color color, Color? textColor)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ProfileDecoration() when $default != null:
return $default(_that.text,_that.color,_that.textColor);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String text, Color color, Color? textColor) $default,) {final _that = this;
switch (_that) {
case _ProfileDecoration():
return $default(_that.text,_that.color,_that.textColor);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String text, Color color, Color? textColor)? $default,) {final _that = this;
switch (_that) {
case _ProfileDecoration() when $default != null:
return $default(_that.text,_that.color,_that.textColor);case _:
return null;
}
}
}
/// @nodoc
class _ProfileDecoration implements ProfileDecoration {
const _ProfileDecoration({required this.text, required this.color, this.textColor});
@override final String text;
@override final Color color;
@override final Color? textColor;
/// Create a copy of ProfileDecoration
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ProfileDecorationCopyWith<_ProfileDecoration> get copyWith => __$ProfileDecorationCopyWithImpl<_ProfileDecoration>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProfileDecoration&&(identical(other.text, text) || other.text == text)&&(identical(other.color, color) || other.color == color)&&(identical(other.textColor, textColor) || other.textColor == textColor));
}
@override
int get hashCode => Object.hash(runtimeType,text,color,textColor);
@override
String toString() {
return 'ProfileDecoration(text: $text, color: $color, textColor: $textColor)';
}
}
/// @nodoc
abstract mixin class _$ProfileDecorationCopyWith<$Res> implements $ProfileDecorationCopyWith<$Res> {
factory _$ProfileDecorationCopyWith(_ProfileDecoration value, $Res Function(_ProfileDecoration) _then) = __$ProfileDecorationCopyWithImpl;
@override @useResult
$Res call({
String text, Color color, Color? textColor
});
}
/// @nodoc
class __$ProfileDecorationCopyWithImpl<$Res>
implements _$ProfileDecorationCopyWith<$Res> {
__$ProfileDecorationCopyWithImpl(this._self, this._then);
final _ProfileDecoration _self;
final $Res Function(_ProfileDecoration) _then;
/// Create a copy of ProfileDecoration
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? text = null,Object? color = null,Object? textColor = freezed,}) {
return _then(_ProfileDecoration(
text: null == text ? _self.text : text // ignore: cast_nullable_to_non_nullable
as String,color: null == color ? _self.color : color // ignore: cast_nullable_to_non_nullable
as Color,textColor: freezed == textColor ? _self.textColor : textColor // ignore: cast_nullable_to_non_nullable
as Color?,
));
}
}
// dart format on

View File

@@ -12,8 +12,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/file_list_item.dart';
import 'package:island/models/file.dart';
import 'package:island/models/file_pool.dart';
import 'package:island/pods/file_list.dart';
import 'package:island/pods/file_pool.dart';
import 'package:island/pods/drive/file_list.dart';
import 'package:island/pods/drive/file_pool.dart';
import 'package:island/pods/network.dart';
import 'package:island/services/file_uploader.dart';
import 'package:island/services/responsive.dart';
@@ -123,12 +123,8 @@ class FileListView extends HookConsumerWidget {
notifier: unindexedFileListProvider.notifier,
isRefreshable: false,
isSliver: true,
contentBuilder:
(data, footer) =>
data.isEmpty
? SliverToBoxAdapter(
child: _buildEmptyUnindexedFilesHint(ref),
)
contentBuilder: (data, footer) => data.isEmpty
? SliverToBoxAdapter(child: _buildEmptyUnindexedFilesHint(ref))
: _buildUnindexedFileListContent(
data,
ref,
@@ -145,9 +141,7 @@ class FileListView extends HookConsumerWidget {
notifier: indexedCloudFileListProvider.notifier,
isRefreshable: false,
isSliver: true,
contentBuilder:
(data, footer) =>
data.isEmpty
contentBuilder: (data, footer) => data.isEmpty
? SliverToBoxAdapter(
child: _buildEmptyDirectoryHint(ref, currentPath),
)
@@ -177,8 +171,7 @@ class FileListView extends HookConsumerWidget {
style: TextStyle(fontWeight: FontWeight.bold),
);
} else {
final pathParts =
currentPath.value
final pathParts = currentPath.value
.split('/')
.where((part) => part.isNotEmpty)
.toList();
@@ -266,8 +259,7 @@ class FileListView extends HookConsumerWidget {
dragging.value = false;
},
child: Container(
color:
dragging.value
color: dragging.value
? Theme.of(context).primaryColor.withOpacity(0.1)
: null,
child: Column(
@@ -302,23 +294,20 @@ class FileListView extends HookConsumerWidget {
? Symbols.arrow_back
: Symbols.folder,
),
onPressed:
isRefreshing
onPressed: isRefreshing
? null
: () {
if (mode.value == FileListMode.unindexed) {
mode.value = FileListMode.normal;
currentPath.value = '/';
} else {
final pathParts =
currentPath.value
final pathParts = currentPath.value
.split('/')
.where((part) => part.isNotEmpty)
.toList();
if (pathParts.isNotEmpty) {
pathParts.removeLast();
currentPath.value =
pathParts.isEmpty
currentPath.value = pathParts.isEmpty
? '/'
: '/${pathParts.join('/')}';
}
@@ -342,14 +331,11 @@ class FileListView extends HookConsumerWidget {
? Symbols.view_module
: Symbols.list,
),
onPressed:
() =>
viewMode.value =
onPressed: () => viewMode.value =
viewMode.value == FileListViewMode.list
? FileListViewMode.waterfall
: FileListViewMode.list,
tooltip:
viewMode.value == FileListViewMode.list
tooltip: viewMode.value == FileListViewMode.list
? 'Switch to Waterfall View'
: 'Switch to List View',
visualDensity: const VisualDensity(
@@ -363,10 +349,9 @@ class FileListView extends HookConsumerWidget {
? Symbols.close
: Symbols.select_check_box,
),
onPressed:
() => isSelectionMode.value = !isSelectionMode.value,
tooltip:
isSelectionMode.value
onPressed: () =>
isSelectionMode.value = !isSelectionMode.value,
tooltip: isSelectionMode.value
? 'Exit Selection Mode'
: 'Enter Selection Mode',
visualDensity: const VisualDensity(
@@ -377,8 +362,7 @@ class FileListView extends HookConsumerWidget {
if (mode.value == FileListMode.normal)
IconButton(
icon: const Icon(Symbols.create_new_folder),
onPressed:
() =>
onPressed: () =>
onShowCreateDirectory(ref.context, currentPath),
tooltip: 'Create Directory',
visualDensity: const VisualDensity(
@@ -397,8 +381,7 @@ class FileListView extends HookConsumerWidget {
recycled.value = !recycled.value;
unindexedNotifier.setRecycled(recycled.value);
},
tooltip:
recycled.value
tooltip: recycled.value
? 'Show Active Files'
: 'Show Recycle Bin',
visualDensity: const VisualDensity(
@@ -429,11 +412,13 @@ class FileListView extends HookConsumerWidget {
if (mode.value == FileListMode.normal && currentPath.value == '/')
_buildUnindexedFilesEntry(ref).padding(bottom: 12),
Expanded(
child: CustomScrollView(
child:
CustomScrollView(
slivers: [bodyWidget, const SliverGap(12)],
).padding(
horizontal:
viewMode.value == FileListViewMode.waterfall ? 12 : null,
horizontal: viewMode.value == FileListViewMode.waterfall
? 12
: null,
),
),
if (isSelectionMode.value)
@@ -457,8 +442,7 @@ class FileListView extends HookConsumerWidget {
const Gap(12),
OutlinedButton(
onPressed: () {
final allIds =
currentVisibleItems.value
final allIds = currentVisibleItems.value
.expand(
(item) => item.maybeMap(
file: (f) => [f.fileIndex.id],
@@ -502,8 +486,7 @@ class FileListView extends HookConsumerWidget {
ElevatedButton.icon(
icon: const Icon(Symbols.delete),
label: const Text('Delete'),
onPressed:
selectedFileIds.value.isNotEmpty
onPressed: selectedFileIds.value.isNotEmpty
? () async {
final confirmed = await showConfirmAlert(
'Are you sure you want to delete the selected files?',
@@ -519,8 +502,8 @@ class FileListView extends HookConsumerWidget {
final resp = await client.post(
'/drive/files/batches/delete',
data: {
'file_ids':
selectedFileIds.value.toList(),
'file_ids': selectedFileIds.value
.toList(),
},
);
final count = resp.data['count'] as int;
@@ -584,8 +567,7 @@ class FileListView extends HookConsumerWidget {
final item = items[index];
return item.map(
file:
(fileItem) => _buildWaterfallFileTile(
file: (fileItem) => _buildWaterfallFileTile(
fileItem,
ref,
context,
@@ -601,8 +583,7 @@ class FileListView extends HookConsumerWidget {
}
},
),
folder:
(folderItem) =>
folder: (folderItem) =>
_buildWaterfallFolderTile(folderItem, currentPath, context),
unindexedFile: (unindexedFileItem) {
// Should not happen
@@ -620,8 +601,7 @@ class FileListView extends HookConsumerWidget {
}
final item = items[index];
return item.map(
file:
(fileItem) => _buildIndexedListTile(
file: (fileItem) => _buildIndexedListTile(
fileItem,
ref,
context,
@@ -637,8 +617,7 @@ class FileListView extends HookConsumerWidget {
}
},
),
folder:
(folderItem) => ListTile(
folder: (folderItem) => ListTile(
leading: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(8)),
child: SizedBox(
@@ -654,8 +633,7 @@ class FileListView extends HookConsumerWidget {
),
subtitle: const Text('folder').tr(),
onTap: () {
final newPath =
currentPath.value == '/'
final newPath = currentPath.value == '/'
? '/${folderItem.folderName}'
: '${currentPath.value}/${folderItem.folderName}';
currentPath.value = newPath;
@@ -705,8 +683,7 @@ class FileListView extends HookConsumerWidget {
ValueNotifier<String> currentPath,
) {
return Card(
margin:
viewMode.value == FileListViewMode.waterfall
margin: viewMode.value == FileListViewMode.waterfall
? const EdgeInsets.fromLTRB(0, 0, 0, 16)
: const EdgeInsets.fromLTRB(12, 0, 12, 16),
child: Padding(
@@ -748,8 +725,8 @@ class FileListView extends HookConsumerWidget {
),
const Gap(12),
OutlinedButton.icon(
onPressed:
() => onShowCreateDirectory(ref.context, currentPath),
onPressed: () =>
onShowCreateDirectory(ref.context, currentPath),
icon: const Icon(Symbols.create_new_folder),
label: const Text('Create Directory'),
),
@@ -822,8 +799,9 @@ class FileListView extends HookConsumerWidget {
VoidCallback? toggleSelection,
) {
final meta = file.fileMeta is Map ? (file.fileMeta as Map) : const {};
final ratio =
meta['ratio'] is num ? (meta['ratio'] as num).toDouble() : 1.0;
final ratio = meta['ratio'] is num
? (meta['ratio'] as num).toDouble()
: 1.0;
final itemType = file.mimeType?.split('/').first;
final uri =
'${ref.read(apiClientProvider).options.baseUrl}/drive/files/${file.id}';
@@ -851,9 +829,7 @@ class FileListView extends HookConsumerWidget {
.read(apiClientProvider)
.get(uri)
.then((response) => response.data as String),
builder:
(context, snapshot) =>
snapshot.hasData
builder: (context, snapshot) => snapshot.hasData
? SingleChildScrollView(
padding: EdgeInsets.all(24),
child: Text(
@@ -961,8 +937,7 @@ class FileListView extends HookConsumerWidget {
return InkWell(
borderRadius: BorderRadius.circular(8),
onTap: () {
final newPath =
currentPath.value == '/'
final newPath = currentPath.value == '/'
? '/${folderItem.folderName}'
: '${currentPath.value}/${folderItem.folderName}';
currentPath.value = newPath;
@@ -1038,8 +1013,8 @@ class FileListView extends HookConsumerWidget {
// Should not happen in unindexed mode
return const SizedBox.shrink();
},
unindexedFile:
(unindexedFileItem) => _buildWaterfallUnindexedFileTile(
unindexedFile: (unindexedFileItem) =>
_buildWaterfallUnindexedFileTile(
unindexedFileItem,
ref,
context,
@@ -1077,17 +1052,14 @@ class FileListView extends HookConsumerWidget {
// Should not happen in unindexed mode
return const SizedBox.shrink();
},
unindexedFile:
(unindexedFileItem) => _buildUnindexedListTile(
unindexedFile: (unindexedFileItem) => _buildUnindexedListTile(
unindexedFileItem,
ref,
context,
isSelectionMode.value,
selectedFileIds.value.contains(unindexedFileItem.file.id),
() {
if (selectedFileIds.value.contains(
unindexedFileItem.file.id,
)) {
if (selectedFileIds.value.contains(unindexedFileItem.file.id)) {
selectedFileIds.value = Set.from(selectedFileIds.value)
..remove(unindexedFileItem.file.id);
} else {
@@ -1130,8 +1102,7 @@ class FileListView extends HookConsumerWidget {
),
],
),
title:
file.name.isEmpty
title: file.name.isEmpty
? Text('untitled').tr().italic()
: Text(file.name, maxLines: 1, overflow: TextOverflow.ellipsis),
subtitle: Text(formatFileSize(file.size)),
@@ -1199,8 +1170,7 @@ class FileListView extends HookConsumerWidget {
),
],
),
title:
file.name.isEmpty
title: file.name.isEmpty
? Text('untitled').tr().italic()
: Text(file.name, maxLines: 1, overflow: TextOverflow.ellipsis),
subtitle: Text(formatFileSize(file.size)),
@@ -1289,8 +1259,7 @@ class FileListView extends HookConsumerWidget {
Widget _buildEmptyUnindexedFilesHint(WidgetRef ref) {
return Card(
margin:
viewMode.value == FileListViewMode.waterfall
margin: viewMode.value == FileListViewMode.waterfall
? EdgeInsets.zero
: const EdgeInsets.fromLTRB(12, 0, 12, 0),
child: Padding(
@@ -1395,8 +1364,7 @@ class FileListView extends HookConsumerWidget {
ObjectRef<Timer?> queryDebounceTimer,
) {
final poolDropdownItems = poolsAsync.when(
data:
(pools) => [
data: (pools) => [
const DropdownMenuItem<SnFilePool>(
value: null,
child: Text('All Pools', style: TextStyle(fontSize: 14)),
@@ -1416,8 +1384,7 @@ class FileListView extends HookConsumerWidget {
child: DropdownButton2<SnFilePool>(
value: selectedPool.value,
items: poolDropdownItems,
onChanged:
isRefreshing
onChanged: isRefreshing
? null
: (value) {
selectedPool.value = value;
@@ -1493,13 +1460,11 @@ class FileListView extends HookConsumerWidget {
final orderDropdown = DropdownButtonHideUnderline(
child: DropdownButton2<String>(
value: order.value,
items:
['date', 'size', 'name']
items: ['date', 'size', 'name']
.map(
(e) => DropdownMenuItem(
value: e,
child:
Text(
child: Text(
e == 'date' ? e : 'file${e.capitalizeEachWord()}',
style: const TextStyle(fontSize: 14),
).tr(),
@@ -1517,8 +1482,7 @@ class FileListView extends HookConsumerWidget {
borderRadius: BorderRadius.circular(8),
),
child: Center(
child:
Text(
child: Text(
(order.value ?? 'date') == 'date'
? (order.value ?? 'date')
: 'file${order.value?.capitalizeEachWord()}',

View File

@@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_riverpod/misc.dart';
import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/pods/paging.dart';
import 'package:island/widgets/extended_refresh_indicator.dart';
@@ -17,21 +18,27 @@ class PaginationList<T> extends HookConsumerWidget {
final ProviderListenable<AsyncValue<List<T>>> provider;
final Refreshable<PaginationController<T>> notifier;
final Widget? Function(BuildContext, int, T) itemBuilder;
final Widget? Function(BuildContext, int, T)? seperatorBuilder;
final double? spacing;
final bool isRefreshable;
final bool isSliver;
final bool showDefaultWidgets;
final EdgeInsets? padding;
final Widget? footerSkeletonChild;
final double? footerSkeletonMaxWidth;
const PaginationList({
super.key,
required this.provider,
required this.notifier,
required this.itemBuilder,
this.seperatorBuilder,
this.spacing,
this.isRefreshable = true,
this.isSliver = false,
this.showDefaultWidgets = true,
this.padding,
this.footerSkeletonChild,
this.footerSkeletonMaxWidth,
});
@override
@@ -39,9 +46,26 @@ class PaginationList<T> extends HookConsumerWidget {
final data = ref.watch(provider);
final noti = ref.watch(notifier);
if (data.isLoading && data.value?.isEmpty == true) {
final content = ResponseLoadingWidget();
return isSliver ? SliverFillRemaining(child: content) : content;
// For sliver cases, avoid animation to prevent complex sliver issues
if (isSliver) {
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
final content = List<Widget>.generate(
10,
(_) => Skeletonizer(
enabled: true,
effect: ShimmerEffect(
baseColor: Theme.of(context).colorScheme.surfaceContainerHigh,
highlightColor: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
),
containersColor: Theme.of(context).colorScheme.surfaceContainerLow,
child:
footerSkeletonChild ??
_DefaultSkeletonChild(maxWidth: footerSkeletonMaxWidth),
),
);
return SliverList.list(children: content);
}
if (data.hasError) {
@@ -49,11 +73,10 @@ class PaginationList<T> extends HookConsumerWidget {
error: data.error,
onRetry: noti.refresh,
);
return isSliver ? SliverFillRemaining(child: content) : content;
return SliverFillRemaining(child: content);
}
final listView = isSliver
? SuperSliverList.builder(
final listView = SuperSliverList.separated(
itemCount: (data.value?.length ?? 0) + 1,
itemBuilder: (context, idx) {
if (idx == data.value?.length) {
@@ -61,14 +84,68 @@ class PaginationList<T> extends HookConsumerWidget {
noti: noti,
data: data,
skeletonChild: footerSkeletonChild,
skeletonMaxWidth: footerSkeletonMaxWidth,
);
}
final entry = data.value?[idx];
if (entry != null) return itemBuilder(context, idx, entry);
return null;
},
)
: SuperListView.builder(
separatorBuilder: (context, index) {
if (seperatorBuilder != null) {
final entry = data.value?[index];
if (entry != null) {
return seperatorBuilder!(context, index, entry) ??
const SizedBox();
}
return const SizedBox();
}
if (spacing != null && spacing! > 0) {
return Gap(spacing!);
}
return const SizedBox();
},
);
return isRefreshable
? ExtendedRefreshIndicator(onRefresh: noti.refresh, child: listView)
: listView;
}
// For non-sliver cases, use AnimatedSwitcher for smooth transitions
Widget buildContent() {
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
final content = List<Widget>.generate(
10,
(_) => Skeletonizer(
enabled: true,
effect: ShimmerEffect(
baseColor: Theme.of(context).colorScheme.surfaceContainerHigh,
highlightColor: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
),
containersColor: Theme.of(context).colorScheme.surfaceContainerLow,
child:
footerSkeletonChild ??
_DefaultSkeletonChild(maxWidth: footerSkeletonMaxWidth),
),
);
return SizedBox(
key: const ValueKey('loading'),
child: ListView(children: content),
);
}
if (data.hasError) {
final content = ResponseErrorWidget(
error: data.error,
onRetry: noti.refresh,
);
return SizedBox(key: const ValueKey('error'), child: content);
}
final listView = SuperListView.separated(
padding: padding,
itemCount: (data.value?.length ?? 0) + 1,
itemBuilder: (context, idx) {
@@ -77,17 +154,41 @@ class PaginationList<T> extends HookConsumerWidget {
noti: noti,
data: data,
skeletonChild: footerSkeletonChild,
skeletonMaxWidth: footerSkeletonMaxWidth,
);
}
final entry = data.value?[idx];
if (entry != null) return itemBuilder(context, idx, entry);
return null;
},
separatorBuilder: (context, index) {
if (seperatorBuilder != null) {
final entry = data.value?[index];
if (entry != null) {
return seperatorBuilder!(context, index, entry) ??
const SizedBox();
}
return const SizedBox();
}
if (spacing != null && spacing! > 0) {
return Gap(spacing!);
}
return const SizedBox();
},
);
return isRefreshable
return SizedBox(
key: const ValueKey('data'),
child: isRefreshable
? ExtendedRefreshIndicator(onRefresh: noti.refresh, child: listView)
: listView;
: listView,
);
}
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: buildContent(),
);
}
}
@@ -99,6 +200,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
final bool isSliver;
final bool showDefaultWidgets;
final Widget? footerSkeletonChild;
final double? footerSkeletonMaxWidth;
const PaginationWidget({
super.key,
required this.provider,
@@ -108,6 +210,7 @@ class PaginationWidget<T> extends HookConsumerWidget {
this.isSliver = false,
this.showDefaultWidgets = true,
this.footerSkeletonChild,
this.footerSkeletonMaxWidth,
});
@override
@@ -115,9 +218,26 @@ class PaginationWidget<T> extends HookConsumerWidget {
final data = ref.watch(provider);
final noti = ref.watch(notifier);
if (data.isLoading && data.value?.isEmpty == true) {
final content = ResponseLoadingWidget();
return isSliver ? SliverFillRemaining(child: content) : content;
// For sliver cases, avoid animation to prevent complex sliver issues
if (isSliver) {
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
final content = List<Widget>.generate(
10,
(_) => Skeletonizer(
enabled: true,
effect: ShimmerEffect(
baseColor: Theme.of(context).colorScheme.surfaceContainerHigh,
highlightColor: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
),
containersColor: Theme.of(context).colorScheme.surfaceContainerLow,
child:
footerSkeletonChild ??
_DefaultSkeletonChild(maxWidth: footerSkeletonMaxWidth),
),
);
return SliverList.list(children: content);
}
if (data.hasError) {
@@ -125,13 +245,14 @@ class PaginationWidget<T> extends HookConsumerWidget {
error: data.error,
onRetry: noti.refresh,
);
return isSliver ? SliverFillRemaining(child: content) : content;
return SliverFillRemaining(child: content);
}
final footer = PaginationListFooter(
noti: noti,
data: data,
skeletonChild: footerSkeletonChild,
skeletonMaxWidth: footerSkeletonMaxWidth,
);
final content = contentBuilder(data.value ?? [], footer);
@@ -139,12 +260,68 @@ class PaginationWidget<T> extends HookConsumerWidget {
? ExtendedRefreshIndicator(onRefresh: noti.refresh, child: content)
: content;
}
// For non-sliver cases, use AnimatedSwitcher for smooth transitions
Widget buildContent() {
if ((data.isLoading || noti.isLoading) && data.value?.isEmpty == true) {
final content = List<Widget>.generate(
10,
(_) => Skeletonizer(
enabled: true,
effect: ShimmerEffect(
baseColor: Theme.of(context).colorScheme.surfaceContainerHigh,
highlightColor: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
),
containersColor: Theme.of(context).colorScheme.surfaceContainerLow,
child:
footerSkeletonChild ??
_DefaultSkeletonChild(maxWidth: footerSkeletonMaxWidth),
),
);
return SizedBox(
key: const ValueKey('loading'),
child: ListView(children: content),
);
}
if (data.hasError) {
final content = ResponseErrorWidget(
error: data.error,
onRetry: noti.refresh,
);
return SizedBox(key: const ValueKey('error'), child: content);
}
final footer = PaginationListFooter(
noti: noti,
data: data,
skeletonChild: footerSkeletonChild,
skeletonMaxWidth: footerSkeletonMaxWidth,
);
final content = contentBuilder(data.value ?? [], footer);
return SizedBox(
key: const ValueKey('data'),
child: isRefreshable
? ExtendedRefreshIndicator(onRefresh: noti.refresh, child: content)
: content,
);
}
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: buildContent(),
);
}
}
class PaginationListFooter<T> extends HookConsumerWidget {
final PaginationController<T> noti;
final AsyncValue<List<T>> data;
final Widget? skeletonChild;
final double? skeletonMaxWidth;
final bool isSliver;
const PaginationListFooter({
@@ -152,6 +329,7 @@ class PaginationListFooter<T> extends HookConsumerWidget {
required this.noti,
required this.data,
this.skeletonChild,
this.skeletonMaxWidth,
this.isSliver = false,
});
@@ -161,13 +339,12 @@ class PaginationListFooter<T> extends HookConsumerWidget {
final placeholder = Skeletonizer(
enabled: true,
child:
skeletonChild ??
ListTile(
title: Text('Some data'),
subtitle: const Text('Subtitle here'),
trailing: const Icon(Icons.ac_unit),
effect: ShimmerEffect(
baseColor: Theme.of(context).colorScheme.surfaceContainerHigh,
highlightColor: Theme.of(context).colorScheme.surfaceContainerHighest,
),
containersColor: Theme.of(context).colorScheme.surfaceContainerLow,
child: skeletonChild ?? _DefaultSkeletonChild(maxWidth: skeletonMaxWidth),
);
final child = hasBeenVisible.value
? data.isLoading
@@ -194,3 +371,26 @@ class PaginationListFooter<T> extends HookConsumerWidget {
);
}
}
class _DefaultSkeletonChild extends StatelessWidget {
final double? maxWidth;
const _DefaultSkeletonChild({this.maxWidth});
@override
Widget build(BuildContext context) {
final content = ListTile(
title: Text('Some data'),
subtitle: const Text('Subtitle here'),
trailing: const Icon(Icons.ac_unit),
);
if (maxWidth != null) {
return Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth!),
child: content,
),
);
}
return content;
}
}

View File

@@ -9,33 +9,14 @@ import 'package:island/models/post_category.dart';
import 'package:island/models/post_tag.dart';
import 'package:island/models/realm.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/post/post_categories.dart';
import 'package:island/screens/realm/realms.dart';
import 'package:island/widgets/content/cloud_files.dart';
import 'package:island/widgets/content/sheet.dart';
import 'package:island/widgets/post/compose_shared.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:styled_widget/styled_widget.dart';
part 'compose_settings_sheet.g.dart';
@riverpod
Future<List<SnPostCategory>> postCategories(Ref ref) async {
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get('/sphere/posts/categories');
final categories =
resp.data
.map((e) => SnPostCategory.fromJson(e))
.cast<SnPostCategory>()
.toList();
// Remove duplicates based on id
final uniqueCategories = <String, SnPostCategory>{};
for (final category in categories) {
uniqueCategories[category.id] = category;
}
return uniqueCategories.values.toList();
}
class ComposeSettingsSheet extends HookConsumerWidget {
final ComposeState state;
@@ -121,8 +102,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
void showVisibilitySheet() {
showModalBottomSheet(
context: context,
builder:
(context) => SheetScaffold(
builder: (context) => SheetScaffold(
titleText: 'postVisibility'.tr(),
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -182,8 +162,8 @@ class ComposeSettingsSheet extends HookConsumerWidget {
borderRadius: BorderRadius.circular(12),
),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
// Tags field
@@ -209,8 +189,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
Wrap(
spacing: 8,
runSpacing: 8,
children:
currentTags.map((tag) {
children: currentTags.map((tag) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
@@ -226,8 +205,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
Text(
'#$tag',
style: TextStyle(
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.onPrimary,
fontSize: 14,
@@ -244,8 +222,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
child: Icon(
Icons.close,
size: 16,
color:
Theme.of(
color: Theme.of(
context,
).colorScheme.onPrimary,
),
@@ -274,8 +251,8 @@ class ComposeSettingsSheet extends HookConsumerWidget {
},
);
},
suggestionsCallback:
(pattern) => _fetchTagSuggestions(pattern, ref),
suggestionsCallback: (pattern) =>
_fetchTagSuggestions(pattern, ref),
itemBuilder: (context, suggestion) {
return ListTile(
shape: const RoundedRectangleBorder(
@@ -314,21 +291,17 @@ class ComposeSettingsSheet extends HookConsumerWidget {
),
),
hint: Text('categories'.tr(), style: TextStyle(fontSize: 15)),
items:
(postCategories.value ?? <SnPostCategory>[]).map((item) {
items: (postCategories.value ?? <SnPostCategory>[]).map((item) {
return DropdownMenuItem(
value: item,
enabled: false,
child: StatefulBuilder(
builder: (context, menuSetState) {
final isSelected = state.categories.value.contains(
item,
);
final isSelected = state.categories.value.contains(item);
return InkWell(
onTap: () {
isSelected
? state.categories.value =
state.categories.value
? state.categories.value = state.categories.value
.where((e) => e != item)
.toList()
: state.categories.value = [
@@ -339,9 +312,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
},
child: Container(
height: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
children: [
if (isSelected)

View File

@@ -1,51 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'compose_settings_sheet.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(postCategories)
const postCategoriesProvider = PostCategoriesProvider._();
final class PostCategoriesProvider
extends
$FunctionalProvider<
AsyncValue<List<SnPostCategory>>,
List<SnPostCategory>,
FutureOr<List<SnPostCategory>>
>
with
$FutureModifier<List<SnPostCategory>>,
$FutureProvider<List<SnPostCategory>> {
const PostCategoriesProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'postCategoriesProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$postCategoriesHash();
@$internal
@override
$FutureProviderElement<List<SnPostCategory>> $createElement(
$ProviderPointer pointer,
) => $FutureProviderElement(pointer);
@override
FutureOr<List<SnPostCategory>> create(Ref ref) {
return postCategories(ref);
}
}
String _$postCategoriesHash() => r'8799c10eb91cf8c8c7ea72eff3475e1eaa7b9a2b';

View File

@@ -24,7 +24,7 @@ import 'package:island/widgets/post/compose_link_attachments.dart';
import 'package:island/widgets/post/compose_poll.dart';
import 'package:island/widgets/post/compose_fund.dart';
import 'package:island/widgets/post/compose_recorder.dart';
import 'package:island/pods/file_pool.dart';
import 'package:island/pods/drive/file_pool.dart';
import 'package:pasteboard/pasteboard.dart';
import 'package:island/talker.dart';
@@ -108,8 +108,8 @@ class ComposeLogic {
String? pollId;
String? fundId;
if (originalPost?.meta?['embeds'] is List) {
final embeds =
(originalPost!.meta!['embeds'] as List).cast<Map<String, dynamic>>();
final embeds = (originalPost!.meta!['embeds'] as List)
.cast<Map<String, dynamic>>();
try {
final pollEmbed = embeds.firstWhere((e) => e['type'] == 'poll');
pollId = pollEmbed['id'];
@@ -202,8 +202,7 @@ class ComposeLogic {
final attachment = state.attachments.value[i];
if (attachment.data is! SnCloudFile) {
try {
final cloudFile =
await FileUploader.createCloudFile(
final cloudFile = await FileUploader.createCloudFile(
ref: ref,
fileData: attachment,
).future;
@@ -242,8 +241,7 @@ class ComposeLogic {
repliedPost: null,
forwardedPostId: null,
forwardedPost: null,
attachments:
state.attachments.value
attachments: state.attachments.value
.map((e) => e.data)
.whereType<SnCloudFile>()
.toList(),
@@ -315,8 +313,7 @@ class ComposeLogic {
repliedPost: null,
forwardedPostId: null,
forwardedPost: null,
attachments:
state.attachments.value
attachments: state.attachments.value
.map((e) => e.data)
.whereType<SnCloudFile>()
.toList(),
@@ -501,8 +498,7 @@ class ComposeLogic {
UniversalFile value,
int index,
) {
state.attachments.value =
state.attachments.value.mapIndexed((idx, ele) {
state.attachments.value = state.attachments.value.mapIndexed((idx, ele) {
if (idx == index) return value;
return ele;
}).toList();
@@ -528,13 +524,11 @@ class ComposeLogic {
final pools = await ref.read(poolsProvider.future);
final selectedPoolId = resolveDefaultPoolId(ref, pools);
cloudFile =
await FileUploader.createCloudFile(
cloudFile = await FileUploader.createCloudFile(
ref: ref,
fileData: attachment,
poolId: poolId ?? selectedPoolId,
mode:
attachment.type == UniversalFileType.file
mode: attachment.type == UniversalFileType.file
? FileUploadMode.generic
: FileUploadMode.mediaSafe,
onProgress: (progress, _) {
@@ -713,8 +707,7 @@ class ComposeLogic {
if (state.slugController.text.isNotEmpty)
'slug': state.slugController.text,
'visibility': state.visibility.value,
'attachments':
state.attachments.value
'attachments': state.attachments.value
.where((e) => e.isOnCloud)
.map((e) => e.data.id)
.toList(),

View File

@@ -1,12 +1,17 @@
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/file.dart';
import 'package:island/models/post.dart';
import 'package:island/screens/posts/compose.dart';
import 'package:island/screens/posts/post_detail.dart';
import 'package:island/services/compose_storage_db.dart';
import 'package:island/services/responsive.dart';
import 'package:island/widgets/content/sheet.dart';
import 'package:island/widgets/post/compose_card.dart';
import 'package:island/widgets/post/compose_shared.dart';
@@ -32,12 +37,17 @@ class PostComposeSheet extends HookConsumerWidget {
SnPost? originalPost,
PostComposeInitialState? initialState,
}) {
// Check if editing an article
if (originalPost != null && originalPost.type == 1) {
context.pushNamed('articleEdit', pathParameters: {'id': originalPost.id});
return Future.value(true);
}
return showModalBottomSheet<bool>(
context: context,
isScrollControlled: true,
useRootNavigator: true,
builder:
(context) => PostComposeSheet(
builder: (context) => PostComposeSheet(
originalPost: originalPost,
initialState: initialState,
isBottomSheet: true,
@@ -52,8 +62,7 @@ class PostComposeSheet extends HookConsumerWidget {
final prompted = useState(false);
// Fetch full post data if we're editing a post
final fullPostData =
originalPost != null
final fullPostData = originalPost != null
? ref.watch(postProvider(originalPost!.id))
: const AsyncValue.data(null);
@@ -115,7 +124,11 @@ class PostComposeSheet extends HookConsumerWidget {
}, [drafts, prompted.value]);
// Dispose state when widget is disposed
useEffect(() => () => ComposeLogic.dispose(state), []);
useEffect(
() =>
() => ComposeLogic.dispose(state),
[],
);
// Helper methods for actions
void showSettingsSheet() {
@@ -147,8 +160,7 @@ class PostComposeSheet extends HookConsumerWidget {
(state.submitting.value || state.currentPublisher.value == null)
? null
: performSubmit,
icon:
state.submitting.value
icon: state.submitting.value
? SizedBox(
width: 24,
height: 24,
@@ -157,14 +169,20 @@ class PostComposeSheet extends HookConsumerWidget {
: Icon(
effectiveOriginalPost != null ? Symbols.edit : Symbols.upload,
),
tooltip:
effectiveOriginalPost != null
tooltip: effectiveOriginalPost != null
? 'postUpdate'.tr()
: 'postPublish'.tr(),
),
];
// Tablet will show a virtual keyboard, so we adjust the height factor accordingly
final isTablet =
isWideScreen(context) &&
!kIsWeb &&
(Platform.isAndroid || Platform.isAndroid);
return SheetScaffold(
heightFactor: isTablet ? 0.95 : 0.8,
titleText: 'postCompose'.tr(),
actions: actions,
child: PostComposeCard(
@@ -192,8 +210,7 @@ class PostComposeSheet extends HookConsumerWidget {
final restore = await showDialog<bool>(
context: ref.context,
useRootNavigator: true,
builder:
(context) => AlertDialog(
builder: (context) => AlertDialog(
title: Text('restoreDraftTitle'.tr()),
content: Column(
mainAxisSize: MainAxisSize.min,
@@ -226,8 +243,7 @@ class PostComposeSheet extends HookConsumerWidget {
description: latestDraft.description,
content: latestDraft.content,
visibility: latestDraft.visibility,
attachments:
latestDraft.attachments
attachments: latestDraft.attachments
.map((e) => UniversalFile.fromAttachment(e))
.toList(),
);

View File

@@ -26,7 +26,12 @@ class PostItemSkeleton extends StatelessWidget {
final renderingPadding =
padding ?? const EdgeInsets.symmetric(horizontal: 8, vertical: 8);
return Column(
return Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 640),
child: Card(
margin: EdgeInsets.only(bottom: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -41,13 +46,18 @@ class PostItemSkeleton extends StatelessWidget {
renderingPadding: renderingPadding,
),
if (isShowReference)
_ReferencedPostWidgetSkeleton(renderingPadding: renderingPadding),
_ReferencedPostWidgetSkeleton(
renderingPadding: renderingPadding,
),
if (isEmbedReply)
_PostReplyPreviewSkeleton(
renderingPadding: renderingPadding,
).padding(horizontal: renderingPadding.horizontal, top: 8),
Gap(renderingPadding.vertical),
],
),
),
),
);
}
}

View File

@@ -1,81 +1,13 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:island/widgets/post/post_item.dart';
import 'package:island/widgets/post/post_item_creator.dart';
import 'package:island/widgets/post/post_item_skeleton.dart';
part 'post_list.freezed.dart';
@freezed
sealed class PostListQuery with _$PostListQuery {
const factory PostListQuery({
String? pubName,
String? realm,
int? type,
List<String>? categories,
List<String>? tags,
bool? pinned,
@Default(false) bool shuffle,
bool? includeReplies,
bool? mediaOnly,
String? queryTerm,
String? order,
int? periodStart,
int? periodEnd,
@Default(true) bool orderDesc,
}) = _PostListQuery;
}
final postListNotifierProvider = AsyncNotifierProvider.autoDispose
.family<PostListNotifier, List<SnPost>, PostListQuery>(
PostListNotifier.new,
);
class PostListNotifier extends AsyncNotifier<List<SnPost>>
with AsyncPaginationController<SnPost> {
final PostListQuery arg;
PostListNotifier(this.arg);
static const int pageSize = 20;
@override
Future<List<SnPost>> fetch() async {
final client = ref.read(apiClientProvider);
final queryParams = {
'offset': fetchedCount,
'take': pageSize,
'replies': arg.includeReplies,
'orderDesc': arg.orderDesc,
if (arg.shuffle) 'shuffle': arg.shuffle,
if (arg.pubName != null) 'pub': arg.pubName,
if (arg.realm != null) 'realm': arg.realm,
if (arg.type != null) 'type': arg.type,
if (arg.tags != null) 'tags': arg.tags,
if (arg.categories != null) 'categories': arg.categories,
if (arg.pinned != null) 'pinned': arg.pinned,
if (arg.order != null) 'order': arg.order,
if (arg.periodStart != null) 'periodStart': arg.periodStart,
if (arg.periodEnd != null) 'periodEnd': arg.periodEnd,
if (arg.queryTerm != null) 'query': arg.queryTerm,
if (arg.mediaOnly != null) 'media': arg.mediaOnly,
};
final response = await client.get(
'/sphere/posts',
queryParameters: queryParams,
);
totalCount = int.parse(response.headers.value('X-Total') ?? '0');
final List<dynamic> data = response.data;
return data.map((json) => SnPost.fromJson(json)).toList();
}
}
/// Defines which post item widget to use in the list
enum PostItemType {
/// Regular post item with user information
@@ -86,21 +18,7 @@ enum PostItemType {
}
class SliverPostList extends HookConsumerWidget {
final String? pubName;
final String? realm;
final int? type;
final List<String>? categories;
final List<String>? tags;
final bool shuffle;
final bool? pinned;
final bool? includeReplies;
final bool? mediaOnly;
final String? queryTerm;
// Can be "populaurity", other value will be treated as "date"
final String? order;
final int? periodStart;
final int? periodEnd;
final bool? orderDesc;
final PostListQuery? query;
final PostItemType itemType;
final Color? backgroundColor;
final EdgeInsets? padding;
@@ -108,23 +26,11 @@ class SliverPostList extends HookConsumerWidget {
final Function? onRefresh;
final Function(SnPost)? onUpdate;
final double? maxWidth;
final String? queryKey;
const SliverPostList({
super.key,
this.pubName,
this.realm,
this.type,
this.categories,
this.tags,
this.shuffle = false,
this.pinned,
this.includeReplies,
this.mediaOnly,
this.queryTerm,
this.order,
this.orderDesc = true,
this.periodStart,
this.periodEnd,
this.query,
this.itemType = PostItemType.regular,
this.backgroundColor,
this.padding,
@@ -132,35 +38,37 @@ class SliverPostList extends HookConsumerWidget {
this.onRefresh,
this.onUpdate,
this.maxWidth,
this.queryKey,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final params = PostListQuery(
pubName: pubName,
realm: realm,
type: type,
categories: categories,
tags: tags,
shuffle: shuffle,
pinned: pinned,
includeReplies: includeReplies,
mediaOnly: mediaOnly,
queryTerm: queryTerm,
order: order,
periodStart: periodStart,
periodEnd: periodEnd,
orderDesc: orderDesc ?? true,
final provider = postListProvider(
PostListQueryConfig(
id: queryKey,
initialFilter: query ?? PostListQuery(),
),
);
final provider = postListNotifierProvider(params);
final notifier = provider.notifier;
final notifier = ref.watch(provider.notifier);
final currentFilter = useState(query ?? PostListQuery());
useEffect(() {
if (currentFilter.value != query) {
notifier.applyFilter(query ?? PostListQuery());
}
return null;
}, [query, queryKey]);
return PaginationList(
provider: provider,
notifier: notifier,
notifier: provider.notifier,
isRefreshable: false,
isSliver: true,
footerSkeletonChild: const PostItemSkeleton(),
footerSkeletonChild: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: const PostItemSkeleton(),
),
itemBuilder: (context, index, post) {
if (maxWidth != null) {
return Center(

View File

@@ -113,10 +113,7 @@ return $default(_that);case _:
final _that = this;
switch (_that) {
case _ReactionListQuery():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
return $default(_that);}
}
/// A variant of `map` that fallback to returning `null`.
///
@@ -175,10 +172,7 @@ return $default(_that.symbol,_that.postId);case _:
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String symbol, String postId) $default,) {final _that = this;
switch (_that) {
case _ReactionListQuery():
return $default(_that.symbol,_that.postId);case _:
throw StateError('Unexpected subclass');
}
return $default(_that.symbol,_that.postId);}
}
/// A variant of `when` that fallback to returning `null`
///

View File

@@ -5,6 +5,7 @@ import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:island/widgets/post/post_item.dart';
import 'package:island/widgets/post/post_item_skeleton.dart';
final postRepliesProvider = AsyncNotifierProvider.autoDispose.family(
PostRepliesNotifier.new,
@@ -47,11 +48,24 @@ class PostRepliesList extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final provider = postRepliesProvider(postId);
final skeletonItem = Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: const PostItemSkeleton(),
);
return PaginationList(
provider: provider,
notifier: provider.notifier,
isRefreshable: false,
isSliver: true,
footerSkeletonChild: maxWidth == null
? skeletonItem
: Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth!),
child: skeletonItem,
),
),
itemBuilder: (context, index, item) {
final contentWidget = Card(
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),

View File

@@ -1,3 +1,5 @@
import 'dart:math' as math;
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
@@ -66,6 +68,7 @@ class PostReplyPreview extends HookConsumerWidget {
final bool isOpenable;
final bool isCompact;
final bool isAutoload;
final double? itemMaxWidth;
final VoidCallback? onOpen;
const PostReplyPreview({
super.key,
@@ -73,6 +76,7 @@ class PostReplyPreview extends HookConsumerWidget {
this.isOpenable = false,
this.isCompact = false,
this.isAutoload = true,
this.itemMaxWidth,
this.onOpen,
});
@@ -114,17 +118,22 @@ class PostReplyPreview extends HookConsumerWidget {
return null;
}, [parent]);
final featuredReply =
isOpenable ? null : ref.watch(postFeaturedReplyProvider(parent.id));
final featuredReply = isOpenable
? null
: ref.watch(postFeaturedReplyProvider(parent.id));
final itemWidget =
isOpenable
Widget itemBuilder(double maxWidth) {
return isOpenable
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (final post in posts.value)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InkWell(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
@@ -142,12 +151,17 @@ class PostReplyPreview extends HookConsumerWidget {
)
else
Expanded(
child: Text(
child:
Text(
'postHasAttachments',
).plural(post.attachments.length),
style: TextStyle(height: 2),
)
.plural(post.attachments.length)
.padding(top: 2),
),
],
),
),
onTap: () {
onOpen?.call();
context.pushNamed(
@@ -162,12 +176,14 @@ class PostReplyPreview extends HookConsumerWidget {
isOpenable: true,
isCompact: true,
isAutoload: false,
itemMaxWidth: math.max(maxWidth - 24, 200),
onOpen: onOpen,
).padding(left: 24),
],
),
if (loading.value)
Row(
mainAxisSize: MainAxisSize.min,
spacing: 8,
children: [
SizedBox(
@@ -179,8 +195,9 @@ class PostReplyPreview extends HookConsumerWidget {
],
)
else if (posts.value.length < parent.repliesCount)
InkWell(
GestureDetector(
child: Row(
mainAxisSize: MainAxisSize.min,
spacing: 8,
children: [
const Icon(Symbols.keyboard_arrow_down, size: 20),
@@ -194,8 +211,9 @@ class PostReplyPreview extends HookConsumerWidget {
],
)
: (featuredReply!).map(
data:
(data) => Row(
data: (data) => ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
@@ -218,16 +236,15 @@ class PostReplyPreview extends HookConsumerWidget {
),
],
),
error:
(e) => Row(
),
error: (e) => Row(
spacing: 8,
children: [
const Icon(Symbols.close, size: 18),
Text(e.error.toString()),
],
),
loading:
(_) => Row(
loading: (_) => Row(
spacing: 8,
children: [
SizedBox(
@@ -239,10 +256,10 @@ class PostReplyPreview extends HookConsumerWidget {
],
),
);
}
final contentWidget =
isCompact
? itemWidget
final contentWidget = isCompact
? itemBuilder(itemMaxWidth ?? MediaQuery.of(context).size.width)
: Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
@@ -252,8 +269,11 @@ class PostReplyPreview extends HookConsumerWidget {
),
borderRadius: BorderRadius.all(Radius.circular(8)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
width: double.infinity,
child: LayoutBuilder(
builder: (context, constraints) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 4,
children: [
Text('repliesCount')
@@ -261,13 +281,17 @@ class PostReplyPreview extends HookConsumerWidget {
.fontSize(15)
.bold()
.padding(horizontal: 5),
itemWidget,
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: itemBuilder(constraints.maxWidth),
),
],
);
},
),
);
return InkWell(
borderRadius: const BorderRadius.all(Radius.circular(8)),
return GestureDetector(
onTap: () {
showModalBottomSheet(
context: context,
@@ -479,8 +503,9 @@ class ReferencedPostWidget extends StatelessWidget {
referencePost.description!,
style: TextStyle(
fontSize: 12,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
@@ -490,8 +515,7 @@ class ReferencedPostWidget extends StatelessWidget {
content: referencePost.content!,
textStyle: const TextStyle(fontSize: 14),
isSelectable: false,
linesMargin:
referencePost.type == 0
linesMargin: referencePost.type == 0
? const EdgeInsets.only(bottom: 4)
: null,
attachments: item.attachments,
@@ -537,8 +561,7 @@ class ReferencedPostWidget extends StatelessWidget {
}
return content.gestures(
onTap:
() => context.pushNamed(
onTap: () => context.pushNamed(
'postDetail',
pathParameters: {'id': referencePost!.id},
),
@@ -577,8 +600,7 @@ class PostHeader extends StatelessWidget {
spacing: 12,
children: [
GestureDetector(
onTap:
isInteractive
onTap: isInteractive
? () {
context.pushNamed(
'publisherProfile',
@@ -627,8 +649,7 @@ class PostHeader extends StatelessWidget {
),
if (item.realm == null)
Flexible(
child:
isCompact
child: isCompact
? const SizedBox.shrink()
: Text(
'@${item.publisher.name}',
@@ -734,8 +755,7 @@ class PostBody extends ConsumerWidget {
const Icon(Symbols.label, size: 16).padding(top: 2),
for (final tag in isFullPost ? item.tags : item.tags.take(3))
InkWell(
onTap:
isInteractive
onTap: isInteractive
? () {
GoRouter.of(context).pushNamed(
'postTagDetail',
@@ -761,8 +781,7 @@ class PostBody extends ConsumerWidget {
for (final category
in isFullPost ? item.categories : item.categories.take(2))
InkWell(
onTap:
isInteractive
onTap: isInteractive
? () {
GoRouter.of(context).pushNamed(
'postCategoryDetail',
@@ -798,8 +817,7 @@ class PostBody extends ConsumerWidget {
hideOverlay
? text
: Tooltip(
message:
!isFullPost && isRelativeTime
message: !isFullPost && isRelativeTime
? item.editedAt!.formatSystem()
: item.editedAt!.formatRelative(context),
child: text,
@@ -936,8 +954,7 @@ class PostBody extends ConsumerWidget {
],
).padding(bottom: 4),
MarkdownTextContent(
content:
item.isTruncated
content: item.isTruncated
? '${item.content!}...'
: item.content ?? '',
isSelectable: isTextSelectable,

View File

@@ -3,22 +3,26 @@ import 'package:flutter/material.dart';
import 'package:flutter_card_swiper/flutter_card_swiper.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/post/post_item.dart';
import 'package:island/widgets/post/post_list.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart';
const kShufflePostListId = 'shuffle';
class PostShuffleScreen extends HookConsumerWidget {
const PostShuffleScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
const params = PostListQuery(shuffle: true);
final postListState = ref.watch(postListNotifierProvider(params));
final postListNotifier = ref.watch(
postListNotifierProvider(params).notifier,
const query = PostListQuery(shuffle: true);
final cfg = PostListQueryConfig(
id: kShufflePostListId,
initialFilter: query,
);
final postListState = ref.watch(postListProvider(cfg));
final postListNotifier = ref.watch(postListProvider(cfg).notifier);
final cardSwiperController = useMemoized(() => CardSwiperController(), []);
@@ -46,7 +50,8 @@ class PostShuffleScreen extends HookConsumerWidget {
controller: cardSwiperController,
cardsCount: items.length,
isLoop: false,
cardBuilder: (
cardBuilder:
(
context,
index,
horizontalOffsetPercentage,
@@ -62,7 +67,9 @@ class PostShuffleScreen extends HookConsumerWidget {
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
child: PostActionableItem(item: items[index]),
child: PostActionableItem(
item: items[index],
),
),
),
),
@@ -91,8 +98,7 @@ class PostShuffleScreen extends HookConsumerWidget {
bottom: MediaQuery.of(context).padding.bottom,
),
height: kBottomControlHeight,
child:
Row(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(

View File

@@ -0,0 +1,348 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:island/pods/post/post_list.dart';
import 'package:material_symbols_icons/symbols.dart';
class PostFilterWidget extends StatefulWidget {
final TabController categoryTabController;
final PostListQuery initialQuery;
final ValueChanged<PostListQuery> onQueryChanged;
final bool hideSearch;
const PostFilterWidget({
super.key,
required this.categoryTabController,
required this.initialQuery,
required this.onQueryChanged,
this.hideSearch = false,
});
@override
State<PostFilterWidget> createState() => _PostFilterWidgetState();
}
class _PostFilterWidgetState extends State<PostFilterWidget> {
late bool? _includeReplies;
late bool _mediaOnly;
late String? _queryTerm;
late String? _order;
late bool _orderDesc;
late int? _periodStart;
late int? _periodEnd;
late int? _type;
late bool _showAdvancedFilters;
late TextEditingController _searchController;
@override
void initState() {
super.initState();
_includeReplies = widget.initialQuery.includeReplies;
_mediaOnly = widget.initialQuery.mediaOnly ?? false;
_queryTerm = widget.initialQuery.queryTerm;
_order = widget.initialQuery.order;
_orderDesc = widget.initialQuery.orderDesc;
_periodStart = widget.initialQuery.periodStart;
_periodEnd = widget.initialQuery.periodEnd;
_type = widget.initialQuery.type;
_showAdvancedFilters = false;
_searchController = TextEditingController(text: _queryTerm);
widget.categoryTabController.addListener(_onTabChanged);
}
@override
void dispose() {
widget.categoryTabController.removeListener(_onTabChanged);
_searchController.dispose();
super.dispose();
}
void _onTabChanged() {
final tabIndex = widget.categoryTabController.index;
setState(() {
_type = switch (tabIndex) {
1 => 0,
2 => 1,
_ => null,
};
});
_updateQuery();
}
void _updateQuery() {
final newQuery = widget.initialQuery.copyWith(
includeReplies: _includeReplies,
mediaOnly: _mediaOnly,
queryTerm: _queryTerm,
order: _order,
periodStart: _periodStart,
periodEnd: _periodEnd,
orderDesc: _orderDesc,
type: _type,
);
widget.onQueryChanged(newQuery);
}
@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
children: [
TabBar(
controller: widget.categoryTabController,
dividerColor: Colors.transparent,
splashBorderRadius: const BorderRadius.all(Radius.circular(8)),
tabs: [
Tab(text: 'all'.tr()),
Tab(text: 'postTypePost'.tr()),
Tab(text: 'postArticle'.tr()),
],
),
const Divider(height: 1),
Column(
children: [
Row(
children: [
Expanded(
child: CheckboxListTile(
title: Text('reply'.tr()),
value: _includeReplies,
tristate: true,
onChanged: (value) {
// Cycle through: null -> false -> true -> null
setState(() {
if (_includeReplies == null) {
_includeReplies = false;
} else if (_includeReplies == false) {
_includeReplies = true;
} else {
_includeReplies = null;
}
});
_updateQuery();
},
dense: true,
controlAffinity: ListTileControlAffinity.leading,
secondary: const Icon(Symbols.reply),
),
),
Expanded(
child: CheckboxListTile(
title: Text('attachments'.tr()),
value: _mediaOnly,
onChanged: (value) {
setState(() {
if (value != null) {
_mediaOnly = value;
}
});
_updateQuery();
},
dense: true,
controlAffinity: ListTileControlAffinity.leading,
secondary: const Icon(Symbols.attachment),
),
),
],
),
CheckboxListTile(
title: Text('descendingOrder'.tr()),
value: _orderDesc,
onChanged: (value) {
setState(() {
if (value != null) {
_orderDesc = value;
}
});
_updateQuery();
},
dense: true,
controlAffinity: ListTileControlAffinity.leading,
secondary: const Icon(Symbols.sort),
),
],
),
const Divider(height: 1),
ListTile(
title: Text('advancedFilters'.tr()),
leading: const Icon(Symbols.filter_list),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(const Radius.circular(8)),
),
trailing: Icon(
_showAdvancedFilters ? Symbols.expand_less : Symbols.expand_more,
),
onTap: () {
setState(() {
_showAdvancedFilters = !_showAdvancedFilters;
});
},
),
if (_showAdvancedFilters) ...[
const Divider(height: 1),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (!widget.hideSearch)
TextField(
controller: _searchController,
decoration: InputDecoration(
labelText: 'search'.tr(),
hintText: 'searchPosts'.tr(),
prefixIcon: const Icon(Symbols.search),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
),
onChanged: (value) {
setState(() {
_queryTerm = value.isEmpty ? null : value;
});
_updateQuery();
},
),
if (!widget.hideSearch) const Gap(12),
DropdownButtonFormField<String>(
decoration: InputDecoration(
labelText: 'sortBy'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
),
value: _order,
items: [
DropdownMenuItem(value: 'date', child: Text('date'.tr())),
DropdownMenuItem(
value: 'popularity',
child: Text('popularity'.tr()),
),
],
onChanged: (value) {
setState(() {
_order = value;
});
_updateQuery();
},
),
const Gap(12),
Row(
children: [
Expanded(
child: InkWell(
onTap: () async {
final pickedDate = await showDatePicker(
context: context,
initialDate: _periodStart != null
? DateTime.fromMillisecondsSinceEpoch(
_periodStart! * 1000,
)
: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime.now().add(
const Duration(days: 365),
),
);
if (pickedDate != null) {
setState(() {
_periodStart =
pickedDate.millisecondsSinceEpoch ~/ 1000;
});
_updateQuery();
}
},
child: InputDecorator(
decoration: InputDecoration(
labelText: 'fromDate'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
suffixIcon: const Icon(Symbols.calendar_today),
),
child: Text(
_periodStart != null
? DateTime.fromMillisecondsSinceEpoch(
_periodStart! * 1000,
).toString().split(' ')[0]
: 'selectDate'.tr(),
),
),
),
),
const Gap(8),
Expanded(
child: InkWell(
onTap: () async {
final pickedDate = await showDatePicker(
context: context,
initialDate: _periodEnd != null
? DateTime.fromMillisecondsSinceEpoch(
_periodEnd! * 1000,
)
: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime.now().add(
const Duration(days: 365),
),
);
if (pickedDate != null) {
setState(() {
_periodEnd =
pickedDate.millisecondsSinceEpoch ~/ 1000;
});
_updateQuery();
}
},
child: InputDecorator(
decoration: InputDecoration(
labelText: 'toDate'.tr(),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
suffixIcon: const Icon(Symbols.calendar_today),
),
child: Text(
_periodEnd != null
? DateTime.fromMillisecondsSinceEpoch(
_periodEnd! * 1000,
).toString().split(' ')[0]
: 'selectDate'.tr(),
),
),
),
),
],
),
],
),
),
],
],
),
);
}
}

View File

@@ -1,11 +1,10 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/realm.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/paging.dart';
import 'package:island/widgets/paging/pagination_list.dart';
import 'package:island/widgets/realm/realm_card.dart';
import 'package:island/widgets/realm/realm_list_tile.dart';
import 'package:styled_widget/styled_widget.dart';
final realmListNotifierProvider = AsyncNotifierProvider.autoDispose
@@ -51,25 +50,12 @@ class SliverRealmList extends HookConsumerWidget {
notifier: provider.notifier,
isSliver: true,
isRefreshable: false,
spacing: 8,
itemBuilder: (context, index, realm) {
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child:
ConstrainedBox(
return ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 540),
child: RealmCard(realm: realm),
).center(),
),
if (index <
(ref.read(provider).value?.length ?? 0) -
1) // Add gap except for last item? Actually PaginationList handles loading indicator which might look like last item.
// Wait, ref.read(provider).value?.length might change.
// Simpler to just add bottom padding to all, or Gap.
const Gap(8),
],
);
child: RealmListTile(realm: realm),
).center();
},
);
}

Some files were not shown because too many files have changed in this diff Show More