diff --git a/lib/database/drift_db.g.dart b/lib/database/drift_db.g.dart index 0941217c..75cddb9f 100644 --- a/lib/database/drift_db.g.dart +++ b/lib/database/drift_db.g.dart @@ -264,11 +264,10 @@ class $ChatRoomsTable extends ChatRooms ChatRoom map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return ChatRoom( - id: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, name: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}name'], @@ -277,11 +276,10 @@ class $ChatRoomsTable extends ChatRooms DriftSqlType.string, data['${effectivePrefix}description'], ), - type: - attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}type'], - )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, isPublic: attachedDatabase.typeMapping.read( DriftSqlType.bool, data['${effectivePrefix}is_public'], @@ -310,16 +308,14 @@ class $ChatRoomsTable extends ChatRooms DriftSqlType.string, data['${effectivePrefix}account_id'], ), - createdAt: - attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}created_at'], - )!, - updatedAt: - attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}updated_at'], - )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, deletedAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}deleted_at'], @@ -416,41 +412,33 @@ class ChatRoom extends DataClass implements Insertable { return ChatRoomsCompanion( id: Value(id), name: name == null && nullToAbsent ? const Value.absent() : Value(name), - description: - description == null && nullToAbsent - ? const Value.absent() - : Value(description), + description: description == null && nullToAbsent + ? const Value.absent() + : Value(description), type: Value(type), - isPublic: - isPublic == null && nullToAbsent - ? const Value.absent() - : Value(isPublic), - isCommunity: - isCommunity == null && nullToAbsent - ? const Value.absent() - : Value(isCommunity), - picture: - picture == null && nullToAbsent - ? const Value.absent() - : Value(picture), - background: - background == null && nullToAbsent - ? const Value.absent() - : Value(background), - realmId: - realmId == null && nullToAbsent - ? const Value.absent() - : Value(realmId), - accountId: - accountId == null && nullToAbsent - ? const Value.absent() - : Value(accountId), + isPublic: isPublic == null && nullToAbsent + ? const Value.absent() + : Value(isPublic), + isCommunity: isCommunity == null && nullToAbsent + ? const Value.absent() + : Value(isCommunity), + picture: picture == null && nullToAbsent + ? const Value.absent() + : Value(picture), + background: background == null && nullToAbsent + ? const Value.absent() + : Value(background), + realmId: realmId == null && nullToAbsent + ? const Value.absent() + : Value(realmId), + accountId: accountId == null && nullToAbsent + ? const Value.absent() + : Value(accountId), createdAt: Value(createdAt), updatedAt: Value(updatedAt), - deletedAt: - deletedAt == null && nullToAbsent - ? const Value.absent() - : Value(deletedAt), + deletedAt: deletedAt == null && nullToAbsent + ? const Value.absent() + : Value(deletedAt), ); } @@ -530,15 +518,18 @@ class ChatRoom extends DataClass implements Insertable { 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,21 +1035,18 @@ class $ChatMembersTable extends ChatMembers ChatMember map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return ChatMember( - id: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - chatRoomId: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}chat_room_id'], - )!, - accountId: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}account_id'], - )!, + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + chatRoomId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}chat_room_id'], + )!, + accountId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}account_id'], + )!, account: $ChatMembersTable.$converteraccount.fromSql( attachedDatabase.typeMapping.read( DriftSqlType.string, @@ -1069,11 +1057,10 @@ class $ChatMembersTable extends ChatMembers DriftSqlType.string, data['${effectivePrefix}nick'], ), - notify: - attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}notify'], - )!, + notify: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}notify'], + )!, joinedAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}joined_at'], @@ -1086,16 +1073,14 @@ class $ChatMembersTable extends ChatMembers DriftSqlType.dateTime, data['${effectivePrefix}timeout_until'], ), - createdAt: - attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}created_at'], - )!, - updatedAt: - attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}updated_at'], - )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}created_at'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, deletedAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}deleted_at'], @@ -1179,24 +1164,20 @@ class ChatMember extends DataClass implements Insertable { account: Value(account), nick: nick == null && nullToAbsent ? const Value.absent() : Value(nick), notify: Value(notify), - joinedAt: - joinedAt == null && nullToAbsent - ? const Value.absent() - : Value(joinedAt), - breakUntil: - breakUntil == null && nullToAbsent - ? const Value.absent() - : Value(breakUntil), - timeoutUntil: - timeoutUntil == null && nullToAbsent - ? const Value.absent() - : Value(timeoutUntil), + joinedAt: joinedAt == null && nullToAbsent + ? const Value.absent() + : Value(joinedAt), + breakUntil: breakUntil == null && nullToAbsent + ? const Value.absent() + : Value(breakUntil), + timeoutUntil: timeoutUntil == null && nullToAbsent + ? const Value.absent() + : Value(timeoutUntil), createdAt: Value(createdAt), updatedAt: Value(updatedAt), - deletedAt: - deletedAt == null && nullToAbsent - ? const Value.absent() - : Value(deletedAt), + deletedAt: deletedAt == null && nullToAbsent + ? const Value.absent() + : Value(deletedAt), ); } @@ -1269,19 +1250,20 @@ class ChatMember extends DataClass implements Insertable { 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 - ? data.timeoutUntil.value - : this.timeoutUntil, + 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, updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, @@ -1695,31 +1677,33 @@ class $ChatMessagesTable extends ChatMessages List>, String > - attachments = GeneratedColumn( - 'attachments', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - defaultValue: const Constant('[]'), - ).withConverter>>( - $ChatMessagesTable.$converterattachments, - ); + attachments = + GeneratedColumn( + 'attachments', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant('[]'), + ).withConverter>>( + $ChatMessagesTable.$converterattachments, + ); @override late final GeneratedColumnWithTypeConverter< List>, String > - reactions = GeneratedColumn( - 'reactions', - aliasedName, - false, - type: DriftSqlType.string, - requiredDuringInsert: false, - defaultValue: const Constant('[]'), - ).withConverter>>( - $ChatMessagesTable.$converterreactions, - ); + reactions = + GeneratedColumn( + 'reactions', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant('[]'), + ).withConverter>>( + $ChatMessagesTable.$converterreactions, + ); static const VerificationMeta _repliedMessageIdMeta = const VerificationMeta( 'repliedMessageId', ); @@ -1882,21 +1866,18 @@ class $ChatMessagesTable extends ChatMessages ChatMessage map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return ChatMessage( - id: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, - roomId: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}room_id'], - )!, - senderId: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}sender_id'], - )!, + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + roomId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}room_id'], + )!, + senderId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}sender_id'], + )!, content: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}content'], @@ -1905,16 +1886,14 @@ class $ChatMessagesTable extends ChatMessages DriftSqlType.string, data['${effectivePrefix}nonce'], ), - data: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}data'], - )!, - createdAt: - attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}created_at'], - )!, + data: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}data'], + )!, + createdAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}created_at'], + )!, status: $ChatMessagesTable.$converterstatus.fromSql( attachedDatabase.typeMapping.read( DriftSqlType.int, @@ -1933,11 +1912,10 @@ class $ChatMessagesTable extends ChatMessages DriftSqlType.dateTime, data['${effectivePrefix}deleted_at'], ), - type: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}type'], - )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}type'], + )!, meta: $ChatMessagesTable.$convertermeta.fromSql( attachedDatabase.typeMapping.read( DriftSqlType.string, @@ -2101,44 +2079,38 @@ class ChatMessage extends DataClass implements Insertable { id: Value(id), roomId: Value(roomId), senderId: Value(senderId), - content: - content == null && nullToAbsent - ? const Value.absent() - : Value(content), - nonce: - nonce == null && nullToAbsent ? const Value.absent() : Value(nonce), + content: content == null && nullToAbsent + ? const Value.absent() + : Value(content), + nonce: nonce == null && nullToAbsent + ? const Value.absent() + : Value(nonce), data: Value(data), createdAt: Value(createdAt), status: Value(status), - isDeleted: - isDeleted == null && nullToAbsent - ? const Value.absent() - : Value(isDeleted), - updatedAt: - updatedAt == null && nullToAbsent - ? const Value.absent() - : Value(updatedAt), - deletedAt: - deletedAt == null && nullToAbsent - ? const Value.absent() - : Value(deletedAt), + isDeleted: isDeleted == null && nullToAbsent + ? const Value.absent() + : Value(isDeleted), + updatedAt: updatedAt == null && nullToAbsent + ? const Value.absent() + : Value(updatedAt), + deletedAt: deletedAt == null && nullToAbsent + ? const Value.absent() + : Value(deletedAt), type: Value(type), meta: Value(meta), membersMentioned: Value(membersMentioned), - editedAt: - editedAt == null && nullToAbsent - ? const Value.absent() - : Value(editedAt), + editedAt: editedAt == null && nullToAbsent + ? const Value.absent() + : Value(editedAt), attachments: Value(attachments), reactions: Value(reactions), - repliedMessageId: - repliedMessageId == null && nullToAbsent - ? const Value.absent() - : Value(repliedMessageId), - forwardedMessageId: - forwardedMessageId == null && nullToAbsent - ? const Value.absent() - : Value(forwardedMessageId), + repliedMessageId: repliedMessageId == null && nullToAbsent + ? const Value.absent() + : Value(repliedMessageId), + forwardedMessageId: forwardedMessageId == null && nullToAbsent + ? const Value.absent() + : Value(forwardedMessageId), ); } @@ -2245,14 +2217,12 @@ class ChatMessage extends DataClass implements Insertable { editedAt: editedAt.present ? editedAt.value : this.editedAt, attachments: attachments ?? this.attachments, reactions: reactions ?? this.reactions, - repliedMessageId: - repliedMessageId.present - ? repliedMessageId.value - : this.repliedMessageId, - forwardedMessageId: - forwardedMessageId.present - ? forwardedMessageId.value - : this.forwardedMessageId, + repliedMessageId: repliedMessageId.present + ? repliedMessageId.value + : this.repliedMessageId, + forwardedMessageId: forwardedMessageId.present + ? forwardedMessageId.value + : this.forwardedMessageId, ); ChatMessage copyWithCompanion(ChatMessagesCompanion data) { return ChatMessage( @@ -2269,22 +2239,20 @@ class ChatMessage extends DataClass implements Insertable { 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 - ? data.membersMentioned.value - : this.membersMentioned, + 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 - ? data.repliedMessageId.value - : this.repliedMessageId, - forwardedMessageId: - data.forwardedMessageId.present - ? data.forwardedMessageId.value - : this.forwardedMessageId, + repliedMessageId: data.repliedMessageId.present + ? data.repliedMessageId.value + : this.repliedMessageId, + forwardedMessageId: data.forwardedMessageId.present + ? data.forwardedMessageId.value + : this.forwardedMessageId, ); } @@ -2809,11 +2777,10 @@ class $PostDraftsTable extends PostDrafts PostDraft map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return PostDraft( - id: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}id'], - )!, + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, title: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}title'], @@ -2826,26 +2793,22 @@ class $PostDraftsTable extends PostDrafts DriftSqlType.string, data['${effectivePrefix}content'], ), - visibility: - attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}visibility'], - )!, - type: - attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}type'], - )!, - lastModified: - attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}last_modified'], - )!, - postData: - attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}post_data'], - )!, + visibility: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}visibility'], + )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, + lastModified: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}last_modified'], + )!, + postData: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}post_data'], + )!, ); } @@ -2897,16 +2860,15 @@ class PostDraft extends DataClass implements Insertable { PostDraftsCompanion toCompanion(bool nullToAbsent) { return PostDraftsCompanion( id: Value(id), - title: - title == null && nullToAbsent ? const Value.absent() : Value(title), - description: - description == null && nullToAbsent - ? const Value.absent() - : Value(description), - content: - content == null && nullToAbsent - ? const Value.absent() - : Value(content), + title: title == null && nullToAbsent + ? const Value.absent() + : Value(title), + description: description == null && nullToAbsent + ? const Value.absent() + : Value(description), + content: content == null && nullToAbsent + ? const Value.absent() + : Value(content), visibility: Value(visibility), type: Value(type), lastModified: Value(lastModified), @@ -2968,16 +2930,17 @@ class PostDraft extends DataClass implements Insertable { 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 - ? data.lastModified.value - : this.lastModified, + 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 id = const Value.absent(), @@ -3655,76 +3618,71 @@ class $$ChatRoomsTableTableManager deletedAt: deletedAt, rowid: rowid, ), - withReferenceMapper: - (p0) => - p0 - .map( - (e) => ( - e.readTable(table), - $$ChatRoomsTableReferences(db, table, e), - ), - ) - .toList(), - prefetchHooksCallback: ({ - chatMembersRefs = false, - chatMessagesRefs = false, - }) { - return PrefetchHooks( - db: db, - explicitlyWatchedTables: [ - if (chatMembersRefs) db.chatMembers, - if (chatMessagesRefs) db.chatMessages, - ], - addJoins: null, - getPrefetchedDataCallback: (items) async { - return [ - if (chatMembersRefs) - await $_getPrefetchedData< - ChatRoom, - $ChatRoomsTable, - ChatMember - >( - currentTable: table, - referencedTable: $$ChatRoomsTableReferences - ._chatMembersRefsTable(db), - managerFromTypedResult: - (p0) => + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$ChatRoomsTableReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: + ({chatMembersRefs = false, chatMessagesRefs = false}) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [ + if (chatMembersRefs) db.chatMembers, + if (chatMessagesRefs) db.chatMessages, + ], + addJoins: null, + getPrefetchedDataCallback: (items) async { + return [ + if (chatMembersRefs) + await $_getPrefetchedData< + ChatRoom, + $ChatRoomsTable, + ChatMember + >( + currentTable: table, + referencedTable: $$ChatRoomsTableReferences + ._chatMembersRefsTable(db), + managerFromTypedResult: (p0) => $$ChatRoomsTableReferences( db, table, p0, ).chatMembersRefs, - referencedItemsForCurrentItem: - (item, referencedItems) => referencedItems.where( - (e) => e.chatRoomId == item.id, - ), - typedResults: items, - ), - if (chatMessagesRefs) - await $_getPrefetchedData< - ChatRoom, - $ChatRoomsTable, - ChatMessage - >( - currentTable: table, - referencedTable: $$ChatRoomsTableReferences - ._chatMessagesRefsTable(db), - managerFromTypedResult: - (p0) => + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.chatRoomId == item.id, + ), + typedResults: items, + ), + if (chatMessagesRefs) + await $_getPrefetchedData< + ChatRoom, + $ChatRoomsTable, + ChatMessage + >( + currentTable: table, + referencedTable: $$ChatRoomsTableReferences + ._chatMessagesRefsTable(db), + managerFromTypedResult: (p0) => $$ChatRoomsTableReferences( db, table, p0, ).chatMessagesRefs, - referencedItemsForCurrentItem: - (item, referencedItems) => - referencedItems.where((e) => e.roomId == item.id), - typedResults: items, - ), - ]; + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.roomId == item.id, + ), + typedResults: items, + ), + ]; + }, + ); }, - ); - }, ), ); } @@ -4142,13 +4100,12 @@ class $$ChatMembersTableTableManager TableManagerState( db: db, table: table, - createFilteringComposer: - () => $$ChatMembersTableFilterComposer($db: db, $table: table), - createOrderingComposer: - () => $$ChatMembersTableOrderingComposer($db: db, $table: table), - createComputedFieldComposer: - () => - $$ChatMembersTableAnnotationComposer($db: db, $table: table), + createFilteringComposer: () => + $$ChatMembersTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$ChatMembersTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$ChatMembersTableAnnotationComposer($db: db, $table: table), updateCompanionCallback: ({ Value id = const Value.absent(), @@ -4209,83 +4166,82 @@ class $$ChatMembersTableTableManager deletedAt: deletedAt, rowid: rowid, ), - withReferenceMapper: - (p0) => - p0 - .map( - (e) => ( - e.readTable(table), - $$ChatMembersTableReferences(db, table, e), - ), - ) - .toList(), - prefetchHooksCallback: ({ - chatRoomId = false, - chatMessagesRefs = false, - }) { - return PrefetchHooks( - db: db, - explicitlyWatchedTables: [if (chatMessagesRefs) db.chatMessages], - addJoins: < - T extends TableManagerState< - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic - > - >(state) { - if (chatRoomId) { - state = - state.withJoin( - currentTable: table, - currentColumn: table.chatRoomId, - referencedTable: $$ChatMembersTableReferences - ._chatRoomIdTable(db), - referencedColumn: - $$ChatMembersTableReferences - ._chatRoomIdTable(db) - .id, - ) - as T; - } + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$ChatMembersTableReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: + ({chatRoomId = false, chatMessagesRefs = false}) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [ + if (chatMessagesRefs) db.chatMessages, + ], + addJoins: + < + T extends TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic + > + >(state) { + if (chatRoomId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.chatRoomId, + referencedTable: + $$ChatMembersTableReferences + ._chatRoomIdTable(db), + referencedColumn: + $$ChatMembersTableReferences + ._chatRoomIdTable(db) + .id, + ) + as T; + } - return state; - }, - getPrefetchedDataCallback: (items) async { - return [ - if (chatMessagesRefs) - await $_getPrefetchedData< - ChatMember, - $ChatMembersTable, - ChatMessage - >( - currentTable: table, - referencedTable: $$ChatMembersTableReferences - ._chatMessagesRefsTable(db), - managerFromTypedResult: - (p0) => + return state; + }, + getPrefetchedDataCallback: (items) async { + return [ + if (chatMessagesRefs) + await $_getPrefetchedData< + ChatMember, + $ChatMembersTable, + ChatMessage + >( + currentTable: table, + referencedTable: $$ChatMembersTableReferences + ._chatMessagesRefsTable(db), + managerFromTypedResult: (p0) => $$ChatMembersTableReferences( db, table, p0, ).chatMessagesRefs, - referencedItemsForCurrentItem: - (item, referencedItems) => referencedItems.where( - (e) => e.senderId == item.id, - ), - typedResults: items, - ), - ]; + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.senderId == item.id, + ), + typedResults: items, + ), + ]; + }, + ); }, - ); - }, ), ); } @@ -4831,13 +4787,12 @@ class $$ChatMessagesTableTableManager TableManagerState( db: db, table: table, - createFilteringComposer: - () => $$ChatMessagesTableFilterComposer($db: db, $table: table), - createOrderingComposer: - () => $$ChatMessagesTableOrderingComposer($db: db, $table: table), - createComputedFieldComposer: - () => - $$ChatMessagesTableAnnotationComposer($db: db, $table: table), + createFilteringComposer: () => + $$ChatMessagesTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$ChatMessagesTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$ChatMessagesTableAnnotationComposer($db: db, $table: table), updateCompanionCallback: ({ Value id = const Value.absent(), @@ -4930,66 +4885,63 @@ class $$ChatMessagesTableTableManager forwardedMessageId: forwardedMessageId, rowid: rowid, ), - withReferenceMapper: - (p0) => - p0 - .map( - (e) => ( - e.readTable(table), - $$ChatMessagesTableReferences(db, table, e), - ), - ) - .toList(), + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$ChatMessagesTableReferences(db, table, e), + ), + ) + .toList(), prefetchHooksCallback: ({roomId = false, senderId = false}) { return PrefetchHooks( db: db, explicitlyWatchedTables: [], - addJoins: < - T extends TableManagerState< - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic, - dynamic - > - >(state) { - if (roomId) { - state = - state.withJoin( - currentTable: table, - currentColumn: table.roomId, - referencedTable: $$ChatMessagesTableReferences - ._roomIdTable(db), - referencedColumn: - $$ChatMessagesTableReferences + addJoins: + < + T extends TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic + > + >(state) { + if (roomId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.roomId, + referencedTable: $$ChatMessagesTableReferences + ._roomIdTable(db), + referencedColumn: $$ChatMessagesTableReferences ._roomIdTable(db) .id, - ) - as T; - } - if (senderId) { - state = - state.withJoin( - currentTable: table, - currentColumn: table.senderId, - referencedTable: $$ChatMessagesTableReferences - ._senderIdTable(db), - referencedColumn: - $$ChatMessagesTableReferences + ) + as T; + } + if (senderId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.senderId, + referencedTable: $$ChatMessagesTableReferences + ._senderIdTable(db), + referencedColumn: $$ChatMessagesTableReferences ._senderIdTable(db) .id, - ) - as T; - } + ) + as T; + } - return state; - }, + return state; + }, getPrefetchedDataCallback: (items) async { return []; }, @@ -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 id = const Value.absent(), @@ -5251,16 +5203,9 @@ class $$PostDraftsTableTableManager postData: postData, rowid: rowid, ), - withReferenceMapper: - (p0) => - p0 - .map( - (e) => ( - e.readTable(table), - BaseReferences(db, table, e), - ), - ) - .toList(), + withReferenceMapper: (p0) => p0 + .map((e) => (e.readTable(table), BaseReferences(db, table, e))) + .toList(), prefetchHooksCallback: null, ), ); diff --git a/lib/models/abuse_report.g.dart b/lib/models/abuse_report.g.dart index bb6010ca..7fa3f367 100644 --- a/lib/models/abuse_report.g.dart +++ b/lib/models/abuse_report.g.dart @@ -12,18 +12,16 @@ _SnAbuseReport _$SnAbuseReportFromJson(Map json) => resourceIdentifier: json['resource_identifier'] as String, type: (json['type'] as num).toInt(), reason: json['reason'] as String, - resolvedAt: - json['resolved_at'] == null - ? null - : DateTime.parse(json['resolved_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAbuseReportToJson(_SnAbuseReport instance) => diff --git a/lib/models/account.g.dart b/lib/models/account.g.dart index 57307a19..b5fac57f 100644 --- a/lib/models/account.g.dart +++ b/lib/models/account.g.dart @@ -15,12 +15,11 @@ _SnAccount _$SnAccountFromJson(Map json) => _SnAccount( isSuperuser: json['is_superuser'] as bool, automatedId: json['automated_id'] as String?, profile: SnAccountProfile.fromJson(json['profile'] as Map), - perkSubscription: - json['perk_subscription'] == null - ? null - : SnWalletSubscriptionRef.fromJson( - json['perk_subscription'] as Map, - ), + perkSubscription: json['perk_subscription'] == null + ? null + : SnWalletSubscriptionRef.fromJson( + json['perk_subscription'] as Map, + ), badges: (json['badges'] as List?) ?.map((e) => SnAccountBadge.fromJson(e as Map)) @@ -31,16 +30,14 @@ _SnAccount _$SnAccountFromJson(Map json) => _SnAccount( ?.map((e) => SnContactMethod.fromJson(e as Map)) .toList() ?? const [], - activatedAt: - json['activated_at'] == null - ? null - : DateTime.parse(json['activated_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAccountToJson(_SnAccount instance) => @@ -73,8 +70,9 @@ _UsernameColor _$UsernameColorFromJson(Map json) => type: json['type'] as String? ?? 'plain', value: json['value'] as String?, direction: json['direction'] as String?, - colors: - (json['colors'] as List?)?.map((e) => e as String).toList(), + colors: (json['colors'] as List?) + ?.map((e) => e as String) + .toList(), ); Map _$UsernameColorToJson(_UsernameColor instance) => @@ -85,69 +83,55 @@ Map _$UsernameColorToJson(_UsernameColor instance) => 'colors': instance.colors, }; -_SnAccountProfile _$SnAccountProfileFromJson(Map json) => - _SnAccountProfile( - id: json['id'] as String, - firstName: json['first_name'] as String? ?? '', - middleName: json['middle_name'] as String? ?? '', - lastName: json['last_name'] as String? ?? '', - bio: json['bio'] as String? ?? '', - gender: json['gender'] as String? ?? '', - pronouns: json['pronouns'] as String? ?? '', - location: json['location'] as String? ?? '', - timeZone: json['time_zone'] as String? ?? '', - birthday: - json['birthday'] == null - ? null - : DateTime.parse(json['birthday'] as String), - links: - json['links'] == null - ? const [] - : const ProfileLinkConverter().fromJson(json['links']), - lastSeenAt: - json['last_seen_at'] == null - ? null - : DateTime.parse(json['last_seen_at'] as String), - activeBadge: - json['active_badge'] == null - ? null - : SnAccountBadge.fromJson( - json['active_badge'] as Map, - ), - 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 - ? null - : SnCloudFile.fromJson(json['picture'] as Map), - background: - json['background'] == null - ? null - : SnCloudFile.fromJson( - json['background'] as Map, - ), - verification: - json['verification'] == null - ? null - : SnVerificationMark.fromJson( - json['verification'] as Map, - ), - usernameColor: - json['username_color'] == null - ? null - : UsernameColor.fromJson( - json['username_color'] as Map, - ), - createdAt: DateTime.parse(json['created_at'] as String), - updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), - ); +_SnAccountProfile _$SnAccountProfileFromJson( + Map json, +) => _SnAccountProfile( + id: json['id'] as String, + firstName: json['first_name'] as String? ?? '', + middleName: json['middle_name'] as String? ?? '', + lastName: json['last_name'] as String? ?? '', + bio: json['bio'] as String? ?? '', + gender: json['gender'] as String? ?? '', + pronouns: json['pronouns'] as String? ?? '', + location: json['location'] as String? ?? '', + timeZone: json['time_zone'] as String? ?? '', + birthday: json['birthday'] == null + ? null + : DateTime.parse(json['birthday'] as String), + links: json['links'] == null + ? const [] + : const ProfileLinkConverter().fromJson(json['links']), + lastSeenAt: json['last_seen_at'] == null + ? null + : DateTime.parse(json['last_seen_at'] as String), + activeBadge: json['active_badge'] == null + ? null + : SnAccountBadge.fromJson(json['active_badge'] as Map), + 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 + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), + verification: json['verification'] == null + ? null + : SnVerificationMark.fromJson( + json['verification'] as Map, + ), + usernameColor: json['username_color'] == null + ? null + : UsernameColor.fromJson(json['username_color'] as Map), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), +); Map _$SnAccountProfileToJson(_SnAccountProfile instance) => { @@ -188,17 +172,15 @@ _SnAccountStatus _$SnAccountStatusFromJson(Map json) => isCustomized: json['is_customized'] as bool, label: json['label'] as String? ?? "", meta: json['meta'] as Map?, - clearedAt: - json['cleared_at'] == null - ? null - : DateTime.parse(json['cleared_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAccountStatusToJson(_SnAccountStatus instance) => @@ -225,21 +207,18 @@ _SnAccountBadge _$SnAccountBadgeFromJson(Map json) => label: json['label'] as String?, caption: json['caption'] as String?, meta: json['meta'] as Map, - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + 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 - ? null - : DateTime.parse(json['activated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + activatedAt: json['activated_at'] == null + ? null + : DateTime.parse(json['activated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAccountBadgeToJson(_SnAccountBadge instance) => @@ -261,20 +240,18 @@ _SnContactMethod _$SnContactMethodFromJson(Map json) => _SnContactMethod( id: json['id'] as String, type: (json['type'] as num).toInt(), - verifiedAt: - json['verified_at'] == null - ? null - : DateTime.parse(json['verified_at'] as String), + verifiedAt: json['verified_at'] == null + ? null + : DateTime.parse(json['verified_at'] as String), isPrimary: json['is_primary'] as bool, isPublic: json['is_public'] as bool, content: json['content'] 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnContactMethodToJson(_SnContactMethod instance) => @@ -295,10 +272,9 @@ _SnNotification _$SnNotificationFromJson(Map json) => _SnNotification( createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), id: json['id'] as String, topic: json['topic'] as String, title: json['title'] as String, @@ -306,10 +282,9 @@ _SnNotification _$SnNotificationFromJson(Map json) => content: json['content'] as String, meta: json['meta'] as Map? ?? const {}, priority: (json['priority'] as num).toInt(), - viewedAt: - json['viewed_at'] == null - ? null - : DateTime.parse(json['viewed_at'] as String), + viewedAt: json['viewed_at'] == null + ? null + : DateTime.parse(json['viewed_at'] as String), accountId: json['account_id'] as String, ); @@ -376,10 +351,9 @@ _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) - .map((e) => SnAuthSession.fromJson(e as Map)) - .toList(), + sessions: (json['sessions'] as List) + .map((e) => SnAuthSession.fromJson(e as Map)) + .toList(), isCurrent: json['is_current'] as bool? ?? false, ); @@ -405,10 +379,9 @@ _SnExperienceRecord _$SnExperienceRecordFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnExperienceRecordToJson(_SnExperienceRecord instance) => @@ -430,16 +403,14 @@ _SnSocialCreditRecord _$SnSocialCreditRecordFromJson( delta: (json['delta'] as num).toDouble(), reasonType: json['reason_type'] as String, reason: json['reason'] as String, - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnSocialCreditRecordToJson( @@ -460,10 +431,9 @@ _SnFriendOverviewItem _$SnFriendOverviewItemFromJson( ) => _SnFriendOverviewItem( account: SnAccount.fromJson(json['account'] as Map), status: SnAccountStatus.fromJson(json['status'] as Map), - activities: - (json['activities'] as List) - .map((e) => SnPresenceActivity.fromJson(e as Map)) - .toList(), + activities: (json['activities'] as List) + .map((e) => SnPresenceActivity.fromJson(e as Map)) + .toList(), ); Map _$SnFriendOverviewItemToJson( diff --git a/lib/models/activity.g.dart b/lib/models/activity.g.dart index 1b7d45df..87f8a7d6 100644 --- a/lib/models/activity.g.dart +++ b/lib/models/activity.g.dart @@ -12,10 +12,9 @@ _SnNotableDay _$SnNotableDayFromJson(Map json) => localName: json['local_name'] as String, globalName: json['global_name'] as String, countryCode: json['country_code'] as String, - holidays: - (json['holidays'] as List) - .map((e) => (e as num).toInt()) - .toList(), + holidays: (json['holidays'] as List) + .map((e) => (e as num).toInt()) + .toList(), ); Map _$SnNotableDayToJson(_SnNotableDay instance) => @@ -35,10 +34,9 @@ _SnTimelineEvent _$SnTimelineEventFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnTimelineEventToJson(_SnTimelineEvent instance) => @@ -56,21 +54,18 @@ _SnCheckInResult _$SnCheckInResultFromJson(Map json) => _SnCheckInResult( id: json['id'] as String, level: (json['level'] as num).toInt(), - tips: - (json['tips'] as List) - .map((e) => SnFortuneTip.fromJson(e as Map)) - .toList(), + tips: (json['tips'] as List) + .map((e) => SnFortuneTip.fromJson(e as Map)) + .toList(), accountId: json['account_id'] as String, - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnCheckInResultToJson(_SnCheckInResult instance) => @@ -103,16 +98,14 @@ _SnEventCalendarEntry _$SnEventCalendarEntryFromJson( Map json, ) => _SnEventCalendarEntry( date: DateTime.parse(json['date'] as String), - checkInResult: - json['check_in_result'] == null - ? null - : SnCheckInResult.fromJson( - json['check_in_result'] as Map, - ), - statuses: - (json['statuses'] as List) - .map((e) => SnAccountStatus.fromJson(e as Map)) - .toList(), + checkInResult: json['check_in_result'] == null + ? null + : SnCheckInResult.fromJson( + json['check_in_result'] as Map, + ), + statuses: (json['statuses'] as List) + .map((e) => SnAccountStatus.fromJson(e as Map)) + .toList(), ); Map _$SnEventCalendarEntryToJson( @@ -141,10 +134,9 @@ _SnPresenceActivity _$SnPresenceActivityFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPresenceActivityToJson(_SnPresenceActivity instance) => diff --git a/lib/models/auth.g.dart b/lib/models/auth.g.dart index 0bdf5fa4..3746f62f 100644 --- a/lib/models/auth.g.dart +++ b/lib/models/auth.g.dart @@ -34,35 +34,29 @@ Map _$GeoIpLocationToJson(_GeoIpLocation instance) => _SnAuthChallenge _$SnAuthChallengeFromJson(Map json) => _SnAuthChallenge( id: json['id'] as String, - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + 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) - .map((e) => e as String) - .toList(), + blacklistFactors: (json['blacklist_factors'] as List) + .map((e) => e as String) + .toList(), audiences: json['audiences'] as List, scopes: json['scopes'] as List, ipAddress: json['ip_address'] as String, userAgent: json['user_agent'] as String, nonce: json['nonce'] as String?, - location: - json['location'] == null - ? null - : GeoIpLocation.fromJson( - json['location'] as Map, - ), + location: json['location'] == null + ? null + : GeoIpLocation.fromJson(json['location'] as Map), 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAuthChallengeToJson(_SnAuthChallenge instance) => @@ -90,28 +84,23 @@ _SnAuthSession _$SnAuthSessionFromJson(Map 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 - ? null - : DateTime.parse(json['expired_at'] as String), + expiredAt: json['expired_at'] == null + ? null + : DateTime.parse(json['expired_at'] as String), audiences: json['audiences'] as List, scopes: json['scopes'] as List, ipAddress: json['ip_address'] as String?, userAgent: json['user_agent'] as String?, - location: - json['location'] == null - ? null - : GeoIpLocation.fromJson( - json['location'] as Map, - ), + location: json['location'] == null + ? null + : GeoIpLocation.fromJson(json['location'] as Map), 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAuthSessionToJson(_SnAuthSession instance) => @@ -138,18 +127,15 @@ _SnAuthFactor _$SnAuthFactorFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), - enabledAt: - json['enabled_at'] == null - ? null - : DateTime.parse(json['enabled_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + expiredAt: json['expired_at'] == null + ? null + : DateTime.parse(json['expired_at'] as String), + enabledAt: json['enabled_at'] == null + ? null + : DateTime.parse(json['enabled_at'] as String), trustworthy: (json['trustworthy'] as num).toInt(), createdResponse: json['created_response'] as Map?, ); @@ -177,10 +163,9 @@ _SnAccountConnection _$SnAccountConnectionFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnAccountConnectionToJson( diff --git a/lib/models/auto_completion.g.dart b/lib/models/auto_completion.g.dart index a0b7d178..afa7b927 100644 --- a/lib/models/auto_completion.g.dart +++ b/lib/models/auto_completion.g.dart @@ -10,10 +10,9 @@ AutoCompletionAccountResponse _$AutoCompletionAccountResponseFromJson( Map json, ) => AutoCompletionAccountResponse( type: json['type'] as String, - items: - (json['items'] as List) - .map((e) => AutoCompletionItem.fromJson(e as Map)) - .toList(), + items: (json['items'] as List) + .map((e) => AutoCompletionItem.fromJson(e as Map)) + .toList(), $type: json['runtimeType'] as String?, ); @@ -29,10 +28,9 @@ AutoCompletionStickerResponse _$AutoCompletionStickerResponseFromJson( Map json, ) => AutoCompletionStickerResponse( type: json['type'] as String, - items: - (json['items'] as List) - .map((e) => AutoCompletionItem.fromJson(e as Map)) - .toList(), + items: (json['items'] as List) + .map((e) => AutoCompletionItem.fromJson(e as Map)) + .toList(), $type: json['runtimeType'] as String?, ); diff --git a/lib/models/bot.g.dart b/lib/models/bot.g.dart index 49e25c28..8ad4f348 100644 --- a/lib/models/bot.g.dart +++ b/lib/models/bot.g.dart @@ -14,10 +14,9 @@ _Bot _$BotFromJson(Map 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), - developer: - json['developer'] == null - ? null - : SnDeveloper.fromJson(json['developer'] as Map), + developer: json['developer'] == null + ? null + : SnDeveloper.fromJson(json['developer'] as Map), ); Map _$BotToJson(_Bot instance) => { @@ -74,10 +73,9 @@ _BotSecret _$BotSecretFromJson(Map json) => _BotSecret( id: json['id'] as String? ?? '', secret: json['secret'] as String? ?? '', description: json['description'] as String?, - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + expiredAt: json['expired_at'] == null + ? null + : DateTime.parse(json['expired_at'] as String), botId: json['bot_id'] as String? ?? '', ); diff --git a/lib/models/chat.g.dart b/lib/models/chat.g.dart index 60c3bc0c..3595d029 100644 --- a/lib/models/chat.g.dart +++ b/lib/models/chat.g.dart @@ -13,30 +13,25 @@ _SnChatRoom _$SnChatRoomFromJson(Map 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 - ? null - : SnCloudFile.fromJson(json['picture'] as Map), - background: - json['background'] == null - ? null - : SnCloudFile.fromJson(json['background'] as Map), + picture: json['picture'] == null + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), realmId: json['realm_id'] as String?, accountId: json['account_id'] as String?, - realm: - json['realm'] == null - ? null - : SnRealm.fromJson(json['realm'] as Map), + realm: json['realm'] == null + ? null + : SnRealm.fromJson(json['realm'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), - members: - (json['members'] as List?) - ?.map((e) => SnChatMember.fromJson(e as Map)) - .toList(), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + members: (json['members'] as List?) + ?.map((e) => SnChatMember.fromJson(e as Map)) + .toList(), ); Map _$SnChatRoomToJson(_SnChatRoom instance) => @@ -62,10 +57,9 @@ _SnChatMessage _$SnChatMessageFromJson(Map json) => _SnChatMessage( createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), id: json['id'] as String, type: json['type'] as String? ?? 'text', content: json['content'] as String?, @@ -76,10 +70,9 @@ _SnChatMessage _$SnChatMessageFromJson(Map json) => ?.map((e) => e as String) .toList() ?? const [], - editedAt: - json['edited_at'] == null - ? null - : DateTime.parse(json['edited_at'] as String), + editedAt: json['edited_at'] == null + ? null + : DateTime.parse(json['edited_at'] as String), attachments: (json['attachments'] as List?) ?.map((e) => SnCloudFile.fromJson(e as Map)) @@ -122,10 +115,9 @@ _SnChatReaction _$SnChatReactionFromJson(Map json) => _SnChatReaction( createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), id: json['id'] as String, messageId: json['message_id'] as String, senderId: json['sender_id'] as String, @@ -151,42 +143,33 @@ _SnChatMember _$SnChatMemberFromJson(Map json) => _SnChatMember( createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + 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 - ? null - : SnChatRoom.fromJson(json['chat_room'] as Map), + chatRoom: json['chat_room'] == null + ? null + : SnChatRoom.fromJson(json['chat_room'] as Map), accountId: json['account_id'] as String, account: SnAccount.fromJson(json['account'] as Map), nick: json['nick'] as String?, notify: (json['notify'] as num).toInt(), - joinedAt: - json['joined_at'] == null - ? null - : DateTime.parse(json['joined_at'] as String), - breakUntil: - json['break_until'] == null - ? null - : DateTime.parse(json['break_until'] as String), - timeoutUntil: - json['timeout_until'] == null - ? null - : DateTime.parse(json['timeout_until'] as String), - status: - json['status'] == null - ? null - : SnAccountStatus.fromJson( - json['status'] as Map, - ), - lastTyped: - json['last_typed'] == null - ? null - : DateTime.parse(json['last_typed'] as String), + joinedAt: json['joined_at'] == null + ? null + : DateTime.parse(json['joined_at'] as String), + breakUntil: json['break_until'] == null + ? null + : DateTime.parse(json['break_until'] as String), + timeoutUntil: json['timeout_until'] == null + ? null + : DateTime.parse(json['timeout_until'] as String), + status: json['status'] == null + ? null + : SnAccountStatus.fromJson(json['status'] as Map), + lastTyped: json['last_typed'] == null + ? null + : DateTime.parse(json['last_typed'] as String), ); Map _$SnChatMemberToJson(_SnChatMember instance) => @@ -211,12 +194,11 @@ Map _$SnChatMemberToJson(_SnChatMember instance) => _SnChatSummary _$SnChatSummaryFromJson(Map json) => _SnChatSummary( unreadCount: (json['unread_count'] as num).toInt(), - lastMessage: - json['last_message'] == null - ? null - : SnChatMessage.fromJson( - json['last_message'] as Map, - ), + lastMessage: json['last_message'] == null + ? null + : SnChatMessage.fromJson( + json['last_message'] as Map, + ), ); Map _$SnChatSummaryToJson(_SnChatSummary instance) => @@ -251,10 +233,9 @@ _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) - .map((e) => CallParticipant.fromJson(e as Map)) - .toList(), + participants: (json['participants'] as List) + .map((e) => CallParticipant.fromJson(e as Map)) + .toList(), ); Map _$ChatRealtimeJoinResponseToJson( @@ -288,14 +269,12 @@ _SnRealtimeCall _$SnRealtimeCallFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), - endedAt: - json['ended_at'] == null - ? null - : DateTime.parse(json['ended_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + endedAt: json['ended_at'] == null + ? null + : DateTime.parse(json['ended_at'] as String), senderId: json['sender_id'] as String, sender: SnChatMember.fromJson(json['sender'] as Map), roomId: json['room_id'] as String, diff --git a/lib/models/custom_app.g.dart b/lib/models/custom_app.g.dart index cbde9a77..2d13bbf9 100644 --- a/lib/models/custom_app.g.dart +++ b/lib/models/custom_app.g.dart @@ -12,30 +12,25 @@ _CustomApp _$CustomAppFromJson(Map json) => _CustomApp( name: json['name'] as String? ?? '', description: json['description'] as String?, status: (json['status'] as num?)?.toInt() ?? 0, - picture: - json['picture'] == null - ? null - : SnCloudFile.fromJson(json['picture'] as Map), - background: - json['background'] == null - ? null - : SnCloudFile.fromJson(json['background'] as Map), - verification: - json['verification'] == null - ? null - : SnVerificationMark.fromJson( - json['verification'] as Map, - ), - oauthConfig: - json['oauth_config'] == null - ? null - : CustomAppOauthConfig.fromJson( - json['oauth_config'] as Map, - ), - links: - json['links'] == null - ? null - : CustomAppLinks.fromJson(json['links'] as Map), + picture: json['picture'] == null + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), + verification: json['verification'] == null + ? null + : SnVerificationMark.fromJson( + json['verification'] as Map, + ), + oauthConfig: json['oauth_config'] == null + ? null + : CustomAppOauthConfig.fromJson( + json['oauth_config'] as Map, + ), + links: json['links'] == null + ? null + : CustomAppLinks.fromJson(json['links'] as Map), secrets: (json['secrets'] as List?) ?.map((e) => CustomAppSecret.fromJson(e as Map)) @@ -83,10 +78,9 @@ _CustomAppOauthConfig _$CustomAppOauthConfigFromJson( ?.map((e) => e as String) .toList() ?? const [], - postLogoutRedirectUris: - (json['post_logout_redirect_uris'] as List?) - ?.map((e) => e as String) - .toList(), + postLogoutRedirectUris: (json['post_logout_redirect_uris'] as List?) + ?.map((e) => e as String) + .toList(), allowedScopes: (json['allowed_scopes'] as List?) ?.map((e) => e as String) @@ -118,10 +112,9 @@ _CustomAppSecret _$CustomAppSecretFromJson(Map json) => id: json['id'] as String? ?? '', secret: json['secret'] as String? ?? '', description: json['description'] as String?, - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + expiredAt: json['expired_at'] == null + ? null + : DateTime.parse(json['expired_at'] as String), isOidc: json['is_oidc'] as bool? ?? false, appId: json['app_id'] as String? ?? '', ); diff --git a/lib/models/developer.g.dart b/lib/models/developer.g.dart index 7fa257ce..83b5ee27 100644 --- a/lib/models/developer.g.dart +++ b/lib/models/developer.g.dart @@ -9,10 +9,9 @@ part of 'developer.dart'; _SnDeveloper _$SnDeveloperFromJson(Map json) => _SnDeveloper( id: json['id'] as String, publisherId: json['publisher_id'] as String, - publisher: - json['publisher'] == null - ? null - : SnPublisher.fromJson(json['publisher'] as Map), + publisher: json['publisher'] == null + ? null + : SnPublisher.fromJson(json['publisher'] as Map), ); Map _$SnDeveloperToJson(_SnDeveloper instance) => diff --git a/lib/models/drive_task.g.dart b/lib/models/drive_task.g.dart index 17f1d2e2..8fe98795 100644 --- a/lib/models/drive_task.g.dart +++ b/lib/models/drive_task.g.dart @@ -22,10 +22,9 @@ _DriveTask _$DriveTaskFromJson(Map 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 - ? null - : SnCloudFile.fromJson(json['result'] as Map), + result: json['result'] == null + ? null + : SnCloudFile.fromJson(json['result'] as Map), poolId: json['pool_id'] as String?, bundleId: json['bundle_id'] as String?, encryptPassword: json['encrypt_password'] as String?, diff --git a/lib/models/embed.g.dart b/lib/models/embed.g.dart index dc740e70..8dbfe38c 100644 --- a/lib/models/embed.g.dart +++ b/lib/models/embed.g.dart @@ -17,10 +17,9 @@ _SnScrappedLink _$SnScrappedLinkFromJson(Map json) => siteName: json['site_name'] as String?, contentType: json['content_type'] as String?, author: json['author'] as String?, - publishedDate: - json['published_date'] == null - ? null - : DateTime.parse(json['published_date'] as String), + publishedDate: json['published_date'] == null + ? null + : DateTime.parse(json['published_date'] as String), ); Map _$SnScrappedLinkToJson(_SnScrappedLink instance) => diff --git a/lib/models/file.g.dart b/lib/models/file.g.dart index 95464852..a1f95113 100644 --- a/lib/models/file.g.dart +++ b/lib/models/file.g.dart @@ -35,10 +35,9 @@ _SnCloudFile _$SnCloudFileFromJson(Map json) => _SnCloudFile( description: json['description'] as String?, fileMeta: json['file_meta'] as Map?, userMeta: json['user_meta'] as Map?, - pool: - json['pool'] == null - ? null - : SnFilePool.fromJson(json['pool'] as Map), + pool: json['pool'] == null + ? null + : SnFilePool.fromJson(json['pool'] as Map), sensitiveMarks: (json['sensitive_marks'] as List?) ?.map((e) => (e as num).toInt()) @@ -47,17 +46,15 @@ _SnCloudFile _$SnCloudFileFromJson(Map json) => _SnCloudFile( mimeType: json['mime_type'] as String?, hash: json['hash'] as String?, size: (json['size'] as num).toInt(), - uploadedAt: - json['uploaded_at'] == null - ? null - : DateTime.parse(json['uploaded_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnCloudFileToJson(_SnCloudFile instance) => @@ -87,10 +84,9 @@ _SnCloudFileIndex _$SnCloudFileIndexFromJson(Map json) => file: SnCloudFile.fromJson(json['file'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnCloudFileIndexToJson(_SnCloudFileIndex instance) => diff --git a/lib/models/file_pool.g.dart b/lib/models/file_pool.g.dart index a2b2cb4d..bf257101 100644 --- a/lib/models/file_pool.g.dart +++ b/lib/models/file_pool.g.dart @@ -16,18 +16,15 @@ _SnFilePool _$SnFilePoolFromJson(Map 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 - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: - json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnFilePoolToJson(_SnFilePool instance) => diff --git a/lib/models/heatmap.g.dart b/lib/models/heatmap.g.dart index 5c17236c..d4eea2ad 100644 --- a/lib/models/heatmap.g.dart +++ b/lib/models/heatmap.g.dart @@ -10,10 +10,9 @@ _SnHeatmap _$SnHeatmapFromJson(Map 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) - .map((e) => SnHeatmapItem.fromJson(e as Map)) - .toList(), + items: (json['items'] as List) + .map((e) => SnHeatmapItem.fromJson(e as Map)) + .toList(), ); Map _$SnHeatmapToJson(_SnHeatmap instance) => diff --git a/lib/models/poll.g.dart b/lib/models/poll.g.dart index da950084..832a0b28 100644 --- a/lib/models/poll.g.dart +++ b/lib/models/poll.g.dart @@ -8,31 +8,25 @@ part of 'poll.dart'; _SnPollWithStats _$SnPollWithStatsFromJson(Map json) => _SnPollWithStats( - userAnswer: - json['user_answer'] == null - ? null - : SnPollAnswer.fromJson( - json['user_answer'] as Map, - ), + userAnswer: json['user_answer'] == null + ? null + : SnPollAnswer.fromJson(json['user_answer'] as Map), stats: json['stats'] as Map? ?? const {}, id: json['id'] as String, - questions: - (json['questions'] as List) - .map((e) => SnPollQuestion.fromJson(e as Map)) - .toList(), + questions: (json['questions'] as List) + .map((e) => SnPollQuestion.fromJson(e as Map)) + .toList(), title: json['title'] as String?, description: json['description'] as String?, - endedAt: - json['ended_at'] == null - ? null - : DateTime.parse(json['ended_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPollWithStatsToJson(_SnPollWithStats instance) => @@ -52,27 +46,23 @@ Map _$SnPollWithStatsToJson(_SnPollWithStats instance) => _SnPoll _$SnPollFromJson(Map json) => _SnPoll( id: json['id'] as String, - questions: - (json['questions'] as List) - .map((e) => SnPollQuestion.fromJson(e as Map)) - .toList(), + questions: (json['questions'] as List) + .map((e) => SnPollQuestion.fromJson(e as Map)) + .toList(), title: json['title'] as String?, description: json['description'] as String?, - endedAt: - json['ended_at'] == null - ? null - : DateTime.parse(json['ended_at'] as String), + endedAt: json['ended_at'] == null + ? null + : DateTime.parse(json['ended_at'] as String), publisherId: json['publisher_id'] as String, - publisher: - json['publisher'] == null - ? null - : SnPublisher.fromJson(json['publisher'] as Map), + publisher: json['publisher'] == null + ? null + : SnPublisher.fromJson(json['publisher'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPollToJson(_SnPoll instance) => { @@ -92,10 +82,9 @@ _SnPollQuestion _$SnPollQuestionFromJson(Map json) => _SnPollQuestion( id: json['id'] as String, type: $enumDecode(_$SnPollQuestionTypeEnumMap, json['type']), - options: - (json['options'] as List?) - ?.map((e) => SnPollOption.fromJson(e as Map)) - .toList(), + options: (json['options'] as List?) + ?.map((e) => SnPollOption.fromJson(e as Map)) + .toList(), title: json['title'] as String, description: json['description'] as String?, order: (json['order'] as num).toInt(), @@ -145,14 +134,12 @@ _SnPollAnswer _$SnPollAnswerFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), ); Map _$SnPollAnswerToJson(_SnPollAnswer instance) => diff --git a/lib/models/post.g.dart b/lib/models/post.g.dart index 66751d9d..958c52bf 100644 --- a/lib/models/post.g.dart +++ b/lib/models/post.g.dart @@ -11,25 +11,20 @@ _SnPost _$SnPostFromJson(Map json) => _SnPost( title: json['title'] as String?, description: json['description'] as String?, language: json['language'] as String?, - editedAt: - json['edited_at'] == null - ? null - : DateTime.parse(json['edited_at'] as String), - publishedAt: - json['published_at'] == null - ? null - : DateTime.parse(json['published_at'] as String), + editedAt: json['edited_at'] == null + ? null + : DateTime.parse(json['edited_at'] as String), + publishedAt: json['published_at'] == null + ? null + : DateTime.parse(json['published_at'] as String), visibility: (json['visibility'] as num?)?.toInt() ?? 0, content: json['content'] as String?, slug: json['slug'] as String?, type: (json['type'] as num?)?.toInt() ?? 0, meta: json['meta'] as Map?, - embedView: - json['embed_view'] == null - ? null - : SnPostEmbedView.fromJson( - json['embed_view'] as Map, - ), + embedView: json['embed_view'] == null + ? null + : SnPostEmbedView.fromJson(json['embed_view'] as Map), viewsUnique: (json['views_unique'] as num?)?.toInt() ?? 0, viewsTotal: (json['views_total'] as num?)?.toInt() ?? 0, upvotes: (json['upvotes'] as num?)?.toInt() ?? 0, @@ -38,25 +33,21 @@ _SnPost _$SnPostFromJson(Map 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 - ? null - : SnPost.fromJson(json['threaded_post'] as Map), + threadedPost: json['threaded_post'] == null + ? null + : SnPost.fromJson(json['threaded_post'] as Map), repliedPostId: json['replied_post_id'] as String?, - repliedPost: - json['replied_post'] == null - ? null - : SnPost.fromJson(json['replied_post'] as Map), + repliedPost: json['replied_post'] == null + ? null + : SnPost.fromJson(json['replied_post'] as Map), forwardedPostId: json['forwarded_post_id'] as String?, - forwardedPost: - json['forwarded_post'] == null - ? null - : SnPost.fromJson(json['forwarded_post'] as Map), + forwardedPost: json['forwarded_post'] == null + ? null + : SnPost.fromJson(json['forwarded_post'] as Map), realmId: json['realm_id'] as String?, - realm: - json['realm'] == null - ? null - : SnRealm.fromJson(json['realm'] as Map), + realm: json['realm'] == null + ? null + : SnRealm.fromJson(json['realm'] as Map), attachments: (json['attachments'] as List?) ?.map((e) => SnCloudFile.fromJson(e as Map)) @@ -90,18 +81,15 @@ _SnPost _$SnPostFromJson(Map json) => _SnPost( ?.map((e) => SnPostFeaturedRecord.fromJson(e as Map)) .toList() ?? const [], - createdAt: - json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: - json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), repliedGone: json['replied_gone'] as bool? ?? false, forwardedGone: json['forwarded_gone'] as bool? ?? false, isTruncated: json['is_truncated'] as bool? ?? false, @@ -214,18 +202,15 @@ _SnPostAward _$SnPostAwardFromJson(Map json) => _SnPostAward( message: json['message'] as String?, postId: json['post_id'] as String, accountId: json['account_id'] as String, - createdAt: - json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: - json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPostAwardToJson(_SnPostAward instance) => @@ -250,14 +235,12 @@ _SnPostReaction _$SnPostReactionFromJson(Map 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 - ? null - : SnAccount.fromJson(json['account'] as Map), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPostReactionToJson(_SnPostReaction instance) => @@ -278,17 +261,15 @@ _SnPostFeaturedRecord _$SnPostFeaturedRecordFromJson( ) => _SnPostFeaturedRecord( id: json['id'] as String, postId: json['post_id'] as String, - featuredAt: - json['featured_at'] == null - ? null - : DateTime.parse(json['featured_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPostFeaturedRecordToJson( diff --git a/lib/models/publication_site.g.dart b/lib/models/publication_site.g.dart index 4f04a2b2..24bf90ca 100644 --- a/lib/models/publication_site.g.dart +++ b/lib/models/publication_site.g.dart @@ -17,10 +17,9 @@ _SnPublicationSite _$SnPublicationSiteFromJson(Map 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) - .map((e) => SnPublicationPage.fromJson(e as Map)) - .toList(), + pages: (json['pages'] as List) + .map((e) => SnPublicationPage.fromJson(e as Map)) + .toList(), ); Map _$SnPublicationSiteToJson(_SnPublicationSite instance) => diff --git a/lib/models/publisher.g.dart b/lib/models/publisher.g.dart index edd179a4..801ff201 100644 --- a/lib/models/publisher.g.dart +++ b/lib/models/publisher.g.dart @@ -12,38 +12,31 @@ _SnPublisher _$SnPublisherFromJson(Map json) => _SnPublisher( name: json['name'] as String? ?? '', nick: json['nick'] as String? ?? '', bio: json['bio'] as String? ?? '', - picture: - json['picture'] == null - ? null - : SnCloudFile.fromJson(json['picture'] as Map), - background: - json['background'] == null - ? null - : SnCloudFile.fromJson(json['background'] as Map), - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + picture: json['picture'] == null + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), accountId: json['account_id'] as String?, - createdAt: - json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: - json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), realmId: json['realm_id'] as String?, - verification: - json['verification'] == null - ? null - : SnVerificationMark.fromJson( - json['verification'] as Map, - ), + verification: json['verification'] == null + ? null + : SnVerificationMark.fromJson( + json['verification'] as Map, + ), ); Map _$SnPublisherToJson(_SnPublisher instance) => @@ -67,26 +60,22 @@ Map _$SnPublisherToJson(_SnPublisher instance) => _SnPublisherMember _$SnPublisherMemberFromJson(Map json) => _SnPublisherMember( publisherId: json['publisher_id'] as String, - publisher: - json['publisher'] == null - ? null - : SnPublisher.fromJson(json['publisher'] as Map), + publisher: json['publisher'] == null + ? null + : SnPublisher.fromJson(json['publisher'] as Map), accountId: json['account_id'] as String, - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), role: (json['role'] as num).toInt(), - joinedAt: - json['joined_at'] == null - ? null - : DateTime.parse(json['joined_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPublisherMemberToJson(_SnPublisherMember instance) => diff --git a/lib/models/realm.g.dart b/lib/models/realm.g.dart index eabc9a3d..c43d0d91 100644 --- a/lib/models/realm.g.dart +++ b/lib/models/realm.g.dart @@ -12,27 +12,23 @@ _SnRealm _$SnRealmFromJson(Map json) => _SnRealm( name: json['name'] as String? ?? '', description: json['description'] as String? ?? '', verifiedAs: json['verified_as'] as String?, - verifiedAt: - json['verified_at'] == null - ? null - : DateTime.parse(json['verified_at'] as String), + 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 - ? null - : SnCloudFile.fromJson(json['picture'] as Map), - background: - json['background'] == null - ? null - : SnCloudFile.fromJson(json['background'] as Map), + picture: json['picture'] == null + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnRealmToJson(_SnRealm instance) => { @@ -55,32 +51,25 @@ Map _$SnRealmToJson(_SnRealm instance) => { _SnRealmMember _$SnRealmMemberFromJson(Map json) => _SnRealmMember( realmId: json['realm_id'] as String, - realm: - json['realm'] == null - ? null - : SnRealm.fromJson(json['realm'] as Map), + realm: json['realm'] == null + ? null + : SnRealm.fromJson(json['realm'] as Map), accountId: json['account_id'] as String, - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), role: (json['role'] as num).toInt(), - joinedAt: - json['joined_at'] == null - ? null - : DateTime.parse(json['joined_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), - status: - json['status'] == null - ? null - : SnAccountStatus.fromJson( - json['status'] as Map, - ), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + status: json['status'] == null + ? null + : SnAccountStatus.fromJson(json['status'] as Map), ); Map _$SnRealmMemberToJson(_SnRealmMember instance) => diff --git a/lib/models/reference.g.dart b/lib/models/reference.g.dart index 96c5e2b6..9c8d779a 100644 --- a/lib/models/reference.g.dart +++ b/lib/models/reference.g.dart @@ -9,22 +9,19 @@ part of 'reference.dart'; _Reference _$ReferenceFromJson(Map json) => _Reference( id: json['id'] as String, fileId: json['file_id'] as String, - file: - json['file'] == null - ? null - : SnCloudFile.fromJson(json['file'] as Map), + file: json['file'] == null + ? null + : SnCloudFile.fromJson(json['file'] as Map), usage: json['usage'] as String, resourceId: json['resource_id'] as String, - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$ReferenceToJson(_Reference instance) => diff --git a/lib/models/relationship.g.dart b/lib/models/relationship.g.dart index c61a1244..4679a8d0 100644 --- a/lib/models/relationship.g.dart +++ b/lib/models/relationship.g.dart @@ -8,26 +8,22 @@ part of 'relationship.dart'; _SnRelationship _$SnRelationshipFromJson(Map json) => _SnRelationship( - createdAt: - json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: - json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + 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), relatedId: json['related_id'] as String, related: SnAccount.fromJson(json['related'] as Map), - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + expiredAt: json['expired_at'] == null + ? null + : DateTime.parse(json['expired_at'] as String), status: (json['status'] as num).toInt(), ); diff --git a/lib/models/sticker.g.dart b/lib/models/sticker.g.dart index 4770f4a0..00f3049f 100644 --- a/lib/models/sticker.g.dart +++ b/lib/models/sticker.g.dart @@ -11,16 +11,14 @@ _SnSticker _$SnStickerFromJson(Map json) => _SnSticker( slug: json['slug'] as String, image: SnCloudFile.fromJson(json['image'] as Map), packId: json['pack_id'] as String, - pack: - json['pack'] == null - ? null - : SnStickerPack.fromJson(json['pack'] as Map), + pack: json['pack'] == null + ? null + : SnStickerPack.fromJson(json['pack'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnStickerToJson(_SnSticker instance) => @@ -42,20 +40,17 @@ _SnStickerPack _$SnStickerPackFromJson(Map json) => description: json['description'] as String, prefix: json['prefix'] as String, publisherId: json['publisher_id'] as String, - icon: - json['icon'] == null - ? null - : SnCloudFile.fromJson(json['icon'] as Map), - publisher: - json['publisher'] == null - ? null - : SnPublisher.fromJson(json['publisher'] as Map), + icon: json['icon'] == null + ? null + : SnCloudFile.fromJson(json['icon'] as Map), + publisher: json['publisher'] == null + ? null + : SnPublisher.fromJson(json['publisher'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), stickers: (json['stickers'] as List?) ?.map((e) => SnSticker.fromJson(e as Map)) diff --git a/lib/models/thought.g.dart b/lib/models/thought.g.dart index cd8bb138..53c5a333 100644 --- a/lib/models/thought.g.dart +++ b/lib/models/thought.g.dart @@ -16,14 +16,12 @@ _StreamThinkingRequest _$StreamThinkingRequestFromJson( ?.map((e) => e as String) .toList() ?? const [], - attachedPosts: - (json['attached_posts'] as List?) - ?.map((e) => e as String) - .toList(), - attachedMessages: - (json['attached_messages'] as List?) - ?.map((e) => e as Map) - .toList(), + attachedPosts: (json['attached_posts'] as List?) + ?.map((e) => e as String) + .toList(), + attachedMessages: (json['attached_messages'] as List?) + ?.map((e) => e as Map) + .toList(), serviceId: json['service_id'] as String?, ); @@ -87,18 +85,14 @@ _SnThinkingMessagePart _$SnThinkingMessagePartFromJson( (json['type'] as num).toInt(), ), text: json['text'] as String?, - functionCall: - json['function_call'] == null - ? null - : SnFunctionCall.fromJson( - json['function_call'] as Map, - ), - functionResult: - json['function_result'] == null - ? null - : SnFunctionResult.fromJson( - json['function_result'] as Map, - ), + functionCall: json['function_call'] == null + ? null + : SnFunctionCall.fromJson(json['function_call'] as Map), + functionResult: json['function_result'] == null + ? null + : SnFunctionResult.fromJson( + json['function_result'] as Map, + ), ); Map _$SnThinkingMessagePartToJson( @@ -119,10 +113,9 @@ _SnThinkingSequence _$SnThinkingSequenceFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnThinkingSequenceToJson(_SnThinkingSequence instance) => @@ -159,18 +152,16 @@ _SnThinkingThought _$SnThinkingThoughtFromJson(Map json) => tokenCount: (json['token_count'] as num?)?.toInt(), modelName: json['model_name'] as String?, sequenceId: json['sequence_id'] as String, - sequence: - json['sequence'] == null - ? null - : SnThinkingSequence.fromJson( - json['sequence'] as Map, - ), + sequence: json['sequence'] == null + ? null + : SnThinkingSequence.fromJson( + json['sequence'] as Map, + ), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnThinkingThoughtToJson(_SnThinkingThought instance) => @@ -206,10 +197,9 @@ _ThoughtServicesResponse _$ThoughtServicesResponseFromJson( Map json, ) => _ThoughtServicesResponse( defaultService: json['default_service'] as String, - services: - (json['services'] as List) - .map((e) => ThoughtService.fromJson(e as Map)) - .toList(), + services: (json['services'] as List) + .map((e) => ThoughtService.fromJson(e as Map)) + .toList(), ); Map _$ThoughtServicesResponseToJson( diff --git a/lib/models/wallet.g.dart b/lib/models/wallet.g.dart index db822b7e..e37371b8 100644 --- a/lib/models/wallet.g.dart +++ b/lib/models/wallet.g.dart @@ -8,21 +8,18 @@ part of 'wallet.dart'; _SnWallet _$SnWalletFromJson(Map json) => _SnWallet( id: json['id'] as String, - pockets: - (json['pockets'] as List) - .map((e) => SnWalletPocket.fromJson(e as Map)) - .toList(), + pockets: (json['pockets'] as List) + .map((e) => SnWalletPocket.fromJson(e as Map)) + .toList(), accountId: json['account_id'] as String, - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWalletToJson(_SnWallet instance) => { @@ -77,10 +74,9 @@ _SnWalletPocket _$SnWalletPocketFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWalletPocketToJson(_SnWalletPocket instance) => @@ -102,21 +98,18 @@ _SnTransaction _$SnTransactionFromJson(Map json) => remarks: json['remarks'] as String?, type: (json['type'] as num).toInt(), payerWalletId: json['payer_wallet_id'] as String?, - payerWallet: - json['payer_wallet'] == null - ? null - : SnWallet.fromJson(json['payer_wallet'] as Map), + payerWallet: json['payer_wallet'] == null + ? null + : SnWallet.fromJson(json['payer_wallet'] as Map), payeeWalletId: json['payee_wallet_id'] as String?, - payeeWallet: - json['payee_wallet'] == null - ? null - : SnWallet.fromJson(json['payee_wallet'] as Map), + payeeWallet: json['payee_wallet'] == null + ? null + : SnWallet.fromJson(json['payee_wallet'] as Map), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnTransactionToJson(_SnTransaction instance) => @@ -140,10 +133,9 @@ _SnWalletSubscription _$SnWalletSubscriptionFromJson( ) => _SnWalletSubscription( id: json['id'] as String, begunAt: DateTime.parse(json['begun_at'] as String), - endedAt: - json['ended_at'] == null - ? null - : DateTime.parse(json['ended_at'] as String), + endedAt: json['ended_at'] == null + ? null + : DateTime.parse(json['ended_at'] as String), identifier: json['identifier'] as String, isActive: json['is_active'] as bool? ?? true, isFreeTrial: json['is_free_trial'] as bool? ?? false, @@ -153,23 +145,20 @@ _SnWalletSubscription _$SnWalletSubscriptionFromJson( basePrice: (json['base_price'] as num?)?.toDouble(), couponId: json['coupon_id'] as String?, coupon: json['coupon'], - renewalAt: - json['renewal_at'] == null - ? null - : DateTime.parse(json['renewal_at'] as String), + renewalAt: json['renewal_at'] == null + ? null + : DateTime.parse(json['renewal_at'] as String), accountId: json['account_id'] as String, - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWalletSubscriptionToJson( @@ -204,10 +193,9 @@ _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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), identifier: json['identifier'] as String, ); @@ -239,10 +227,9 @@ _SnWalletOrder _$SnWalletOrderFromJson(Map 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWalletOrderToJson(_SnWalletOrder instance) => @@ -269,43 +256,36 @@ _SnWalletGift _$SnWalletGiftFromJson(Map json) => giftCode: json['gift_code'] as String, subscriptionIdentifier: json['subscription_identifier'] as String, recipientId: json['recipient_id'] as String?, - recipient: - json['recipient'] == null - ? null - : SnAccount.fromJson(json['recipient'] as Map), + recipient: json['recipient'] == null + ? null + : SnAccount.fromJson(json['recipient'] as Map), gifterId: json['gifter_id'] as String, - gifter: - json['gifter'] == null - ? null - : SnAccount.fromJson(json['gifter'] as Map), + gifter: json['gifter'] == null + ? null + : SnAccount.fromJson(json['gifter'] as Map), redeemerId: json['redeemer_id'] as String?, - redeemer: - json['redeemer'] == null - ? null - : SnAccount.fromJson(json['redeemer'] as Map), + redeemer: json['redeemer'] == null + ? null + : SnAccount.fromJson(json['redeemer'] as Map), message: json['message'] as String?, status: (json['status'] as num).toInt(), - redeemedAt: - json['redeemed_at'] == null - ? null - : DateTime.parse(json['redeemed_at'] as String), - expiredAt: - json['expired_at'] == null - ? null - : DateTime.parse(json['expired_at'] as String), + redeemedAt: json['redeemed_at'] == null + ? null + : DateTime.parse(json['redeemed_at'] as String), + expiredAt: json['expired_at'] == null + ? null + : DateTime.parse(json['expired_at'] as String), subscriptionId: json['subscription_id'] as String?, - subscription: - json['subscription'] == null - ? null - : SnWalletSubscription.fromJson( - json['subscription'] as Map, - ), + subscription: json['subscription'] == null + ? null + : SnWalletSubscription.fromJson( + json['subscription'] as Map, + ), createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWalletGiftToJson(_SnWalletGift instance) => @@ -330,35 +310,31 @@ Map _$SnWalletGiftToJson(_SnWalletGift instance) => 'deleted_at': instance.deletedAt?.toIso8601String(), }; -_SnWalletFund _$SnWalletFundFromJson( - Map json, -) => _SnWalletFund( - id: json['id'] as String, - currency: json['currency'] as String, - totalAmount: (json['total_amount'] as num).toDouble(), - remainingAmount: (json['remaining_amount'] as num).toDouble(), - amountOfSplits: (json['amount_of_splits'] as num).toInt(), - splitType: (json['split_type'] as num).toInt(), - status: (json['status'] as num).toInt(), - message: json['message'] as String?, - creatorAccountId: json['creator_account_id'] as String, - creatorAccount: - json['creator_account'] == null +_SnWalletFund _$SnWalletFundFromJson(Map json) => + _SnWalletFund( + id: json['id'] as String, + currency: json['currency'] as String, + totalAmount: (json['total_amount'] as num).toDouble(), + remainingAmount: (json['remaining_amount'] as num).toDouble(), + amountOfSplits: (json['amount_of_splits'] as num).toInt(), + splitType: (json['split_type'] as num).toInt(), + status: (json['status'] as num).toInt(), + message: json['message'] as String?, + creatorAccountId: json['creator_account_id'] as String, + creatorAccount: json['creator_account'] == null ? null : SnAccount.fromJson(json['creator_account'] as Map), - expiredAt: DateTime.parse(json['expired_at'] as String), - recipients: - (json['recipients'] as List) + expiredAt: DateTime.parse(json['expired_at'] as String), + recipients: (json['recipients'] as List) .map((e) => SnWalletFundRecipient.fromJson(e as Map)) .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 + 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 ? null : DateTime.parse(json['deleted_at'] as String), -); + ); Map _$SnWalletFundToJson(_SnWalletFund instance) => { @@ -386,24 +362,19 @@ _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 - ? null - : SnAccount.fromJson( - json['recipient_account'] as Map, - ), + recipientAccount: json['recipient_account'] == null + ? null + : SnAccount.fromJson(json['recipient_account'] as Map), amount: (json['amount'] as num).toDouble(), isReceived: json['is_received'] as bool, - receivedAt: - json['received_at'] == null - ? null - : DateTime.parse(json['received_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWalletFundRecipientToJson( @@ -425,33 +396,29 @@ _SnLotteryTicket _$SnLotteryTicketFromJson(Map json) => _SnLotteryTicket( id: json['id'] as String, accountId: json['account_id'] as String, - account: - json['account'] == null - ? null - : SnAccount.fromJson(json['account'] as Map), - regionOneNumbers: - (json['region_one_numbers'] as List) - .map((e) => (e as num).toInt()) - .toList(), + account: json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), + regionOneNumbers: (json['region_one_numbers'] as List) + .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 - ? null - : DateTime.parse(json['draw_date'] as String), + drawDate: json['draw_date'] == null + ? null + : DateTime.parse(json['draw_date'] as String), matchedRegionOneNumbers: (json['matched_region_one_numbers'] as List?) ?.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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnLotteryTicketToJson(_SnLotteryTicket instance) => @@ -471,26 +438,24 @@ Map _$SnLotteryTicketToJson(_SnLotteryTicket instance) => 'deleted_at': instance.deletedAt?.toIso8601String(), }; -_SnLotteryRecord _$SnLotteryRecordFromJson(Map json) => - _SnLotteryRecord( - id: json['id'] as String, - drawDate: DateTime.parse(json['draw_date'] as String), - winningRegionOneNumbers: - (json['winning_region_one_numbers'] as List) - .map((e) => (e as num).toInt()) - .toList(), - 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 - ? null - : DateTime.parse(json['deleted_at'] as String), - ); +_SnLotteryRecord _$SnLotteryRecordFromJson( + Map json, +) => _SnLotteryRecord( + id: json['id'] as String, + drawDate: DateTime.parse(json['draw_date'] as String), + winningRegionOneNumbers: (json['winning_region_one_numbers'] as List) + .map((e) => (e as num).toInt()) + .toList(), + 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 + ? null + : DateTime.parse(json['deleted_at'] as String), +); Map _$SnLotteryRecordToJson(_SnLotteryRecord instance) => { diff --git a/lib/models/webfeed.g.dart b/lib/models/webfeed.g.dart index 05ccfea3..9cbf8136 100644 --- a/lib/models/webfeed.g.dart +++ b/lib/models/webfeed.g.dart @@ -17,14 +17,12 @@ _SnWebFeed _$SnWebFeedFromJson(Map json) => _SnWebFeed( url: json['url'] as String, title: json['title'] as String, description: json['description'] as String?, - preview: - json['preview'] == null - ? null - : SnScrappedLink.fromJson(json['preview'] as Map), - config: - json['config'] == null - ? const SnWebFeedConfig() - : SnWebFeedConfig.fromJson(json['config'] as Map), + preview: json['preview'] == null + ? null + : SnScrappedLink.fromJson(json['preview'] as Map), + config: json['config'] == null + ? const SnWebFeedConfig() + : SnWebFeedConfig.fromJson(json['config'] as Map), publisherId: json['publisher_id'] as String, articles: (json['articles'] as List?) @@ -33,10 +31,9 @@ _SnWebFeed _$SnWebFeedFromJson(Map json) => _SnWebFeed( const [], createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: - json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWebFeedToJson(_SnWebFeed instance) => @@ -61,28 +58,22 @@ _SnWebArticle _$SnWebArticleFromJson(Map json) => url: json['url'] as String, author: json['author'] as String?, meta: json['meta'] as Map?, - preview: - json['preview'] == null - ? null - : SnScrappedLink.fromJson( - json['preview'] as Map, - ), - feed: - json['feed'] == null - ? null - : SnWebFeed.fromJson(json['feed'] as Map), + preview: json['preview'] == null + ? null + : SnScrappedLink.fromJson(json['preview'] as Map), + feed: json['feed'] == null + ? null + : SnWebFeed.fromJson(json['feed'] as Map), content: json['content'] as String?, - publishedAt: - json['published_at'] == null - ? null - : DateTime.parse(json['published_at'] as String), + 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 - ? null - : DateTime.parse(json['deleted_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnWebArticleToJson(_SnWebArticle instance) => diff --git a/lib/pods/file_list.dart b/lib/pods/drive/file_list.dart similarity index 100% rename from lib/pods/file_list.dart rename to lib/pods/drive/file_list.dart diff --git a/lib/pods/file_list.g.dart b/lib/pods/drive/file_list.g.dart similarity index 100% rename from lib/pods/file_list.g.dart rename to lib/pods/drive/file_list.g.dart diff --git a/lib/pods/file_pool.dart b/lib/pods/drive/file_pool.dart similarity index 100% rename from lib/pods/file_pool.dart rename to lib/pods/drive/file_pool.dart diff --git a/lib/pods/file_references.dart b/lib/pods/drive/file_references.dart similarity index 100% rename from lib/pods/file_references.dart rename to lib/pods/drive/file_references.dart diff --git a/lib/pods/file_references.g.dart b/lib/pods/drive/file_references.g.dart similarity index 100% rename from lib/pods/file_references.g.dart rename to lib/pods/drive/file_references.g.dart diff --git a/lib/pods/upload_tasks.dart b/lib/pods/drive/upload_tasks.dart similarity index 100% rename from lib/pods/upload_tasks.dart rename to lib/pods/drive/upload_tasks.dart diff --git a/lib/pods/post/post_list.dart b/lib/pods/post/post_list.dart new file mode 100644 index 00000000..4e4127e7 --- /dev/null +++ b/lib/pods/post/post_list.dart @@ -0,0 +1,72 @@ +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? categories, + List? 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, PostListQuery>( + PostListNotifier.new, + ); + +class PostListNotifier extends AsyncNotifier> + with AsyncPaginationController { + final PostListQuery arg; + PostListNotifier(this.arg); + + static const int pageSize = 20; + + @override + Future> 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 data = response.data; + return data.map((json) => SnPost.fromJson(json)).toList(); + } +} diff --git a/lib/widgets/post/post_list.freezed.dart b/lib/pods/post/post_list.freezed.dart similarity index 100% rename from lib/widgets/post/post_list.freezed.dart rename to lib/pods/post/post_list.freezed.dart diff --git a/lib/screens/files/file_detail.dart b/lib/screens/files/file_detail.dart index 7c871410..7f985d99 100644 --- a/lib/screens/files/file_detail.dart +++ b/lib/screens/files/file_detail.dart @@ -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,17 +177,15 @@ class FileDetailScreen extends HookConsumerWidget { actions.add( IconButton( icon: Icon(Icons.link), - onPressed: - () => showModalBottomSheet( - useRootNavigator: true, - context: context, - isScrollControlled: true, - builder: - (context) => SheetScaffold( - titleText: 'File References', - child: ReferencesList(fileId: item.id), - ), - ), + onPressed: () => showModalBottomSheet( + useRootNavigator: true, + context: context, + isScrollControlled: true, + builder: (context) => SheetScaffold( + titleText: 'File References', + child: ReferencesList(fileId: item.id), + ), + ), ), ); @@ -300,43 +299,39 @@ class ReferencesList extends ConsumerWidget { final asyncReferences = ref.watch(fileReferencesProvider(fileId)); return asyncReferences.when( - data: - (references) => ListView.builder( - itemCount: references.length, - itemBuilder: (context, index) { - final reference = references[index]; - return ListTile( - leading: const Icon(Icons.link), - title: Row( - spacing: 6, - children: [ - Text( - reference.usage, - style: GoogleFonts.robotoMono( - fontWeight: FontWeight.bold, - fontSize: 13, - ), - ), - Text( - reference.id, - style: GoogleFonts.robotoMono(fontSize: 13), - ), - ], + data: (references) => ListView.builder( + itemCount: references.length, + itemBuilder: (context, index) { + final reference = references[index]; + return ListTile( + leading: const Icon(Icons.link), + title: Row( + spacing: 6, + children: [ + Text( + reference.usage, + style: GoogleFonts.robotoMono( + fontWeight: FontWeight.bold, + fontSize: 13, + ), ), - subtitle: Row( - spacing: 8, - children: [ - Text(reference.createdAt.formatRelative(context)), - const VerticalDivider(width: 1, thickness: 1).height(12), - Text(reference.createdAt.formatSystem()), - ], - ), - ); - }, - ), + Text(reference.id, style: GoogleFonts.robotoMono(fontSize: 13)), + ], + ), + subtitle: Row( + spacing: 8, + children: [ + Text(reference.createdAt.formatRelative(context)), + const VerticalDivider(width: 1, thickness: 1).height(12), + Text(reference.createdAt.formatSystem()), + ], + ), + ); + }, + ), loading: () => const Center(child: CircularProgressIndicator()), - error: - (error, _) => Center(child: Text('Error loading references: $error')), + error: (error, _) => + Center(child: Text('Error loading references: $error')), ); } } diff --git a/lib/screens/files/file_list.dart b/lib/screens/files/file_list.dart index a51c086e..ceddce3b 100644 --- a/lib/screens/files/file_list.dart +++ b/lib/screens/files/file_list.dart @@ -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,38 +40,31 @@ 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( - usage: usage, - quota: quota, - currentPath: currentPath, - selectedPool: selectedPool, - onPickAndUpload: - () => _pickAndUploadFile( - ref, - currentPath.value, - selectedPool.value?.id, - ), - onShowCreateDirectory: _showCreateDirectoryDialog, - mode: mode, - viewMode: viewMode, - ), - loading: () => const Center(child: CircularProgressIndicator()), - error: (e, _) => Center(child: Text('Error loading quota')), + data: (usage) => quotaAsync.when( + data: (quota) => FileListView( + usage: usage, + quota: quota, + currentPath: currentPath, + selectedPool: selectedPool, + onPickAndUpload: () => _pickAndUploadFile( + ref, + currentPath.value, + selectedPool.value?.id, ), + onShowCreateDirectory: _showCreateDirectoryDialog, + mode: mode, + viewMode: viewMode, + ), + loading: () => const Center(child: CircularProgressIndicator()), + error: (e, _) => Center(child: Text('Error loading quota')), + ), loading: () => const Center(child: CircularProgressIndicator()), error: (e, _) => Center(child: Text('Error loading usage')), ), @@ -158,44 +151,43 @@ class FileListScreen extends HookConsumerWidget { await showDialog( context: context, - builder: - (context) => AlertDialog( - title: const Text('Navigate to Directory'), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Gap(8), - TextField( - controller: controller, - decoration: const InputDecoration( - labelText: 'Directory path', - hintText: 'e.g., documents, projects/my-app', - helperText: - 'Enter a directory path. The directory will be created when you upload files to it.', - helperMaxLines: 3, - border: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(12)), - ), - ), - onSubmitted: (_) { - handleChangeDirectory(context); - }, + builder: (context) => AlertDialog( + title: const Text('Navigate to Directory'), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Gap(8), + TextField( + controller: controller, + decoration: const InputDecoration( + labelText: 'Directory path', + hintText: 'e.g., documents, projects/my-app', + helperText: + 'Enter a directory path. The directory will be created when you upload files to it.', + helperMaxLines: 3, + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(12)), ), - ], + ), + onSubmitted: (_) { + handleChangeDirectory(context); + }, ), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: const Text('Cancel'), - ), - TextButton.icon( - onPressed: () => handleChangeDirectory(context), - label: const Text('Go to Directory'), - icon: const Icon(Symbols.arrow_right_alt), - ), - ], + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text('Cancel'), ), + TextButton.icon( + onPressed: () => handleChangeDirectory(context), + label: const Text('Go to Directory'), + icon: const Icon(Symbols.arrow_right_alt), + ), + ], + ), ); } @@ -207,14 +199,13 @@ class FileListScreen extends HookConsumerWidget { showModalBottomSheet( context: context, isScrollControlled: true, - builder: - (context) => SheetScaffold( - titleText: 'Usage Overview', - child: UsageOverviewWidget( - usage: usage, - quota: quota, - ).padding(horizontal: 8, vertical: 16), - ), + builder: (context) => SheetScaffold( + titleText: 'Usage Overview', + child: UsageOverviewWidget( + usage: usage, + quota: quota, + ).padding(horizontal: 8, vertical: 16), + ), ); } } diff --git a/lib/screens/posts/compose.g.dart b/lib/screens/posts/compose.g.dart index e9b29d6e..ca565093 100644 --- a/lib/screens/posts/compose.g.dart +++ b/lib/screens/posts/compose.g.dart @@ -18,14 +18,12 @@ _PostComposeInitialState _$PostComposeInitialStateFromJson( .toList() ?? const [], visibility: (json['visibility'] as num?)?.toInt(), - replyingTo: - json['replying_to'] == null - ? null - : SnPost.fromJson(json['replying_to'] as Map), - forwardingTo: - json['forwarding_to'] == null - ? null - : SnPost.fromJson(json['forwarding_to'] as Map), + replyingTo: json['replying_to'] == null + ? null + : SnPost.fromJson(json['replying_to'] as Map), + forwardingTo: json['forwarding_to'] == null + ? null + : SnPost.fromJson(json['forwarding_to'] as Map), ); Map _$PostComposeInitialStateToJson( diff --git a/lib/screens/posts/post_search.dart b/lib/screens/posts/post_search.dart index 921c8919..93288ad3 100644 --- a/lib/screens/posts/post_search.dart +++ b/lib/screens/posts/post_search.dart @@ -7,9 +7,12 @@ import 'package:island/models/post.dart'; import 'package:island/pods/network.dart'; import 'package:island/widgets/app_scaffold.dart'; import 'package:island/widgets/post/post_item.dart'; - +import 'package:island/widgets/posts/post_filter.dart'; +import 'package:gap/gap.dart'; import 'package:island/pods/paging.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( @@ -36,6 +39,14 @@ class PostSearchNotifier extends AsyncNotifier> return []; } + bool? _includeReplies; + bool _mediaOnly = false; + String? _queryTerm; + String? _order; + bool _orderDesc = true; + int? _periodStart; + int? _periodEnd; + Future search( String query, { String? pubName, @@ -45,6 +56,13 @@ class PostSearchNotifier extends AsyncNotifier> List? tags, bool shuffle = false, bool? pinned, + bool? includeReplies, + bool mediaOnly = false, + String? queryTerm, + String? order, + bool orderDesc = true, + int? periodStart, + int? periodEnd, }) async { _currentQuery = query.trim(); _pubName = pubName; @@ -54,6 +72,13 @@ class PostSearchNotifier extends AsyncNotifier> _tags = tags; _shuffle = shuffle; _pinned = pinned; + _includeReplies = includeReplies; + _mediaOnly = mediaOnly; + _queryTerm = queryTerm; + _order = order; + _orderDesc = orderDesc; + _periodStart = periodStart; + _periodEnd = periodEnd; final hasFilters = pubName != null || @@ -62,7 +87,13 @@ class PostSearchNotifier extends AsyncNotifier> categories != null || tags != null || shuffle || - pinned != null; + pinned != null || + includeReplies != null || + mediaOnly || + queryTerm != null || + order != null || + periodStart != null || + periodEnd != null; if (_currentQuery.isEmpty && !hasFilters) { state = const AsyncData([]); @@ -91,6 +122,13 @@ class PostSearchNotifier extends AsyncNotifier> if (_categories != null) 'categories': _categories, if (_shuffle) 'shuffle': true, if (_pinned != null) 'pinned': _pinned, + if (_includeReplies != null) 'includeReplies': _includeReplies, + if (_mediaOnly) 'mediaOnly': true, + if (_queryTerm != null) 'queryTerm': _queryTerm, + if (_order != null) 'order': _order, + if (_orderDesc) 'orderDesc': true, + if (_periodStart != null) 'periodStart': _periodStart, + if (_periodEnd != null) 'periodEnd': _periodEnd, }, ); @@ -117,6 +155,17 @@ class PostSearchScreen extends HookConsumerWidget { final shuffleValue = useState(false); final pinnedValue = useState(null); + // State variables for PostFilterWidget + final categoryTabController = useTabController(initialLength: 3); + final includeReplies = useState(null); + final mediaOnly = useState(false); + final queryTerm = useState(null); + final order = useState('date'); + final orderDesc = useState(true); + final periodStart = useState(null); + final periodEnd = useState(null); + final showAdvancedFilters = useState(false); + useEffect(() { return () { searchController.dispose(); @@ -130,7 +179,21 @@ class PostSearchScreen extends HookConsumerWidget { if (debounceTimer.value?.isActive ?? false) debounceTimer.value!.cancel(); debounceTimer.value = Timer(debounce, () { - ref.read(postSearchProvider.notifier).search(query); + ref + .read(postSearchProvider.notifier) + .search( + query, + type: categoryTabController.index == 1 + ? 0 + : (categoryTabController.index == 2 ? 1 : null), + includeReplies: includeReplies.value, + mediaOnly: mediaOnly.value, + queryTerm: queryTerm.value, + order: order.value, + orderDesc: orderDesc.value, + periodStart: periodStart.value, + periodEnd: periodEnd.value, + ); }); } @@ -142,20 +205,28 @@ class PostSearchScreen extends HookConsumerWidget { .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, + pubName: pubNameController.text.isNotEmpty + ? pubNameController.text + : null, + realm: realmController.text.isNotEmpty + ? realmController.text + : null, + type: categoryTabController.index == 1 + ? 0 + : (categoryTabController.index == 2 ? 1 : null), + categories: selectedCategories.value.isNotEmpty + ? selectedCategories.value + : null, tags: selectedTags.value.isNotEmpty ? selectedTags.value : null, shuffle: shuffleValue.value, pinned: pinnedValue.value, + includeReplies: includeReplies.value, + mediaOnly: mediaOnly.value, + queryTerm: queryTerm.value, + order: order.value, + orderDesc: orderDesc.value, + periodStart: periodStart.value, + periodEnd: periodEnd.value, ); }); } @@ -164,187 +235,213 @@ class PostSearchScreen extends HookConsumerWidget { 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); - }, - ), - Text('shuffle'.tr()), - ], - ), - Row( - children: [ - Checkbox( - value: pinnedValue.value ?? false, - onChanged: (value) { - pinnedValue.value = value; - onSearchWithFilters(searchController.text); - }, - ), - Text('pinned'.tr()), - ], - ), - ], - ), - ), + return PostFilterWidget( + categoryTabController: categoryTabController, + includeReplies: includeReplies, + mediaOnly: mediaOnly, + queryTerm: queryTerm, + order: order, + orderDesc: orderDesc, + periodStart: periodStart, + periodEnd: periodEnd, + showAdvancedFilters: showAdvancedFilters, + 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, + appBar: isWideScreen(context) + ? null + : 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, + ), ), - ), - style: TextStyle( - color: Theme.of(context).appBarTheme.foregroundColor, - ), - onChanged: onSearchChanged, - onSubmitted: (value) { - onSearchWithFilters(value); - }, - autofocus: true, + IconButton( + icon: Icon( + showFilters.value + ? Icons.filter_alt + : Icons.filter_alt_outlined, + ), + onPressed: toggleFilters, + tooltip: 'toggleFilters'.tr(), + ), + ], ), ), - IconButton( - icon: Icon( - showFilters.value - ? Icons.filter_alt - : Icons.filter_alt_outlined, - ), - onPressed: toggleFilters, - tooltip: 'toggleFilters'.tr(), - ), - ], - ), - ), body: Consumer( builder: (context, ref, child) { final searchState = ref.watch(postSearchProvider); - return CustomScrollView( - slivers: [ - if (showFilters.value) - SliverToBoxAdapter( - child: Center( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 600), - child: buildFilterPanel(), + return isWideScreen(context) + ? Row( + children: [ + Flexible( + flex: 4, + child: CustomScrollView( + slivers: [ + SliverGap(16), + SliverToBoxAdapter( + 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) { + onSearchWithFilters(value); + }, + ), + ), + const SliverGap(16), + if (showFilters.value && !isWideScreen(context)) + SliverToBoxAdapter(child: buildFilterPanel()), + // Use PaginationList with isSliver=true + PaginationList( + provider: postSearchProvider, + notifier: postSearchProvider.notifier, + isSliver: true, + isRefreshable: false, + 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), ), - ), - ), - // Use PaginationList with isSliver=true - PaginationList( - provider: postSearchProvider, - notifier: postSearchProvider.notifier, - isSliver: true, - isRefreshable: - false, // CustomScrollView handles refreshing usually, but here we don't have PullToRefresh - itemBuilder: (context, index, post) { - return Center( - child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: 600), - child: Card( - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, + 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: toggleFilters, + tooltip: 'toggleFilters'.tr(), + ), + const Gap(4), + ], + ), + ), + ), + const Gap(8), + if (showFilters.value) buildFilterPanel(), + ], + ), ), - child: PostActionableItem(item: post, borderRadius: 8), ), ), - ); - }, - ), - if (searchState.value?.isEmpty == true && - searchController.text.isNotEmpty && - !searchState.isLoading) - SliverFillRemaining( - child: Center(child: Text('noResultsFound'.tr())), - ), - ], - ); + ], + ) + : CustomScrollView( + slivers: [ + if (showFilters.value) + SliverToBoxAdapter( + child: Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 600), + child: buildFilterPanel(), + ), + ), + ), + // Use PaginationList with isSliver=true + PaginationList( + provider: postSearchProvider, + notifier: postSearchProvider.notifier, + isSliver: true, + isRefreshable: false, + itemBuilder: (context, index, post) { + return Center( + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 600), + child: 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())), + ), + ], + ); }, ), ); diff --git a/lib/screens/posts/publisher_profile.dart b/lib/screens/posts/publisher_profile.dart index 956a070b..32661b85 100644 --- a/lib/screens/posts/publisher_profile.dart +++ b/lib/screens/posts/publisher_profile.dart @@ -22,6 +22,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 +83,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 +123,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,45 +204,41 @@ class _PublisherBasisWidget extends StatelessWidget { ), subStatus .when( - data: - (status) => FilledButton.icon( - onPressed: - subscribing.value - ? null - : (status.isSubscribed - ? unsubscribe - : subscribe), - icon: Icon( - status.isSubscribed - ? Symbols.remove_circle - : Symbols.add_circle, - ), - label: - Text( - status.isSubscribed - ? 'unsubscribe' - : 'subscribe', - ).tr(), - style: ButtonStyle( - visualDensity: VisualDensity( - vertical: -2, - ), - ), + data: (status) => FilledButton.icon( + onPressed: subscribing.value + ? null + : (status.isSubscribed + ? unsubscribe + : subscribe), + icon: Icon( + status.isSubscribed + ? Symbols.remove_circle + : Symbols.add_circle, + ), + label: Text( + status.isSubscribed + ? 'unsubscribe' + : 'subscribe', + ).tr(), + style: ButtonStyle( + visualDensity: VisualDensity( + vertical: -2, ), + ), + ), error: (_, _) => const SizedBox(), - loading: - () => const SizedBox( - height: 36, - child: Center( - child: SizedBox( - width: 20, - height: 20, - child: CircularProgressIndicator( - strokeWidth: 2, - ), - ), + loading: () => const SizedBox( + height: 36, + child: Center( + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + strokeWidth: 2, ), ), + ), + ), ) .padding(vertical: 12), ], @@ -271,10 +270,10 @@ class _PublisherBadgesWidget extends StatelessWidget { Widget build(BuildContext context) { return (badges.value?.isNotEmpty ?? false) ? Card( - child: BadgeList( - badges: badges.value!, - ).padding(horizontal: 26, vertical: 20), - ).padding(horizontal: 4) + child: BadgeList( + badges: badges.value!, + ).padding(horizontal: 26, vertical: 20), + ).padding(horizontal: 4) : const SizedBox.shrink(); } } @@ -288,9 +287,9 @@ class _PublisherVerificationWidget extends StatelessWidget { Widget build(BuildContext context) { return (data.verification != null) ? Card( - margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - child: VerificationStatusCard(mark: data.verification!), - ) + margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: VerificationStatusCard(mark: data.verification!), + ) : const SizedBox.shrink(); } } @@ -333,14 +332,12 @@ class _PublisherHeatmapWidget extends StatelessWidget { @override Widget build(BuildContext context) { return heatmap.when( - data: - (data) => - data != null - ? ActivityHeatmapWidget( - heatmap: data, - forceDense: forceDense, - ).padding(horizontal: 8) - : const SizedBox.shrink(), + data: (data) => data != null + ? ActivityHeatmapWidget( + heatmap: data, + forceDense: forceDense, + ).padding(horizontal: 8) + : const SizedBox.shrink(), loading: () => const SizedBox.shrink(), error: (_, _) => const SizedBox.shrink(), ); @@ -372,242 +369,16 @@ class _PublisherCategoryTabWidget extends StatelessWidget { @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( - 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(), - ), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ], - ), + return PostFilterWidget( + categoryTabController: categoryTabController, + includeReplies: includeReplies, + mediaOnly: mediaOnly, + queryTerm: queryTerm, + order: order, + orderDesc: orderDesc, + periodStart: periodStart, + periodEnd: periodEnd, + showAdvancedFilters: showAdvancedFilters, ); } } @@ -739,205 +510,34 @@ class PublisherProfileScreen extends HookConsumerWidget { ); return publisher.when( - data: - (data) => AppScaffold( - isNoBackground: false, - appBar: - isWideScreen(context) - ? AppBar( - foregroundColor: appbarColor.value, - leading: PageBackButton( - color: appbarColor.value, - shadows: [appbarShadow], - ), - title: Text( - data.nick, - style: TextStyle( - color: - appbarColor.value ?? - Theme.of(context).appBarTheme.foregroundColor, - shadows: [appbarShadow], - ), - ), - ) - : null, - body: - isWideScreen(context) - ? Row( - children: [ - Flexible( - flex: 4, - child: CustomScrollView( - slivers: [ - SliverGap(16), - SliverToBoxAdapter( - child: Card( - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: ListTile( - title: Text('pinnedPosts'.tr()), - leading: const Icon(Symbols.push_pin), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(8), - ), - ), - trailing: Icon( - isPinnedExpanded.value - ? Symbols.expand_less - : Symbols.expand_more, - ), - onTap: - () => - isPinnedExpanded.value = - !isPinnedExpanded.value, - ), - ), - ), - ...[ - if (isPinnedExpanded.value) - SliverPostList(pubName: name, pinned: true), - ], - SliverToBoxAdapter( - child: _PublisherCategoryTabWidget( - categoryTabController: categoryTabController, - includeReplies: includeReplies, - mediaOnly: mediaOnly, - queryTerm: queryTerm, - order: order, - orderDesc: orderDesc, - periodStart: periodStart, - periodEnd: periodEnd, - showAdvancedFilters: showAdvancedFilters, - ), - ), - 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, - ), - ], - ).padding(left: 8), - ), - Flexible( - flex: 3, - child: Align( - alignment: Alignment.topLeft, - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - _PublisherBasisWidget( - data: data, - subStatus: subStatus, - subscribing: subscribing, - subscribe: subscribe, - unsubscribe: unsubscribe, - ).padding(horizontal: 4, top: 20), - _PublisherBadgesWidget( - data: data, - badges: badges, - ), - _PublisherVerificationWidget(data: data), - _PublisherBioWidget(data: data), - _PublisherHeatmapWidget( - heatmap: heatmap, - forceDense: true, - ).padding(vertical: 4), - ], - ), - ), - ), - ), - ], - ) - : CustomScrollView( + data: (data) => AppScaffold( + isNoBackground: false, + appBar: isWideScreen(context) + ? AppBar( + foregroundColor: appbarColor.value, + leading: PageBackButton( + color: appbarColor.value, + shadows: [appbarShadow], + ), + title: Text( + data.nick, + style: TextStyle( + color: + appbarColor.value ?? + Theme.of(context).appBarTheme.foregroundColor, + shadows: [appbarShadow], + ), + ), + ) + : null, + body: isWideScreen(context) + ? Row( + children: [ + Flexible( + flex: 4, + child: CustomScrollView( slivers: [ - SliverAppBar( - foregroundColor: appbarColor.value, - expandedHeight: 180, - pinned: true, - leading: PageBackButton( - color: appbarColor.value, - shadows: [appbarShadow], - ), - flexibleSpace: Stack( - children: [ - Positioned.fill( - child: - data.background?.id != null - ? CloudImageWidget( - file: data.background, - ) - : Container( - color: - Theme.of( - context, - ).appBarTheme.backgroundColor, - ), - ), - FlexibleSpaceBar( - title: Text( - data.nick, - style: TextStyle( - color: - appbarColor.value ?? - Theme.of( - context, - ).appBarTheme.foregroundColor, - shadows: [appbarShadow], - ), - ), - background: - Container(), // Empty container since background is handled by Stack - ), - ], - ), - ), - SliverToBoxAdapter( - child: _PublisherBasisWidget( - data: data, - subStatus: subStatus, - subscribing: subscribing, - subscribe: subscribe, - unsubscribe: unsubscribe, - ).padding(horizontal: 4, top: 8), - ), - SliverToBoxAdapter( - child: _PublisherBadgesWidget( - data: data, - badges: badges, - ), - ), - SliverToBoxAdapter( - child: _PublisherVerificationWidget(data: data), - ), - SliverToBoxAdapter( - child: _PublisherBioWidget(data: data), - ), - SliverToBoxAdapter( - child: _PublisherHeatmapWidget( - heatmap: heatmap, - ).padding(vertical: 4), - ), + SliverGap(16), SliverToBoxAdapter( child: Card( margin: EdgeInsets.symmetric( @@ -946,15 +546,19 @@ class PublisherProfileScreen extends HookConsumerWidget { ), child: ListTile( title: Text('pinnedPosts'.tr()), + leading: const Icon(Symbols.push_pin), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(8), + ), + ), trailing: Icon( isPinnedExpanded.value ? Symbols.expand_less : Symbols.expand_more, ), - onTap: - () => - isPinnedExpanded.value = - !isPinnedExpanded.value, + onTap: () => isPinnedExpanded.value = + !isPinnedExpanded.value, ), ), ), @@ -981,10 +585,9 @@ class PublisherProfileScreen extends HookConsumerWidget { ), pubName: name, pinned: false, - type: - categoryTab.value == 1 - ? 0 - : (categoryTab.value == 2 ? 1 : null), + type: categoryTab.value == 1 + ? 0 + : (categoryTab.value == 2 ? 1 : null), includeReplies: includeReplies.value, mediaOnly: mediaOnly.value, queryTerm: queryTerm.value, @@ -995,20 +598,158 @@ class PublisherProfileScreen extends HookConsumerWidget { ), 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: [ + _PublisherBasisWidget( + data: data, + subStatus: subStatus, + subscribing: subscribing, + subscribe: subscribe, + unsubscribe: unsubscribe, + ).padding(horizontal: 4, top: 20), + _PublisherBadgesWidget(data: data, badges: badges), + _PublisherVerificationWidget(data: data), + _PublisherBioWidget(data: data), + _PublisherHeatmapWidget( + heatmap: heatmap, + forceDense: true, + ).padding(vertical: 4), + ], + ), + ), ), - ), - error: - (error, stackTrace) => AppScaffold( - isNoBackground: false, - appBar: AppBar(leading: const PageBackButton()), - body: Center(child: Text(error.toString())), - ), - loading: - () => AppScaffold( - isNoBackground: false, - appBar: AppBar(leading: const PageBackButton()), - body: Center(child: CircularProgressIndicator()), - ), + ), + ], + ) + : CustomScrollView( + slivers: [ + SliverAppBar( + foregroundColor: appbarColor.value, + expandedHeight: 180, + pinned: true, + leading: PageBackButton( + color: appbarColor.value, + shadows: [appbarShadow], + ), + flexibleSpace: Stack( + children: [ + Positioned.fill( + child: data.background?.id != null + ? CloudImageWidget(file: data.background) + : Container( + color: Theme.of( + context, + ).appBarTheme.backgroundColor, + ), + ), + FlexibleSpaceBar( + title: Text( + data.nick, + style: TextStyle( + color: + appbarColor.value ?? + Theme.of(context).appBarTheme.foregroundColor, + shadows: [appbarShadow], + ), + ), + background: + Container(), // Empty container since background is handled by Stack + ), + ], + ), + ), + SliverToBoxAdapter( + child: _PublisherBasisWidget( + data: data, + subStatus: subStatus, + subscribing: subscribing, + subscribe: subscribe, + unsubscribe: unsubscribe, + ).padding(horizontal: 4, top: 8), + ), + SliverToBoxAdapter( + child: _PublisherBadgesWidget(data: data, badges: badges), + ), + SliverToBoxAdapter( + child: _PublisherVerificationWidget(data: data), + ), + SliverToBoxAdapter(child: _PublisherBioWidget(data: data)), + SliverToBoxAdapter( + child: _PublisherHeatmapWidget( + heatmap: heatmap, + ).padding(vertical: 4), + ), + SliverToBoxAdapter( + child: Card( + margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: ListTile( + title: Text('pinnedPosts'.tr()), + trailing: Icon( + isPinnedExpanded.value + ? Symbols.expand_less + : Symbols.expand_more, + ), + onTap: () => + isPinnedExpanded.value = !isPinnedExpanded.value, + ), + ), + ), + ...[ + if (isPinnedExpanded.value) + SliverPostList(pubName: name, pinned: true), + ], + SliverToBoxAdapter( + child: _PublisherCategoryTabWidget( + categoryTabController: categoryTabController, + includeReplies: includeReplies, + mediaOnly: mediaOnly, + queryTerm: queryTerm, + order: order, + orderDesc: orderDesc, + periodStart: periodStart, + periodEnd: periodEnd, + showAdvancedFilters: showAdvancedFilters, + ), + ), + 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), + ], + ), + ), + error: (error, stackTrace) => AppScaffold( + isNoBackground: false, + appBar: AppBar(leading: const PageBackButton()), + body: Center(child: Text(error.toString())), + ), + loading: () => AppScaffold( + isNoBackground: false, + appBar: AppBar(leading: const PageBackButton()), + body: Center(child: CircularProgressIndicator()), + ), ); } } diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 41cd0553..30a2c6dd 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -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,10 +249,9 @@ class SettingsScreen extends HookConsumerWidget { showDialog( context: context, builder: (context) { - Color selectedColor = - settings.appColorScheme != null - ? Color(settings.appColorScheme!) - : Colors.indigo; + Color selectedColor = settings.appColorScheme != null + ? Color(settings.appColorScheme!) + : Colors.indigo; return AlertDialog( title: Text('Seed Color').tr(), @@ -292,10 +291,9 @@ class SettingsScreen extends HookConsumerWidget { height: 24, margin: EdgeInsets.symmetric(horizontal: 2, vertical: 8), decoration: BoxDecoration( - color: - settings.appColorScheme != null - ? Color(settings.appColorScheme!) - : Colors.indigo, + color: settings.appColorScheme != null + ? Color(settings.appColorScheme!) + : Colors.indigo, shape: BoxShape.circle, border: Border.all( color: Theme.of( @@ -310,19 +308,17 @@ class SettingsScreen extends HookConsumerWidget { // Custom colors section Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8), - child: - Text( - 'Custom Colors', - style: Theme.of(context).textTheme.titleMedium, - ).bold(), + child: Text( + 'Custom Colors', + style: Theme.of(context).textTheme.titleMedium, + ).bold(), ), // Primary color _ColorPickerTile( title: 'Primary', - color: - settings.customColors?.primary != null - ? Color(settings.customColors!.primary!) - : null, + color: settings.customColors?.primary != null + ? Color(settings.customColors!.primary!) + : null, onColorChanged: (color) { final current = settings.customColors ?? ThemeColors(); ref @@ -333,10 +329,9 @@ class SettingsScreen extends HookConsumerWidget { // Secondary _ColorPickerTile( title: 'Secondary', - color: - settings.customColors?.secondary != null - ? Color(settings.customColors!.secondary!) - : null, + color: settings.customColors?.secondary != null + ? Color(settings.customColors!.secondary!) + : null, onColorChanged: (color) { final current = settings.customColors ?? ThemeColors(); ref @@ -347,10 +342,9 @@ class SettingsScreen extends HookConsumerWidget { // Tertiary _ColorPickerTile( title: 'Tertiary', - color: - settings.customColors?.tertiary != null - ? Color(settings.customColors!.tertiary!) - : null, + color: settings.customColors?.tertiary != null + ? Color(settings.customColors!.tertiary!) + : null, onColorChanged: (color) { final current = settings.customColors ?? ThemeColors(); ref @@ -361,10 +355,9 @@ class SettingsScreen extends HookConsumerWidget { // Surface _ColorPickerTile( title: 'Surface', - color: - settings.customColors?.surface != null - ? Color(settings.customColors!.surface!) - : null, + color: settings.customColors?.surface != null + ? Color(settings.customColors!.surface!) + : null, onColorChanged: (color) { final current = settings.customColors ?? ThemeColors(); ref @@ -375,10 +368,9 @@ class SettingsScreen extends HookConsumerWidget { // Background _ColorPickerTile( title: 'Background', - color: - settings.customColors?.background != null - ? Color(settings.customColors!.background!) - : null, + color: settings.customColors?.background != null + ? Color(settings.customColors!.background!) + : null, onColorChanged: (color) { final current = settings.customColors ?? ThemeColors(); ref @@ -391,10 +383,9 @@ class SettingsScreen extends HookConsumerWidget { // Error _ColorPickerTile( title: 'Error', - color: - settings.customColors?.error != null - ? Color(settings.customColors!.error!) - : null, + color: settings.customColors?.error != null + ? Color(settings.customColors!.error!) + : null, onColorChanged: (color) { final current = settings.customColors ?? ThemeColors(); ref @@ -509,8 +500,9 @@ class SettingsScreen extends HookConsumerWidget { // Background image enabled 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(); @@ -536,8 +528,9 @@ class SettingsScreen extends HookConsumerWidget { // Clear background image option 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(); @@ -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(); @@ -598,8 +592,8 @@ class SettingsScreen extends HookConsumerWidget { ); final color = MediaQuery.of(context).platformBrightness == Brightness.dark - ? colorScheme.primary - : colorScheme.primary; + ? colorScheme.primary + : colorScheme.primary; ref .read(appSettingsProvider.notifier) .setAppColorScheme(color.value); @@ -674,20 +668,19 @@ class SettingsScreen extends HookConsumerWidget { trailing: DropdownButtonHideUnderline( child: DropdownButton2( isExpanded: true, - items: - validPools.map((p) { - return DropdownMenuItem( - value: p.id, - child: Tooltip( - message: p.name, - child: Text( - p.name, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ).fontSize(14), - ), - ); - }).toList(), + items: validPools.map((p) { + return DropdownMenuItem( + value: p.id, + child: Tooltip( + message: p.name, + child: Text( + p.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ).fontSize(14), + ), + ); + }).toList(), value: currentPoolId, onChanged: (value) { ref @@ -705,19 +698,17 @@ class SettingsScreen extends HookConsumerWidget { ), ); }, - loading: - () => const ListTile( - minLeadingWidth: 48, - title: Text('Loading pools...'), - leading: CircularProgressIndicator(), - ), - error: - (err, st) => ListTile( - minLeadingWidth: 48, - title: Text('settingsDefaultPool').tr(), - subtitle: Text('Error: $err'), - leading: const Icon(Icons.error, color: Colors.red), - ), + loading: () => const ListTile( + minLeadingWidth: 48, + title: Text('Loading pools...'), + leading: CircularProgressIndicator(), + ), + error: (err, st) => ListTile( + minLeadingWidth: 48, + title: Text('settingsDefaultPool').tr(), + subtitle: Text('Error: $err'), + leading: const Icon(Icons.error, color: Colors.red), + ), ), ]; @@ -767,10 +758,9 @@ class SettingsScreen extends HookConsumerWidget { ListTile( minLeadingWidth: 48, title: Text('settingsEnterToSend').tr(), - subtitle: - isDesktop - ? Text('settingsEnterToSendDesktopHint').tr().fontSize(12) - : null, + subtitle: isDesktop + ? Text('settingsEnterToSendDesktopHint').tr().fontSize(12) + : null, contentPadding: const EdgeInsets.only(left: 24, right: 17), leading: const Icon(Symbols.send), trailing: Switch( @@ -823,33 +813,32 @@ class SettingsScreen extends HookConsumerWidget { ]; // Desktop-specific settings - final desktopSettings = - !isDesktop - ? [] - : [ - ListTile( - minLeadingWidth: 48, - title: Text('settingsWindowOpacity').tr(), - contentPadding: const EdgeInsets.only(left: 24, right: 17), - leading: const Icon(Symbols.opacity), - subtitle: Padding( - padding: const EdgeInsets.only(top: 8), - child: Slider( - value: settings.windowOpacity, - min: 0.1, - max: 1.0, - year2023: true, - padding: EdgeInsets.only(right: 24), - label: '${(settings.windowOpacity * 100).round()}%', - onChanged: (value) { - ref - .read(appSettingsProvider.notifier) - .setWindowOpacity(value); - }, - ), + final desktopSettings = !isDesktop + ? [] + : [ + ListTile( + minLeadingWidth: 48, + title: Text('settingsWindowOpacity').tr(), + contentPadding: const EdgeInsets.only(left: 24, right: 17), + leading: const Icon(Symbols.opacity), + subtitle: Padding( + padding: const EdgeInsets.only(top: 8), + child: Slider( + value: settings.windowOpacity, + min: 0.1, + max: 1.0, + year2023: true, + padding: EdgeInsets.only(right: 24), + label: '${(settings.windowOpacity * 100).round()}%', + onChanged: (value) { + ref + .read(appSettingsProvider.notifier) + .setWindowOpacity(value); + }, ), ), - ]; + ), + ]; // Create a responsive layout based on screen width Widget buildSettingsList() { diff --git a/lib/services/file_uploader.dart b/lib/services/file_uploader.dart index d379765c..c3a60014 100644 --- a/lib/services/file_uploader.dart +++ b/lib/services/file_uploader.dart @@ -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 = []; 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))); } diff --git a/lib/widgets/attachment_uploader.dart b/lib/widgets/attachment_uploader.dart index c443073f..ace0791e 100644 --- a/lib/widgets/attachment_uploader.dart +++ b/lib/widgets/attachment_uploader.dart @@ -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,13 +79,12 @@ class _AttachmentUploaderSheetState extends State { children: [ DropdownButtonFormField( value: selectedPoolId, - items: - pools.map((pool) { - return DropdownMenuItem( - value: pool.id, - child: Text(pool.name), - ); - }).toList(), + items: pools.map((pool) { + return DropdownMenuItem( + value: pool.id, + child: Text(pool.name), + ); + }).toList(), onChanged: (value) { setState(() { selectedPoolId = value; @@ -140,10 +139,9 @@ class _AttachmentUploaderSheetState extends State { Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: - Theme.of( - context, - ).colorScheme.errorContainer, + color: Theme.of( + context, + ).colorScheme.errorContainer, borderRadius: BorderRadius.circular(8), ), child: Column( @@ -155,23 +153,22 @@ class _AttachmentUploaderSheetState extends State { Icon( Symbols.warning, size: 18, - color: - Theme.of( - context, - ).colorScheme.error, + 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, - ), + fontWeight: FontWeight.w600, + ), ), ], ), @@ -183,28 +180,28 @@ class _AttachmentUploaderSheetState extends State { _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, - ), + ), ), ], if (!typeAccepted) ...[ 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,10 +226,9 @@ class _AttachmentUploaderSheetState extends State { ), ], ), - style: - Theme.of( - context, - ).textTheme.bodyMedium, + style: Theme.of( + context, + ).textTheme.bodyMedium, ).fontSize(13), ), ], @@ -300,8 +296,8 @@ class _AttachmentUploaderSheetState extends State { final maxFileSize = selectedPool.policyConfig?['max_file_size'] as int?; final fileSizeExceeded = maxFileSize != null && fileSize > maxFileSize; - final acceptTypes = - (selectedPool.policyConfig?['accept_types'] as List?)?.cast(); + final acceptTypes = (selectedPool.policyConfig?['accept_types'] as List?) + ?.cast(); final mimeType = attachment.data.mimeType ?? ComposeLogic.getMimeTypeFromFileType(attachment.type); diff --git a/lib/widgets/file_list_view.dart b/lib/widgets/file_list_view.dart index b1d6a824..afb030a6 100644 --- a/lib/widgets/file_list_view.dart +++ b/lib/widgets/file_list_view.dart @@ -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,45 +123,39 @@ class FileListView extends HookConsumerWidget { notifier: unindexedFileListProvider.notifier, isRefreshable: false, isSliver: true, - contentBuilder: - (data, footer) => - data.isEmpty - ? SliverToBoxAdapter( - child: _buildEmptyUnindexedFilesHint(ref), - ) - : _buildUnindexedFileListContent( - data, - ref, - context, - viewMode, - isSelectionMode, - selectedFileIds, - currentVisibleItems, - footer, - ), + contentBuilder: (data, footer) => data.isEmpty + ? SliverToBoxAdapter(child: _buildEmptyUnindexedFilesHint(ref)) + : _buildUnindexedFileListContent( + data, + ref, + context, + viewMode, + isSelectionMode, + selectedFileIds, + currentVisibleItems, + footer, + ), ), _ => PaginationWidget( provider: indexedCloudFileListProvider, notifier: indexedCloudFileListProvider.notifier, isRefreshable: false, isSliver: true, - contentBuilder: - (data, footer) => - data.isEmpty - ? SliverToBoxAdapter( - child: _buildEmptyDirectoryHint(ref, currentPath), - ) - : _buildFileListContent( - data, - ref, - context, - currentPath, - viewMode, - isSelectionMode, - selectedFileIds, - currentVisibleItems, - footer, - ), + contentBuilder: (data, footer) => data.isEmpty + ? SliverToBoxAdapter( + child: _buildEmptyDirectoryHint(ref, currentPath), + ) + : _buildFileListContent( + data, + ref, + context, + currentPath, + viewMode, + isSelectionMode, + selectedFileIds, + currentVisibleItems, + footer, + ), ), }; @@ -177,11 +171,10 @@ class FileListView extends HookConsumerWidget { style: TextStyle(fontWeight: FontWeight.bold), ); } else { - final pathParts = - currentPath.value - .split('/') - .where((part) => part.isNotEmpty) - .toList(); + final pathParts = currentPath.value + .split('/') + .where((part) => part.isNotEmpty) + .toList(); final breadcrumbs = []; // Add root @@ -266,10 +259,9 @@ class FileListView extends HookConsumerWidget { dragging.value = false; }, child: Container( - color: - dragging.value - ? Theme.of(context).primaryColor.withOpacity(0.1) - : null, + color: dragging.value + ? Theme.of(context).primaryColor.withOpacity(0.1) + : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -302,28 +294,25 @@ class FileListView extends HookConsumerWidget { ? Symbols.arrow_back : Symbols.folder, ), - onPressed: - isRefreshing - ? null - : () { - if (mode.value == FileListMode.unindexed) { - mode.value = FileListMode.normal; - currentPath.value = '/'; - } else { - final pathParts = - currentPath.value - .split('/') - .where((part) => part.isNotEmpty) - .toList(); - if (pathParts.isNotEmpty) { - pathParts.removeLast(); - currentPath.value = - pathParts.isEmpty - ? '/' - : '/${pathParts.join('/')}'; - } + onPressed: isRefreshing + ? null + : () { + if (mode.value == FileListMode.unindexed) { + mode.value = FileListMode.normal; + currentPath.value = '/'; + } else { + final pathParts = currentPath.value + .split('/') + .where((part) => part.isNotEmpty) + .toList(); + if (pathParts.isNotEmpty) { + pathParts.removeLast(); + currentPath.value = pathParts.isEmpty + ? '/' + : '/${pathParts.join('/')}'; } - }, + } + }, visualDensity: const VisualDensity( horizontal: -4, vertical: -4, @@ -342,16 +331,13 @@ class FileListView extends HookConsumerWidget { ? Symbols.view_module : Symbols.list, ), - onPressed: - () => - viewMode.value = - viewMode.value == FileListViewMode.list - ? FileListViewMode.waterfall - : FileListViewMode.list, - tooltip: + onPressed: () => viewMode.value = viewMode.value == FileListViewMode.list - ? 'Switch to Waterfall View' - : 'Switch to List View', + ? FileListViewMode.waterfall + : FileListViewMode.list, + tooltip: viewMode.value == FileListViewMode.list + ? 'Switch to Waterfall View' + : 'Switch to List View', visualDensity: const VisualDensity( horizontal: -4, vertical: -4, @@ -363,12 +349,11 @@ class FileListView extends HookConsumerWidget { ? Symbols.close : Symbols.select_check_box, ), - onPressed: - () => isSelectionMode.value = !isSelectionMode.value, - tooltip: - isSelectionMode.value - ? 'Exit Selection Mode' - : 'Enter Selection Mode', + onPressed: () => + isSelectionMode.value = !isSelectionMode.value, + tooltip: isSelectionMode.value + ? 'Exit Selection Mode' + : 'Enter Selection Mode', visualDensity: const VisualDensity( horizontal: -4, vertical: -4, @@ -377,9 +362,8 @@ class FileListView extends HookConsumerWidget { if (mode.value == FileListMode.normal) IconButton( icon: const Icon(Symbols.create_new_folder), - onPressed: - () => - onShowCreateDirectory(ref.context, currentPath), + onPressed: () => + onShowCreateDirectory(ref.context, currentPath), tooltip: 'Create Directory', visualDensity: const VisualDensity( horizontal: -4, @@ -397,10 +381,9 @@ class FileListView extends HookConsumerWidget { recycled.value = !recycled.value; unindexedNotifier.setRecycled(recycled.value); }, - tooltip: - recycled.value - ? 'Show Active Files' - : 'Show Recycle Bin', + tooltip: recycled.value + ? 'Show Active Files' + : 'Show Recycle Bin', visualDensity: const VisualDensity( horizontal: -4, vertical: -4, @@ -429,12 +412,14 @@ class FileListView extends HookConsumerWidget { if (mode.value == FileListMode.normal && currentPath.value == '/') _buildUnindexedFilesEntry(ref).padding(bottom: 12), Expanded( - child: CustomScrollView( - slivers: [bodyWidget, const SliverGap(12)], - ).padding( - horizontal: - viewMode.value == FileListViewMode.waterfall ? 12 : null, - ), + child: + CustomScrollView( + slivers: [bodyWidget, const SliverGap(12)], + ).padding( + horizontal: viewMode.value == FileListViewMode.waterfall + ? 12 + : null, + ), ), if (isSelectionMode.value) Material( @@ -457,16 +442,15 @@ class FileListView extends HookConsumerWidget { const Gap(12), OutlinedButton( onPressed: () { - final allIds = - currentVisibleItems.value - .expand( - (item) => item.maybeMap( - file: (f) => [f.fileIndex.id], - unindexedFile: (u) => [u.file.id], - orElse: () => [], - ), - ) - .toSet(); + final allIds = currentVisibleItems.value + .expand( + (item) => item.maybeMap( + file: (f) => [f.fileIndex.id], + unindexedFile: (u) => [u.file.id], + orElse: () => [], + ), + ) + .toSet(); if (allIds .difference(selectedFileIds.value) @@ -482,16 +466,16 @@ class FileListView extends HookConsumerWidget { currentVisibleItems.value.isEmpty ? 'Select All' : currentVisibleItems.value - .expand( - (item) => item.maybeMap( - file: (f) => [f.fileIndex.id], - unindexedFile: (u) => [u.file.id], - orElse: () => [], - ), - ) - .toSet() - .difference(selectedFileIds.value) - .isEmpty + .expand( + (item) => item.maybeMap( + file: (f) => [f.fileIndex.id], + unindexedFile: (u) => [u.file.id], + orElse: () => [], + ), + ) + .toSet() + .difference(selectedFileIds.value) + .isEmpty ? 'Deselect All' : 'Select All', ), @@ -502,47 +486,46 @@ class FileListView extends HookConsumerWidget { ElevatedButton.icon( icon: const Icon(Symbols.delete), label: const Text('Delete'), - onPressed: - selectedFileIds.value.isNotEmpty - ? () async { - final confirmed = await showConfirmAlert( - 'Are you sure you want to delete the selected files?', - 'Delete Selected Files', - isDanger: true, + onPressed: selectedFileIds.value.isNotEmpty + ? () async { + final confirmed = await showConfirmAlert( + 'Are you sure you want to delete the selected files?', + 'Delete Selected Files', + isDanger: true, + ); + if (!confirmed) return; + if (context.mounted) { + showLoadingModal(context); + } + try { + final client = ref.read(apiClientProvider); + final resp = await client.post( + '/drive/files/batches/delete', + data: { + 'file_ids': selectedFileIds.value + .toList(), + }, ); - if (!confirmed) return; + final count = resp.data['count'] as int; + selectedFileIds.value.clear(); + isSelectionMode.value = false; + ref.invalidate( + mode.value == FileListMode.normal + ? indexedCloudFileListProvider + : unindexedFileListProvider, + ); + showSnackBar('Deleted $count files.'); + } catch (e) { + showSnackBar( + 'Failed to delete selected files.', + ); + } finally { if (context.mounted) { - showLoadingModal(context); - } - try { - final client = ref.read(apiClientProvider); - final resp = await client.post( - '/drive/files/batches/delete', - data: { - 'file_ids': - selectedFileIds.value.toList(), - }, - ); - final count = resp.data['count'] as int; - selectedFileIds.value.clear(); - isSelectionMode.value = false; - ref.invalidate( - mode.value == FileListMode.normal - ? indexedCloudFileListProvider - : unindexedFileListProvider, - ); - showSnackBar('Deleted $count files.'); - } catch (e) { - showSnackBar( - 'Failed to delete selected files.', - ); - } finally { - if (context.mounted) { - hideLoadingModal(context); - } + hideLoadingModal(context); } } - : null, + } + : null, ), ], ), @@ -584,26 +567,24 @@ class FileListView extends HookConsumerWidget { final item = items[index]; return item.map( - file: - (fileItem) => _buildWaterfallFileTile( - fileItem, - ref, - context, - isSelectionMode.value, - selectedFileIds.value.contains(fileItem.fileIndex.id), - () { - if (selectedFileIds.value.contains(fileItem.fileIndex.id)) { - selectedFileIds.value = Set.from(selectedFileIds.value) - ..remove(fileItem.fileIndex.id); - } else { - selectedFileIds.value = Set.from(selectedFileIds.value) - ..add(fileItem.fileIndex.id); - } - }, - ), - folder: - (folderItem) => - _buildWaterfallFolderTile(folderItem, currentPath, context), + file: (fileItem) => _buildWaterfallFileTile( + fileItem, + ref, + context, + isSelectionMode.value, + selectedFileIds.value.contains(fileItem.fileIndex.id), + () { + if (selectedFileIds.value.contains(fileItem.fileIndex.id)) { + selectedFileIds.value = Set.from(selectedFileIds.value) + ..remove(fileItem.fileIndex.id); + } else { + selectedFileIds.value = Set.from(selectedFileIds.value) + ..add(fileItem.fileIndex.id); + } + }, + ), + folder: (folderItem) => + _buildWaterfallFolderTile(folderItem, currentPath, context), unindexedFile: (unindexedFileItem) { // Should not happen return const SizedBox.shrink(); @@ -620,47 +601,44 @@ class FileListView extends HookConsumerWidget { } final item = items[index]; return item.map( - file: - (fileItem) => _buildIndexedListTile( - fileItem, - ref, - context, - isSelectionMode.value, - selectedFileIds.value.contains(fileItem.fileIndex.id), - () { - if (selectedFileIds.value.contains(fileItem.fileIndex.id)) { - selectedFileIds.value = Set.from(selectedFileIds.value) - ..remove(fileItem.fileIndex.id); - } else { - selectedFileIds.value = Set.from(selectedFileIds.value) - ..add(fileItem.fileIndex.id); - } - }, - ), - folder: - (folderItem) => ListTile( - leading: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(8)), - child: SizedBox( - height: 48, - width: 48, - child: const Icon(Symbols.folder, fill: 1).center(), - ), - ), - title: Text( - folderItem.folderName, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - subtitle: const Text('folder').tr(), - onTap: () { - final newPath = - currentPath.value == '/' - ? '/${folderItem.folderName}' - : '${currentPath.value}/${folderItem.folderName}'; - currentPath.value = newPath; - }, + file: (fileItem) => _buildIndexedListTile( + fileItem, + ref, + context, + isSelectionMode.value, + selectedFileIds.value.contains(fileItem.fileIndex.id), + () { + if (selectedFileIds.value.contains(fileItem.fileIndex.id)) { + selectedFileIds.value = Set.from(selectedFileIds.value) + ..remove(fileItem.fileIndex.id); + } else { + selectedFileIds.value = Set.from(selectedFileIds.value) + ..add(fileItem.fileIndex.id); + } + }, + ), + folder: (folderItem) => ListTile( + leading: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(8)), + child: SizedBox( + height: 48, + width: 48, + child: const Icon(Symbols.folder, fill: 1).center(), ), + ), + title: Text( + folderItem.folderName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + subtitle: const Text('folder').tr(), + onTap: () { + final newPath = currentPath.value == '/' + ? '/${folderItem.folderName}' + : '${currentPath.value}/${folderItem.folderName}'; + currentPath.value = newPath; + }, + ), unindexedFile: (unindexedFileItem) { // Should not happen in normal mode return const SizedBox.shrink(); @@ -705,10 +683,9 @@ class FileListView extends HookConsumerWidget { ValueNotifier currentPath, ) { return Card( - margin: - viewMode.value == FileListViewMode.waterfall - ? const EdgeInsets.fromLTRB(0, 0, 0, 16) - : const EdgeInsets.fromLTRB(12, 0, 12, 16), + margin: viewMode.value == FileListViewMode.waterfall + ? const EdgeInsets.fromLTRB(0, 0, 0, 16) + : const EdgeInsets.fromLTRB(12, 0, 12, 16), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 48), child: Column( @@ -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,22 +829,20 @@ class FileListView extends HookConsumerWidget { .read(apiClientProvider) .get(uri) .then((response) => response.data as String), - builder: - (context, snapshot) => - snapshot.hasData - ? SingleChildScrollView( - padding: EdgeInsets.all(24), - child: Text( - snapshot.data!, - style: const TextStyle( - fontSize: 9, - fontFamily: 'monospace', - ), - maxLines: 20, - overflow: TextOverflow.ellipsis, - ), - ) - : const Center(child: CircularProgressIndicator()), + builder: (context, snapshot) => snapshot.hasData + ? SingleChildScrollView( + padding: EdgeInsets.all(24), + child: Text( + snapshot.data!, + style: const TextStyle( + fontSize: 9, + fontFamily: 'monospace', + ), + maxLines: 20, + overflow: TextOverflow.ellipsis, + ), + ) + : const Center(child: CircularProgressIndicator()), ), ); break; @@ -961,10 +937,9 @@ class FileListView extends HookConsumerWidget { return InkWell( borderRadius: BorderRadius.circular(8), onTap: () { - final newPath = - currentPath.value == '/' - ? '/${folderItem.folderName}' - : '${currentPath.value}/${folderItem.folderName}'; + final newPath = currentPath.value == '/' + ? '/${folderItem.folderName}' + : '${currentPath.value}/${folderItem.folderName}'; currentPath.value = newPath; }, child: Container( @@ -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,25 +1052,22 @@ class FileListView extends HookConsumerWidget { // Should not happen in unindexed mode return const SizedBox.shrink(); }, - unindexedFile: - (unindexedFileItem) => _buildUnindexedListTile( - unindexedFileItem, - ref, - context, - isSelectionMode.value, - selectedFileIds.value.contains(unindexedFileItem.file.id), - () { - if (selectedFileIds.value.contains( - unindexedFileItem.file.id, - )) { - selectedFileIds.value = Set.from(selectedFileIds.value) - ..remove(unindexedFileItem.file.id); - } else { - selectedFileIds.value = Set.from(selectedFileIds.value) - ..add(unindexedFileItem.file.id); - } - }, - ), + unindexedFile: (unindexedFileItem) => _buildUnindexedListTile( + unindexedFileItem, + ref, + context, + isSelectionMode.value, + selectedFileIds.value.contains(unindexedFileItem.file.id), + () { + if (selectedFileIds.value.contains(unindexedFileItem.file.id)) { + selectedFileIds.value = Set.from(selectedFileIds.value) + ..remove(unindexedFileItem.file.id); + } else { + selectedFileIds.value = Set.from(selectedFileIds.value) + ..add(unindexedFileItem.file.id); + } + }, + ), ); }, ), @@ -1130,10 +1102,9 @@ class FileListView extends HookConsumerWidget { ), ], ), - title: - file.name.isEmpty - ? Text('untitled').tr().italic() - : Text(file.name, maxLines: 1, overflow: TextOverflow.ellipsis), + title: file.name.isEmpty + ? Text('untitled').tr().italic() + : Text(file.name, maxLines: 1, overflow: TextOverflow.ellipsis), subtitle: Text(formatFileSize(file.size)), onTap: () { if (isSelectionMode) { @@ -1199,10 +1170,9 @@ class FileListView extends HookConsumerWidget { ), ], ), - title: - file.name.isEmpty - ? Text('untitled').tr().italic() - : Text(file.name, maxLines: 1, overflow: TextOverflow.ellipsis), + title: file.name.isEmpty + ? Text('untitled').tr().italic() + : Text(file.name, maxLines: 1, overflow: TextOverflow.ellipsis), subtitle: Text(formatFileSize(file.size)), onTap: () { if (isSelectionMode) { @@ -1289,10 +1259,9 @@ class FileListView extends HookConsumerWidget { Widget _buildEmptyUnindexedFilesHint(WidgetRef ref) { return Card( - margin: - viewMode.value == FileListViewMode.waterfall - ? EdgeInsets.zero - : const EdgeInsets.fromLTRB(12, 0, 12, 0), + margin: viewMode.value == FileListViewMode.waterfall + ? EdgeInsets.zero + : const EdgeInsets.fromLTRB(12, 0, 12, 0), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 48), child: Column( @@ -1395,19 +1364,18 @@ class FileListView extends HookConsumerWidget { ObjectRef queryDebounceTimer, ) { final poolDropdownItems = poolsAsync.when( - data: - (pools) => [ - const DropdownMenuItem( - value: null, - child: Text('All Pools', style: TextStyle(fontSize: 14)), - ), - ...pools.map( - (p) => DropdownMenuItem( - value: p, - child: Text(p.name, style: const TextStyle(fontSize: 14)), - ), - ), - ], + data: (pools) => [ + const DropdownMenuItem( + value: null, + child: Text('All Pools', style: TextStyle(fontSize: 14)), + ), + ...pools.map( + (p) => DropdownMenuItem( + value: p, + child: Text(p.name, style: const TextStyle(fontSize: 14)), + ), + ), + ], loading: () => const >[], error: (err, stack) => const >[], ); @@ -1416,17 +1384,16 @@ class FileListView extends HookConsumerWidget { child: DropdownButton2( value: selectedPool.value, items: poolDropdownItems, - onChanged: - isRefreshing - ? null - : (value) { - selectedPool.value = value; - if (mode.value == FileListMode.unindexed) { - unindexedNotifier.setPool(value?.id); - } else { - cloudNotifier.setPool(value?.id); - } - }, + onChanged: isRefreshing + ? null + : (value) { + selectedPool.value = value; + if (mode.value == FileListMode.unindexed) { + unindexedNotifier.setPool(value?.id); + } else { + cloudNotifier.setPool(value?.id); + } + }, customButton: Container( height: 28, width: 200, @@ -1493,19 +1460,17 @@ class FileListView extends HookConsumerWidget { final orderDropdown = DropdownButtonHideUnderline( child: DropdownButton2( value: order.value, - items: - ['date', 'size', 'name'] - .map( - (e) => DropdownMenuItem( - value: e, - child: - Text( - e == 'date' ? e : 'file${e.capitalizeEachWord()}', - style: const TextStyle(fontSize: 14), - ).tr(), - ), - ) - .toList(), + items: ['date', 'size', 'name'] + .map( + (e) => DropdownMenuItem( + value: e, + child: Text( + e == 'date' ? e : 'file${e.capitalizeEachWord()}', + style: const TextStyle(fontSize: 14), + ).tr(), + ), + ) + .toList(), onChanged: (value) => order.value = value, customButton: Container( height: 28, @@ -1517,13 +1482,12 @@ class FileListView extends HookConsumerWidget { borderRadius: BorderRadius.circular(8), ), child: Center( - child: - Text( - (order.value ?? 'date') == 'date' - ? (order.value ?? 'date') - : 'file${order.value?.capitalizeEachWord()}', - style: const TextStyle(fontSize: 12), - ).tr(), + child: Text( + (order.value ?? 'date') == 'date' + ? (order.value ?? 'date') + : 'file${order.value?.capitalizeEachWord()}', + style: const TextStyle(fontSize: 12), + ).tr(), ), ), buttonStyleData: const ButtonStyleData( diff --git a/lib/widgets/post/compose_shared.dart b/lib/widgets/post/compose_shared.dart index 569cd08a..c3822fc3 100644 --- a/lib/widgets/post/compose_shared.dart +++ b/lib/widgets/post/compose_shared.dart @@ -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>(); + final embeds = (originalPost!.meta!['embeds'] as List) + .cast>(); try { final pollEmbed = embeds.firstWhere((e) => e['type'] == 'poll'); pollId = pollEmbed['id']; @@ -202,11 +202,10 @@ class ComposeLogic { final attachment = state.attachments.value[i]; if (attachment.data is! SnCloudFile) { try { - final cloudFile = - await FileUploader.createCloudFile( - ref: ref, - fileData: attachment, - ).future; + final cloudFile = await FileUploader.createCloudFile( + ref: ref, + fileData: attachment, + ).future; if (cloudFile != null) { // Update attachments list with cloud file final clone = List.of(state.attachments.value); @@ -242,11 +241,10 @@ class ComposeLogic { repliedPost: null, forwardedPostId: null, forwardedPost: null, - attachments: - state.attachments.value - .map((e) => e.data) - .whereType() - .toList(), + attachments: state.attachments.value + .map((e) => e.data) + .whereType() + .toList(), publisher: SnPublisher( id: '', type: 0, @@ -315,11 +313,10 @@ class ComposeLogic { repliedPost: null, forwardedPostId: null, forwardedPost: null, - attachments: - state.attachments.value - .map((e) => e.data) - .whereType() - .toList(), + attachments: state.attachments.value + .map((e) => e.data) + .whereType() + .toList(), publisher: SnPublisher( id: '', type: 0, @@ -501,11 +498,10 @@ class ComposeLogic { UniversalFile value, int index, ) { - state.attachments.value = - state.attachments.value.mapIndexed((idx, ele) { - if (idx == index) return value; - return ele; - }).toList(); + state.attachments.value = state.attachments.value.mapIndexed((idx, ele) { + if (idx == index) return value; + return ele; + }).toList(); } static Future uploadAttachment( @@ -528,22 +524,20 @@ class ComposeLogic { final pools = await ref.read(poolsProvider.future); final selectedPoolId = resolveDefaultPoolId(ref, pools); - cloudFile = - await FileUploader.createCloudFile( - ref: ref, - fileData: attachment, - poolId: poolId ?? selectedPoolId, - mode: - attachment.type == UniversalFileType.file - ? FileUploadMode.generic - : FileUploadMode.mediaSafe, - onProgress: (progress, _) { - state.attachmentProgress.value = { - ...state.attachmentProgress.value, - index: progress ?? 0.0, - }; - }, - ).future; + cloudFile = await FileUploader.createCloudFile( + ref: ref, + fileData: attachment, + poolId: poolId ?? selectedPoolId, + mode: attachment.type == UniversalFileType.file + ? FileUploadMode.generic + : FileUploadMode.mediaSafe, + onProgress: (progress, _) { + state.attachmentProgress.value = { + ...state.attachmentProgress.value, + index: progress ?? 0.0, + }; + }, + ).future; if (cloudFile == null) { throw ArgumentError('Failed to upload the file...'); @@ -713,11 +707,10 @@ class ComposeLogic { if (state.slugController.text.isNotEmpty) 'slug': state.slugController.text, 'visibility': state.visibility.value, - 'attachments': - state.attachments.value - .where((e) => e.isOnCloud) - .map((e) => e.data.id) - .toList(), + 'attachments': state.attachments.value + .where((e) => e.isOnCloud) + .map((e) => e.data.id) + .toList(), 'type': state.postType, if (repliedPost != null) 'replied_post_id': repliedPost.id, if (forwardedPost != null) 'forwarded_post_id': forwardedPost.id, diff --git a/lib/widgets/post/post_list.dart b/lib/widgets/post/post_list.dart index 3e2be9e4..6698fc0c 100644 --- a/lib/widgets/post/post_list.dart +++ b/lib/widgets/post/post_list.dart @@ -1,81 +1,12 @@ import 'package:flutter/material.dart'; -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'; +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? categories, - List? 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, PostListQuery>( - PostListNotifier.new, - ); - -class PostListNotifier extends AsyncNotifier> - with AsyncPaginationController { - final PostListQuery arg; - PostListNotifier(this.arg); - - static const int pageSize = 20; - - @override - Future> 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 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 diff --git a/lib/widgets/post/post_reaction_sheet.freezed.dart b/lib/widgets/post/post_reaction_sheet.freezed.dart index 46d3d44d..03c651c5 100644 --- a/lib/widgets/post/post_reaction_sheet.freezed.dart +++ b/lib/widgets/post/post_reaction_sheet.freezed.dart @@ -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 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` /// diff --git a/lib/widgets/posts/post_filter.dart b/lib/widgets/posts/post_filter.dart new file mode 100644 index 00000000..6a15f4e9 --- /dev/null +++ b/lib/widgets/posts/post_filter.dart @@ -0,0 +1,271 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:material_symbols_icons/symbols.dart'; + +class PostFilterWidget extends StatelessWidget { + final TabController categoryTabController; + final ValueNotifier includeReplies; + final ValueNotifier mediaOnly; + final ValueNotifier queryTerm; + final ValueNotifier order; + final ValueNotifier orderDesc; + final ValueNotifier periodStart; + final ValueNotifier periodEnd; + final ValueNotifier showAdvancedFilters; + final bool hideSearch; + + const PostFilterWidget({ + super.key, + 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, + this.hideSearch = false, + }); + + @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: [ + if (!hideSearch) + 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; + }, + ), + if (!hideSearch) const Gap(12), + DropdownButtonFormField( + 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(), + ), + ), + ), + ), + ], + ), + ], + ), + ), + ], + ], + ), + ); + } +} diff --git a/lib/widgets/upload_overlay.dart b/lib/widgets/upload_overlay.dart index b86a97ab..e86ca097 100644 --- a/lib/widgets/upload_overlay.dart +++ b/lib/widgets/upload_overlay.dart @@ -5,7 +5,7 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/models/drive_task.dart'; -import 'package:island/pods/upload_tasks.dart'; +import 'package:island/pods/drive/upload_tasks.dart'; import 'package:island/services/responsive.dart'; import 'package:material_symbols_icons/material_symbols_icons.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -223,14 +223,14 @@ class _UploadOverlayContent extends HookConsumerWidget { if (!isExpanded && activeTasks.isNotEmpty) Text( _getOverallProgressText(activeTasks), - style: Theme.of( - context, - ).textTheme.bodySmall?.copyWith( - color: - Theme.of( + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith( + color: Theme.of( context, ).colorScheme.onSurfaceVariant, - ), + ), ), ], ), @@ -244,10 +244,9 @@ class _UploadOverlayContent extends HookConsumerWidget { child: CircularProgressIndicator( value: _getOverallProgress(activeTasks), strokeWidth: 3, - backgroundColor: - Theme.of( - context, - ).colorScheme.surfaceContainerHighest, + backgroundColor: Theme.of( + context, + ).colorScheme.surfaceContainerHighest, ), ), @@ -263,8 +262,8 @@ class _UploadOverlayContent extends HookConsumerWidget { size: 20, ), ), - onPressed: - () => onExpansionChanged?.call(!isExpanded), + onPressed: () => + onExpansionChanged?.call(!isExpanded), padding: EdgeInsets.zero, constraints: const BoxConstraints(), ), @@ -297,20 +296,18 @@ class _UploadOverlayContent extends HookConsumerWidget { leading: Icon( Symbols.clear_all, size: 18, - color: - Theme.of( - context, - ).colorScheme.onSurfaceVariant, + color: Theme.of( + context, + ).colorScheme.onSurfaceVariant, ), onTap: () { taskNotifier.clearCompletedTasks(); onExpansionChanged?.call(false); }, - tileColor: - Theme.of( - context, - ).colorScheme.surfaceContainerHighest, + tileColor: Theme.of( + context, + ).colorScheme.surfaceContainerHighest, ), ), @@ -326,17 +323,17 @@ class _UploadOverlayContent extends HookConsumerWidget { leading: Icon( Symbols.clear_all, size: 18, - color: - Theme.of(context).colorScheme.error, + color: Theme.of( + context, + ).colorScheme.error, ), onTap: () { taskNotifier.clearAllTasks(); onExpansionChanged?.call(false); }, - tileColor: - Theme.of( - context, - ).colorScheme.surfaceContainerHighest, + tileColor: Theme.of( + context, + ).colorScheme.surfaceContainerHighest, ), ), @@ -556,8 +553,9 @@ class _UploadTaskTileState extends State child: CircularProgressIndicator( value: widget.task.progress, strokeWidth: 2.5, - backgroundColor: - Theme.of(context).colorScheme.surfaceContainerHighest, + backgroundColor: Theme.of( + context, + ).colorScheme.surfaceContainerHighest, ), ), ), @@ -604,10 +602,9 @@ class _UploadTaskTileState extends State color = Theme.of(context).colorScheme.secondary; break; case DriveTaskStatus.inProgress: - icon = - widget.task.type == 'FileDownload' - ? Symbols.download - : Symbols.upload; + icon = widget.task.type == 'FileDownload' + ? Symbols.download + : Symbols.upload; color = Theme.of(context).colorScheme.primary; break; case DriveTaskStatus.paused: