Compare commits

...

29 Commits

Author SHA1 Message Date
2c4040096f 🚀 Launch 1.2.1+36 2024-09-13 20:22:33 +08:00
b449735bf5 Better side navigation
🐛 Bug fixes and optimizations
2024-09-13 20:22:10 +08:00
dd01f964d4 Focused realm linked with feed stream 2024-09-13 00:17:56 +08:00
6daa04c208 Brand new app navigation region 2024-09-12 23:55:31 +08:00
19ec0a7ede 🚀 Launch 1.2.1+35 2024-09-12 20:29:08 +08:00
f3b2a2a0ac 👽 The removal of external id 2024-09-11 23:40:23 +08:00
bba38e6845 🌐 Localize daily sign history chart 2024-09-11 22:03:43 +08:00
408a2489e2 ♻️ Move translations out of dart code 2024-09-11 19:56:32 +08:00
133213b430 🚑 Hot fix thumbnail duration issue 2024-09-10 23:52:10 +08:00
2ff142a84f 🚀 Launch 1.2.1+33 2024-09-10 23:46:08 +08:00
e385f79df2 Attachment thumbnail 2024-09-10 22:47:28 +08:00
8d9a8b5435 🧑‍💻 All in one auto cache image widget 2024-09-10 21:53:05 +08:00
c5a975b5ed Setting of attachment thumbnail 2024-09-10 21:36:10 +08:00
1210cda998 Roll back to use media_kit as media player 2024-09-09 23:09:16 +08:00
3b56b94242 🚀 Launch 1.2.1+30 2024-09-09 13:07:21 +08:00
34043e722b Able to play music 2024-09-08 22:43:01 +08:00
e4a5ac9d0a 🚑 Fix cannot load ongoing call 2024-09-08 16:03:50 +08:00
c991590b27 🚀 Launch 1.2.1+28 2024-09-08 12:47:27 +08:00
d8b2c7f81e User experience & level 2024-09-08 12:32:21 +08:00
1fd042bcae 🐛 Bug fixes on profile page 2024-09-08 01:48:01 +08:00
0a04c72468 Daily sign history 2024-09-08 00:23:59 +08:00
4e8f2ddef3 🎨 Use SizedBox.shrink instead of empty SizedBox for placeholder 2024-09-07 17:48:07 +08:00
85f97521e5 🎨 Use Gap instead of empty SizedBox 2024-09-07 17:45:44 +08:00
9c451f485a 🎨 Refactored all models with json annotation to make code cleaner 2024-09-07 15:36:06 +08:00
f836b22c73 💄 Remove message ripple effect 2024-09-06 23:55:44 +08:00
18fba0c9e7 🚀 Launch 1.2.1+27 2024-09-05 21:41:01 +08:00
c68138e516 🐛 Fix missing gap between sections in dashboard 2024-09-05 21:13:50 +08:00
cedd0b083a 🐛 Fix overflow in dashboard 2024-09-05 20:28:22 +08:00
1a0721ba3a Better dashboard design for large screen (and mobile device) 2024-09-05 20:25:17 +08:00
122 changed files with 4184 additions and 2513 deletions

View File

@ -22,7 +22,8 @@
android:label="Solian"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:supportsRtl="true">
android:supportsRtl="true"
android:usesCleartextTraffic="true">
<receiver android:exported="false"
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:exported="false"

396
assets/locales/en_us.json Normal file
View File

@ -0,0 +1,396 @@
{
"done": "Done",
"hide": "Hide",
"okay": "Okay",
"next": "Next",
"reset": "Reset",
"page": "Page",
"home": "Home",
"guest": "Guest",
"draft": "Draft",
"dashboard": "Dashboard",
"today": "Today",
"yesterday": "Yesterday",
"draftSave": "Save",
"draftBox": "Draft Box",
"more": "More",
"share": "Share",
"shareNoUri": "Share text content",
"alias": "Alias",
"feed": "Feed",
"explore": "Explore",
"posts": "Posts",
"unlink": "Unlink",
"feedSearch": "Search Feed",
"feedSearchWithTag": "Searching with tag #@key",
"feedSearchWithCategory": "Searching in category @category",
"feedUnreadCount": "@count posts you may missed",
"messages": "Messages",
"messagesUnreadCount": "@count messages unread",
"dailySign": "Daily Sign",
"dailySignAction": "Sign Today",
"dailySignHistoryAction": "View History",
"dailySignNone": "You haven't sign today",
"dailySignTier0": "Everything may not be good",
"dailySignTier1": "Something may be wrong",
"dailySignTier2": "Just so so",
"dailySignTier3": "Something may goes well",
"dailySignTier4": "Everything will be awesome",
"dailySignHistoryTitle": "Fortune History",
"dailySignHistoryRecent": "Recent Fortune",
"dailySignHistoryReward": "Reward Trends",
"dashboardFooter": "Don't be serious, just for fun.",
"visitProfilePage": "Visit Profile Page",
"profilePage": "Page",
"profilePosts": "Posts",
"profileAlbum": "Album",
"chat": "Chat",
"apply": "Apply",
"cancel": "Cancel",
"confirm": "Confirm",
"leave": "Leave",
"loading": "Loading...",
"about": "About",
"edit": "Edit",
"delete": "Delete",
"settings": "Settings",
"search": "Search",
"post": "Post",
"article": "Article",
"reply": "Reply",
"repost": "Repost",
"openInAlbum": "Open in album",
"openInBrowser": "Open in browser",
"notification": "Notification",
"notificationUnreadCount": "@count unread notifications",
"errorHappened": "An error occurred",
"errorHappenedUnauthorized": "Unauthorized request, please sign in or try resign in.",
"forgotPassword": "Forgot password",
"email": "Email",
"username": "Username",
"nickname": "Nickname",
"password": "Password",
"title": "Title",
"description": "Description",
"birthday": "Birthday",
"firstName": "First Name",
"lastName": "Last Name",
"account": "Account",
"accountPersonalize": "Personalize",
"accountPersonalizeApplied": "Account personalize settings has been saved.",
"accountStickers": "Stickers",
"accountFriend": "Friend",
"accountFriendNew": "New friend",
"accountFriendNewHint": "Use someone's username to send a request of making friends with them!",
"accountFriendPending": "Friend requests",
"accountFriendBlocked": "Friend blocklist",
"accountFriendListHint": "Swipe left to decline, right to approve",
"accountFriendRequestSent": "Friend request sent, waiting for processing...",
"accountSuspended": "Account was suspended",
"accountSuspendedAt": "Account was suspended since @date",
"aspectRatio": "Aspect Ratio",
"aspectRatioSquare": "Square",
"aspectRatioPortrait": "Portrait",
"aspectRatioLandscape": "Landscape",
"unsignedIn": "Unsigned in",
"signin": "Sign in",
"signinRequired": "Sign in",
"signinRequiredHint": "Sign in to get full access of Solar Network",
"signinGreeting": "Welcome back\nSolar Network",
"signinCaption": "Sign in to create post, start a realm, message your friend and more!",
"signinRiskDetected": "Risk detected, click Next to open a webpage and signin through it to pass security check.",
"signinResetPasswordHint": "Please enter username to request reset password.",
"signinResetPasswordSent": "Reset password request sent, check your inbox!",
"signup": "Sign up",
"signupGreeting": "Welcome onboard",
"signupCaption": "Create an account on Solarpass and then get the access of entire Solar Network!",
"signupDone": "Sign up successfully.",
"signupDoneCaption": "You successfully created an account on Solar Network. Now go sign in!",
"signout": "Sign out",
"joinedAt": "Joined at @date",
"riskDetection": "Risk Detected",
"matureContent": "Mature Content",
"matureContentCaption": "The content is rated and may not suitable for everyone to view",
"notifyAllRead": "Mark all as read",
"notifyEmpty": "All notifications read",
"notifyEmptyCaption": "It seems like nothing happened recently",
"totalSocialCreditPoints": "Social Credit Points",
"totalPostCount": "Posts",
"totalUpvote": "Upvote",
"totalDownvote": "Downvote",
"clear": "Clear",
"pinPost": "Pin this post",
"unpinPost": "Unpin this post",
"postRestoreFromLocal": "Restore from local",
"postAutoSaveAt": "Auto saved at @date",
"postCategoriesAndTags": "Categories n' Tags",
"postPublishDate": "Publish Date",
"postPublishAt": "Publish At",
"postPublishedUntil": "Publish Until",
"postPublishZone": "Publish Zone",
"postPublishZoneNone": "None",
"postVisibility": "Visibility",
"postVisibilityAll": "Everyone",
"postVisibilityFriends": "Friends",
"postVisibilitySelected": "Selected visible",
"postVisibilityFiltered": "Selected invisible",
"postVisibilityNone": "Only me",
"postVisibleUsers": "Visible users",
"postInvisibleUsers": "Invisible users",
"postOverview": "Overview",
"postThumbnail": "Thumbnail",
"postThumbnailAttachmentNew": "Upload thumbnail",
"postThumbnailAttachment": "Attachment serial number",
"postPinned": "Pinned",
"postListNews": "News",
"postListFriends": "Friends",
"postListShuffle": "Random",
"postEditorModeStory": "Post a post",
"postEditorModeArticle": "Post an article",
"postEditor": "Post editor",
"articleEditor": "Create new article",
"articleDetail": "Article details",
"draftBoxOpen": "Open draft box",
"postNew": "Create a new post",
"postNewInRealmHint": "Add post in realm @realm",
"postAction": "Post",
"postEdited": "Edited at @date",
"postNewCreated": "Created at @date",
"attachmentHint": "@count attachment(s)",
"postInRealm": "In @realm",
"postDetail": "Post",
"postReplies": "Replies",
"postPublish": "Post a post",
"articlePublish": "Write an article",
"articleTitlePlaceholder": "Title",
"articleDescriptionPlaceholder": "Description",
"articleContentPlaceholder": "Content",
"postIdentityNotify": "You will post this post as",
"postContentPlaceholder": "What's happened?!",
"postTagsPlaceholder": "Tags",
"postReaction": "Reactions of the Post",
"postActionList": "Actions of Post",
"postReplyAction": "Make a reply",
"postRepliedNotify": "Replied a post from @username.",
"postRepostedNotify": "Reposted a post from @username.",
"postInRealmNotify": "You're posting in realm @realm.",
"postEditingNotify": "You're editing as post from you.",
"postReplyingNotify": "You're replying a post from @username.",
"postRepostingNotify": "You're reposting a post from @username.",
"postDeletionConfirm": "Confirm post deletion",
"postDeletionConfirmCaption": "Are your sure to delete post \"@content\"? This action cannot be undone!",
"reactAdd": "React",
"reactCompleted": "Your reaction has been added",
"reactUncompleted": "Your reaction has been removed",
"attachmentUploadBy": "Upload by",
"attachmentAutoUpload": "Auto Upload",
"attachmentUploadQueue": "Upload Queue",
"attachmentUploadQueueStart": "Start All",
"attachmentUploadInProgress": "There are attachments being uploaded. Please wait until all attachments have been uploaded before proceeding...",
"attachmentAttached": "Exists Files",
"attachmentUploadBlocked": "Upload blocked, there is currently a task in progress...",
"attachmentAdd": "Attach file",
"attachmentAddGalleryPhoto": "Gallery photo",
"attachmentAddGalleryVideo": "Gallery video",
"attachmentAddCameraPhoto": "Capture photo",
"attachmentAddCameraVideo": "Capture video",
"attachmentAddClipboard": "Paste file",
"attachmentAddFile": "Attach file",
"attachmentAddLink": "Link attachments",
"attachmentAddLinkHint": "Enter attachment serial number to link that attachment",
"attachmentAddLinkInput": "Serial number",
"attachmentSetting": "Adjust attachment",
"attachmentAlt": "Alternative text",
"attachmentLoadFailed": "Load Attachment Failed",
"attachmentLoadFailedCaption": "Something went wrong during loading the attachment metadata...",
"attachmentUploading": "Uploading @name...",
"attachmentUploadingWebMode": "Uploading @name... Due to browser's limitation, calculate attachment information may cause some lag...",
"realm": "Realm",
"realms": "Realms",
"realmOrganizing": "Organize a realm",
"realmAlias": "Alias (Identifier)",
"realmName": "Name",
"realmDescription": "Description",
"realmPublic": "Public Realm",
"realmCommunity": "Community Realm",
"realmDetail": "Realm detail",
"realmMember": "Realm member",
"realmMembers": "Realm members",
"realmMembersAdd": "Add realm members",
"realmMembersAddHint": "Into @realm",
"realmAdjust": "Realm adjustment",
"realmSettings": "Realm settings",
"realmEditingNotify": "You're editing realm @realm",
"realmLeaveConfirm": "Confirm realm quit",
"realmLeaveConfirmCaption": "Are you sure you want leave realm @realm? Your content published in this realm will not be deleted.",
"realmDeletionConfirm": "Confirm realm deletion",
"realmDeletionConfirmCaption": "Are you sure to delete realm @realm? This action cannot be undone!",
"channels": "Channels",
"channelNew": "Create a new channel",
"channelNewInRealmHint": "Create channel in realm @realm",
"channelOrganizing": "Organize a channel",
"channelOrganizeCommon": "Create regular channel",
"channelOrganizeDirect": "Create DM",
"channelOrganizeDirectHint": "Choose friend to create DM",
"channelInRealmNotify": "You're creating channel in realm @realm",
"channelEditingNotify": "You're editing channel @channel",
"channelAlias": "Alias (Identifier)",
"channelName": "Name",
"channelDescription": "Description",
"channelDirectDescription": "Direct message with @username",
"channelEncrypted": "Encrypted Channel",
"channelMember": "Channel member",
"channelMembers": "Channel members",
"channelMembersAdd": "Add channel members",
"channelMembersAddHint": "Into @channel",
"channelType": "Channel type",
"channelTypeCommon": "Regular",
"channelTypeDirect": "DM",
"channelAdjust": "Channel adjustment",
"channelDetail": "Channel detail",
"channelSettings": "Channel settings",
"channelLeaveConfirm": "Confirm channel quit",
"channelLeaveConfirmCaption": "Are you sure to leave channel @channel? All your messages will be deleted!",
"channelDeletionConfirm": "Confirm channel deletion",
"channelDeletionConfirmCaption": "Are you sure to delete channel @channel? This action cannot be undone!",
"channelCategoryDirect": "DM",
"channelCategoryDirectHint": "Your direct messages",
"channelNotifyLevel": "Notify level",
"channelNotifyLevelAll": "All",
"channelNotifyLevelMentioned": "Only mentioned",
"channelNotifyLevelNone": "Ignore all",
"channelNotifyLevelApplied": "Your notification settings has been applied.",
"messageUnSync": "Messages Un-synced",
"messageUnSyncCaption": "@count message(s) still in un-synced.",
"messageSending": "Sending...",
"messageEditDesc": "Edited message @id",
"messageDeleteDesc": "Deleted message @id",
"messageCallStartDesc": "@user starts a call",
"messageCallEndDesc": "Call last for @duration",
"messageTypeUnsupported": "Unsupported Message: @type",
"messageInputPlaceholder": "Message @channel",
"messageActionList": "Actions of Message",
"messageDeletionConfirm": "Confirm message deletion",
"messageDeletionConfirmCaption": "Are your sure to delete message @id? This action cannot be undone!",
"call": "Call",
"callOngoing": "A call is ongoing...",
"callOngoingEmpty": "A call is on hold...",
"callOngoingParticipants": "@count people are calling...",
"callOngoingJoined": "Call last @duration",
"callJoin": "Join",
"callResume": "Resume",
"callMicrophone": "Microphone",
"callMicrophoneDisabled": "Microphone Disabled",
"callMicrophoneSelect": "Select Microphone",
"callCamera": "Camera",
"callCameraDisabled": "Camera Disabled",
"callCameraSelect": "Select Camera",
"callSpeakerSelect": "Select Speaker",
"callDisconnected": "Call Disconnected... @reason",
"callMicrophoneOn": "Turn Microphone On",
"callMicrophoneOff": "Turn Microphone Off",
"callCameraOn": "Turn Camera On",
"callCameraOff": "Turn Camera Off",
"callVideoFlip": "Flip Video Input",
"callSpeakerphoneToggle": "Toggle Speakerphone Mode",
"callScreenOn": "Start Screen Sharing",
"callScreenOff": "Stop Screen Sharing",
"callDisconnect": "Disconnect",
"callDisconnectCaption": "Are you sure you want to disconnect from this call? You can also just return to the page, and the call will continue in the background.",
"callParticipantAction": "Participant Actions",
"callParticipantMicrophoneOff": "Mute Participant",
"callParticipantMicrophoneOn": "Unmute Participant",
"callParticipantVideoOff": "Turn Off Participant Video",
"callParticipantVideoOn": "Turn On Participant Video",
"callAlreadyOngoing": "A call is already ongoing",
"badge": "Badge",
"badges": "Badges",
"badgeGrantAt": "Badge awarded on @date",
"badgeSolsynthStaff": "Solsynth Staff",
"badgeSolarOriginalCitizen": "Solar Network Natives",
"badgeGreatCommunityContributor": "Great Community Contributor",
"pushNotifyRegister": "Register Push Notification Device",
"pushNotifyRegisterCaption": "Activating push notifications allows you to get our latest notifications even when the app is completely closed. We use Apple's official push service on iOS/macOS devices; other devices provide push notifications through Google Firebase. To register a device for push notifications, you may need to connect to Google's servers and install the Google Framework on your device. Although you dismiss this dialog, this registration will be auto performed when you next time launch the app.",
"pushNotifyRegisterDone": "Push notifications has been activated.",
"pushNotifyRegisterFailed": "Unable to active push notification... @reason",
"accountChangeStatus": "Change Status",
"accountCustomStatus": "Set Custom Status",
"accountClearStatus": "Clear Status",
"accountStatusOnline": "Online",
"accountStatusSilent": "Do not Disturb",
"accountStatusSilentDesc": "The notification will stop popping up",
"accountStatusInvisible": "Invisible",
"accountStatusInvisibleDesc": "Will show as offline, but all features still remain normal",
"accountStatusOffline": "Offline",
"accountLastSeenAt": "@date ago online",
"accountStatusLabel": "Status Text",
"accountStatusClearAt": "Clear At",
"accountStatusNegative": "Negative",
"accountStatusNeutral": "Neutral",
"accountStatusPositive": "Positive",
"bsLoadingTheme": "Loading Theme",
"bsCheckForUpdate": "Checking For Updates",
"bsCheckForUpdateFailed": "Unable to Check Updates",
"bsCheckForUpdateNew": "Found New Version",
"bsCheckForUpdateDescApple": "Please head to TestFlight and update your app to latest version to prevent error happens and get latest functions.",
"bsCheckForUpdateDescCommon": "Please head to our website download and install latest version of application to prevent error happens and get latest functions.",
"bsCheckingServer": "Checking Server Status",
"bsCheckingServerFail": "Unable connect to server, check your network connection",
"bsCheckingServerDown": "Server currently unavailable, please retry later",
"bsAuthorizing": "Authorizing",
"bsEstablishingConn": "Establishing Connection",
"bsPreparingData": "Preparing User Data",
"bsRegisteringPushNotify": "Enabling Push Notifications",
"bsDismissibleErrorHint": "Click anywhere to ignore this error",
"postShareContent": "@content\n\n@username on the Solar Network\nCheck it out: @link",
"postShareSubject": "@username posted a post on the Solar Network",
"themeColor": "Global Theme Color",
"themeColorRed": "Modern Red",
"themeColorBlue": "Classic Blue",
"themeColorMiku": "Miku Blue",
"themeColorKagamine": "Kagamine Yellow",
"themeColorLuka": "Luka Pink",
"stickerDeletionConfirm": "Confirm sticker delete",
"stickerDeletionConfirmCaption": "Are you sure to delete sticker @name? This action cannot be undo.",
"themeColorApplied": "Global theme color has been applied.",
"attachmentSaved": "Attachment saved to your system album.",
"cropImage": "Crop Image",
"stickerUploader": "Upload sticker",
"stickerUploaderAttachmentNew": "Upload sticker",
"stickerUploaderAttachment": "Attachment serial number",
"stickerUploaderPack": "Sticker pack serial number",
"stickerUploaderPackHint": "Don't have pack id? Head to creator platform and create one!",
"stickerUploaderAlias": "Alias",
"stickerUploaderAliasHint": "Will be used as a placeholder with the sticker pack prefix when entered.",
"stickerUploaderName": "Name",
"stickerUploaderNameHint": "A human-friendly name given to the user in the sticker selection interface.",
"readMore": "Read more",
"attachmentUnload": "Not Loaded",
"attachmentUnloadCaption": "In order to save traffic, this attachment is not loaded automatically. Click it to start loading.",
"callStatusConnected": "Connected",
"callStatusDisconnected": "Disconnected",
"callStatusConnecting": "Connecting",
"callStatusReconnected": "Reconnecting",
"messageOutOfSync": "May Out of Sync with Server",
"messageOutOfSyncCaption": "Since the App has entered the background, there may be a time difference between the message list and the server. Click to Refresh.",
"messageHistoryWipe": "Wipe local message history",
"unknown": "Unknown",
"collapse": "Collapse",
"expand": "Expand",
"typingMessage": "@user are typing...",
"userLevel0": "Newbie",
"userLevel1": "Novice",
"userLevel2": "Apprentice",
"userLevel3": "Explorer",
"userLevel4": "Adventurer",
"userLevel5": "Warrior",
"userLevel6": "Knight",
"userLevel7": "Champion",
"userLevel8": "Hero",
"userLevel9": "Master",
"userLevel10": "Grandmaster",
"userLevel11": "Legend",
"userLevel12": "Mythic",
"userLevel13": "Immortal",
"postBrowsingIn": "Browsing in @region"
}

397
assets/locales/zh_cn.json Normal file
View File

@ -0,0 +1,397 @@
{
"done": "完成",
"hide": "隐藏",
"okay": "确认",
"home": "首页",
"next": "下一步",
"reset": "重置",
"cancel": "取消",
"confirm": "确认",
"leave": "离开",
"loading": "载入中…",
"guest": "游客",
"about": "关于",
"edit": "编辑",
"delete": "删除",
"settings": "设置",
"page": "页面",
"draft": "草稿",
"draftSave": "存为草稿",
"draftBox": "草稿箱",
"more": "更多",
"share": "分享",
"shareNoUri": "分享文字内容",
"alias": "别名",
"feed": "资讯",
"explore": "探索",
"posts": "帖子",
"unlink": "移除链接",
"dashboard": "仪表盘",
"today": "今日",
"yesterday": "昨日",
"feedSearch": "搜索资讯",
"feedSearchWithTag": "检索带有 #@key 标签的资讯",
"feedSearchWithCategory": "检索位于分类 @category 的资讯",
"feedUnreadCount": "@count 条你可能错过的帖子",
"messages": "消息",
"messagesUnreadCount": "@count 条未读的消息",
"dailySign": "签到",
"dailySignAction": "烧香拜佛",
"dailySignHistoryAction": "查看运势历史",
"dailySignNone": "今日未拜访佛祖",
"dailySignTier0": "诸事不宜",
"dailySignTier1": "有些不宜",
"dailySignTier2": "平平淡淡",
"dailySignTier3": "有些事宜",
"dailySignTier4": "诸事皆宜",
"dailySignHistoryTitle": "运势历史",
"dailySignHistoryRecent": "近期运势",
"dailySignHistoryReward": "成果趋势",
"dashboardFooter": "占卜多少沾点玩,人生还得靠实力",
"visitProfilePage": "造访个人主页",
"profilePage": "主页",
"profilePosts": "帖子",
"profileAlbum": "相簿",
"chat": "聊天",
"apply": "应用",
"search": "搜索",
"post": "帖子",
"article": "文章",
"reply": "回复",
"repost": "转帖",
"openInAlbum": "在相簿中打开",
"openInBrowser": "在浏览器中打开",
"notification": "通知",
"notificationUnreadCount": "@count 条未读通知",
"errorHappened": "发生错误了",
"errorHappenedUnauthorized": "未经授权的请求,请登录或尝试重新登录。",
"errorHappenedRequestBad": "请求错误,服务器拒绝处理该请求,请检查您的请求数据。",
"errorHappenedRequestForbidden": "请求错误,权限不足。",
"errorHappenedRequestNotFound": "请求错误,请求的数据不存在。",
"errorHappenedRequestConnection": "网络请求失败,请检查连接状态与服务状态后再试。",
"errorHappenedRequestUnknown": "请求错误,类型未知,请将本提示完整截图提交反馈。",
"forgotPassword": "忘记密码",
"email": "邮件地址",
"username": "用户名",
"nickname": "显示名",
"password": "密码",
"title": "标题",
"description": "简介",
"birthday": "生日",
"firstName": "名称",
"lastName": "姓氏",
"account": "账号",
"accountPersonalize": "个性化",
"accountPersonalizeApplied": "账户的个性化设置已保存。",
"accountStickers": "贴图",
"accountFriend": "好友",
"accountFriendNew": "添加好友",
"accountFriendNewHint": "使用他人的用户名来发送一个好友请求吧!",
"accountFriendPending": "好友请求",
"accountFriendBlocked": "好友黑名单",
"accountFriendListHint": "左滑来拒绝,右滑来接受",
"accountFriendRequestSent": "好友请求已发送,等待处理对方中……",
"accountSuspended": "帐号被停用",
"accountSuspendedAt": "该帐号自 @date 起被停用",
"aspectRatio": "纵横比",
"aspectRatioSquare": "方型",
"aspectRatioPortrait": "竖型",
"aspectRatioLandscape": "横型",
"unsignedIn": "未登录",
"signin": "登录",
"signinRequired": "需要登录",
"signinRequiredHint": "登陆以获得 Solar Network 的全部功能使用权。",
"signinGreeting": "欢迎回来\nSolar Network",
"signinCaption": "登录以发表帖子、文章、创建领域、和你的朋友聊天,以及获取更多功能!",
"signinRiskDetected": "检测到风险,点击下一步按钮来打开一个网页,并通过在其上面登录来通过安全检查。",
"signinResetPasswordHint": "请先填写用户名以发送重置密码请求。",
"signinResetPasswordSent": "重置密码请求已发送,在绑定邮件收件箱可收取一份包含重置密码链接的邮件。",
"signup": "注册",
"signupGreeting": "欢迎加入\nSolar Network",
"signupCaption": "在 Solarpass 注册一个账号以获得整个 Solar Network 的存取权!",
"signupDone": "注册成功",
"signupDoneCaption": "你成功地注册了一个帐户,现在去尝试登陆吧!",
"signout": "登出",
"joinedAt": "加入于 @date",
"riskDetection": "检测到风险",
"matureContent": "评级内容",
"matureContentCaption": "该内容已被评级为家长指导级或以上,这可能说明内容包含一系列不友好的成分",
"notifyAllRead": "已读所有通知",
"notifyEmpty": "通知箱为空",
"notifyEmptyCaption": "看起来最近没发生什么呢",
"totalSocialCreditPoints": "社会信用点",
"totalPostCount": "总帖数",
"totalUpvote": "获顶数",
"totalDownvote": "获踩数",
"clear": "清除",
"pinPost": "置顶本帖",
"unpinPost": "取消置顶本帖",
"postRestoreFromLocal": "内容从本地暂存回复",
"postAutoSaveAt": "已自动保存于 @date",
"postCategoriesAndTags": "分类与标签",
"postPublishDate": "发布时间",
"postPublishAt": "发布帖子于",
"postPublishedUntil": "取消发布于",
"postPublishZone": "帖子发布区",
"postPublishZoneNone": "无所属领域",
"postVisibility": "帖子可见性",
"postVisibilityAll": "所有人可见",
"postVisibilityFriends": "仅好友可见",
"postVisibilitySelected": "选中者可见",
"postVisibilityFiltered": "选中者不可见",
"postVisibilityNone": "仅自己可见",
"postVisibleUsers": "可见帖子者",
"postInvisibleUsers": "隐藏帖子者",
"postOverview": "帖子概览",
"postThumbnail": "帖子缩略图",
"postThumbnailAttachmentNew": "上传附件作为缩略图",
"postThumbnailAttachment": "附件序列号",
"postPinned": "已置顶",
"postEditorModeStory": "发个帖子",
"postEditorModeArticle": "撰写文章",
"postEditor": "帖子编辑器",
"articleEditor": "撰写文章",
"articleDetail": "文章详情",
"draftBoxOpen": "打开草稿箱",
"postListNews": "新鲜事",
"postListFriends": "好友圈",
"postListShuffle": "打乱看",
"postNew": "创建新帖子",
"postNewInRealmHint": "在领域 @realm 里发表新帖子",
"postAction": "发表",
"postEdited": "编辑于 @date",
"postNewCreated": "创建于 @date",
"postInRealm": "发表于 @realm",
"attachmentHint": "@count 个附件",
"postDetail": "帖子详情",
"postReplies": "帖子回复",
"postPublish": "编辑帖子",
"postIdentityNotify": "你将会以本身份发表帖子",
"postContentPlaceholder": "发生什么事了?!",
"postTagsPlaceholder": "标签",
"postReaction": "帖子的反应",
"postActionList": "帖子的操作",
"postReplyAction": "发表一则回复",
"postRepliedNotify": "回了一个 @username 的帖子",
"postRepostedNotify": "转了一个 @username 的帖子",
"postInRealmNotify": "你正在领域 @realm 中发表帖子",
"postEditingNotify": "你正在编辑一个你发布的帖子",
"postReplyingNotify": "你正在回一个来自 @username 的帖子",
"postRepostingNotify": "你正在转一个来自 @username 的帖子",
"postDeletionConfirm": "确认删除帖子",
"postDeletionConfirmCaption": "你确定要删除帖子 “@content” 吗?该操作不可撤销。",
"reactAdd": "作出反应",
"reactCompleted": "你的反应已被添加",
"reactUncompleted": "你的反应已被移除",
"attachmentUploadBy": "由上传",
"attachmentAutoUpload": "自动上传",
"attachmentUploadQueue": "上传队列",
"attachmentUploadQueueStart": "整队上传",
"attachmentUploadInProgress": "有附件正在上传,请等待所有附件上传完毕后再进行操作……",
"attachmentAttached": "已附附件",
"attachmentUploadBlocked": "上传受阻,当前已有任务进行中……",
"attachmentAdd": "附加附件",
"attachmentAddGalleryPhoto": "相册照片",
"attachmentAddGalleryVideo": "相册视频",
"attachmentAddCameraPhoto": "拍摄图片",
"attachmentAddCameraVideo": "拍摄视频",
"attachmentAddClipboard": "粘贴文件",
"attachmentAddFile": "附加文件",
"attachmentAddLink": "链接附件",
"attachmentAddLinkHint": "输入附件的神秘代号来链接对应附件",
"attachmentAddLinkInput": "神秘代号",
"attachmentSetting": "调整附件",
"attachmentAlt": "替代文字",
"attachmentLoadFailed": "加载失败",
"attachmentLoadFailedCaption": "有错误发生于加载附件元数据的过程中了…",
"attachmentUploading": "上传附件 @name 中…",
"attachmentUploadingWebMode": "上传附件 @name 中… 由于浏览器单线程限制,计算所需资源可能会导致界面卡顿…",
"realm": "领域",
"realms": "领域",
"realmOrganizing": "组织领域",
"realmAlias": "别称(标识符)",
"realmName": "显示名称",
"realmDescription": "领域简介",
"realmPublic": "公开领域",
"realmCommunity": "社区领域",
"realmDetail": "领域详情",
"realmMember": "领域成员",
"realmMembers": "领域成员",
"realmMembersAdd": "添加领域成员",
"realmMembersAddHint": "到 @realm",
"realmAdjust": "调整领域",
"realmSettings": "领域设置",
"realmEditingNotify": "你正在编辑领域 @realm",
"realmLeaveConfirm": "确认离开领域",
"realmLeaveConfirmCaption": "你确认要离开领域 @realm 吗?你在该领域发表的内容不会被删除。",
"realmDeletionConfirm": "确认删除领域",
"realmDeletionConfirmCaption": "你确定要删除领域 @realm 嘛?该操作不可撤销。",
"channels": "频道",
"channelNew": "创建新频道",
"channelNewInRealmHint": "在领域 @realm 里创建新频道",
"channelOrganizing": "组织频道",
"channelOrganizeCommon": "创建普通频道",
"channelOrganizeDirect": "创建私信频道",
"channelOrganizeDirectHint": "选择好友来创建私信",
"channelInRealmNotify": "你正在领域 @realm 中创建频道",
"channelEditingNotify": "你正在编辑频道 @channel",
"channelAlias": "别称(标识符)",
"channelName": "显示名称",
"channelDescription": "频道简介",
"channelDirectDescription": "与 @username 的私聊",
"channelEncrypted": "加密频道",
"channelMember": "频道成员",
"channelMembers": "频道成员",
"channelMembersAdd": "添加频道成员",
"channelMembersAddHint": "到 @channel",
"channelType": "频道类型",
"channelTypeCommon": "普通频道",
"channelTypeDirect": "私信聊天",
"channelAdjust": "调整频道",
"channelDetail": "频道详情",
"channelSettings": "频道设置",
"channelLeaveConfirm": "确认离开频道",
"channelLeaveConfirmCaption": "你确认要离开频道 @channel 吗?你在这个频道的消息将被删除。",
"channelDeletionConfirm": "确认删除频道",
"channelDeletionConfirmCaption": "你确认要删除频道 @channel 吗?该操作不可撤销。",
"channelCategoryDirect": "私聊频道",
"channelCategoryDirectHint": "你的所有私聊频道",
"channelNotifyLevel": "通知等级",
"channelNotifyLevelAll": "全部通知",
"channelNotifyLevelMentioned": "仅提及",
"channelNotifyLevelNone": "忽略一切",
"channelNotifyLevelApplied": "你的通知设置已经应用。",
"messageUnSync": "消息未同步",
"messageUnSyncCaption": "还有 @count 条消息未同步",
"messageSending": "消息发送中…",
"messageEditDesc": "修改了消息 @id",
"messageDeleteDesc": "删除了消息 @id",
"messageCallStartDesc": "@user 发起了一次通话",
"messageCallEndDesc": "通话持续了 @duration",
"messageTypeUnsupported": "不支持的消息类型 @type",
"messageInputPlaceholder": "发消息于 @channel",
"messageActionList": "消息的操作",
"messageDeletionConfirm": "确认删除消息",
"messageDeletionConfirmCaption": "你确定要删除消息 @id 吗?该操作不可撤销。",
"call": "通话",
"callOngoing": "一则通话正在进行中…",
"callOngoingEmpty": "一则通话待机中…",
"callOngoingParticipants": "@count 人正在进行通话…",
"callOngoingJoined": "通话进行 @duration",
"callJoin": "加入",
"callResume": "恢复",
"callMicrophone": "麦克风",
"callMicrophoneDisabled": "麦克风禁用",
"callMicrophoneSelect": "选择麦克风",
"callCamera": "摄像头",
"callCameraDisabled": "摄像头禁用",
"callCameraSelect": "选择摄像头",
"callSpeakerSelect": "选择扬声器",
"callDisconnected": "通话已断开… @reason",
"callMicrophoneOn": "开启麦克风",
"callMicrophoneOff": "关闭麦克风",
"callCameraOn": "开启摄像头",
"callCameraOff": "关闭摄像头",
"callVideoFlip": "翻转视频输入",
"callSpeakerphoneToggle": "切换扬声器模式",
"callScreenOn": "启动屏幕分享",
"callScreenOff": "关闭屏幕分享",
"callDisconnect": "断开连接",
"callDisconnectCaption": "你确定要断开与该则通话的连接吗?你也可以直接返回页面,通话将在后台继续。",
"callParticipantAction": "通话参与者的操作",
"callParticipantMicrophoneOff": "静音参与者",
"callParticipantMicrophoneOn": "解除静音参与者",
"callParticipantVideoOff": "静音参与者",
"callParticipantVideoOn": "解除静音参与者",
"callAlreadyOngoing": "当前正在进行一则通话",
"badge": "徽章",
"badges": "徽章",
"badgeGrantAt": "徽章颁发于 @date",
"badgeSolsynthStaff": "Solsynth 工作人员",
"badgeSolarOriginalCitizen": "Solar Network 原住民",
"badgeGreatCommunityContributor": "优秀社区贡献者",
"pushNotifyRegister": "注册推送通知设备",
"pushNotifyRegisterCaption": "激活推送通知便可以让你在应用程序完全关闭的时候仍然获取到我们最新的通知。在 iOS/macOS 设备上我们使用 Apple 官方的推送服务;其他设备则通过 Google Firebase 提供推送通知。要注册推送通知设备,您可能需要连接到 Google 的服务器(在中国大陆不可用)并在您的设备上安装 Google Framework。即使您关闭此对话框下次启动应用程序时仍会自动执行此注册。",
"pushNotifyRegisterDone": "推送通知已成功激活",
"pushNotifyRegisterFailed": "推送通知激活失败…… @reason",
"accountChangeStatus": "变更状态",
"accountCustomStatus": "自定义状态",
"accountClearStatus": "清除状态",
"accountStatusOnline": "在线",
"accountStatusSilent": "请勿打扰",
"accountStatusSilentDesc": "将会暂停所有通知推送",
"accountStatusInvisible": "隐身",
"accountStatusInvisibleDesc": "将会在他人界面显示离线,但不影响功能使用",
"accountStatusOffline": "离线",
"accountLastSeenAt": "最后上线于 @date 前",
"accountStatusLabel": "状态文字",
"accountStatusClearAt": "清除状态于",
"accountStatusNegative": "负面",
"accountStatusNeutral": "中性",
"accountStatusPositive": "积极",
"bsLoadingTheme": "正在装载主题",
"bsCheckForUpdate": "正在检查更新",
"bsCheckForUpdateFailed": "无法检查更新",
"bsCheckForUpdateNew": "发现新版本",
"bsCheckForUpdateDescApple": "请前往 TestFlight 并将您的应用程序更新到最新版本,以防止出现错误并获取最新功能。",
"bsCheckForUpdateDescCommon": "请前往我们的网站下载并安装最新版本的应用程序,以防止出现错误并获取最新功能。",
"bsCheckingServer": "检查服务器状态中",
"bsCheckingServerFail": "无法连接至服务器,请检查你的网络连接状态",
"bsCheckingServerDown": "当前服务器不可用,请稍后重试",
"bsAuthorizing": "正在授权中",
"bsEstablishingConn": "部署连接中",
"bsPreparingData": "正在准备用户资料",
"bsRegisteringPushNotify": "正在启用推送通知",
"bsDismissibleErrorHint": "点击任意地方忽略此错误",
"postShareContent": "@content\n\n@username 在 Solar Network\n原帖地址@link",
"postShareSubject": "@username 在 Solar Network 上发布了一篇帖子",
"themeColor": "全局主题色",
"themeColorRed": "现代红",
"themeColorBlue": "经典蓝",
"themeColorMiku": "未来蓝",
"themeColorKagamine": "镜音黄",
"themeColorLuka": "流音粉",
"themeColorApplied": "全局主题颜色已应用",
"stickerDeletionConfirm": "确认删除贴图",
"stickerDeletionConfirmCaption": "你确认要删除贴图 @name 吗?该操作不可撤销。",
"attachmentSaved": "附件已保存到系统相册",
"cropImage": "裁剪图片",
"stickerUploader": "上传贴图",
"stickerUploaderAttachmentNew": "上传附件作为贴图",
"stickerUploaderAttachment": "附件序列号",
"stickerUploaderPack": "贴图包序号",
"stickerUploaderPackHint": "没有该序号?请转到我们的创作者平台创建一个贴图包。",
"stickerUploaderAlias": "贴图别名",
"stickerUploaderAliasHint": "将会在输入时使用和贴图包前缀组成占位符。",
"stickerUploaderName": "贴图名称",
"stickerUploaderNameHint": "在贴图选择界面提供给用户的人类友好名称。",
"readMore": "阅读更多",
"attachmentUnload": "附件未加载",
"attachmentUnloadCaption": "为了节省流量,本附件未自动加载,点一下来开始加载。",
"callStatusConnected": "已连接",
"callStatusDisconnected": "已断开",
"callStatusConnecting": "连接中",
"callStatusReconnected": "重连中",
"messageOutOfSync": "消息可能与服务器脱节",
"messageOutOfSyncCaption": "由于 App 进入后台,消息列表可能与服务器存在时差,点击刷新。",
"messageHistoryWipe": "清除消息记录",
"unknown": "未知",
"collapse": "折叠",
"expand": "展开",
"typingMessage": "@user 正在输入中…",
"userLevel0": "不慕名利",
"userLevel1": "初出茅庐",
"userLevel2": "小试牛刀",
"userLevel3": "磨杵成针",
"userLevel4": "披荆斩棘",
"userLevel5": "力挽狂澜",
"userLevel6": "一骑当千",
"userLevel7": "所向披靡",
"userLevel8": "气吞山河",
"userLevel9": "登峰造极",
"userLevel10": "出神入化",
"userLevel11": "名垂千古",
"userLevel12": "独占鳌头",
"userLevel13": "万古流芳",
"postBrowsingIn": "浏览 @region 内的帖子中"
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
@ -197,7 +198,7 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
height: 24,
child: CircularProgressIndicator(strokeWidth: 3),
),
const SizedBox(height: 12),
const Gap(12),
CenteredContainer(
maxWidth: 280,
child: Column(

View File

@ -155,13 +155,14 @@ class PostEditorController extends GetxController {
);
}
void localRead() {
SharedPreferences.getInstance().then((inst) {
if (inst.containsKey('post_editor_local_save')) {
isRestoreFromLocal.value = true;
payload = jsonDecode(inst.getString('post_editor_local_save')!);
}
});
Future<bool> localRead() async {
final inst = await SharedPreferences.getInstance();
if (inst.containsKey('post_editor_local_save')) {
isRestoreFromLocal.value = true;
payload = jsonDecode(inst.getString('post_editor_local_save')!);
return true;
}
return false;
}
void localClear() {

View File

@ -9,6 +9,7 @@ import 'package:solian/providers/last_read.dart';
class PostListController extends GetxController {
String? author;
String? realm;
/// The polling source modifier.
/// - `0`: default recommendations
@ -99,8 +100,10 @@ class PostListController extends GetxController {
final idx = <dynamic>{};
postList.retainWhere((x) => idx.add(x.id));
var lastId = postList.map((x) => x.id).reduce(max);
Get.find<LastReadProvider>().feedLastReadAt = lastId;
if (postList.isNotEmpty) {
var lastId = postList.map((x) => x.id).reduce(max);
Get.find<LastReadProvider>().feedLastReadAt = lastId;
}
return result;
}
@ -123,16 +126,21 @@ class PostListController extends GetxController {
resp = await provider.listRecommendations(
pageKey,
channel: 'shuffle',
realm: realm,
);
break;
case 1:
resp = await provider.listRecommendations(
pageKey,
channel: 'friends',
realm: realm,
);
break;
default:
resp = await provider.listRecommendations(pageKey);
resp = await provider.listRecommendations(
pageKey,
realm: realm,
);
break;
}
}

View File

@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:media_kit/media_kit.dart';
import 'package:protocol_handler/protocol_handler.dart';
import 'package:provider/provider.dart';
import 'package:solian/bootstrapper.dart';
@ -16,6 +15,7 @@ import 'package:solian/providers/attachment_uploader.dart';
import 'package:solian/providers/daily_sign.dart';
import 'package:solian/providers/last_read.dart';
import 'package:solian/providers/link_expander.dart';
import 'package:solian/providers/navigation.dart';
import 'package:solian/providers/stickers.dart';
import 'package:solian/providers/theme_switcher.dart';
import 'package:solian/providers/websocket.dart';
@ -35,7 +35,6 @@ import 'package:flutter_web_plugins/url_strategy.dart' show usePathUrlStrategy;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
MediaKit.ensureInitialized();
await Future.wait([
_initializeFirebase(),
@ -44,6 +43,9 @@ void main() async {
GoRouter.optionURLReflectsImperativeAPIs = true;
Get.put(AppTranslations());
await AppTranslations.init();
usePathUrlStrategy();
runApp(const SolianApp());
}
@ -78,8 +80,8 @@ Future<void> _initializePlatformComponents() async {
}
final themeSwitcher = ThemeSwitcher(
lightThemeData: SolianTheme.build(Brightness.light),
darkThemeData: SolianTheme.build(Brightness.dark),
lightThemeData: AppTheme.build(Brightness.light),
darkThemeData: AppTheme.build(Brightness.dark),
);
class SolianApp extends StatelessWidget {
@ -101,15 +103,17 @@ class SolianApp extends StatelessWidget {
routeInformationParser: AppRouter.instance.routeInformationParser,
routeInformationProvider: AppRouter.instance.routeInformationProvider,
backButtonDispatcher: AppRouter.instance.backButtonDispatcher,
translations: SolianMessages(),
translations: Get.find<AppTranslations>(),
locale: Get.deviceLocale,
fallbackLocale: const Locale('en', 'US'),
onInit: () => _initializeProviders(context),
onInit: () {
_initializeProviders(context);
},
builder: (context, child) {
return SystemShell(
child: ScaffoldMessenger(
child: BootstrapperShell(
child: child ?? const SizedBox(),
child: child ?? const SizedBox.shrink(),
),
),
);
@ -120,6 +124,8 @@ class SolianApp extends StatelessWidget {
}
void _initializeProviders(BuildContext context) async {
Get.put(NavigationStateProvider());
Get.lazyPut(() => AuthProvider());
Get.lazyPut(() => RelationshipProvider());
Get.lazyPut(() => PostProvider());

View File

@ -1,3 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'account.g.dart';
@JsonSerializable()
class Account {
int id;
DateTime createdAt;
@ -10,9 +15,9 @@ class Account {
dynamic avatar;
dynamic banner;
String description;
AccountProfile? profile;
List<AccountBadge>? badges;
String? emailAddress;
int? externalId;
Account({
required this.id,
@ -26,55 +31,18 @@ class Account {
required this.avatar,
required this.banner,
required this.description,
required this.profile,
required this.badges,
required this.emailAddress,
this.externalId,
});
factory Account.fromJson(Map<String, dynamic> json) => Account(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
confirmedAt: json['confirmed_at'] != null
? DateTime.parse(json['confirmed_at'])
: null,
suspendedAt: json['suspended_at'] != null
? DateTime.parse(json['suspended_at'])
: null,
name: json['name'],
nick: json['nick'],
avatar: json['avatar'],
banner: json['banner'],
description: json['description'],
emailAddress: json['email_address'],
badges: json['badges']
?.map((e) => AccountBadge.fromJson(e))
.toList()
.cast<AccountBadge>(),
externalId: json['external_id'],
);
factory Account.fromJson(Map<String, dynamic> json) =>
_$AccountFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'confirmed_at': confirmedAt?.toIso8601String(),
'suspended_at': suspendedAt?.toIso8601String(),
'name': name,
'nick': nick,
'avatar': avatar,
'banner': banner,
'description': description,
'email_address': emailAddress,
'badges': badges?.map((e) => e.toJson()).toList(),
'external_id': externalId,
};
Map<String, dynamic> toJson() => _$AccountToJson(this);
}
@JsonSerializable()
class AccountBadge {
int id;
DateTime createdAt;
@ -94,25 +62,40 @@ class AccountBadge {
required this.type,
});
factory AccountBadge.fromJson(Map<String, dynamic> json) => AccountBadge(
id: json['id'],
accountId: json['account_id'],
updatedAt: DateTime.parse(json['updated_at']),
createdAt: DateTime.parse(json['created_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
metadata: json['metadata'],
type: json['type'],
);
factory AccountBadge.fromJson(Map<String, dynamic> json) =>
_$AccountBadgeFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'account_id': accountId,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'metadata': metadata,
'type': type,
};
Map<String, dynamic> toJson() => _$AccountBadgeToJson(this);
}
@JsonSerializable()
class AccountProfile {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String? firstName;
String? lastName;
int? experience;
DateTime? lastSeenAt;
DateTime? birthday;
int accountId;
AccountProfile({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.firstName,
required this.lastName,
required this.experience,
required this.lastSeenAt,
required this.birthday,
required this.accountId,
});
factory AccountProfile.fromJson(Map<String, dynamic> json) =>
_$AccountProfileFromJson(json);
Map<String, dynamic> toJson() => _$AccountProfileToJson(this);
}

108
lib/models/account.g.dart Normal file
View File

@ -0,0 +1,108 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'account.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Account _$AccountFromJson(Map<String, dynamic> json) => Account(
id: (json['id'] 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),
confirmedAt: json['confirmed_at'] == null
? null
: DateTime.parse(json['confirmed_at'] as String),
suspendedAt: json['suspended_at'] == null
? null
: DateTime.parse(json['suspended_at'] as String),
name: json['name'] as String,
nick: json['nick'] as String,
avatar: json['avatar'],
banner: json['banner'],
description: json['description'] as String,
profile: json['profile'] == null
? null
: AccountProfile.fromJson(json['profile'] as Map<String, dynamic>),
badges: (json['badges'] as List<dynamic>?)
?.map((e) => AccountBadge.fromJson(e as Map<String, dynamic>))
.toList(),
emailAddress: json['email_address'] as String?,
);
Map<String, dynamic> _$AccountToJson(Account instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'confirmed_at': instance.confirmedAt?.toIso8601String(),
'suspended_at': instance.suspendedAt?.toIso8601String(),
'name': instance.name,
'nick': instance.nick,
'avatar': instance.avatar,
'banner': instance.banner,
'description': instance.description,
'profile': instance.profile?.toJson(),
'badges': instance.badges?.map((e) => e.toJson()).toList(),
'email_address': instance.emailAddress,
};
AccountBadge _$AccountBadgeFromJson(Map<String, dynamic> json) => AccountBadge(
id: (json['id'] as num).toInt(),
accountId: (json['account_id'] 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),
metadata: json['metadata'] as Map<String, dynamic>?,
type: json['type'] as String,
);
Map<String, dynamic> _$AccountBadgeToJson(AccountBadge instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'metadata': instance.metadata,
'type': instance.type,
'account_id': instance.accountId,
};
AccountProfile _$AccountProfileFromJson(Map<String, dynamic> json) =>
AccountProfile(
id: (json['id'] 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),
firstName: json['first_name'] as String?,
lastName: json['last_name'] as String?,
experience: (json['experience'] as num?)?.toInt(),
lastSeenAt: json['last_seen_at'] == null
? null
: DateTime.parse(json['last_seen_at'] as String),
birthday: json['birthday'] == null
? null
: DateTime.parse(json['birthday'] as String),
accountId: (json['account_id'] as num).toInt(),
);
Map<String, dynamic> _$AccountProfileToJson(AccountProfile instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'first_name': instance.firstName,
'last_name': instance.lastName,
'experience': instance.experience,
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
'birthday': instance.birthday?.toIso8601String(),
'account_id': instance.accountId,
};

View File

@ -1,3 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'account_status.g.dart';
@JsonSerializable()
class AccountStatus {
bool isDisturbable;
bool isOnline;
@ -11,21 +16,13 @@ class AccountStatus {
required this.status,
});
factory AccountStatus.fromJson(Map<String, dynamic> json) => AccountStatus(
isDisturbable: json['is_disturbable'],
isOnline: json['is_online'],
lastSeenAt: json['last_seen_at'] != null ? DateTime.parse(json['last_seen_at']) : null,
status: json['status'] != null ? Status.fromJson(json['status']) : null,
);
factory AccountStatus.fromJson(Map<String, dynamic> json) =>
_$AccountStatusFromJson(json);
Map<String, dynamic> toJson() => {
'is_disturbable': isDisturbable,
'is_online': isOnline,
'last_seen_at': lastSeenAt?.toIso8601String(),
'status': status?.toJson(),
};
Map<String, dynamic> toJson() => _$AccountStatusToJson(this);
}
@JsonSerializable()
class Status {
int id;
DateTime createdAt;
@ -53,31 +50,7 @@ class Status {
required this.accountId,
});
factory Status.fromJson(Map<String, dynamic> json) => Status(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null ? DateTime.parse(json['deleted_at']) : null,
type: json['type'],
label: json['label'],
attitude: json['attitude'],
isNoDisturb: json['is_no_disturb'],
isInvisible: json['is_invisible'],
clearAt: json['clear_at'] != null ? DateTime.parse(json['clear_at']) : null,
accountId: json['account_id'],
);
factory Status.fromJson(Map<String, dynamic> json) => _$StatusFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'type': type,
'label': label,
'attitude': attitude,
'is_no_disturb': isNoDisturb,
'is_invisible': isInvisible,
'clear_at': clearAt?.toIso8601String(),
'account_id': accountId,
};
Map<String, dynamic> toJson() => _$StatusToJson(this);
}

View File

@ -0,0 +1,59 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'account_status.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
AccountStatus _$AccountStatusFromJson(Map<String, dynamic> json) =>
AccountStatus(
isDisturbable: json['is_disturbable'] as bool,
isOnline: json['is_online'] as bool,
lastSeenAt: json['last_seen_at'] == null
? null
: DateTime.parse(json['last_seen_at'] as String),
status: json['status'] == null
? null
: Status.fromJson(json['status'] as Map<String, dynamic>),
);
Map<String, dynamic> _$AccountStatusToJson(AccountStatus instance) =>
<String, dynamic>{
'is_disturbable': instance.isDisturbable,
'is_online': instance.isOnline,
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
'status': instance.status?.toJson(),
};
Status _$StatusFromJson(Map<String, dynamic> json) => Status(
id: (json['id'] 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),
type: json['type'] as String,
label: json['label'] as String,
attitude: (json['attitude'] as num).toInt(),
isNoDisturb: json['is_no_disturb'] as bool,
isInvisible: json['is_invisible'] as bool,
clearAt: json['clear_at'] == null
? null
: DateTime.parse(json['clear_at'] as String),
accountId: (json['account_id'] as num).toInt(),
);
Map<String, dynamic> _$StatusToJson(Status instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'type': instance.type,
'label': instance.label,
'attitude': instance.attitude,
'is_no_disturb': instance.isNoDisturb,
'is_invisible': instance.isInvisible,
'clear_at': instance.clearAt?.toIso8601String(),
'account_id': instance.accountId,
};

View File

@ -1,5 +1,9 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/account.dart';
part 'attachment.g.dart';
@JsonSerializable()
class AttachmentPlaceholder {
int chunkCount;
int chunkSize;
@ -12,19 +16,12 @@ class AttachmentPlaceholder {
});
factory AttachmentPlaceholder.fromJson(Map<String, dynamic> json) =>
AttachmentPlaceholder(
chunkCount: json['chunk_count'],
chunkSize: json['chunk_size'],
meta: Attachment.fromJson(json['meta']),
);
_$AttachmentPlaceholderFromJson(json);
Map<String, dynamic> toJson() => {
'chunk_count': chunkCount,
'chunk_size': chunkSize,
'meta': meta.toJson(),
};
Map<String, dynamic> toJson() => _$AttachmentPlaceholderToJson(this);
}
@JsonSerializable()
class Attachment {
int id;
DateTime createdAt;
@ -68,50 +65,8 @@ class Attachment {
required this.accountId,
});
factory Attachment.fromJson(Map<String, dynamic> json) => Attachment(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
rid: json['rid'],
uuid: json['uuid'],
size: json['size'],
name: json['name'],
alt: json['alt'],
mimetype: json['mimetype'],
hash: json['hash'],
destination: json['destination'],
isAnalyzed: json['is_analyzed'],
isUploaded: json['is_uploaded'],
metadata: json['metadata'],
fileChunks: json['file_chunks'],
isMature: json['is_mature'],
account:
json['account'] != null ? Account.fromJson(json['account']) : null,
accountId: json['account_id'],
);
factory Attachment.fromJson(Map<String, dynamic> json) =>
_$AttachmentFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'rid': rid,
'uuid': uuid,
'size': size,
'name': name,
'alt': alt,
'mimetype': mimetype,
'hash': hash,
'destination': destination,
'is_analyzed': isAnalyzed,
'is_uploaded': isUploaded,
'metadata': metadata,
'file_chunks': fileChunks,
'is_mature': isMature,
'account': account?.toJson(),
'account_id': accountId,
};
Map<String, dynamic> toJson() => _$AttachmentToJson(this);
}

View File

@ -0,0 +1,72 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'attachment.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
AttachmentPlaceholder _$AttachmentPlaceholderFromJson(
Map<String, dynamic> json) =>
AttachmentPlaceholder(
chunkCount: (json['chunk_count'] as num).toInt(),
chunkSize: (json['chunk_size'] as num).toInt(),
meta: Attachment.fromJson(json['meta'] as Map<String, dynamic>),
);
Map<String, dynamic> _$AttachmentPlaceholderToJson(
AttachmentPlaceholder instance) =>
<String, dynamic>{
'chunk_count': instance.chunkCount,
'chunk_size': instance.chunkSize,
'meta': instance.meta.toJson(),
};
Attachment _$AttachmentFromJson(Map<String, dynamic> json) => Attachment(
id: (json['id'] 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),
rid: json['rid'] as String,
uuid: json['uuid'] as String,
size: (json['size'] as num).toInt(),
name: json['name'] as String,
alt: json['alt'] as String,
mimetype: json['mimetype'] as String,
hash: json['hash'] as String,
destination: (json['destination'] as num).toInt(),
isAnalyzed: json['is_analyzed'] as bool,
isUploaded: json['is_uploaded'] as bool,
metadata: json['metadata'] as Map<String, dynamic>?,
fileChunks: json['file_chunks'] as Map<String, dynamic>?,
isMature: json['is_mature'] as bool,
account: json['account'] == null
? null
: Account.fromJson(json['account'] as Map<String, dynamic>),
accountId: (json['account_id'] as num?)?.toInt(),
);
Map<String, dynamic> _$AttachmentToJson(Attachment instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'rid': instance.rid,
'uuid': instance.uuid,
'size': instance.size,
'name': instance.name,
'alt': instance.alt,
'mimetype': instance.mimetype,
'hash': instance.hash,
'destination': instance.destination,
'is_analyzed': instance.isAnalyzed,
'is_uploaded': instance.isUploaded,
'metadata': instance.metadata,
'file_chunks': instance.fileChunks,
'is_mature': instance.isMature,
'account': instance.account?.toJson(),
'account_id': instance.accountId,
};

View File

@ -1,6 +1,10 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:livekit_client/livekit_client.dart';
import 'package:solian/models/channel.dart';
part 'call.g.dart';
@JsonSerializable()
class Call {
int id;
DateTime createdAt;
@ -10,7 +14,8 @@ class Call {
String externalId;
int founderId;
int channelId;
List<dynamic> participants;
@JsonKey(defaultValue: [])
List<dynamic>? participants;
Channel channel;
Call({
@ -26,32 +31,9 @@ class Call {
required this.channel,
});
factory Call.fromJson(Map<String, dynamic> json) => Call(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
endedAt:
json['ended_at'] != null ? DateTime.parse(json['ended_at']) : null,
externalId: json['external_id'],
founderId: json['founder_id'],
channelId: json['channel_id'],
participants: json['participants'] ?? List.empty(),
channel: Channel.fromJson(json['channel']),
);
factory Call.fromJson(Map<String, dynamic> json) => _$CallFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'ended_at': endedAt?.toIso8601String(),
'external_id': externalId,
'founder_id': founderId,
'channel_id': channelId,
'participants': participants,
'channel': channel.toJson(),
};
Map<String, dynamic> toJson() => _$CallToJson(this);
}
enum ParticipantStatsType {

37
lib/models/call.g.dart Normal file
View File

@ -0,0 +1,37 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'call.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Call _$CallFromJson(Map<String, dynamic> json) => Call(
id: (json['id'] 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),
endedAt: json['ended_at'] == null
? null
: DateTime.parse(json['ended_at'] as String),
externalId: json['external_id'] as String,
founderId: (json['founder_id'] as num).toInt(),
channelId: (json['channel_id'] as num).toInt(),
participants: json['participants'] as List<dynamic>? ?? [],
channel: Channel.fromJson(json['channel'] as Map<String, dynamic>),
);
Map<String, dynamic> _$CallToJson(Call instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'ended_at': instance.endedAt?.toIso8601String(),
'external_id': instance.externalId,
'founder_id': instance.founderId,
'channel_id': instance.channelId,
'participants': instance.participants,
'channel': instance.channel.toJson(),
};

View File

@ -1,6 +1,10 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/realm.dart';
part 'channel.g.dart';
@JsonSerializable()
class Channel {
int id;
DateTime createdAt;
@ -17,6 +21,7 @@ class Channel {
int? realmId;
bool isEncrypted;
@JsonKey(includeFromJson: false, includeToJson: true)
bool isAvailable = false;
Channel({
@ -36,44 +41,22 @@ class Channel {
required this.realmId,
});
factory Channel.fromJson(Map<String, dynamic> json) => Channel(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
alias: json['alias'],
name: json['name'],
description: json['description'],
type: json['type'],
members: json['members']
?.map((e) => ChannelMember.fromJson(e))
.toList()
.cast<ChannelMember>(),
account: Account.fromJson(json['account']),
accountId: json['account_id'],
realm: json['realm'] != null ? Realm.fromJson(json['realm']) : null,
realmId: json['realm_id'],
isEncrypted: json['is_encrypted'],
);
factory Channel.fromJson(Map<String, dynamic> json) =>
_$ChannelFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'alias': alias,
'name': name,
'description': description,
'type': type,
'members': members?.map((e) => e.toJson()).toList(),
'account': account.toJson(),
'account_id': accountId,
'realm': realm?.toJson(),
'realm_id': realmId,
'is_encrypted': isEncrypted,
};
Map<String, dynamic> toJson() => _$ChannelToJson(this);
@override
bool operator ==(Object other) {
if (other is! Channel) return false;
return id == other.id;
}
@override
int get hashCode => id;
}
@JsonSerializable()
class ChannelMember {
int id;
DateTime createdAt;
@ -95,25 +78,8 @@ class ChannelMember {
required this.notify,
});
factory ChannelMember.fromJson(Map<String, dynamic> json) => ChannelMember(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
channelId: json['channel_id'],
accountId: json['account_id'],
account: Account.fromJson(json['account']),
notify: json['notify'],
);
factory ChannelMember.fromJson(Map<String, dynamic> json) =>
_$ChannelMemberFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'channel_id': channelId,
'account_id': accountId,
'account': account.toJson(),
'notify': notify,
};
Map<String, dynamic> toJson() => _$ChannelMemberToJson(this);
}

74
lib/models/channel.g.dart Normal file
View File

@ -0,0 +1,74 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'channel.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Channel _$ChannelFromJson(Map<String, dynamic> json) => Channel(
id: (json['id'] 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),
alias: json['alias'] as String,
name: json['name'] as String,
description: json['description'] as String,
type: (json['type'] as num).toInt(),
members: (json['members'] as List<dynamic>?)
?.map((e) => ChannelMember.fromJson(e as Map<String, dynamic>))
.toList(),
account: Account.fromJson(json['account'] as Map<String, dynamic>),
accountId: (json['account_id'] as num).toInt(),
isEncrypted: json['is_encrypted'] as bool,
realm: json['realm'] == null
? null
: Realm.fromJson(json['realm'] as Map<String, dynamic>),
realmId: (json['realm_id'] as num?)?.toInt(),
);
Map<String, dynamic> _$ChannelToJson(Channel instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'alias': instance.alias,
'name': instance.name,
'description': instance.description,
'type': instance.type,
'members': instance.members?.map((e) => e.toJson()).toList(),
'account': instance.account.toJson(),
'account_id': instance.accountId,
'realm': instance.realm?.toJson(),
'realm_id': instance.realmId,
'is_encrypted': instance.isEncrypted,
'is_available': instance.isAvailable,
};
ChannelMember _$ChannelMemberFromJson(Map<String, dynamic> json) =>
ChannelMember(
id: (json['id'] 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),
channelId: (json['channel_id'] as num).toInt(),
accountId: (json['account_id'] as num).toInt(),
account: Account.fromJson(json['account'] as Map<String, dynamic>),
notify: (json['notify'] as num).toInt(),
);
Map<String, dynamic> _$ChannelMemberToJson(ChannelMember instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'channel_id': instance.channelId,
'account_id': instance.accountId,
'account': instance.account.toJson(),
'notify': instance.notify,
};

View File

@ -1,6 +1,9 @@
import 'package:solian/models/account.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/channel.dart';
part 'event.g.dart';
@JsonSerializable()
class Event {
int id;
String uuid;
@ -10,10 +13,11 @@ class Event {
Map<String, dynamic> body;
String type;
Channel? channel;
Sender sender;
ChannelMember sender;
int channelId;
int senderId;
@JsonKey(includeFromJson: false, includeToJson: true)
bool isPending = false;
Event({
@ -30,38 +34,16 @@ class Event {
required this.senderId,
});
factory Event.fromJson(Map<String, dynamic> json) => Event(
id: json['id'],
uuid: json['uuid'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
body: json['body'],
type: json['type'],
channel:
json['channel'] != null ? Channel.fromJson(json['channel']) : null,
sender: Sender.fromJson(json['sender']),
channelId: json['channel_id'],
senderId: json['sender_id'],
);
factory Event.fromJson(Map<String, dynamic> json) => _$EventFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'uuid': uuid,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'body': body,
'type': type,
'channel': channel?.toJson(),
'sender': sender.toJson(),
'channel_id': channelId,
'sender_id': senderId,
};
Map<String, dynamic> toJson() => _$EventToJson(this);
}
@JsonSerializable()
class EventMessageBody {
@JsonKey(defaultValue: '')
String text;
@JsonKey(defaultValue: 'plain')
String algorithm;
List<String>? attachments;
int? quoteEvent;
@ -78,69 +60,7 @@ class EventMessageBody {
});
factory EventMessageBody.fromJson(Map<String, dynamic> json) =>
EventMessageBody(
text: json['text'] ?? '',
algorithm: json['algorithm'] ?? 'plain',
attachments: json['attachments'] != null
? List<String>.from(json['attachments']?.whereType<String>())
: null,
quoteEvent: json['quote_event'],
relatedEvent: json['related_event'],
relatedUsers: json['related_users'] != null
? List<int>.from(json['related_users'].map((x) => x))
: null,
);
_$EventMessageBodyFromJson(json);
Map<String, dynamic> toJson() => {
'text': text,
'algorithm': algorithm,
'attachments': attachments?.cast<dynamic>(),
'quote_event': quoteEvent,
'related_event': relatedEvent,
'related_users': relatedUsers?.cast<dynamic>(),
};
}
class Sender {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
Account account;
int channelId;
int accountId;
int notify;
Sender({
required this.id,
required this.createdAt,
required this.updatedAt,
this.deletedAt,
required this.account,
required this.channelId,
required this.accountId,
required this.notify,
});
factory Sender.fromJson(Map<String, dynamic> json) => Sender(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
account: Account.fromJson(json['account']),
channelId: json['channel_id'],
accountId: json['account_id'],
notify: json['notify'],
);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'account': account.toJson(),
'channel_id': channelId,
'account_id': accountId,
'notify': notify,
};
Map<String, dynamic> toJson() => _$EventMessageBodyToJson(this);
}

64
lib/models/event.g.dart Normal file
View File

@ -0,0 +1,64 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'event.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Event _$EventFromJson(Map<String, dynamic> json) => Event(
id: (json['id'] as num).toInt(),
uuid: json['uuid'] 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),
body: json['body'] as Map<String, dynamic>,
type: json['type'] as String,
channel: json['channel'] == null
? null
: Channel.fromJson(json['channel'] as Map<String, dynamic>),
sender: ChannelMember.fromJson(json['sender'] as Map<String, dynamic>),
channelId: (json['channel_id'] as num).toInt(),
senderId: (json['sender_id'] as num).toInt(),
);
Map<String, dynamic> _$EventToJson(Event instance) => <String, dynamic>{
'id': instance.id,
'uuid': instance.uuid,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'body': instance.body,
'type': instance.type,
'channel': instance.channel?.toJson(),
'sender': instance.sender.toJson(),
'channel_id': instance.channelId,
'sender_id': instance.senderId,
'is_pending': instance.isPending,
};
EventMessageBody _$EventMessageBodyFromJson(Map<String, dynamic> json) =>
EventMessageBody(
text: json['text'] as String? ?? '',
algorithm: json['algorithm'] as String? ?? 'plain',
attachments: (json['attachments'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
quoteEvent: (json['quote_event'] as num?)?.toInt(),
relatedEvent: (json['related_event'] as num?)?.toInt(),
relatedUsers: (json['related_users'] as List<dynamic>?)
?.map((e) => (e as num).toInt())
.toList(),
);
Map<String, dynamic> _$EventMessageBodyToJson(EventMessageBody instance) =>
<String, dynamic>{
'text': instance.text,
'algorithm': instance.algorithm,
'attachments': instance.attachments,
'quote_event': instance.quoteEvent,
'related_event': instance.relatedEvent,
'related_users': instance.relatedUsers,
};

View File

@ -1,83 +0,0 @@
class Tag {
int id;
String alias;
String name;
String description;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
Tag({
required this.id,
required this.alias,
required this.name,
required this.description,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
});
factory Tag.fromJson(Map<String, dynamic> json) => Tag(
id: json['id'],
alias: json['alias'],
name: json['name'],
description: json['description'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
);
Map<String, dynamic> toJson() => {
'id': id,
'alias': alias,
'description': description,
'name': name,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
};
}
class Category {
int id;
String alias;
String name;
String description;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
Category({
required this.id,
required this.alias,
required this.name,
required this.description,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
});
factory Category.fromJson(Map<String, dynamic> json) => Category(
id: json['id'],
alias: json['alias'],
name: json['name'],
description: json['description'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
);
Map<String, dynamic> toJson() => {
'id': id,
'alias': alias,
'description': description,
'name': name,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
};
}

View File

@ -1,32 +0,0 @@
class Keypair {
final String id;
final String algorithm;
final String publicKey;
final String? privateKey;
final bool isOwned;
Keypair({
required this.id,
required this.algorithm,
required this.publicKey,
required this.privateKey,
this.isOwned = false,
});
factory Keypair.fromJson(Map<String, dynamic> json) => Keypair(
id: json['id'],
algorithm: json['algorithm'],
publicKey: json['public_key'],
privateKey: json['private_key'],
isOwned: json['is_owned'],
);
Map<String, dynamic> toJson() => {
'id': id,
'algorithm': algorithm,
'public_key': publicKey,
'private_key': privateKey,
'is_owned': isOwned,
};
}

View File

@ -1,3 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'link.g.dart';
@JsonSerializable()
class LinkMeta {
int id;
DateTime createdAt;
@ -29,37 +34,8 @@ class LinkMeta {
required this.siteName,
});
factory LinkMeta.fromJson(Map<String, dynamic> json) => LinkMeta(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
entryId: json['entry_id'],
icon: json['icon'],
url: json['url'],
title: json['title'],
image: json['image'],
video: json['video'],
audio: json['audio'],
description: json['description'],
siteName: json['site_name'],
);
factory LinkMeta.fromJson(Map<String, dynamic> json) =>
_$LinkMetaFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'entry_id': entryId,
'icon': icon,
'url': url,
'title': title,
'image': image,
'video': video,
'audio': audio,
'description': description,
'site_name': siteName,
};
Map<String, dynamic> toJson() => _$LinkMetaToJson(this);
}

41
lib/models/link.g.dart Normal file
View File

@ -0,0 +1,41 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'link.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
LinkMeta _$LinkMetaFromJson(Map<String, dynamic> json) => LinkMeta(
id: (json['id'] 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),
entryId: json['entry_id'] as String,
icon: json['icon'] as String?,
url: json['url'] as String,
title: json['title'] as String?,
image: json['image'] as String?,
video: json['video'] as String?,
audio: json['audio'] as String?,
description: json['description'] as String?,
siteName: json['site_name'] as String?,
);
Map<String, dynamic> _$LinkMetaToJson(LinkMeta instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'entry_id': instance.entryId,
'icon': instance.icon,
'url': instance.url,
'title': instance.title,
'image': instance.image,
'video': instance.video,
'audio': instance.audio,
'description': instance.description,
'site_name': instance.siteName,
};

View File

@ -1,3 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'notification.g.dart';
@JsonSerializable()
class Notification {
int id;
DateTime createdAt;
@ -25,35 +30,8 @@ class Notification {
required this.accountId,
});
factory Notification.fromJson(Map<String, dynamic> json) => Notification(
id: json['id'] ?? 0,
createdAt: json['created_at'] == null
? DateTime.now()
: DateTime.parse(json['created_at']),
updatedAt: json['updated_at'] == null
? DateTime.now()
: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
title: json['title'],
subtitle: json['subtitle'],
body: json['body'],
avatar: json['avatar'],
picture: json['picture'],
senderId: json['sender_id'],
accountId: json['account_id'],
);
factory Notification.fromJson(Map<String, dynamic> json) =>
_$NotificationFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'title': title,
'subtitle': subtitle,
'body': body,
'avatar': avatar,
'picture': picture,
'sender_id': senderId,
'account_id': accountId,
};
Map<String, dynamic> toJson() => _$NotificationToJson(this);
}

View File

@ -0,0 +1,38 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'notification.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Notification _$NotificationFromJson(Map<String, dynamic> json) => Notification(
id: (json['id'] 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),
title: json['title'] as String,
subtitle: json['subtitle'] as String?,
body: json['body'] as String,
avatar: json['avatar'] as String?,
picture: json['picture'] as String?,
senderId: (json['sender_id'] as num?)?.toInt(),
accountId: (json['account_id'] as num).toInt(),
);
Map<String, dynamic> _$NotificationToJson(Notification instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'title': instance.title,
'subtitle': instance.subtitle,
'body': instance.body,
'avatar': instance.avatar,
'picture': instance.picture,
'sender_id': instance.senderId,
'account_id': instance.accountId,
};

View File

@ -1,7 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'packet.g.dart';
@JsonSerializable()
class NetworkPackage {
@JsonKey(name: 'w')
String method;
@JsonKey(name: 'e')
String? endpoint;
@JsonKey(name: 'm')
String? message;
@JsonKey(name: 'p')
Map<String, dynamic>? payload;
NetworkPackage({
@ -11,17 +20,8 @@ class NetworkPackage {
this.payload,
});
factory NetworkPackage.fromJson(Map<String, dynamic> json) => NetworkPackage(
method: json['w'],
endpoint: json['e'],
message: json['m'],
payload: json['p'],
);
factory NetworkPackage.fromJson(Map<String, dynamic> json) =>
_$NetworkPackageFromJson(json);
Map<String, dynamic> toJson() => {
'w': method,
'e': endpoint,
'm': message,
'p': payload,
};
Map<String, dynamic> toJson() => _$NetworkPackageToJson(this);
}

23
lib/models/packet.g.dart Normal file
View File

@ -0,0 +1,23 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'packet.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
NetworkPackage _$NetworkPackageFromJson(Map<String, dynamic> json) =>
NetworkPackage(
method: json['w'] as String,
endpoint: json['e'] as String?,
message: json['m'] as String?,
payload: json['p'] as Map<String, dynamic>?,
);
Map<String, dynamic> _$NetworkPackageToJson(NetworkPackage instance) =>
<String, dynamic>{
'w': instance.method,
'e': instance.endpoint,
'm': instance.message,
'p': instance.payload,
};

View File

@ -1,3 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'pagination.g.dart';
@JsonSerializable()
class PaginationResult {
int count;
List<dynamic>? data;
@ -8,10 +13,7 @@ class PaginationResult {
});
factory PaginationResult.fromJson(Map<String, dynamic> json) =>
PaginationResult(count: json['count'], data: json['data']);
_$PaginationResultFromJson(json);
Map<String, dynamic> toJson() => {
'count': count,
'data': data,
};
Map<String, dynamic> toJson() => _$PaginationResultToJson(this);
}

View File

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'pagination.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
PaginationResult _$PaginationResultFromJson(Map<String, dynamic> json) =>
PaginationResult(
count: (json['count'] as num).toInt(),
data: json['data'] as List<dynamic>?,
);
Map<String, dynamic> _$PaginationResultToJson(PaginationResult instance) =>
<String, dynamic>{
'count': instance.count,
'data': instance.data,
};

View File

@ -1,7 +1,11 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/feed.dart';
import 'package:solian/models/post_categories.dart';
import 'package:solian/models/realm.dart';
part 'post.g.dart';
@JsonSerializable()
class Post {
int id;
DateTime createdAt;
@ -57,81 +61,15 @@ class Post {
required this.metric,
});
factory Post.fromJson(Map<String, dynamic> json) => Post(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
alias: json['alias'],
areaAlias: json['area_alias'],
type: json['type'],
body: json['body'],
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
categories: json['categories']
?.map((x) => Category.fromJson(x))
.toList()
.cast<Category>(),
replies: json['replies'],
replyId: json['reply_id'],
repostId: json['repost_id'],
realmId: json['realm_id'],
replyTo:
json['reply_to'] != null ? Post.fromJson(json['reply_to']) : null,
repostTo:
json['repost_to'] != null ? Post.fromJson(json['repost_to']) : null,
realm: json['realm'] != null ? Realm.fromJson(json['realm']) : null,
editedAt: json['edited_at'] != null
? DateTime.parse(json['edited_at'])
: null,
publishedAt: json['published_at'] != null
? DateTime.parse(json['published_at'])
: null,
publishedUntil: json['published_until'] != null
? DateTime.parse(json['published_until'])
: null,
pinnedAt: json['pinned_at'] != null
? DateTime.parse(json['pinned_at'])
: null,
isDraft: json['is_draft'],
authorId: json['author_id'],
author: Account.fromJson(json['author']),
metric:
json['metric'] != null ? PostMetric.fromJson(json['metric']) : null,
);
factory Post.fromJson(Map<String, dynamic> json) => _$PostFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'edited_at': editedAt?.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'alias': alias,
'area_alias': areaAlias,
'type': type,
'body': body,
'tags': tags,
'categories': categories,
'replies': replies,
'reply_id': replyId,
'repost_id': repostId,
'realm_id': realmId,
'reply_to': replyTo?.toJson(),
'repost_to': repostTo?.toJson(),
'realm': realm?.toJson(),
'published_at': publishedAt?.toIso8601String(),
'published_until': publishedUntil?.toIso8601String(),
'pinned_at': pinnedAt?.toIso8601String(),
'is_draft': isDraft,
'author_id': authorId,
'author': author.toJson(),
'metric': metric?.toJson(),
};
Map<String, dynamic> toJson() => _$PostToJson(this);
}
@JsonSerializable()
class PostMetric {
int reactionCount;
@JsonKey(defaultValue: {})
Map<String, int> reactionList;
int replyCount;
@ -141,22 +79,8 @@ class PostMetric {
required this.replyCount,
});
factory PostMetric.fromJson(Map<String, dynamic> json) => PostMetric(
reactionCount: json['reaction_count'],
replyCount: json['reply_count'],
reactionList: json['reaction_list'] != null
? json['reaction_list']
.map((key, value) => MapEntry(
key,
int.tryParse(value.toString()) ??
(value is double ? value.toInt() : null)))
.cast<String, int>()
: {},
);
factory PostMetric.fromJson(Map<String, dynamic> json) =>
_$PostMetricFromJson(json);
Map<String, dynamic> toJson() => {
'reaction_count': reactionCount,
'reply_count': replyCount,
'reaction_list': reactionList,
};
Map<String, dynamic> toJson() => _$PostMetricToJson(this);
}

103
lib/models/post.g.dart Normal file
View File

@ -0,0 +1,103 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'post.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Post _$PostFromJson(Map<String, dynamic> json) => Post(
id: (json['id'] as num).toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
editedAt: json['edited_at'] == null
? null
: DateTime.parse(json['edited_at'] as String),
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
alias: json['alias'] as String?,
areaAlias: json['area_alias'] as String?,
type: json['type'] as String,
body: json['body'],
tags: (json['tags'] as List<dynamic>?)
?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
.toList(),
categories: (json['categories'] as List<dynamic>?)
?.map((e) => Category.fromJson(e as Map<String, dynamic>))
.toList(),
replies: (json['replies'] as List<dynamic>?)
?.map((e) => Post.fromJson(e as Map<String, dynamic>))
.toList(),
replyId: (json['reply_id'] as num?)?.toInt(),
repostId: (json['repost_id'] as num?)?.toInt(),
realmId: (json['realm_id'] as num?)?.toInt(),
replyTo: json['reply_to'] == null
? null
: Post.fromJson(json['reply_to'] as Map<String, dynamic>),
repostTo: json['repost_to'] == null
? null
: Post.fromJson(json['repost_to'] as Map<String, dynamic>),
realm: json['realm'] == null
? null
: Realm.fromJson(json['realm'] as Map<String, dynamic>),
publishedAt: json['published_at'] == null
? null
: DateTime.parse(json['published_at'] as String),
publishedUntil: json['published_until'] == null
? null
: DateTime.parse(json['published_until'] as String),
pinnedAt: json['pinned_at'] == null
? null
: DateTime.parse(json['pinned_at'] as String),
isDraft: json['is_draft'] as bool?,
authorId: (json['author_id'] as num).toInt(),
author: Account.fromJson(json['author'] as Map<String, dynamic>),
metric: json['metric'] == null
? null
: PostMetric.fromJson(json['metric'] as Map<String, dynamic>),
);
Map<String, dynamic> _$PostToJson(Post instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'edited_at': instance.editedAt?.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'alias': instance.alias,
'area_alias': instance.areaAlias,
'body': instance.body,
'tags': instance.tags?.map((e) => e.toJson()).toList(),
'categories': instance.categories?.map((e) => e.toJson()).toList(),
'replies': instance.replies?.map((e) => e.toJson()).toList(),
'type': instance.type,
'reply_id': instance.replyId,
'repost_id': instance.repostId,
'realm_id': instance.realmId,
'reply_to': instance.replyTo?.toJson(),
'repost_to': instance.repostTo?.toJson(),
'realm': instance.realm?.toJson(),
'published_at': instance.publishedAt?.toIso8601String(),
'published_until': instance.publishedUntil?.toIso8601String(),
'pinned_at': instance.pinnedAt?.toIso8601String(),
'is_draft': instance.isDraft,
'author_id': instance.authorId,
'author': instance.author.toJson(),
'metric': instance.metric?.toJson(),
};
PostMetric _$PostMetricFromJson(Map<String, dynamic> json) => PostMetric(
reactionCount: (json['reaction_count'] as num).toInt(),
reactionList: (json['reaction_list'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, (e as num).toInt()),
) ??
{},
replyCount: (json['reply_count'] as num).toInt(),
);
Map<String, dynamic> _$PostMetricToJson(PostMetric instance) =>
<String, dynamic>{
'reaction_count': instance.reactionCount,
'reaction_list': instance.reactionList,
'reply_count': instance.replyCount,
};

View File

@ -0,0 +1,54 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'post_categories.g.dart';
@JsonSerializable()
class Tag {
int id;
String alias;
String name;
String description;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
Tag({
required this.id,
required this.alias,
required this.name,
required this.description,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
});
factory Tag.fromJson(Map<String, dynamic> json) => _$TagFromJson(json);
Map<String, dynamic> toJson() => _$TagToJson(this);
}
@JsonSerializable()
class Category {
int id;
String alias;
String name;
String description;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
Category({
required this.id,
required this.alias,
required this.name,
required this.description,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
});
factory Category.fromJson(Map<String, dynamic> json) =>
_$CategoryFromJson(json);
Map<String, dynamic> toJson() => _$CategoryToJson(this);
}

View File

@ -0,0 +1,51 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'post_categories.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Tag _$TagFromJson(Map<String, dynamic> json) => Tag(
id: (json['id'] as num).toInt(),
alias: json['alias'] as String,
name: json['name'] as String,
description: json['description'] 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),
);
Map<String, dynamic> _$TagToJson(Tag instance) => <String, dynamic>{
'id': instance.id,
'alias': instance.alias,
'name': instance.name,
'description': instance.description,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
};
Category _$CategoryFromJson(Map<String, dynamic> json) => Category(
id: (json['id'] as num).toInt(),
alias: json['alias'] as String,
name: json['name'] as String,
description: json['description'] 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),
);
Map<String, dynamic> _$CategoryToJson(Category instance) => <String, dynamic>{
'id': instance.id,
'alias': instance.alias,
'name': instance.name,
'description': instance.description,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
};

View File

@ -1,5 +1,9 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/account.dart';
part 'realm.g.dart';
@JsonSerializable()
class Realm {
int id;
DateTime createdAt;
@ -8,9 +12,12 @@ class Realm {
String alias;
String name;
String description;
String? avatar;
String? banner;
bool isPublic;
bool isCommunity;
int? accountId;
int? externalId;
Realm({
required this.id,
@ -20,38 +27,17 @@ class Realm {
required this.alias,
required this.name,
required this.description,
required this.avatar,
required this.banner,
required this.isPublic,
required this.isCommunity,
this.accountId,
this.externalId,
});
factory Realm.fromJson(Map<String, dynamic> json) => Realm(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
alias: json['alias'],
name: json['name'],
description: json['description'],
isPublic: json['is_public'],
isCommunity: json['is_community'],
accountId: json['account_id'],
);
factory Realm.fromJson(Map<String, dynamic> json) => _$RealmFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'alias': alias,
'name': name,
'description': description,
'is_public': isPublic,
'is_community': isCommunity,
'account_id': accountId,
};
Map<String, dynamic> toJson() => _$RealmToJson(this);
@override
bool operator ==(Object other) {
@ -65,6 +51,7 @@ class Realm {
int get hashCode => id;
}
@JsonSerializable()
class RealmMember {
int id;
DateTime createdAt;
@ -86,27 +73,8 @@ class RealmMember {
required this.powerLevel,
});
factory RealmMember.fromJson(Map<String, dynamic> json) => RealmMember(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
realmId: json['realm_id'],
accountId: json['account_id'],
account: Account.fromJson(json['account']),
powerLevel: json['power_level'],
);
factory RealmMember.fromJson(Map<String, dynamic> json) =>
_$RealmMemberFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'realm_id': realmId,
'account_id': accountId,
'account': account.toJson(),
'power_level': powerLevel,
};
Map<String, dynamic> toJson() => _$RealmMemberToJson(this);
}

66
lib/models/realm.g.dart Normal file
View File

@ -0,0 +1,66 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'realm.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Realm _$RealmFromJson(Map<String, dynamic> json) => Realm(
id: (json['id'] 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),
alias: json['alias'] as String,
name: json['name'] as String,
description: json['description'] as String,
avatar: json['avatar'] as String?,
banner: json['banner'] as String?,
isPublic: json['is_public'] as bool,
isCommunity: json['is_community'] as bool,
accountId: (json['account_id'] as num?)?.toInt(),
externalId: (json['external_id'] as num?)?.toInt(),
);
Map<String, dynamic> _$RealmToJson(Realm instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'alias': instance.alias,
'name': instance.name,
'description': instance.description,
'avatar': instance.avatar,
'banner': instance.banner,
'is_public': instance.isPublic,
'is_community': instance.isCommunity,
'account_id': instance.accountId,
'external_id': instance.externalId,
};
RealmMember _$RealmMemberFromJson(Map<String, dynamic> json) => RealmMember(
id: (json['id'] 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),
realmId: (json['realm_id'] as num).toInt(),
accountId: (json['account_id'] as num).toInt(),
account: Account.fromJson(json['account'] as Map<String, dynamic>),
powerLevel: (json['power_level'] as num).toInt(),
);
Map<String, dynamic> _$RealmMemberToJson(RealmMember instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'realm_id': instance.realmId,
'account_id': instance.accountId,
'account': instance.account.toJson(),
'power_level': instance.powerLevel,
};

View File

@ -1,5 +1,9 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/account.dart';
part 'relations.g.dart';
@JsonSerializable()
class Relationship {
int id;
DateTime createdAt;
@ -23,27 +27,8 @@ class Relationship {
required this.status,
});
factory Relationship.fromJson(Map<String, dynamic> json) => Relationship(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
accountId: json['account_id'],
relatedId: json['related_id'],
account: Account.fromJson(json['account']),
related: Account.fromJson(json['related']),
status: json['status'],
);
factory Relationship.fromJson(Map<String, dynamic> json) =>
_$RelationshipFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'account_id': accountId,
'related_id': relatedId,
'account': account.toJson(),
'related': related.toJson(),
'status': status,
};
Map<String, dynamic> toJson() => _$RelationshipToJson(this);
}

View File

@ -0,0 +1,34 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'relations.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Relationship _$RelationshipFromJson(Map<String, dynamic> json) => Relationship(
id: (json['id'] 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),
accountId: (json['account_id'] as num).toInt(),
relatedId: (json['related_id'] as num).toInt(),
account: Account.fromJson(json['account'] as Map<String, dynamic>),
related: Account.fromJson(json['related'] as Map<String, dynamic>),
status: (json['status'] as num).toInt(),
);
Map<String, dynamic> _$RelationshipToJson(Relationship instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'account_id': instance.accountId,
'related_id': instance.relatedId,
'account': instance.account.toJson(),
'related': instance.related.toJson(),
'status': instance.status,
};

View File

@ -1,7 +1,11 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/services.dart';
part 'stickers.g.dart';
@JsonSerializable()
class Sticker {
int id;
DateTime createdAt;
@ -39,38 +43,13 @@ class Sticker {
'/attachments/${attachment.rid}',
);
factory Sticker.fromJson(Map<String, dynamic> json) => Sticker(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: json['deleted_at'],
alias: json['alias'],
name: json['name'],
attachmentId: json['attachment_id'],
attachment: Attachment.fromJson(json['attachment']),
packId: json['pack_id'],
pack: json['pack'] != null ? StickerPack.fromJson(json['pack']) : null,
accountId: json['account_id'],
account: Account.fromJson(json['account']),
);
factory Sticker.fromJson(Map<String, dynamic> json) =>
_$StickerFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'alias': alias,
'name': name,
'attachment_id': attachmentId,
'attachment': attachment.toJson(),
'pack_id': packId,
'account_id': accountId,
'account': account.toJson(),
};
Map<String, dynamic> toJson() => _$StickerToJson(this);
}
@JsonSerializable()
class StickerPack {
int id;
DateTime createdAt;
@ -96,36 +75,8 @@ class StickerPack {
required this.account,
});
factory StickerPack.fromJson(Map<String, dynamic> json) => StickerPack(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: json['deleted_at'],
prefix: json['prefix'],
name: json['name'],
description: json['description'],
stickers: json['stickers'] == null
? []
: List<Sticker>.from(
json['stickers']!.map((x) => Sticker.fromJson(x))),
accountId: json['account_id'],
account: Account.fromJson(json['account']),
);
factory StickerPack.fromJson(Map<String, dynamic> json) =>
_$StickerPackFromJson(json);
Map<String, dynamic> toJson() => {
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'prefix': prefix,
'name': name,
'description': description,
'stickers': stickers == null
? []
: List<dynamic>.from(stickers!.map((x) => x.toJson())),
'account_id': accountId,
'account': account.toJson(),
};
Map<String, dynamic> toJson() => _$StickerPackToJson(this);
}

View File

@ -0,0 +1,73 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'stickers.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Sticker _$StickerFromJson(Map<String, dynamic> json) => Sticker(
id: (json['id'] 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),
alias: json['alias'] as String,
name: json['name'] as String,
attachmentId: (json['attachment_id'] as num).toInt(),
attachment:
Attachment.fromJson(json['attachment'] as Map<String, dynamic>),
packId: (json['pack_id'] as num).toInt(),
pack: json['pack'] == null
? null
: StickerPack.fromJson(json['pack'] as Map<String, dynamic>),
accountId: (json['account_id'] as num).toInt(),
account: Account.fromJson(json['account'] as Map<String, dynamic>),
);
Map<String, dynamic> _$StickerToJson(Sticker instance) => <String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'alias': instance.alias,
'name': instance.name,
'attachment_id': instance.attachmentId,
'attachment': instance.attachment.toJson(),
'pack_id': instance.packId,
'pack': instance.pack?.toJson(),
'account_id': instance.accountId,
'account': instance.account.toJson(),
};
StickerPack _$StickerPackFromJson(Map<String, dynamic> json) => StickerPack(
id: (json['id'] 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),
prefix: json['prefix'] as String,
name: json['name'] as String,
description: json['description'] as String,
stickers: (json['stickers'] as List<dynamic>?)
?.map((e) => Sticker.fromJson(e as Map<String, dynamic>))
.toList(),
accountId: (json['account_id'] as num).toInt(),
account: Account.fromJson(json['account'] as Map<String, dynamic>),
);
Map<String, dynamic> _$StickerPackToJson(StickerPack instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'prefix': instance.prefix,
'name': instance.name,
'description': instance.description,
'stickers': instance.stickers?.map((e) => e.toJson()).toList(),
'account_id': instance.accountId,
'account': instance.account.toJson(),
};

View File

@ -192,6 +192,7 @@ class AttachmentProvider extends GetConnect {
Future<Response> updateAttachment(
int id,
String alt, {
required Map<String, dynamic> metadata,
bool isMature = false,
}) async {
final AuthProvider auth = Get.find();
@ -201,6 +202,7 @@ class AttachmentProvider extends GetConnect {
var resp = await client.put('/attachments/$id', {
'alt': alt,
'metadata': metadata,
'is_mature': isMature,
});

View File

@ -2,9 +2,30 @@ import 'package:get/get.dart';
import 'package:solian/exceptions/request.dart';
import 'package:solian/exceptions/unauthorized.dart';
import 'package:solian/models/daily_sign.dart';
import 'package:solian/models/pagination.dart';
import 'package:solian/providers/auth.dart';
class DailySignProvider extends GetxController {
Future<List<DailySignRecord>> listLastRecord(int take) async {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) throw const UnauthorizedException();
final client = auth.configureClient('id');
final resp = await client.get('/daily?take=$take');
if (resp.statusCode != 200 && resp.statusCode != 404) {
throw RequestException(resp);
} else if (resp.statusCode == 404) {
return List.empty();
}
final result = PaginationResult.fromJson(resp.body);
return List.from(
result.data?.map((x) => DailySignRecord.fromJson(x)) ?? [],
);
}
Future<DailySignRecord?> getToday() async {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) throw const UnauthorizedException();

View File

@ -0,0 +1,26 @@
extension DurationToHumanReadableString on Duration {
String toHumanReadableString({padZero = true}) {
final mm = inMinutes
.remainder(60)
.toString()
.padLeft(2, !padZero && inHours == 0 ? '' : '0');
final ss = inSeconds.remainder(60).toString().padLeft(2, '0');
if (inHours > 0) {
final hh = inHours.toString().padLeft(2, !padZero ? '' : '0');
return '$hh:$mm:$ss';
}
return '$mm:$ss';
}
}
extension ParseDuration on Duration {
static Duration fromString(String duration) {
final parts = duration.split(':').reversed.toList();
final seconds = int.parse(parts[0]);
final minutes = parts.length > 1 ? int.parse(parts[1]) : 0;
final hours = parts.length > 2 ? int.parse(parts[2]) : 0;
return Duration(hours: hours, minutes: minutes, seconds: seconds);
}
}

View File

@ -0,0 +1,51 @@
import 'package:get/get.dart';
import 'package:intl/intl.dart';
class ExperienceProvider extends GetxController {
static List<int> experienceToLevelRequirements = [
0, // Level 0
100, // Level 1
400, // Level 2
900, // Level 3
1600, // Level 4
2500, // Level 5
3600, // Level 6
4900, // Level 7
6400, // Level 8
8100, // Level 9
10000, // Level 10
12100, // Level 11
14400, // Level 12
36800 // Level 13
];
static List<String> levelLabelMapping =
List.generate(experienceToLevelRequirements.length, (x) => 'userLevel$x');
static (int level, String label) getLevelFromExp(int experience) {
final exp = experienceToLevelRequirements.reversed
.firstWhere((x) => x <= experience);
final idx = experienceToLevelRequirements.indexOf(exp);
return (idx, levelLabelMapping[idx]);
}
static double calcLevelUpProgress(int experience) {
final exp = experienceToLevelRequirements.reversed
.firstWhere((x) => x <= experience);
final idx = experienceToLevelRequirements.indexOf(exp);
if (idx + 1 >= experienceToLevelRequirements.length) return 1;
final nextExp = experienceToLevelRequirements[idx + 1];
return exp / nextExp;
}
static String calcLevelUpProgressLevel(int experience) {
final exp = experienceToLevelRequirements.reversed
.firstWhere((x) => x <= experience);
final idx = experienceToLevelRequirements.indexOf(exp);
if (idx + 1 >= experienceToLevelRequirements.length) return 'Infinity';
final nextExp = experienceToLevelRequirements[idx + 1];
final formatter =
NumberFormat.compactCurrency(symbol: '', decimalDigits: 1);
return '${formatter.format(exp)}/${formatter.format(nextExp)}';
}
}

View File

@ -12,14 +12,20 @@ class LastReadProvider extends GetxController {
set feedLastReadAt(int? value) {
if (value == _feedLastReadAt) return;
_feedLastReadAt = max(_feedLastReadAt ?? 0, value ?? 0);
if (value != _feedLastReadAt) _saveToStorage();
final newValue = max(_feedLastReadAt ?? 0, value ?? 0);
if (newValue != _feedLastReadAt) {
_feedLastReadAt = newValue;
_saveToStorage();
}
}
set messagesLastReadAt(int? value) {
if (value == _messagesLastReadAt) return;
_messagesLastReadAt = max(_messagesLastReadAt ?? 0, value ?? 0);
if (value != _messagesLastReadAt) _saveToStorage();
final newValue = max(_messagesLastReadAt ?? 0, value ?? 0);
if (newValue != _messagesLastReadAt) {
_messagesLastReadAt = newValue;
_saveToStorage();
}
}
LastReadProvider() {

View File

@ -0,0 +1,6 @@
import 'package:get/get.dart';
import 'package:solian/models/realm.dart';
class NavigationStateProvider extends GetxController {
final Rx<Realm?> focusedRealm = Rx(null);
}

View File

@ -16,8 +16,8 @@ class ThemeSwitcher extends ChangeNotifier {
if (prefs.containsKey('global_theme_color')) {
final value = prefs.getInt('global_theme_color')!;
final color = Color(value);
lightThemeData = SolianTheme.build(Brightness.light, seedColor: color);
darkThemeData = SolianTheme.build(Brightness.dark, seedColor: color);
lightThemeData = AppTheme.build(Brightness.light, seedColor: color);
darkThemeData = AppTheme.build(Brightness.dark, seedColor: color);
notifyListeners();
}
}

View File

@ -154,6 +154,7 @@ abstract class AppRouter {
name: 'channelChat',
builder: (context, state) {
return ChannelChatScreen(
key: UniqueKey(),
alias: state.pathParameters['alias']!,
realm: state.uri.queryParameters['realm'] ?? 'global',
);

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher_string.dart';
@ -21,7 +22,7 @@ class AboutScreen extends StatelessWidget {
borderRadius: const BorderRadius.all(Radius.circular(16)),
child: Image.asset('assets/logo.png', width: 120, height: 120),
),
const SizedBox(height: 8),
const Gap(8),
Text(
'Solian',
style: Theme.of(context).textTheme.headlineMedium,
@ -30,12 +31,12 @@ class AboutScreen extends StatelessWidget {
'The Solar Network',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
const SizedBox(height: 8),
const Gap(8),
FutureBuilder(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
return const SizedBox.shrink();
}
return Text(
@ -45,7 +46,7 @@ class AboutScreen extends StatelessWidget {
},
),
Text('Copyright © ${DateTime.now().year} Solsynth LLC'),
const SizedBox(height: 16),
const Gap(16),
TextButton(
style: denseButtonStyle,
child: const Text('App Details'),
@ -59,7 +60,8 @@ class AboutScreen extends StatelessWidget {
'The Solar Network App is an intuitive and self-hostable social network and computing platform. Experience the freedom of a user-friendly design that empowers you to create and connect with communities on your own terms. Embrace the future of social networking with a platform that prioritizes your independence and privacy.',
applicationIcon: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(16)),
child: Image.asset('assets/logo.png', width: 60, height: 60),
child:
Image.asset('assets/logo.png', width: 60, height: 60),
),
);
},
@ -71,7 +73,7 @@ class AboutScreen extends StatelessWidget {
launchUrlString('https://solsynth.dev/products/solar-network');
},
),
const SizedBox(height: 16),
const Gap(16),
const Text(
'Open-sourced under AGPLv3',
style: TextStyle(

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/relations.dart';
@ -56,7 +57,7 @@ class _FriendScreenState extends State<FriendScreen>
mainAxisSize: MainAxisSize.min,
children: [
Text('accountFriendNewHint'.tr, textAlign: TextAlign.left),
const SizedBox(height: 18),
const Gap(18),
TextField(
controller: controller,
decoration: InputDecoration(
@ -132,7 +133,7 @@ class _FriendScreenState extends State<FriendScreen>
).paddingAll(14),
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
bottom: TabBar(

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
@ -185,7 +186,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
child: ListView(
children: [
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
const SizedBox(height: 24),
const Gap(24),
Stack(
children: [
AccountAvatar(content: _avatar, radius: 40),
@ -202,7 +203,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
],
).paddingSymmetric(horizontal: padding),
const SizedBox(height: 16),
const Gap(16),
Stack(
children: [
ClipRRect(
@ -247,7 +248,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
],
).paddingSymmetric(horizontal: padding),
const SizedBox(height: 24),
const Gap(24),
Row(
children: [
Flexible(
@ -262,7 +263,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
),
),
const SizedBox(width: 16),
const Gap(16),
Flexible(
flex: 1,
child: TextField(
@ -275,7 +276,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
],
).paddingSymmetric(horizontal: padding),
const SizedBox(height: 16),
const Gap(16),
Row(
children: [
Flexible(
@ -288,7 +289,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
),
),
const SizedBox(width: 16),
const Gap(16),
Flexible(
flex: 1,
child: TextField(
@ -301,7 +302,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
],
).paddingSymmetric(horizontal: padding),
const SizedBox(height: 16),
const Gap(16),
TextField(
controller: _descriptionController,
keyboardType: TextInputType.multiline,
@ -312,7 +313,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
labelText: 'description'.tr,
),
).paddingSymmetric(horizontal: padding),
const SizedBox(height: 16),
const Gap(16),
TextField(
controller: _birthdayController,
readOnly: true,
@ -322,7 +323,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
),
onTap: () => _selectBirthday(),
).paddingSymmetric(horizontal: padding),
const SizedBox(height: 16),
const Gap(16),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:solian/controllers/post_list_controller.dart';
@ -7,10 +8,12 @@ import 'package:solian/models/account.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/models/pagination.dart';
import 'package:solian/models/post.dart';
import 'package:solian/providers/account_status.dart';
import 'package:solian/providers/relation.dart';
import 'package:solian/services.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/account/account_avatar.dart';
import 'package:solian/widgets/account/account_heading.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/attachments/attachment_list.dart';
import 'package:solian/widgets/posts/post_list.dart';
@ -83,10 +86,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
}
int get _userSocialCreditPoints {
int birthPart =
DateTime.now().difference(_userinfo!.createdAt.toLocal()).inSeconds;
birthPart = birthPart >> 16;
return _totalUpvote * 2 - _totalDownvote + birthPart;
return _totalUpvote * 2 - _totalDownvote + _postController.postTotal.value;
}
@override
@ -96,8 +96,9 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
_postController = PostListController(author: widget.name);
_albumPagingController.addPageRequestListener((pageKey) async {
final client = ServiceFinder.configureClient('files');
final resp = await client
.get('/attachments?take=10&offset=$pageKey&author=${widget.name}');
final resp = await client.get(
'/attachments?take=10&offset=$pageKey&author=${widget.name}&original=true',
);
if (resp.statusCode == 200) {
final result = PaginationResult.fromJson(resp.body);
final out = result.data
@ -144,24 +145,23 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
return Material(
color: Theme.of(context).colorScheme.surface,
child: DefaultTabController(
length: 2,
length: 3,
child: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
SliverAppBar(
centerTitle: false,
floating: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
leadingWidth: 24,
automaticallyImplyLeading: false,
flexibleSpace: Row(
children: [
AppBarLeadingButton.adaptive(context) ??
const SizedBox(width: 8),
const SizedBox(width: 8),
AppBarLeadingButton.adaptive(context) ?? const Gap(8),
const Gap(8),
if (_userinfo != null)
AccountAvatar(content: _userinfo!.avatar, radius: 16),
const SizedBox(width: 12),
const Gap(12),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@ -207,12 +207,13 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
onPressed: null,
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
),
bottom: TabBar(
tabs: [
Tab(text: 'profilePage'.tr),
Tab(text: 'profilePosts'.tr),
Tab(text: 'profileAlbum'.tr),
],
@ -223,6 +224,24 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
body: TabBarView(
physics: const NeverScrollableScrollPhysics(),
children: [
Column(
children: [
const Gap(16),
AccountHeadingWidget(
name: _userinfo!.name,
nick: _userinfo!.nick,
desc: _userinfo!.description,
badges: _userinfo!.badges,
banner: _userinfo!.banner,
avatar: _userinfo!.avatar,
status: Get.find<StatusProvider>()
.getSomeoneStatus(_userinfo!.name),
detail: _userinfo,
profile: _userinfo!.profile,
extraWidgets: const [],
),
],
),
RefreshIndicator(
onRefresh: () => Future.wait([
_postController.reloadAllOver(),
@ -243,7 +262,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
),
],
),
const SizedBox(height: 16),
const Gap(16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [

View File

@ -1,13 +1,13 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:solian/models/pagination.dart';
import 'package:solian/models/stickers.dart';
import 'package:solian/platform.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/stickers.dart';
import 'package:solian/services.dart';
import 'package:solian/widgets/auto_cache_image.dart';
import 'package:solian/widgets/stickers/sticker_uploader.dart';
class StickerScreen extends StatefulWidget {
@ -93,17 +93,12 @@ class _StickerScreenState extends State<StickerScreen> {
),
],
),
leading: PlatformInfo.canCacheImage
? CachedNetworkImage(
imageUrl: imageUrl,
width: 28,
height: 28,
)
: Image.network(
imageUrl,
width: 28,
height: 28,
),
leading: AutoCacheImage(
imageUrl,
width: 28,
height: 28,
noErrorWidget: true,
),
);
}
@ -163,7 +158,7 @@ class _StickerScreenState extends State<StickerScreen> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(item.name),
const SizedBox(width: 6),
const Gap(6),
Badge(
label: Text('#${item.id}'),
)

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:protocol_handler/protocol_handler.dart';
import 'package:solian/exts.dart';
@ -160,7 +161,7 @@ class _SignInPopupState extends State<SignInPopup> with ProtocolListener {
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 12),
const Gap(12),
TextField(
obscureText: true,
autocorrect: false,
@ -176,7 +177,7 @@ class _SignInPopupState extends State<SignInPopup> with ProtocolListener {
FocusManager.instance.primaryFocus?.unfocus(),
onSubmitted: (_) => performAction(),
),
const SizedBox(height: 12),
const Gap(12),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/services.dart';
@ -94,7 +95,7 @@ class _SignUpPopupState extends State<SignUpPopup> {
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 12),
const Gap(12),
TextField(
autocorrect: false,
enableSuggestions: false,
@ -108,7 +109,7 @@ class _SignUpPopupState extends State<SignUpPopup> {
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 12),
const Gap(12),
TextField(
autocorrect: false,
enableSuggestions: false,
@ -122,7 +123,7 @@ class _SignUpPopupState extends State<SignUpPopup> {
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 12),
const Gap(12),
TextField(
obscureText: true,
autocorrect: false,
@ -138,7 +139,7 @@ class _SignUpPopupState extends State<SignUpPopup> {
FocusManager.instance.primaryFocus?.unfocus(),
onSubmitted: (_) => performAction(context),
),
const SizedBox(height: 16),
const Gap(16),
Align(
alignment: Alignment.centerRight,
child: TextButton(

View File

@ -3,6 +3,7 @@ import 'dart:math' as math;
import 'package:async/async.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/providers/call.dart';
import 'package:solian/theme.dart';
@ -83,7 +84,7 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
participant: call.focusTrack.value!,
onTap: () {},
)
: const SizedBox(),
: const SizedBox.shrink(),
),
Positioned(
left: 0,
@ -204,7 +205,7 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
: AppBar(
leading: AppBarLeadingButton.adaptive(context),
centerTitle: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
title: Obx(
() => RichText(
textAlign: TextAlign.center,
@ -257,7 +258,7 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 6),
const Gap(6),
Text(call.lastDuration.value)
],
);
@ -276,7 +277,7 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
'callStatusReconnecting'.tr,
}[call.room.connectionState]!,
),
const SizedBox(width: 6),
const Gap(6),
if (connectionQuality !=
livekit.ConnectionQuality.unknown)
Icon(

View File

@ -98,6 +98,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
setState(() => _ongoingCall = Call.fromJson(resp.body));
}
} catch (e) {
print((e as dynamic).stackTrace);
context.showErrorDialog(e);
}
@ -203,9 +204,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
String? placeholder;
if (_channel?.type == 1) {
final otherside = _channel!.members!
.where((e) => e.account.externalId != _accountId)
.first;
final otherside =
_channel!.members!.where((e) => e.account.id != _accountId).first;
title = otherside.account.nick;
placeholder = 'messageInputPlaceholder'.trParams(
{'channel': '@${otherside.account.name}'},
@ -217,12 +217,12 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(title),
centerTitle: false,
titleSpacing: SolianTheme.titleSpacing(context),
toolbarHeight: SolianTheme.toolbarHeight(context),
titleSpacing: AppTheme.titleSpacing(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
const BackgroundStateWidget(),
Builder(builder: (context) {
if (_isBusy || _channel == null) return const SizedBox();
if (_isBusy || _channel == null) return const SizedBox.shrink();
return ChatCallButton(
realm: _channel!.realm,
@ -255,7 +255,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
},
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
),
@ -276,7 +276,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
channel: _channel!,
ongoingCall: _ongoingCall!,
onJoin: () {
if (!SolianTheme.isLargeScreen(context)) {
if (!AppTheme.isLargeScreen(context)) {
final ChatCallProvider call = Get.find();
call.gotoScreen(context);
}
@ -299,7 +299,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
if (_chatController.isLoading.isTrue) {
return const LinearProgressIndicator().animate().slideY();
} else {
return const SizedBox();
return const SizedBox.shrink();
}
}),
ClipRect(
@ -337,7 +337,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
),
Obx(() {
final ChatCallProvider call = Get.find();
if (call.isMounted.value && SolianTheme.isLargeScreen(context)) {
if (call.isMounted.value && AppTheme.isLargeScreen(context)) {
return const Expanded(
child: Row(children: [
VerticalDivider(width: 0.3, thickness: 0.3),
@ -350,7 +350,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
]),
);
}
return const SizedBox();
return const SizedBox.shrink();
}),
],
);

View File

@ -1,6 +1,7 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/channel.dart';
@ -42,8 +43,7 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
void checkOwner() async {
final AuthProvider auth = Get.find();
setState(() {
_isOwned =
auth.userProfile.value!['id'] == widget.channel.account.externalId;
_isOwned = auth.userProfile.value!['id'] == widget.channel.account.id;
});
}
@ -148,7 +148,7 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
size: 18,
),
),
const SizedBox(width: 16),
const Gap(16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -110,7 +110,7 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
appBar: AppBar(
title: AppBarTitle('channelOrganizing'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
TextButton(
onPressed: _isBusy ? null : () => applyChannel(),

View File

@ -47,7 +47,7 @@ class _ChatScreenState extends State<ChatScreen> {
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('chat'.tr),
centerTitle: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
const BackgroundStateWidget(),
const NotificationButton(),
@ -95,7 +95,7 @@ class _ChatScreenState extends State<ChatScreen> {
],
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
),
@ -112,7 +112,7 @@ class _ChatScreenState extends State<ChatScreen> {
children: [
Obx(() {
if (_channels.isLoading.isFalse) {
return const SizedBox();
return const SizedBox.shrink();
} else {
return const LinearProgressIndicator();
}

View File

@ -1,16 +1,21 @@
import 'dart:developer';
import 'dart:math' hide log;
import 'package:flutter/material.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart' hide Notification;
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/channel.dart';
import 'package:solian/models/daily_sign.dart';
import 'package:solian/models/event.dart';
import 'package:solian/models/notification.dart';
import 'package:solian/models/pagination.dart';
import 'package:solian/models/post.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/content/posts.dart';
import 'package:solian/providers/daily_sign.dart';
import 'package:solian/providers/last_read.dart';
@ -18,7 +23,9 @@ import 'package:solian/providers/message/adaptor.dart';
import 'package:solian/providers/websocket.dart';
import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/chat/chat_event.dart';
import 'package:solian/widgets/daily_sign/history_chart.dart';
import 'package:solian/widgets/posts/post_list.dart';
class DashboardScreen extends StatefulWidget {
@ -29,6 +36,7 @@ class DashboardScreen extends StatefulWidget {
}
class _DashboardScreenState extends State<DashboardScreen> {
late final AuthProvider _auth = Get.find();
late final LastReadProvider _lastRead = Get.find();
late final WebSocketProvider _ws = Get.find();
late final PostProvider _posts = Get.find();
@ -37,6 +45,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
Color get _unFocusColor =>
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
List<Notification> get _pendingNotifications =>
List<Notification>.from(_ws.notifications)
..sort((a, b) => b.createdAt.compareTo(a.createdAt));
List<Post>? _currentPosts;
int? _currentPostsCount;
@ -54,6 +66,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
List<Event>? _currentMessages;
int? _currentMessagesCount;
Map<Channel, List<Event>>? get _currentGroupedMessages =>
_currentMessages?.groupListsBy((x) => x.channel!);
Future<void> _pullMessages() async {
if (_lastRead.messagesLastReadAt == null) return;
log('[Dashboard] Pulling messages with pivot: ${_lastRead.messagesLastReadAt}');
@ -67,10 +82,14 @@ class _DashboardScreenState extends State<DashboardScreen> {
bool _signingDaily = true;
DailySignRecord? _signRecord;
List<DailySignRecord>? _signRecordHistory;
Future<void> _pullDaily() async {
try {
_signRecord = await _dailySign.getToday();
_dailySign.listLastRecord(30).then((value) {
setState(() => _signRecordHistory = value);
});
} catch (e) {
context.showErrorDialog(e);
}
@ -83,6 +102,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
try {
_signRecord = await _dailySign.signToday();
_dailySign.listLastRecord(30).then((value) {
setState(() => _signRecordHistory = value);
});
} catch (e) {
context.showErrorDialog(e);
}
@ -90,147 +112,279 @@ class _DashboardScreenState extends State<DashboardScreen> {
setState(() => _signingDaily = false);
}
Future<void> _pullData() async {
if (!_auth.isAuthorized.value) return;
await Future.wait([
_pullPosts(),
_pullMessages(),
_pullDaily(),
]);
}
@override
void initState() {
super.initState();
_pullPosts();
_pullMessages();
_pullDaily();
_pullData();
}
@override
Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width;
return ListView(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('today'.tr, style: Theme.of(context).textTheme.headlineSmall),
Text(DateFormat('yyyy/MM/dd').format(DateTime.now())),
],
).paddingOnly(top: 8, left: 18, right: 18, bottom: 12),
Card(
child: ListTile(
leading: AnimatedSwitcher(
switchInCurve: Curves.fastOutSlowIn,
switchOutCurve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
child: _signRecord == null
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
DateFormat('dd').format(DateTime.now()),
style:
GoogleFonts.robotoMono(fontSize: 22, height: 1.2),
),
Text(
DateFormat('yy/MM').format(DateTime.now()),
style: GoogleFonts.robotoMono(fontSize: 12),
),
],
)
: Text(
_signRecord!.symbol,
style: GoogleFonts.notoSerifHk(fontSize: 20, height: 1),
).paddingSymmetric(horizontal: 9),
).paddingOnly(left: 4),
title: _signRecord == null
? Text('dailySign'.tr)
: Text(_signRecord!.overviewSuggestion),
subtitle: _signRecord == null
? Text('dailySignNone'.tr)
: Text('+${_signRecord!.resultExperience} EXP'),
trailing: AnimatedSwitcher(
switchInCurve: Curves.fastOutSlowIn,
switchOutCurve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
child: _signRecord == null
? IconButton(
tooltip: '上香求签',
icon: const Icon(Icons.local_fire_department),
onPressed: _signingDaily ? null : _signDaily,
)
: const SizedBox(),
),
),
).paddingSymmetric(horizontal: 8),
const Divider(thickness: 0.3).paddingSymmetric(vertical: 8),
Obx(
() => Column(
return RefreshIndicator(
onRefresh: _pullData,
child: ListView(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'notification'.tr,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 18),
),
Text(
'notificationUnreadCount'.trParams({
'count': _ws.notifications.length.toString(),
}),
),
],
),
IconButton(
icon: const Icon(Icons.more_horiz),
onPressed: () {
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: true,
context: context,
builder: (context) => const NotificationScreen(),
).then((_) => _ws.notificationUnread.value = 0);
Text(
DateTime.now().day == DateTime.now().toUtc().day
? 'today'.tr
: 'yesterday'.tr,
style: Theme.of(context).textTheme.headlineSmall,
),
Text(DateFormat('yyyy/MM/dd').format(DateTime.now().toUtc())),
],
).paddingOnly(top: 8, left: 18, right: 18, bottom: 12),
Card(
child: Column(
children: [
ListTile(
leading: AnimatedSwitcher(
switchInCurve: Curves.fastOutSlowIn,
switchOutCurve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
child: _signRecord == null
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
DateFormat('dd').format(DateTime.now()),
style: GoogleFonts.robotoMono(
fontSize: 22, height: 1.2),
),
Text(
DateFormat('yy/MM').format(DateTime.now()),
style: GoogleFonts.robotoMono(fontSize: 12),
),
],
)
: Text(
_signRecord!.symbol,
style: GoogleFonts.notoSerifHk(
fontSize: 20, height: 1),
).paddingSymmetric(horizontal: 9),
).paddingOnly(left: 4),
title: _signRecord == null
? Text('dailySign'.tr)
: Text(_signRecord!.overviewSuggestion),
subtitle: _signRecord == null
? Text('dailySignNone'.tr)
: Text('+${_signRecord!.resultExperience} EXP'),
trailing: AnimatedSwitcher(
switchInCurve: Curves.fastOutSlowIn,
switchOutCurve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 300),
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
child: _signRecord == null
? IconButton(
tooltip: 'dailySignAction'.tr,
icon: const Icon(Icons.local_fire_department),
onPressed: _signingDaily ? null : _signDaily,
)
: (_signRecordHistory?.isEmpty ?? true)
? const SizedBox.shrink()
: IconButton(
tooltip: 'dailySignHistoryAction'.tr,
icon: const Icon(Icons.history),
onPressed: () {
showDialog(
context: context,
useRootNavigator: true,
builder: (context) =>
DailySignHistoryChartDialog(
data: _signRecordHistory,
),
);
},
),
),
],
).paddingOnly(left: 18, right: 18, bottom: 8),
if (_ws.notifications.isNotEmpty)
),
],
),
).paddingSymmetric(horizontal: 8),
const Divider(thickness: 0.3).paddingSymmetric(vertical: 8),
/// Unread notifications
Obx(
() => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'notification'.tr,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 18),
),
Text(
'notificationUnreadCount'.trParams({
'count': _ws.notifications.length.toString(),
}),
),
],
),
IconButton(
icon: const Icon(Icons.more_horiz),
onPressed: () {
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: true,
context: context,
builder: (context) => const NotificationScreen(),
).then((_) => _ws.notificationUnread.value = 0);
},
),
],
).paddingOnly(left: 18, right: 18, bottom: 8),
if (_ws.notifications.isNotEmpty)
SizedBox(
height: 76,
child: ListView.separated(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 8),
itemCount: min(_pendingNotifications.length, 10),
itemBuilder: (context, idx) {
final x = _pendingNotifications[idx];
return SizedBox(
width: min(360, width),
child: Card(
child: ListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 4,
),
title: Text(
x.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (x.subtitle != null)
Text(
x.subtitle!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
)
else
Text(
x.body,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
),
);
},
separatorBuilder: (_, __) => const Gap(4),
),
)
else
Card(
child: ListTile(
contentPadding:
const EdgeInsets.only(left: 24, right: 32),
trailing: const Icon(Icons.inbox_outlined),
title: Text('notifyEmpty'.tr),
subtitle: Text('notifyEmptyCaption'.tr),
),
).paddingSymmetric(horizontal: 8),
],
).paddingOnly(bottom: 12),
),
/// Unread friends / followed people posts
if (_currentPosts?.isNotEmpty ?? false)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'feed'.tr,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 18),
),
Text(
'feedUnreadCount'.trParams({
'count': (_currentPostsCount ?? 0).toString(),
}),
),
],
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
AppRouter.instance.goNamed('feed');
},
),
],
).paddingOnly(left: 18, right: 18, bottom: 8),
SizedBox(
height: 76,
width: width,
height: 360,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: min(_ws.notifications.length, 3),
itemCount: _currentPosts!.length,
itemBuilder: (context, idx) {
final x = _ws.notifications[idx];
final item = _currentPosts![idx];
return SizedBox(
width: width,
width: min(480, width),
child: Card(
child: ListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 4,
child: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
title: Text(x.title),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (x.subtitle != null) Text(x.subtitle!),
Text(x.body),
],
child: SingleChildScrollView(
child: PostListEntryWidget(
item: item,
isClickable: true,
isShowEmbed: true,
isNestedClickable: true,
onUpdate: (_) {
_pullPosts();
},
backgroundColor: Theme.of(context)
.colorScheme
.surfaceContainerLow,
),
),
),
).paddingSymmetric(horizontal: 8),
@ -238,191 +392,134 @@ class _DashboardScreenState extends State<DashboardScreen> {
},
),
)
else
Card(
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
trailing: const Icon(Icons.inbox_outlined),
title: Text('notifyEmpty'.tr),
subtitle: Text('notifyEmptyCaption'.tr),
),
).paddingSymmetric(horizontal: 8),
],
).paddingOnly(bottom: 12),
),
if (_currentPosts?.isNotEmpty ?? false)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'feed'.tr,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 18),
),
Text(
'feedUnreadCount'.trParams({
'count': (_currentPostsCount ?? 0).toString(),
}),
),
],
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
AppRouter.instance.goNamed('feed');
},
),
],
).paddingOnly(left: 18, right: 18, bottom: 8),
SizedBox(
height: 360,
width: width,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _currentPosts!.length,
itemBuilder: (context, idx) {
final item = _currentPosts![idx];
return SizedBox(
width: width,
child: Card(
child: PostListEntryWidget(
item: item,
isClickable: true,
isShowEmbed: true,
isNestedClickable: true,
onUpdate: (_) {
_pullPosts();
},
backgroundColor:
Theme.of(context).colorScheme.surfaceContainerLow,
],
).paddingOnly(bottom: 12),
/// Unread messages part
if (_currentMessages?.isNotEmpty ?? false)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'messages'.tr,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 18),
),
).paddingSymmetric(horizontal: 8),
);
},
),
)
],
),
if (_currentMessages?.isNotEmpty ?? false)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'messages'.tr,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontSize: 18),
),
Text(
'messagesUnreadCount'.trParams({
'count': (_currentMessagesCount ?? 0).toString(),
}),
),
],
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
AppRouter.instance.goNamed('chat');
},
),
],
).paddingOnly(left: 18, right: 18, bottom: 8),
SizedBox(
height: 240,
width: width,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _currentMessages!.length,
itemBuilder: (context, idx) {
final item = _currentMessages![idx];
return SizedBox(
width: width,
child: Card(
child: Column(
children: [
ListTile(
tileColor: Theme.of(context)
.colorScheme
.surfaceContainerHigh,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
)),
leading: CircleAvatar(
backgroundColor: item.channel!.realmId == null
? Theme.of(context).colorScheme.primary
: Colors.transparent,
radius: 20,
child: FaIcon(
FontAwesomeIcons.hashtag,
color: item.channel!.realmId == null
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.primary,
size: 16,
Text(
'messagesUnreadCount'.trParams({
'count': (_currentMessagesCount ?? 0).toString(),
}),
),
],
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
AppRouter.instance.goNamed('chat');
},
),
],
).paddingOnly(left: 18, right: 18, bottom: 8),
SizedBox(
height: 360,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _currentGroupedMessages!.length,
itemBuilder: (context, idx) {
final channel =
_currentGroupedMessages!.keys.elementAt(idx);
final itemList =
_currentGroupedMessages!.values.elementAt(idx);
return SizedBox(
width: min(520, width),
child: Card(
child: Column(
children: [
ListTile(
tileColor: Theme.of(context)
.colorScheme
.surfaceContainerHigh,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
)),
leading: CircleAvatar(
backgroundColor: channel.realmId == null
? Theme.of(context).colorScheme.primary
: Colors.transparent,
radius: 20,
child: FaIcon(
FontAwesomeIcons.hashtag,
color: channel.realmId == null
? Theme.of(context)
.colorScheme
.onPrimary
: Theme.of(context).colorScheme.primary,
size: 16,
),
),
contentPadding:
const EdgeInsets.symmetric(horizontal: 16),
title: Text(channel.name),
subtitle: Text(channel.description),
onTap: () {
AppRouter.instance.pushNamed(
'channelChat',
pathParameters: {'alias': channel.alias},
queryParameters: {
if (channel.realmId != null)
'realm': channel.realm!.alias,
},
);
},
),
Expanded(
child: ListView.builder(
itemCount: itemList.length,
itemBuilder: (context, idx) {
final item = itemList[idx];
return ChatEvent(item: item).paddingOnly(
bottom: 8, top: 16, left: 8, right: 8);
},
),
),
contentPadding:
const EdgeInsets.symmetric(horizontal: 16),
title: Text(item.channel!.name),
subtitle: Text(item.channel!.description),
onTap: () {
AppRouter.instance.pushNamed(
'channelChat',
pathParameters: {
'alias': item.channel!.alias
},
queryParameters: {
if (item.channel!.realmId != null)
'realm': item.channel!.realm!.alias,
},
);
},
),
ChatEvent(item: item).paddingOnly(
bottom: 8, top: 16, left: 8, right: 8),
],
),
).paddingSymmetric(horizontal: 8),
);
},
),
],
),
).paddingSymmetric(horizontal: 8),
);
},
),
)
],
).paddingOnly(bottom: 12),
/// Footer
Column(
mainAxisAlignment: AppTheme.isLargeScreen(context)
? MainAxisAlignment.start
: MainAxisAlignment.center,
children: [
Text(
'Powered by Solar Network',
style: TextStyle(color: _unFocusColor, fontSize: 12),
),
Text(
'dashboardFooter'.tr,
style: TextStyle(color: _unFocusColor, fontSize: 12),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Powered by Solar Network',
style: TextStyle(color: _unFocusColor, fontSize: 12),
),
Text(
'dashboardFooter'.tr,
style: GoogleFonts.notoSerifHk(
color: _unFocusColor,
fontSize: 12,
),
)
],
).paddingAll(8),
],
).paddingAll(8),
],
),
);
}
}

View File

@ -1,7 +1,11 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/controllers/post_list_controller.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/navigation.dart';
import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
@ -24,21 +28,34 @@ class _FeedScreenState extends State<FeedScreen>
late final PostListController _postController;
late final TabController _tabController;
List<StreamSubscription>? _subscriptions;
@override
void initState() {
super.initState();
final navState = Get.find<NavigationStateProvider>();
_postController = PostListController();
_postController.realm = navState.focusedRealm.value?.alias;
_tabController = TabController(length: 3, vsync: this);
_tabController.addListener(() {
if (_postController.mode.value == _tabController.index) return;
_postController.mode.value = _tabController.index;
_postController.reloadAllOver();
});
_subscriptions = [
Get.find<NavigationStateProvider>().focusedRealm.listen((value) {
if (value?.alias != _postController.realm) {
_postController.realm = value?.alias;
_postController.reloadAllOver();
}
}),
];
}
@override
Widget build(BuildContext context) {
final AuthProvider auth = Get.find();
final NavigationStateProvider navState = Get.find();
return Material(
color: Theme.of(context).colorScheme.surface,
@ -68,13 +85,13 @@ class _FeedScreenState extends State<FeedScreen>
title: AppBarTitle('feed'.tr),
centerTitle: false,
floating: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
leading: AppBarLeadingButton.adaptive(context),
actions: [
const BackgroundStateWidget(),
const NotificationButton(),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
bottom: TabBar(
@ -95,37 +112,53 @@ class _FeedScreenState extends State<FeedScreen>
);
}
return TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
return Column(
children: [
RefreshIndicator(
onRefresh: () => _postController.reloadAllOver(),
child: CustomScrollView(slivers: [
PostWarpedListWidget(
controller: _postController.pagingController,
onUpdate: () => _postController.reloadAllOver(),
if (navState.focusedRealm.value != null)
MaterialBanner(
leading: const Icon(Icons.layers),
content: Text(
'postBrowsingIn'.trParams({
'region': '#${navState.focusedRealm.value!.alias}',
}),
),
]),
actions: const [SizedBox.shrink()],
),
Expanded(
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
RefreshIndicator(
onRefresh: () => _postController.reloadAllOver(),
child: CustomScrollView(slivers: [
PostWarpedListWidget(
controller: _postController.pagingController,
onUpdate: () => _postController.reloadAllOver(),
),
]),
),
Obx(() {
if (auth.isAuthorized.value) {
return RefreshIndicator(
onRefresh: () => _postController.reloadAllOver(),
child: CustomScrollView(slivers: [
PostWarpedListWidget(
controller: _postController.pagingController,
onUpdate: () => _postController.reloadAllOver(),
),
]),
);
} else {
return SigninRequiredOverlay(
onSignedIn: () => _postController.reloadAllOver(),
);
}
}),
PostShuffleSwiper(controller: _postController),
],
),
),
Obx(() {
if (auth.isAuthorized.value) {
return RefreshIndicator(
onRefresh: () => _postController.reloadAllOver(),
child: CustomScrollView(slivers: [
PostWarpedListWidget(
controller: _postController.pagingController,
onUpdate: () => _postController.reloadAllOver(),
),
]),
);
} else {
return SigninRequiredOverlay(
onSignedIn: () => _postController.reloadAllOver(),
);
}
}),
PostShuffleSwiper(controller: _postController),
],
);
}),
@ -137,6 +170,11 @@ class _FeedScreenState extends State<FeedScreen>
@override
void dispose() {
_postController.dispose();
if (_subscriptions != null) {
for (final subscription in _subscriptions!) {
subscription.cancel();
}
}
super.dispose();
}
}
@ -154,7 +192,7 @@ class PostCreatePopup extends StatelessWidget {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) {
return const SizedBox();
return const SizedBox.shrink();
}
final List<dynamic> actionList = [
@ -224,7 +262,7 @@ class PostCreatePopup extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
x.icon,
const SizedBox(height: 8),
const Gap(8),
Expanded(
child: Text(
x.label,

View File

@ -61,10 +61,10 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('draftBox'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
),

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:markdown_toolbar/markdown_toolbar.dart';
@ -10,6 +11,7 @@ import 'package:solian/models/post.dart';
import 'package:solian/models/realm.dart';
import 'package:solian/providers/attachment_uploader.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/navigation.dart';
import 'package:solian/router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
@ -123,7 +125,12 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
void initState() {
super.initState();
if (widget.edit == null && widget.reply == null && widget.repost == null) {
_editorController.localRead();
_editorController.localRead().then((res) {
if (!res) {
final navState = Get.find<NavigationStateProvider>();
_editorController.realmZone.value = navState.focusedRealm.value;
}
});
}
if (widget.reply != null) {
_editorController.replyTo.value = widget.reply;
@ -157,7 +164,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
),
),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
TextButton(
onPressed: _isBusy ? null : () => _applyPost(),
@ -183,7 +190,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(width: 6),
const Gap(6),
if (_editorController.aliasController.text.isNotEmpty)
Badge(
label: Text('#${_editorController.aliasController.text}'),
@ -296,7 +303,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
?.unfocus(),
),
),
const SizedBox(height: 120)
const Gap(120)
],
),
),
@ -360,12 +367,12 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
],
),
),
if (SolianTheme.isLargeScreen(context))
if (AppTheme.isLargeScreen(context))
const VerticalDivider(width: 0.3, thickness: 0.3)
.paddingSymmetric(
horizontal: 16,
),
if (SolianTheme.isLargeScreen(context))
if (AppTheme.isLargeScreen(context))
Expanded(
child: SingleChildScrollView(
child: MarkdownTextContent(

View File

@ -62,7 +62,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('realm'.tr),
centerTitle: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
const BackgroundStateWidget(),
const NotificationButton(),
@ -77,7 +77,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
},
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/models/realm.dart';
import 'package:solian/providers/auth.dart';
@ -95,7 +96,7 @@ class _RealmDetailScreenState extends State<RealmDetailScreen> {
backgroundColor: Colors.teal,
child: Icon(Icons.group, color: Colors.white),
),
const SizedBox(width: 16),
const Gap(16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -102,7 +102,7 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('realmOrganizing'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
TextButton(
onPressed: _isBusy ? null : () => applyRealm(),

View File

@ -114,7 +114,7 @@ class _RealmViewScreenState extends State<RealmViewScreen> {
},
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
bottom: const TabBar(

View File

@ -33,11 +33,11 @@ class _SettingScreenState extends State<SettingScreen> {
tooltip: label,
onPressed: () {
context.read<ThemeSwitcher>().setTheme(
SolianTheme.build(
AppTheme.build(
Brightness.light,
seedColor: color,
),
SolianTheme.build(
AppTheme.build(
Brightness.dark,
seedColor: color,
),

View File

@ -25,7 +25,7 @@ class CenteredShell extends StatelessWidget {
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
)
: null,
body: Center(

View File

@ -41,10 +41,10 @@ class RootShell extends StatelessWidget {
return Scaffold(
key: rootScaffoldKey,
drawer: SolianTheme.isLargeScreen(context)
drawer: AppTheme.isLargeScreen(context)
? null
: AppNavigationDrawer(routeName: routeName),
body: SolianTheme.isLargeScreen(context)
body: AppTheme.isLargeScreen(context)
? Row(
children: [
if (showNavigation) AppNavigationDrawer(routeName: routeName),

View File

@ -29,9 +29,9 @@ class SidebarShell extends StatelessWidget {
flex: 2,
child: child,
),
if (SolianTheme.isExtraLargeScreen(context))
if (AppTheme.isExtraLargeScreen(context))
const VerticalDivider(thickness: 0.3, width: 1),
if (SolianTheme.isExtraLargeScreen(context))
if (AppTheme.isExtraLargeScreen(context))
Flexible(
flex: 1,
child: sidebar ?? const SidebarPlaceholder(),
@ -47,10 +47,10 @@ class SidebarShell extends StatelessWidget {
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
)
: null,
body: SolianTheme.isLargeScreen(context)
body: AppTheme.isLargeScreen(context)
? Row(
children: sidebarFirst
? buildContent(context).reversed.toList()

View File

@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/current_state_action.dart';
class TitleShell extends StatelessWidget {
final bool showAppBar;
@ -31,7 +32,13 @@ class TitleShell extends StatelessWidget {
title ?? (state!.topRoute?.name?.tr ?? 'page'.tr),
),
centerTitle: isCenteredTitle,
toolbarHeight: SolianTheme.toolbarHeight(context),
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
const BackgroundStateWidget(),
SizedBox(
width: AppTheme.isLargeScreen(context) ? 8 : 16,
),
],
)
: null,
body: child,

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:solian/platform.dart';
abstract class SolianTheme {
abstract class AppTheme {
static bool isLargeScreen(BuildContext context) =>
MediaQuery.of(context).size.width > 640;
@ -9,13 +9,13 @@ abstract class SolianTheme {
MediaQuery.of(context).size.width > 720;
static bool isSpecializedMacOS(BuildContext context) =>
PlatformInfo.isMacOS && !SolianTheme.isLargeScreen(context);
PlatformInfo.isMacOS && !AppTheme.isLargeScreen(context);
static double? titleSpacing(BuildContext context) {
if (SolianTheme.isSpecializedMacOS(context)) {
if (AppTheme.isSpecializedMacOS(context)) {
return 24;
} else {
return SolianTheme.isLargeScreen(context) ? null : 24;
return AppTheme.isLargeScreen(context) ? null : 24;
}
}

View File

@ -1,11 +1,25 @@
import 'package:get/get.dart';
import 'package:solian/translations/en_us.dart';
import 'package:solian/translations/zh_cn.dart';
import 'dart:convert';
import 'package:flutter/services.dart' show rootBundle;
import 'package:get/get.dart';
class AppTranslations extends Translations {
static const List<String> supportedLocales = ['zh_cn', 'en_us'];
final Map<String, Map<String, String>> messages = {};
static Future<void> init() async {
final AppTranslations inst = Get.find();
inst.messages.clear();
for (final locale in supportedLocales) {
inst.messages[locale] = jsonDecode(
await rootBundle.loadString('assets/locales/$locale.json'),
)
.map((key, value) => MapEntry(key, value.toString()))
.cast<String, String>();
}
}
class SolianMessages extends Translations {
@override
Map<String, Map<String, String>> get keys => {
'en_US': i18nEnglish,
'zh_CN': i18nSimplifiedChinese,
};
Map<String, Map<String, String>> get keys => messages;
}

View File

@ -1,403 +0,0 @@
const i18nEnglish = {
'done': 'Done',
'hide': 'Hide',
'okay': 'Okay',
'next': 'Next',
'reset': 'Reset',
'page': 'Page',
'home': 'Home',
'guest': 'Guest',
'draft': 'Draft',
'dashboard': 'Dashboard',
'today': 'Today',
'draftSave': 'Save',
'draftBox': 'Draft Box',
'more': 'More',
'share': 'Share',
'shareNoUri': 'Share text content',
'alias': 'Alias',
'feed': 'Feed',
'unlink': 'Unlink',
'feedSearch': 'Search Feed',
'feedSearchWithTag': 'Searching with tag #@key',
'feedSearchWithCategory': 'Searching in category @category',
'feedUnreadCount': '@count posts you may missed',
'messages': 'Messages',
'messagesUnreadCount': '@count messages unread',
'dailySign': 'Daily Sign',
'dailySignNone': 'You haven\'t sign today',
'dailySignTier0': 'Everything may not be good',
'dailySignTier1': 'Something may be wrong',
'dailySignTier2': 'Just so so',
'dailySignTier3': 'Something may goes well',
'dailySignTier4': 'Everything will be awesome',
'dashboardFooter': 'Don\'t be serious, just for fun.',
'visitProfilePage': 'Visit Profile Page',
'profilePosts': 'Posts',
'profileAlbum': 'Album',
'chat': 'Chat',
'apply': 'Apply',
'cancel': 'Cancel',
'confirm': 'Confirm',
'leave': 'Leave',
'loading': 'Loading...',
'about': 'About',
'edit': 'Edit',
'delete': 'Delete',
'settings': 'Settings',
'search': 'Search',
'post': 'Post',
'article': 'Article',
'reply': 'Reply',
'repost': 'Repost',
'openInAlbum': 'Open in album',
'openInBrowser': 'Open in browser',
'notification': 'Notification',
'notificationUnreadCount': '@count unread notifications',
'errorHappened': 'An error occurred',
'errorHappenedUnauthorized':
'Unauthorized request, please sign in or try resign in.',
'forgotPassword': 'Forgot password',
'email': 'Email',
'username': 'Username',
'nickname': 'Nickname',
'password': 'Password',
'title': 'Title',
'description': 'Description',
'birthday': 'Birthday',
'firstName': 'First Name',
'lastName': 'Last Name',
'account': 'Account',
'accountPersonalize': 'Personalize',
'accountPersonalizeApplied': 'Account personalize settings has been saved.',
'accountStickers': 'Stickers',
'accountFriend': 'Friend',
'accountFriendNew': 'New friend',
'accountFriendNewHint':
'Use someone\'s username to send a request of making friends with them!',
'accountFriendPending': 'Friend requests',
'accountFriendBlocked': 'Friend blocklist',
'accountFriendListHint': 'Swipe left to decline, right to approve',
'accountFriendRequestSent': 'Friend request sent, waiting for processing...',
'accountSuspended': 'Account was suspended',
'accountSuspendedAt': 'Account was suspended since @date',
'aspectRatio': 'Aspect Ratio',
'aspectRatioSquare': 'Square',
'aspectRatioPortrait': 'Portrait',
'aspectRatioLandscape': 'Landscape',
'unsignedIn': 'Unsigned in',
'signin': 'Sign in',
'signinRequired': 'Sign in',
'signinRequiredHint': 'Sign in to get full access of Solar Network',
'signinGreeting': 'Welcome back\nSolar Network',
'signinCaption':
'Sign in to create post, start a realm, message your friend and more!',
'signinRiskDetected':
'Risk detected, click Next to open a webpage and signin through it to pass security check.',
'signinResetPasswordHint': 'Please enter username to request reset password.',
'signinResetPasswordSent': 'Reset password request sent, check your inbox!',
'signup': 'Sign up',
'signupGreeting': 'Welcome onboard',
'signupCaption':
'Create an account on Solarpass and then get the access of entire Solar Network!',
'signupDone': 'Sign up successfully.',
'signupDoneCaption':
'You successfully created an account on Solar Network. Now go sign in!',
'signout': 'Sign out',
'joinedAt': 'Joined at @date',
'riskDetection': 'Risk Detected',
'matureContent': 'Mature Content',
'matureContentCaption':
'The content is rated and may not suitable for everyone to view',
'notifyAllRead': 'Mark all as read',
'notifyEmpty': 'All notifications read',
'notifyEmptyCaption': 'It seems like nothing happened recently',
'totalSocialCreditPoints': 'Social Credit Points',
'totalPostCount': 'Posts',
'totalUpvote': 'Upvote',
'totalDownvote': 'Downvote',
'clear': 'Clear',
'pinPost': 'Pin this post',
'unpinPost': 'Unpin this post',
'postRestoreFromLocal': 'Restore from local',
'postAutoSaveAt': 'Auto saved at @date',
'postCategoriesAndTags': 'Categories n\' Tags',
'postPublishDate': 'Publish Date',
'postPublishAt': 'Publish At',
'postPublishedUntil': 'Publish Until',
'postPublishZone': 'Publish Zone',
'postPublishZoneNone': 'None',
'postVisibility': 'Visibility',
'postVisibilityAll': 'Everyone',
'postVisibilityFriends': 'Friends',
'postVisibilitySelected': 'Selected visible',
'postVisibilityFiltered': 'Selected invisible',
'postVisibilityNone': 'Only me',
'postVisibleUsers': 'Visible users',
'postInvisibleUsers': 'Invisible users',
'postOverview': 'Overview',
'postThumbnail': 'Thumbnail',
'postThumbnailAttachmentNew': 'Upload thumbnail',
'postThumbnailAttachment': 'Attachment serial number',
'postPinned': 'Pinned',
'postListNews': 'News',
'postListFriends': 'Friends',
'postListShuffle': 'Random',
'postEditorModeStory': 'Post a post',
'postEditorModeArticle': 'Post an article',
'postEditor': 'Post editor',
'articleEditor': 'Create new article',
'articleDetail': 'Article details',
'draftBoxOpen': 'Open draft box',
'postNew': 'Create a new post',
'postNewInRealmHint': 'Add post in realm @realm',
'postAction': 'Post',
'postEdited': 'Edited at @date',
'postNewCreated': 'Created at @date',
'attachmentHint': '@count attachment(s)',
'postInRealm': 'In @realm',
'postDetail': 'Post',
'postReplies': 'Replies',
'postPublish': 'Post a post',
'articlePublish': 'Write an article',
'articleTitlePlaceholder': 'Title',
'articleDescriptionPlaceholder': 'Description',
'articleContentPlaceholder': 'Content',
'postIdentityNotify': 'You will post this post as',
'postContentPlaceholder': 'What\'s happened?!',
'postTagsPlaceholder': 'Tags',
'postReaction': 'Reactions of the Post',
'postActionList': 'Actions of Post',
'postReplyAction': 'Make a reply',
'postRepliedNotify': 'Replied a post from @username.',
'postRepostedNotify': 'Reposted a post from @username.',
'postInRealmNotify': 'You\'re posting in realm @realm.',
'postEditingNotify': 'You\'re editing as post from you.',
'postReplyingNotify': 'You\'re replying a post from @username.',
'postRepostingNotify': 'You\'re reposting a post from @username.',
'postDeletionConfirm': 'Confirm post deletion',
'postDeletionConfirmCaption':
'Are your sure to delete post "@content"? This action cannot be undone!',
'reactAdd': 'React',
'reactCompleted': 'Your reaction has been added',
'reactUncompleted': 'Your reaction has been removed',
'attachmentUploadBy': 'Upload by',
'attachmentAutoUpload': 'Auto Upload',
'attachmentUploadQueue': 'Upload Queue',
'attachmentUploadQueueStart': 'Start All',
'attachmentUploadInProgress':
'There are attachments being uploaded. Please wait until all attachments have been uploaded before proceeding...',
'attachmentAttached': 'Exists Files',
'attachmentUploadBlocked':
'Upload blocked, there is currently a task in progress...',
'attachmentAdd': 'Attach file',
'attachmentAddGalleryPhoto': 'Gallery photo',
'attachmentAddGalleryVideo': 'Gallery video',
'attachmentAddCameraPhoto': 'Capture photo',
'attachmentAddCameraVideo': 'Capture video',
'attachmentAddClipboard': 'Paste file',
'attachmentAddFile': 'Attach file',
'attachmentAddLink': 'Link attachments',
'attachmentAddLinkHint':
'Enter attachment serial number to link that attachment',
'attachmentAddLinkInput': 'Serial number',
'attachmentSetting': 'Adjust attachment',
'attachmentAlt': 'Alternative text',
'attachmentLoadFailed': 'Load Attachment Failed',
'attachmentLoadFailedCaption':
'Something went wrong during loading the attachment metadata...',
'attachmentUploading': 'Uploading @name...',
'attachmentUploadingWebMode':
'Uploading @name... Due to browser\'s limitation, calculate attachment information may cause some lag...',
'realm': 'Realm',
'realms': 'Realms',
'realmOrganizing': 'Organize a realm',
'realmAlias': 'Alias (Identifier)',
'realmName': 'Name',
'realmDescription': 'Description',
'realmPublic': 'Public Realm',
'realmCommunity': 'Community Realm',
'realmDetail': 'Realm detail',
'realmMember': 'Realm member',
'realmMembers': 'Realm members',
'realmMembersAdd': 'Add realm members',
'realmMembersAddHint': 'Into @realm',
'realmAdjust': 'Realm adjustment',
'realmSettings': 'Realm settings',
'realmEditingNotify': 'You\'re editing realm @realm',
'realmLeaveConfirm': 'Confirm realm quit',
'realmLeaveConfirmCaption':
'Are you sure you want leave realm @realm? Your content published in this realm will not be deleted.',
'realmDeletionConfirm': 'Confirm realm deletion',
'realmDeletionConfirmCaption':
'Are you sure to delete realm @realm? This action cannot be undone!',
'channels': 'Channels',
'channelNew': 'Create a new channel',
'channelNewInRealmHint': 'Create channel in realm @realm',
'channelOrganizing': 'Organize a channel',
'channelOrganizeCommon': 'Create regular channel',
'channelOrganizeDirect': 'Create DM',
'channelOrganizeDirectHint': 'Choose friend to create DM',
'channelInRealmNotify': 'You\'re creating channel in realm @realm',
'channelEditingNotify': 'You\'re editing channel @channel',
'channelAlias': 'Alias (Identifier)',
'channelName': 'Name',
'channelDescription': 'Description',
'channelDirectDescription': 'Direct message with @username',
'channelEncrypted': 'Encrypted Channel',
'channelMember': 'Channel member',
'channelMembers': 'Channel members',
'channelMembersAdd': 'Add channel members',
'channelMembersAddHint': 'Into @channel',
'channelType': 'Channel type',
'channelTypeCommon': 'Regular',
'channelTypeDirect': 'DM',
'channelAdjust': 'Channel adjustment',
'channelDetail': 'Channel detail',
'channelSettings': 'Channel settings',
'channelLeaveConfirm': 'Confirm channel quit',
'channelLeaveConfirmCaption':
'Are you sure to leave channel @channel? All your messages will be deleted!',
'channelDeletionConfirm': 'Confirm channel deletion',
'channelDeletionConfirmCaption':
'Are you sure to delete channel @channel? This action cannot be undone!',
'channelCategoryDirect': 'DM',
'channelCategoryDirectHint': 'Your direct messages',
'channelNotifyLevel': 'Notify level',
'channelNotifyLevelAll': 'All',
'channelNotifyLevelMentioned': 'Only mentioned',
'channelNotifyLevelNone': 'Ignore all',
'channelNotifyLevelApplied': 'Your notification settings has been applied.',
'messageUnSync': 'Messages Un-synced',
'messageUnSyncCaption': '@count message(s) still in un-synced.',
'messageSending': 'Sending...',
'messageEditDesc': 'Edited message @id',
'messageDeleteDesc': 'Deleted message @id',
'messageCallStartDesc': '@user starts a call',
'messageCallEndDesc': 'Call last for @duration',
'messageTypeUnsupported': 'Unsupported Message: @type',
'messageInputPlaceholder': 'Message @channel',
'messageActionList': 'Actions of Message',
'messageDeletionConfirm': 'Confirm message deletion',
'messageDeletionConfirmCaption':
'Are your sure to delete message @id? This action cannot be undone!',
'call': 'Call',
'callOngoing': 'A call is ongoing...',
'callOngoingEmpty': 'A call is on hold...',
'callOngoingParticipants': '@count people are calling...',
'callOngoingJoined': 'Call last @duration',
'callJoin': 'Join',
'callResume': 'Resume',
'callMicrophone': 'Microphone',
'callMicrophoneDisabled': 'Microphone Disabled',
'callMicrophoneSelect': 'Select Microphone',
'callCamera': 'Camera',
'callCameraDisabled': 'Camera Disabled',
'callCameraSelect': 'Select Camera',
'callSpeakerSelect': 'Select Speaker',
'callDisconnected': 'Call Disconnected... @reason',
'callMicrophoneOn': 'Turn Microphone On',
'callMicrophoneOff': 'Turn Microphone Off',
'callCameraOn': 'Turn Camera On',
'callCameraOff': 'Turn Camera Off',
'callVideoFlip': 'Flip Video Input',
'callSpeakerphoneToggle': 'Toggle Speakerphone Mode',
'callScreenOn': 'Start Screen Sharing',
'callScreenOff': 'Stop Screen Sharing',
'callDisconnect': 'Disconnect',
'callDisconnectCaption':
'Are you sure you want to disconnect from this call? You can also just return to the page, and the call will continue in the background.',
'callParticipantAction': 'Participant Actions',
'callParticipantMicrophoneOff': 'Mute Participant',
'callParticipantMicrophoneOn': 'Unmute Participant',
'callParticipantVideoOff': 'Turn Off Participant Video',
'callParticipantVideoOn': 'Turn On Participant Video',
'callAlreadyOngoing': 'A call is already ongoing',
'badge': 'Badge',
'badges': 'Badges',
'badgeGrantAt': 'Badge awarded on @date',
'badgeSolsynthStaff': 'Solsynth Staff',
'badgeSolarOriginalCitizen': 'Solar Network Natives',
'badgeGreatCommunityContributor': 'Great Community Contributor',
'pushNotifyRegister': 'Register Push Notification Device',
'pushNotifyRegisterCaption':
'Activating push notifications allows you to get our latest notifications even when the app is completely closed. We use Apple\'s official push service on iOS/macOS devices; other devices provide push notifications through Google Firebase. To register a device for push notifications, you may need to connect to Google\'s servers and install the Google Framework on your device. Although you dismiss this dialog, this registration will be auto performed when you next time launch the app.',
'pushNotifyRegisterDone': 'Push notifications has been activated.',
'pushNotifyRegisterFailed': 'Unable to active push notification... @reason',
'accountChangeStatus': 'Change Status',
'accountCustomStatus': 'Set Custom Status',
'accountClearStatus': 'Clear Status',
'accountStatusOnline': 'Online',
'accountStatusSilent': 'Do not Disturb',
'accountStatusSilentDesc': 'The notification will stop popping up',
'accountStatusInvisible': 'Invisible',
'accountStatusInvisibleDesc':
'Will show as offline, but all features still remain normal',
'accountStatusOffline': 'Offline',
'accountLastSeenAt': '@date ago online',
'accountStatusLabel': 'Status Text',
'accountStatusClearAt': 'Clear At',
'accountStatusNegative': 'Negative',
'accountStatusNeutral': 'Neutral',
'accountStatusPositive': 'Positive',
'bsLoadingTheme': 'Loading Theme',
'bsCheckForUpdate': 'Checking For Updates',
'bsCheckForUpdateFailed': 'Unable to Check Updates',
'bsCheckForUpdateNew': 'Found New Version',
'bsCheckForUpdateDescApple':
'Please head to TestFlight and update your app to latest version to prevent error happens and get latest functions.',
'bsCheckForUpdateDescCommon':
'Please head to our website download and install latest version of application to prevent error happens and get latest functions.',
'bsCheckingServer': 'Checking Server Status',
'bsCheckingServerFail':
'Unable connect to server, check your network connection',
'bsCheckingServerDown': 'Server currently unavailable, please retry later',
'bsAuthorizing': 'Authorizing',
'bsEstablishingConn': 'Establishing Connection',
'bsPreparingData': 'Preparing User Data',
'bsRegisteringPushNotify': 'Enabling Push Notifications',
'bsDismissibleErrorHint': 'Click anywhere to ignore this error',
'postShareContent':
'@content\n\n@username on the Solar Network\nCheck it out: @link',
'postShareSubject': '@username posted a post on the Solar Network',
'themeColor': 'Global Theme Color',
'themeColorRed': 'Modern Red',
'themeColorBlue': 'Classic Blue',
'themeColorMiku': 'Miku Blue',
'themeColorKagamine': 'Kagamine Yellow',
'themeColorLuka': 'Luka Pink',
'stickerDeletionConfirm': 'Confirm sticker delete',
'stickerDeletionConfirmCaption':
'Are you sure to delete sticker @name? This action cannot be undo.',
'themeColorApplied': 'Global theme color has been applied.',
'attachmentSaved': 'Attachment saved to your system album.',
'cropImage': 'Crop Image',
'stickerUploader': 'Upload sticker',
'stickerUploaderAttachmentNew': 'Upload sticker',
'stickerUploaderAttachment': 'Attachment serial number',
'stickerUploaderPack': 'Sticker pack serial number',
'stickerUploaderPackHint':
'Don\'t have pack id? Head to creator platform and create one!',
'stickerUploaderAlias': 'Alias',
'stickerUploaderAliasHint':
'Will be used as a placeholder with the sticker pack prefix when entered.',
'stickerUploaderName': 'Name',
'stickerUploaderNameHint':
'A human-friendly name given to the user in the sticker selection interface.',
'readMore': 'Read more',
'attachmentUnload': 'Not Loaded',
'attachmentUnloadCaption':
'In order to save traffic, this attachment is not loaded automatically. Click it to start loading.',
'callStatusConnected': 'Connected',
'callStatusDisconnected': 'Disconnected',
'callStatusConnecting': 'Connecting',
'callStatusReconnected': 'Reconnecting',
'messageOutOfSync': 'May Out of Sync with Server',
'messageOutOfSyncCaption':
'Since the App has entered the background, there may be a time difference between the message list and the server. Click to Refresh.',
'messageHistoryWipe': 'Wipe local message history',
'unknown': 'Unknown',
'collapse': 'Collapse',
'expand': 'Expand',
'typingMessage': '@user are typing...',
};

View File

@ -1,373 +0,0 @@
const i18nSimplifiedChinese = {
'done': '完成',
'hide': '隐藏',
'okay': '确认',
'home': '首页',
'next': '下一步',
'reset': '重置',
'cancel': '取消',
'confirm': '确认',
'leave': '离开',
'loading': '载入中…',
'guest': '游客',
'about': '关于',
'edit': '编辑',
'delete': '删除',
'settings': '设置',
'page': '页面',
'draft': '草稿',
'draftSave': '存为草稿',
'draftBox': '草稿箱',
'more': '更多',
'share': '分享',
'shareNoUri': '分享文字内容',
'alias': '别名',
'feed': '资讯',
'unlink': '移除链接',
'dashboard': '仪表盘',
'today': '今日',
'feedSearch': '搜索资讯',
'feedSearchWithTag': '检索带有 #@key 标签的资讯',
'feedSearchWithCategory': '检索位于分类 @category 的资讯',
'feedUnreadCount': '@count 条你可能错过的帖子',
'messages': '消息',
'messagesUnreadCount': '@count 条未读的消息',
'dailySign': '签到',
'dailySignNone': '今日未拜访佛祖',
'dailySignTier0': '诸事不宜',
'dailySignTier1': '有些不宜',
'dailySignTier2': '平平淡淡',
'dailySignTier3': '有些事宜',
'dailySignTier4': '诸事皆宜',
'dashboardFooter': '占卜多少沾点玩,人生还得靠实力',
'visitProfilePage': '造访个人主页',
'profilePosts': '帖子',
'profileAlbum': '相簿',
'chat': '聊天',
'apply': '应用',
'search': '搜索',
'post': '帖子',
'article': '文章',
'reply': '回复',
'repost': '转帖',
'openInAlbum': '在相簿中打开',
'openInBrowser': '在浏览器中打开',
'notification': '通知',
'notificationUnreadCount': '@count 条未读通知',
'errorHappened': '发生错误了',
'errorHappenedUnauthorized': '未经授权的请求,请登录或尝试重新登录。',
'errorHappenedRequestBad': '请求错误,服务器拒绝处理该请求,请检查您的请求数据。',
'errorHappenedRequestForbidden': '请求错误,权限不足。',
'errorHappenedRequestNotFound': '请求错误,请求的数据不存在。',
'errorHappenedRequestConnection': '网络请求失败,请检查连接状态与服务状态后再试。',
'errorHappenedRequestUnknown': '请求错误,类型未知,请将本提示完整截图提交反馈。',
'forgotPassword': '忘记密码',
'email': '邮件地址',
'username': '用户名',
'nickname': '显示名',
'password': '密码',
'title': '标题',
'description': '简介',
'birthday': '生日',
'firstName': '名称',
'lastName': '姓氏',
'account': '账号',
'accountPersonalize': '个性化',
'accountPersonalizeApplied': '账户的个性化设置已保存。',
'accountStickers': '贴图',
'accountFriend': '好友',
'accountFriendNew': '添加好友',
'accountFriendNewHint': '使用他人的用户名来发送一个好友请求吧!',
'accountFriendPending': '好友请求',
'accountFriendBlocked': '好友黑名单',
'accountFriendListHint': '左滑来拒绝,右滑来接受',
'accountFriendRequestSent': '好友请求已发送,等待处理对方中……',
'accountSuspended': '帐号被停用',
'accountSuspendedAt': '该帐号自 @date 起被停用',
'aspectRatio': '纵横比',
'aspectRatioSquare': '方型',
'aspectRatioPortrait': '竖型',
'aspectRatioLandscape': '横型',
'unsignedIn': '未登录',
'signin': '登录',
'signinRequired': '需要登录',
'signinRequiredHint': '登陆以获得 Solar Network 的全部功能使用权。',
'signinGreeting': '欢迎回来\nSolar Network',
'signinCaption': '登录以发表帖子、文章、创建领域、和你的朋友聊天,以及获取更多功能!',
'signinRiskDetected': '检测到风险,点击下一步按钮来打开一个网页,并通过在其上面登录来通过安全检查。',
'signinResetPasswordHint': '请先填写用户名以发送重置密码请求。',
'signinResetPasswordSent': '重置密码请求已发送,在绑定邮件收件箱可收取一份包含重置密码链接的邮件。',
'signup': '注册',
'signupGreeting': '欢迎加入\nSolar Network',
'signupCaption': '在 Solarpass 注册一个账号以获得整个 Solar Network 的存取权!',
'signupDone': '注册成功',
'signupDoneCaption': '你成功地注册了一个帐户,现在去尝试登陆吧!',
'signout': '登出',
'joinedAt': '加入于 @date',
'riskDetection': '检测到风险',
'matureContent': '评级内容',
'matureContentCaption': '该内容已被评级为家长指导级或以上,这可能说明内容包含一系列不友好的成分',
'notifyAllRead': '已读所有通知',
'notifyEmpty': '通知箱为空',
'notifyEmptyCaption': '看起来最近没发生什么呢',
'totalSocialCreditPoints': '社会信用点',
'totalPostCount': '总帖数',
'totalUpvote': '获顶数',
'totalDownvote': '获踩数',
'clear': '清除',
'pinPost': '置顶本帖',
'unpinPost': '取消置顶本帖',
'postRestoreFromLocal': '内容从本地暂存回复',
'postAutoSaveAt': '已自动保存于 @date',
'postCategoriesAndTags': '分类与标签',
'postPublishDate': '发布时间',
'postPublishAt': '发布帖子于',
'postPublishedUntil': '取消发布于',
'postPublishZone': '帖子发布区',
'postPublishZoneNone': '无所属领域',
'postVisibility': '帖子可见性',
'postVisibilityAll': '所有人可见',
'postVisibilityFriends': '仅好友可见',
'postVisibilitySelected': '选中者可见',
'postVisibilityFiltered': '选中者不可见',
'postVisibilityNone': '仅自己可见',
'postVisibleUsers': '可见帖子者',
'postInvisibleUsers': '隐藏帖子者',
'postOverview': '帖子概览',
'postThumbnail': '帖子缩略图',
'postThumbnailAttachmentNew': '上传附件作为缩略图',
'postThumbnailAttachment': '附件序列号',
'postPinned': '已置顶',
'postEditorModeStory': '发个帖子',
'postEditorModeArticle': '撰写文章',
'postEditor': '帖子编辑器',
'articleEditor': '撰写文章',
'articleDetail': '文章详情',
'draftBoxOpen': '打开草稿箱',
'postListNews': '新鲜事',
'postListFriends': '好友圈',
'postListShuffle': '打乱看',
'postNew': '创建新帖子',
'postNewInRealmHint': '在领域 @realm 里发表新帖子',
'postAction': '发表',
'postEdited': '编辑于 @date',
'postNewCreated': '创建于 @date',
'postInRealm': '发表于 @realm',
'attachmentHint': '@count 个附件',
'postDetail': '帖子详情',
'postReplies': '帖子回复',
'postPublish': '编辑帖子',
'postIdentityNotify': '你将会以本身份发表帖子',
'postContentPlaceholder': '发生什么事了?!',
'postTagsPlaceholder': '标签',
'postReaction': '帖子的反应',
'postActionList': '帖子的操作',
'postReplyAction': '发表一则回复',
'postRepliedNotify': '回了一个 @username 的帖子',
'postRepostedNotify': '转了一个 @username 的帖子',
'postInRealmNotify': '你正在领域 @realm 中发表帖子',
'postEditingNotify': '你正在编辑一个你发布的帖子',
'postReplyingNotify': '你正在回一个来自 @username 的帖子',
'postRepostingNotify': '你正在转一个来自 @username 的帖子',
'postDeletionConfirm': '确认删除帖子',
'postDeletionConfirmCaption': '你确定要删除帖子 “@content” 吗?该操作不可撤销。',
'reactAdd': '作出反应',
'reactCompleted': '你的反应已被添加',
'reactUncompleted': '你的反应已被移除',
'attachmentUploadBy': '由上传',
'attachmentAutoUpload': '自动上传',
'attachmentUploadQueue': '上传队列',
'attachmentUploadQueueStart': '整队上传',
'attachmentUploadInProgress': '有附件正在上传,请等待所有附件上传完毕后再进行操作……',
'attachmentAttached': '已附附件',
'attachmentUploadBlocked': '上传受阻,当前已有任务进行中……',
'attachmentAdd': '附加附件',
'attachmentAddGalleryPhoto': '相册照片',
'attachmentAddGalleryVideo': '相册视频',
'attachmentAddCameraPhoto': '拍摄图片',
'attachmentAddCameraVideo': '拍摄视频',
'attachmentAddClipboard': '粘贴文件',
'attachmentAddFile': '附加文件',
'attachmentAddLink': '链接附件',
'attachmentAddLinkHint': '输入附件的神秘代号来链接对应附件',
'attachmentAddLinkInput': '神秘代号',
'attachmentSetting': '调整附件',
'attachmentAlt': '替代文字',
'attachmentLoadFailed': '加载失败',
'attachmentLoadFailedCaption': '有错误发生于加载附件元数据的过程中了…',
'attachmentUploading': '上传附件 @name 中…',
'attachmentUploadingWebMode': '上传附件 @name 中… 由于浏览器单线程限制,计算所需资源可能会导致界面卡顿…',
'realm': '领域',
'realms': '领域',
'realmOrganizing': '组织领域',
'realmAlias': '别称(标识符)',
'realmName': '显示名称',
'realmDescription': '领域简介',
'realmPublic': '公开领域',
'realmCommunity': '社区领域',
'realmDetail': '领域详情',
'realmMember': '领域成员',
'realmMembers': '领域成员',
'realmMembersAdd': '添加领域成员',
'realmMembersAddHint': '到 @realm',
'realmAdjust': '调整领域',
'realmSettings': '领域设置',
'realmEditingNotify': '你正在编辑领域 @realm',
'realmLeaveConfirm': '确认离开领域',
'realmLeaveConfirmCaption': '你确认要离开领域 @realm 吗?你在该领域发表的内容不会被删除。',
'realmDeletionConfirm': '确认删除领域',
'realmDeletionConfirmCaption': '你确定要删除领域 @realm 嘛?该操作不可撤销。',
'channels': '频道',
'channelNew': '创建新频道',
'channelNewInRealmHint': '在领域 @realm 里创建新频道',
'channelOrganizing': '组织频道',
'channelOrganizeCommon': '创建普通频道',
'channelOrganizeDirect': '创建私信频道',
'channelOrganizeDirectHint': '选择好友来创建私信',
'channelInRealmNotify': '你正在领域 @realm 中创建频道',
'channelEditingNotify': '你正在编辑频道 @channel',
'channelAlias': '别称(标识符)',
'channelName': '显示名称',
'channelDescription': '频道简介',
'channelDirectDescription': '与 @username 的私聊',
'channelEncrypted': '加密频道',
'channelMember': '频道成员',
'channelMembers': '频道成员',
'channelMembersAdd': '添加频道成员',
'channelMembersAddHint': '到 @channel',
'channelType': '频道类型',
'channelTypeCommon': '普通频道',
'channelTypeDirect': '私信聊天',
'channelAdjust': '调整频道',
'channelDetail': '频道详情',
'channelSettings': '频道设置',
'channelLeaveConfirm': '确认离开频道',
'channelLeaveConfirmCaption': '你确认要离开频道 @channel 吗?你在这个频道的消息将被删除。',
'channelDeletionConfirm': '确认删除频道',
'channelDeletionConfirmCaption': '你确认要删除频道 @channel 吗?该操作不可撤销。',
'channelCategoryDirect': '私聊频道',
'channelCategoryDirectHint': '你的所有私聊频道',
'channelNotifyLevel': '通知等级',
'channelNotifyLevelAll': '全部通知',
'channelNotifyLevelMentioned': '仅提及',
'channelNotifyLevelNone': '忽略一切',
'channelNotifyLevelApplied': '你的通知设置已经应用。',
'messageUnSync': '消息未同步',
'messageUnSyncCaption': '还有 @count 条消息未同步',
'messageSending': '消息发送中…',
'messageEditDesc': '修改了消息 @id',
'messageDeleteDesc': '删除了消息 @id',
'messageCallStartDesc': '@user 发起了一次通话',
'messageCallEndDesc': '通话持续了 @duration',
'messageTypeUnsupported': '不支持的消息类型 @type',
'messageActionList': '消息的操作',
'messageDeletionConfirm': '确认删除消息',
'messageDeletionConfirmCaption': '你确定要删除消息 @id 吗?该操作不可撤销。',
'call': '通话',
'callOngoing': '一则通话正在进行中…',
'callOngoingEmpty': '一则通话待机中…',
'callOngoingParticipants': '@count 人正在进行通话…',
'callOngoingJoined': '通话进行 @duration',
'callJoin': '加入',
'callResume': '恢复',
'callMicrophone': '麦克风',
'callMicrophoneDisabled': '麦克风禁用',
'callMicrophoneSelect': '选择麦克风',
'callCamera': '摄像头',
'callCameraDisabled': '摄像头禁用',
'callCameraSelect': '选择摄像头',
'callSpeakerSelect': '选择扬声器',
'callDisconnected': '通话已断开… @reason',
'callMicrophoneOn': '开启麦克风',
'callMicrophoneOff': '关闭麦克风',
'callCameraOn': '开启摄像头',
'callCameraOff': '关闭摄像头',
'callVideoFlip': '翻转视频输入',
'callSpeakerphoneToggle': '切换扬声器模式',
'callScreenOn': '启动屏幕分享',
'callScreenOff': '关闭屏幕分享',
'callDisconnect': '断开连接',
'callDisconnectCaption': '你确定要断开与该则通话的连接吗?你也可以直接返回页面,通话将在后台继续。',
'callParticipantAction': '通话参与者的操作',
'callParticipantMicrophoneOff': '静音参与者',
'callParticipantMicrophoneOn': '解除静音参与者',
'callParticipantVideoOff': '静音参与者',
'callParticipantVideoOn': '解除静音参与者',
'callAlreadyOngoing': '当前正在进行一则通话',
'badge': '徽章',
'badges': '徽章',
'badgeGrantAt': '徽章颁发于 @date',
'badgeSolsynthStaff': 'Solsynth 工作人员',
'badgeSolarOriginalCitizen': 'Solar Network 原住民',
'badgeGreatCommunityContributor': '优秀社区贡献者',
'pushNotifyRegister': '注册推送通知设备',
'pushNotifyRegisterCaption':
'激活推送通知便可以让你在应用程序完全关闭的时候仍然获取到我们最新的通知。在 iOS/macOS 设备上我们使用 Apple 官方的推送服务;其他设备则通过 Google Firebase 提供推送通知。要注册推送通知设备,您可能需要连接到 Google 的服务器(在中国大陆不可用)并在您的设备上安装 Google Framework。即使您关闭此对话框下次启动应用程序时仍会自动执行此注册。',
'pushNotifyRegisterDone': '推送通知已成功激活',
'pushNotifyRegisterFailed': '推送通知激活失败…… @reason',
'accountChangeStatus': '变更状态',
'accountCustomStatus': '自定义状态',
'accountClearStatus': '清除状态',
'accountStatusOnline': '在线',
'accountStatusSilent': '请勿打扰',
'accountStatusSilentDesc': '将会暂停所有通知推送',
'accountStatusInvisible': '隐身',
'accountStatusInvisibleDesc': '将会在他人界面显示离线,但不影响功能使用',
'accountStatusOffline': '离线',
'accountLastSeenAt': '最后上线于 @date 前',
'accountStatusLabel': '状态文字',
'accountStatusClearAt': '清除状态于',
'accountStatusNegative': '负面',
'accountStatusNeutral': '中性',
'accountStatusPositive': '积极',
'bsLoadingTheme': '正在装载主题',
'bsCheckForUpdate': '正在检查更新',
'bsCheckForUpdateFailed': '无法检查更新',
'bsCheckForUpdateNew': '发现新版本',
'bsCheckForUpdateDescApple': '请前往 TestFlight 并将您的应用程序更新到最新版本,以防止出现错误并获取最新功能。',
'bsCheckForUpdateDescCommon': '请前往我们的网站下载并安装最新版本的应用程序,以防止出现错误并获取最新功能。',
'bsCheckingServer': '检查服务器状态中',
'bsCheckingServerFail': '无法连接至服务器,请检查你的网络连接状态',
'bsCheckingServerDown': '当前服务器不可用,请稍后重试',
'bsAuthorizing': '正在授权中',
'bsEstablishingConn': '部署连接中',
'bsPreparingData': '正在准备用户资料',
'bsRegisteringPushNotify': '正在启用推送通知',
'bsDismissibleErrorHint': '点击任意地方忽略此错误',
'postShareContent': '@content\n\n@username 在 Solar Network\n原帖地址:@link',
'postShareSubject': '@username 在 Solar Network 上发布了一篇帖子',
'themeColor': '全局主题色',
'themeColorRed': '现代红',
'themeColorBlue': '经典蓝',
'themeColorMiku': '未来蓝',
'themeColorKagamine': '镜音黄',
'themeColorLuka': '流音粉',
'themeColorApplied': '全局主题颜色已应用',
'stickerDeletionConfirm': '确认删除贴图',
'stickerDeletionConfirmCaption': '你确认要删除贴图 @name 吗?该操作不可撤销。',
'attachmentSaved': '附件已保存到系统相册',
'cropImage': '裁剪图片',
'stickerUploader': '上传贴图',
'stickerUploaderAttachmentNew': '上传附件作为贴图',
'stickerUploaderAttachment': '附件序列号',
'stickerUploaderPack': '贴图包序号',
'stickerUploaderPackHint': '没有该序号?请转到我们的创作者平台创建一个贴图包。',
'stickerUploaderAlias': '贴图别名',
'stickerUploaderAliasHint': '将会在输入时使用和贴图包前缀组成占位符。',
'stickerUploaderName': '贴图名称',
'stickerUploaderNameHint': '在贴图选择界面提供给用户的人类友好名称。',
'readMore': '阅读更多',
'attachmentUnload': '附件未加载',
'attachmentUnloadCaption': '为了节省流量,本附件未自动加载,点一下来开始加载。',
'callStatusConnected': '已连接',
'callStatusDisconnected': '已断开',
'callStatusConnecting': '连接中',
'callStatusReconnected': '重连中',
'messageOutOfSync': '消息可能与服务器脱节',
'messageOutOfSyncCaption': '由于 App 进入后台,消息列表可能与服务器存在时差,点击刷新。',
'messageHistoryWipe': '清除消息记录',
'unknown': '未知',
'collapse': '折叠',
'expand': '展开',
'typingMessage': '@user 正在输入中…',
};

View File

@ -1,7 +1,6 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:solian/platform.dart';
import 'package:solian/services.dart';
import 'package:solian/widgets/auto_cache_image.dart';
class AccountAvatar extends StatelessWidget {
final dynamic content;
@ -34,11 +33,7 @@ class AccountAvatar extends StatelessWidget {
key: Key('a$content'),
radius: radius,
backgroundColor: bgColor,
backgroundImage: !isEmpty
? (PlatformInfo.canCacheImage
? CachedNetworkImageProvider(url)
: NetworkImage(url)) as ImageProvider<Object>?
: null,
backgroundImage: !isEmpty ? AutoCacheImage.provider(url) : null,
child: isEmpty
? Icon(
Icons.account_circle,
@ -74,33 +69,6 @@ class AccountProfileImage extends StatelessWidget {
? content
: ServiceFinder.buildUrl('files', '/attachments/$content');
if (PlatformInfo.canCacheImage) {
return CachedNetworkImage(
imageUrl: url,
fit: fit,
progressIndicatorBuilder: (context, url, downloadProgress) => Center(
child: CircularProgressIndicator(
value: downloadProgress.progress,
),
),
);
} else {
return Image.network(
url,
fit: fit,
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: null,
),
);
},
);
}
return AutoCacheImage(url, fit: fit, noErrorWidget: true);
}
}

View File

@ -45,7 +45,7 @@ class _AccountBadgeWidgetState extends State<AccountBadgeWidget> {
Widget build(BuildContext context) {
final spec = badges[widget.item.type];
if (spec == null) return const SizedBox();
if (spec == null) return const SizedBox.shrink();
return Tooltip(
richMessage: TextSpan(

View File

@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/account_status.dart';
import 'package:solian/platform.dart';
import 'package:solian/providers/account_status.dart';
import 'package:solian/providers/experience.dart';
import 'package:solian/widgets/account/account_avatar.dart';
import 'package:solian/widgets/account/account_badge.dart';
import 'package:solian/widgets/account/account_status_action.dart';
@ -17,6 +20,7 @@ class AccountHeadingWidget extends StatelessWidget {
final String nick;
final String? desc;
final Account? detail;
final AccountProfile? profile;
final List<AccountBadge>? badges;
final List<Widget>? extraWidgets;
@ -32,6 +36,7 @@ class AccountHeadingWidget extends StatelessWidget {
required this.desc,
required this.badges,
this.detail,
this.profile,
this.status,
this.extraWidgets,
this.onEditStatus,
@ -70,7 +75,7 @@ class AccountHeadingWidget extends StatelessWidget {
content: banner,
fit: BoxFit.cover,
)
: const SizedBox(),
: const SizedBox.shrink(),
),
),
).paddingSymmetric(horizontal: 16),
@ -129,7 +134,10 @@ class AccountHeadingWidget extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(info.$3),
Text(
info.$3,
style: const TextStyle(height: 1),
).paddingOnly(bottom: 3),
if (!status.isOnline && status.lastSeenAt != null)
Opacity(
opacity: 0.75,
@ -150,7 +158,7 @@ class AccountHeadingWidget extends StatelessWidget {
),
],
).paddingOnly(left: 116, top: 6),
const SizedBox(height: 4),
const Gap(4),
if (badges?.isNotEmpty ?? false)
SizedBox(
width: double.infinity,
@ -181,6 +189,63 @@ class AccountHeadingWidget extends StatelessWidget {
),
),
).paddingSymmetric(horizontal: 16),
if (profile != null)
Card(
child: ListTile(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
visualDensity:
const VisualDensity(horizontal: -4, vertical: -2),
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
ExperienceProvider.getLevelFromExp(
profile!.experience ?? 0,
).$2.tr,
),
const Gap(4),
Badge(
label: Text(
'Lv${ExperienceProvider.getLevelFromExp(
profile!.experience ?? 0,
).$1}',
style: GoogleFonts.dosis(
fontWeight: FontWeight.bold,
),
),
).paddingOnly(top: 1),
],
),
subtitle: SizedBox(
height: 20,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: LinearProgressIndicator(
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
value: ExperienceProvider.calcLevelUpProgress(
profile!.experience ?? 0,
),
),
),
const Gap(8),
Text(
'${ExperienceProvider.calcLevelUpProgressLevel(profile!.experience ?? 0)} EXP',
style: GoogleFonts.robotoMono(
fontSize: 10,
height: 0.5,
),
),
],
),
),
),
).paddingSymmetric(horizontal: 16),
SizedBox(
width: double.infinity,
child: Card(

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/models/account.dart';
import 'package:solian/providers/account_status.dart';
@ -72,7 +73,7 @@ class _AccountProfilePopupState extends State<AccountProfilePopup> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.cancel, size: 24),
const SizedBox(height: 12),
const Gap(12),
Text(
_hasError.toString(),
textAlign: TextAlign.center,
@ -98,6 +99,7 @@ class _AccountProfilePopupState extends State<AccountProfilePopup> {
nick: _userinfo!.nick,
desc: _userinfo!.description,
detail: _userinfo!,
profile: _userinfo!.profile,
badges: _userinfo!.badges,
status:
Get.find<StatusProvider>().getSomeoneStatus(_userinfo!.name),

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:solian/exts.dart';
@ -214,7 +215,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
borderRadius: const BorderRadius.all(Radius.circular(8)),
child: const LinearProgressIndicator().animate().scaleX(),
),
const SizedBox(height: 18),
const Gap(18),
TextField(
controller: _labelController,
decoration: InputDecoration(
@ -226,7 +227,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 8),
const Gap(8),
TextField(
controller: _clearAtController,
readOnly: true,
@ -238,7 +239,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
),
onTap: () => selectClearAt(),
),
const SizedBox(height: 8),
const Gap(8),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Wrap(
@ -281,7 +282,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
],
),
),
const SizedBox(height: 8),
const Gap(8),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Wrap(

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/screens/auth/signin.dart';
@ -20,7 +21,7 @@ class SigninRequiredOverlay extends StatelessWidget {
Icons.login,
size: 48,
),
const SizedBox(height: 8),
const Gap(8),
Text(
'signinRequired'.tr,
style: Theme.of(context).textTheme.titleLarge,

View File

@ -22,7 +22,7 @@ class AppBarLeadingButton extends StatelessWidget {
onPressed: () => rootScaffoldKey.currentState!.openDrawer(),
);
} else {
return const SizedBox();
return const SizedBox.shrink();
}
}
}

View File

@ -8,7 +8,7 @@ class AppBarTitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (SolianTheme.isSpecializedMacOS(context)) {
if (AppTheme.isSpecializedMacOS(context)) {
return Text(title);
} else {
return Text(title);

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/attachment.dart';
@ -36,6 +37,7 @@ class _AttachmentAttrEditorDialogState
widget.item.id,
_altController.value.text,
isMature: _isMature,
metadata: widget.item.metadata ?? {},
);
Get.find<AttachmentProvider>().clearCache(id: widget.item.rid);
@ -74,7 +76,7 @@ class _AttachmentAttrEditorDialogState
borderRadius: const BorderRadius.all(Radius.circular(8)),
child: const LinearProgressIndicator().animate().scaleX(),
),
const SizedBox(height: 18),
const Gap(18),
TextField(
controller: _altController,
decoration: InputDecoration(
@ -86,7 +88,7 @@ class _AttachmentAttrEditorDialogState
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 8),
const Gap(8),
CheckboxListTile(
contentPadding: const EdgeInsets.only(left: 4, right: 18),
shape: const RoundedRectangleBorder(

View File

@ -7,6 +7,7 @@ import 'package:dismissible_page/dismissible_page.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
@ -19,6 +20,7 @@ import 'package:solian/providers/attachment_uploader.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/content/attachment.dart';
import 'package:solian/widgets/attachments/attachment_attr_editor.dart';
import 'package:solian/widgets/attachments/attachment_editor_thumbnail.dart';
import 'package:solian/widgets/attachments/attachment_fullscreen.dart';
class AttachmentEditorPopup extends StatefulWidget {
@ -144,7 +146,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
mainAxisSize: MainAxisSize.min,
children: [
Text('attachmentAddLinkHint'.tr, textAlign: TextAlign.left),
const SizedBox(height: 18),
const Gap(18),
TextField(
controller: controller,
decoration: InputDecoration(
@ -263,6 +265,21 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
);
}
void _showAttachmentThumbnailEditor(Attachment element, int idx) {
showDialog(
context: context,
builder: (context) => AttachmentEditorThumbnailDialog(
item: element,
pool: widget.pool,
initialItem: element.metadata?['thumbnail'],
onUpdate: (value) {
_attachments[idx]!.metadata ??= {};
_attachments[idx]!.metadata!['thumbnail'] = value;
},
),
);
}
void _showEdit(Attachment element, int index) {
showDialog(
context: context,
@ -346,14 +363,16 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
FutureBuilder(
future: element.file.length(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const SizedBox();
if (!snapshot.hasData) {
return const SizedBox.shrink();
}
return Text(
_formatBytes(snapshot.data!),
style: Theme.of(context).textTheme.bodySmall,
);
},
),
const SizedBox(width: 6),
const Gap(6),
if (element.progress != null)
Text(
'${(element.progress! * 100).toStringAsFixed(2)}%',
@ -452,11 +471,12 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
);
}
Widget _buildListEntry(Attachment element, int index) {
Widget _buildListEntry(Attachment element, int idx) {
var fileType = element.mimetype.split('/').firstOrNull;
fileType ??= 'unknown';
final canBePreview = fileType.toLowerCase() == 'image';
final canHasThumbnail = fileType.toLowerCase() != 'image';
return Container(
padding: const EdgeInsets.only(left: 16, right: 8, bottom: 16),
@ -488,14 +508,23 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
],
),
),
IconButton(
color: Colors.teal,
icon: const Icon(Icons.preview),
visualDensity: const VisualDensity(horizontal: -4),
onPressed: canBePreview
? () => _showAttachmentPreview(element)
: null,
),
if (canBePreview)
IconButton(
color: Colors.teal,
icon: const Icon(Icons.preview),
visualDensity: const VisualDensity(horizontal: -4),
onPressed: () => _showAttachmentPreview(element),
),
if (canHasThumbnail)
IconButton(
color: Colors.teal,
icon: const Icon(Icons.add_photo_alternate),
visualDensity: const VisualDensity(horizontal: -4),
onPressed: () => _showAttachmentThumbnailEditor(
element,
idx,
),
),
PopupMenuButton(
icon: const Icon(Icons.more_horiz),
iconColor: Theme.of(context).colorScheme.primary,
@ -511,7 +540,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
horizontal: 8,
),
),
onTap: () => _showEdit(element, index),
onTap: () => _showEdit(element, idx),
),
PopupMenuItem(
child: ListTile(
@ -524,7 +553,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
onTap: () {
_deleteAttachment(element).then((_) {
widget.onRemove(element.rid);
setState(() => _attachments.removeAt(index));
setState(() => _attachments.removeAt(idx));
});
},
),
@ -538,7 +567,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
onTap: () {
widget.onRemove(element.rid);
setState(() => _attachments.removeAt(index));
setState(() => _attachments.removeAt(idx));
},
),
],
@ -614,7 +643,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(width: 10),
const Gap(10),
Obx(() {
if (_uploadController.isUploading.value) {
return SizedBox(
@ -627,7 +656,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
);
}
return const SizedBox();
return const SizedBox.shrink();
}),
],
),
@ -635,9 +664,9 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
],
),
),
const SizedBox(width: 20),
const Gap(20),
Text('attachmentAutoUpload'.tr),
const SizedBox(width: 8),
const Gap(8),
Switch(
value: _isAutoUpload,
onChanged: (bool? value) {
@ -666,7 +695,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
Obx(() {
if (_uploadController.isUploading.value) {
return const SizedBox();
return const SizedBox.shrink();
}
return TextButton(
child: Text('attachmentUploadQueueStart'.tr),
@ -680,7 +709,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
);
}
return const SliverToBoxAdapter(child: SizedBox());
return const SliverToBoxAdapter(child: SizedBox.shrink());
}),
Obx(() {
if (_uploadController.queueOfUpload.isNotEmpty) {
@ -696,7 +725,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
);
}
return const SliverToBoxAdapter(child: SizedBox());
return const SliverToBoxAdapter(child: SizedBox.shrink());
}),
if (_attachments.isNotEmpty)
SliverPadding(

View File

@ -0,0 +1,148 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/providers/content/attachment.dart';
import 'package:solian/widgets/attachments/attachment_editor.dart';
class AttachmentEditorThumbnailDialog extends StatefulWidget {
final Attachment item;
final String pool;
final String? initialItem;
final Function(String? id) onUpdate;
const AttachmentEditorThumbnailDialog({
super.key,
required this.item,
required this.pool,
required this.initialItem,
required this.onUpdate,
});
@override
State<AttachmentEditorThumbnailDialog> createState() =>
_AttachmentEditorThumbnailDialogState();
}
class _AttachmentEditorThumbnailDialogState
extends State<AttachmentEditorThumbnailDialog> {
bool _isLoading = false;
final TextEditingController _attachmentController = TextEditingController();
void _promptUploadNewAttachment() {
showModalBottomSheet(
context: context,
builder: (context) => AttachmentEditorPopup(
pool: widget.pool,
singleMode: true,
imageOnly: true,
autoUpload: true,
onAdd: (value) {
widget.onUpdate(value);
_attachmentController.text = value;
},
initialAttachments: const [],
onRemove: (_) {},
),
);
}
Future<void> _updateAttachment() async {
setState(() => _isLoading = true);
final AttachmentProvider attach = Get.find();
widget.item.metadata ??= {};
if (_attachmentController.text.isNotEmpty) {
widget.item.metadata!['thumbnail'] = _attachmentController.text;
} else {
widget.item.metadata!['thumbnail'] = null;
}
try {
await attach.updateAttachment(
widget.item.id,
widget.item.alt,
isMature: widget.item.isMature,
metadata: widget.item.metadata!,
);
Get.find<AttachmentProvider>().clearCache(id: widget.item.rid);
} catch (e) {
context.showErrorDialog(e);
} finally {
setState(() => _isLoading = false);
}
}
@override
void initState() {
if (widget.initialItem != null) {
_attachmentController.text = widget.initialItem!;
}
super.initState();
}
@override
void dispose() {
_attachmentController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('postThumbnail'.tr),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Card(
margin: EdgeInsets.zero,
child: ListTile(
title: Text('postThumbnailAttachmentNew'.tr),
contentPadding: const EdgeInsets.only(left: 12, right: 9),
trailing: const Icon(Icons.chevron_right),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
onTap: () {
_promptUploadNewAttachment();
},
),
),
const Row(children: <Widget>[
Expanded(child: Divider()),
Text('OR'),
Expanded(child: Divider()),
]).paddingOnly(top: 12, bottom: 16, left: 16, right: 16),
TextField(
controller: _attachmentController,
decoration: InputDecoration(
isDense: true,
border: const OutlineInputBorder(),
prefixText: '#',
labelText: 'postThumbnailAttachment'.tr,
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
],
),
actions: [
TextButton(
onPressed: _isLoading
? null
: () {
_updateAttachment().then((_) {
widget.onUpdate(_attachmentController.text);
if (mounted) {
Navigator.pop(context);
}
});
},
child: Text('confirm'.tr),
),
],
);
}
}

View File

@ -6,6 +6,7 @@ import 'package:dismissible_page/dismissible_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gal/gal.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/attachment.dart';
@ -171,7 +172,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
end: Alignment.topCenter,
colors: [
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surface.withOpacity(0),
Colors.transparent,
],
),
),
@ -198,7 +199,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
radius: 19,
),
),
const IgnorePointer(child: SizedBox(width: 8)),
const Gap(8),
Expanded(
child: IgnorePointer(
child: Column(
@ -240,7 +241,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
),
],
),
const IgnorePointer(child: SizedBox(height: 4)),
const Gap(4),
IgnorePointer(
child: Text(
widget.item.alt,
@ -252,7 +253,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
),
),
),
const IgnorePointer(child: SizedBox(height: 2)),
const Gap(2),
IgnorePointer(
child: Wrap(
spacing: 6,

View File

@ -1,12 +1,16 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/platform.dart';
import 'package:solian/providers/durations.dart';
import 'package:solian/services.dart';
import 'package:solian/widgets/auto_cache_image.dart';
import 'package:solian/widgets/sized_container.dart';
import 'package:url_launcher/url_launcher_string.dart';
@ -55,6 +59,11 @@ class _AttachmentItemState extends State<AttachmentItem> {
item: widget.item,
autoload: widget.autoload,
);
case 'audio':
return _AttachmentItemAudio(
item: widget.item,
autoload: widget.autoload,
);
default:
return Center(
child: Container(
@ -65,7 +74,7 @@ class _AttachmentItemState extends State<AttachmentItem> {
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.file_present, size: 32),
const SizedBox(height: 6),
const Gap(6),
Text(
widget.item.mimetype,
style: TextStyle(
@ -74,13 +83,13 @@ class _AttachmentItemState extends State<AttachmentItem> {
),
textAlign: TextAlign.center,
),
const SizedBox(height: 2),
const Gap(2),
Text(
widget.item.alt,
style: const TextStyle(fontSize: 13),
textAlign: TextAlign.center,
),
const SizedBox(height: 12),
const Gap(12),
TextButton.icon(
icon: const Icon(Icons.launch),
label: Text('openInBrowser'.tr),
@ -130,66 +139,13 @@ class _AttachmentItemImage extends StatelessWidget {
child: Stack(
fit: StackFit.expand,
children: [
if (PlatformInfo.canCacheImage)
CachedNetworkImage(
fit: fit,
imageUrl: ServiceFinder.buildUrl(
'files',
'/attachments/${item.rid}',
),
progressIndicatorBuilder: (context, url, downloadProgress) {
return Center(
child: CircularProgressIndicator(
value: downloadProgress.progress,
),
);
},
errorWidget: (context, url, error) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.close, size: 32)
.animate(onPlay: (e) => e.repeat(reverse: true))
.fade(duration: 500.ms),
Text(error.toString()),
],
),
);
},
)
else
Image.network(
ServiceFinder.buildUrl('files', '/attachments/${item.rid}'),
fit: fit,
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: null,
),
);
},
errorBuilder: (context, error, stackTrace) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.close, size: 32)
.animate(onPlay: (e) => e.repeat(reverse: true))
.fade(duration: 500.ms),
Text(error.toString()),
],
),
);
},
AutoCacheImage(
ServiceFinder.buildUrl(
'files',
'/attachments/${item.rid}',
),
fit: fit,
),
if (showBadge && badge != null)
Positioned(
right: 12,
@ -239,22 +195,21 @@ class _AttachmentItemVideo extends StatefulWidget {
}
class _AttachmentItemVideoState extends State<_AttachmentItemVideo> {
late final _player = Player(
configuration: const PlayerConfiguration(
logLevel: MPVLogLevel.error,
),
);
late final _controller = VideoController(_player);
bool _showContent = false;
Player? _videoPlayer;
VideoController? _videoController;
Future<void> _startLoad() async {
await _player.open(
Media(ServiceFinder.buildUrl('files', '/attachments/${widget.item.rid}')),
play: false,
);
setState(() => _showContent = true);
MediaKit.ensureInitialized();
final url = ServiceFinder.buildUrl(
'files',
'/attachments/${widget.item.rid}',
);
_videoPlayer = Player();
_videoController = VideoController(_videoPlayer!);
_videoPlayer!.open(Media(url), play: !widget.autoload);
}
@override
@ -267,54 +222,419 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> {
@override
Widget build(BuildContext context) {
const labelShadows = <Shadow>[
Shadow(
offset: Offset(1, 1),
blurRadius: 5.0,
color: Color.fromARGB(255, 0, 0, 0),
),
];
final ratio = widget.item.metadata?['ratio'] ?? 16 / 9;
if (!_showContent) {
return GestureDetector(
child: AspectRatio(
aspectRatio: ratio,
child: CenteredContainer(
maxWidth: 280,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.not_started,
color: Colors.white,
size: 32,
child: Stack(
children: [
if (widget.item.metadata?['thumbnail'] != null)
AspectRatio(
aspectRatio: 16 / 9,
child: AutoCacheImage(
ServiceFinder.buildUrl(
'uc',
'/attachments/${widget.item.metadata?['thumbnail']}',
),
fit: BoxFit.cover,
),
const SizedBox(height: 8),
Text(
'attachmentUnload'.tr,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
)
else
const Center(
child: Icon(Icons.movie, size: 64),
),
Align(
alignment: Alignment.bottomCenter,
child: IgnorePointer(
child: Container(
height: 56,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surface.withOpacity(0),
],
),
),
),
Text(
'attachmentUnloadCaption'.tr,
style: const TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
],
),
),
),
Positioned(
bottom: 4,
left: 16,
right: 16,
child: SizedBox(
height: 45,
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.item.alt,
style: const TextStyle(
shadows: labelShadows,
color: Colors.white,
),
),
Text(
Duration(
milliseconds:
(widget.item.metadata?['duration'] ?? 0)
.toInt() *
1000,
).toHumanReadableString(),
style: GoogleFonts.robotoMono(
fontSize: 12,
shadows: labelShadows,
color: Colors.white,
),
),
],
),
),
const Icon(
Icons.play_arrow,
shadows: labelShadows,
color: Colors.white,
).paddingOnly(bottom: 4, right: 8),
],
),
),
),
],
),
onTap: () {
_startLoad();
},
);
} else if (_videoController == null) {
return const Center(
child: CircularProgressIndicator(),
);
}
return Video(
controller: _videoController!,
aspectRatio: ratio,
controller: _controller,
);
}
@override
void dispose() {
_player.dispose();
_videoPlayer?.dispose();
super.dispose();
}
}
class _AttachmentItemAudio extends StatefulWidget {
final Attachment item;
final bool autoload;
const _AttachmentItemAudio({
required this.item,
this.autoload = false,
});
@override
State<_AttachmentItemAudio> createState() => _AttachmentItemAudioState();
}
class _AttachmentItemAudioState extends State<_AttachmentItemAudio> {
bool _showContent = false;
double? _draggingValue;
bool _isPlaying = false;
Duration _duration = Duration.zero;
Duration _position = Duration.zero;
Duration _bufferedPosition = Duration.zero;
Player? _audioPlayer;
Future<void> _startLoad() async {
setState(() => _showContent = true);
MediaKit.ensureInitialized();
final url = ServiceFinder.buildUrl(
'files',
'/attachments/${widget.item.rid}',
);
_audioPlayer = Player();
await _audioPlayer!.open(Media(url), play: !widget.autoload);
_audioPlayer!.stream.playing.listen((v) => setState(() => _isPlaying = v));
_audioPlayer!.stream.position.listen((v) => setState(() => _position = v));
_audioPlayer!.stream.duration.listen((v) => setState(() => _duration = v));
_audioPlayer!.stream.buffer.listen(
(v) => setState(() => _bufferedPosition = v),
);
}
String _formatBytes(int bytes, {int decimals = 2}) {
if (bytes == 0) return '0 Bytes';
const k = 1024;
final dm = decimals < 0 ? 0 : decimals;
final sizes = [
'Bytes',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB'
];
final i = (math.log(bytes) / math.log(k)).floor().toInt();
return '${(bytes / math.pow(k, i)).toStringAsFixed(dm)} ${sizes[i]}';
}
@override
void initState() {
super.initState();
if (widget.autoload) {
_startLoad();
}
}
@override
Widget build(BuildContext context) {
const labelShadows = <Shadow>[
Shadow(
offset: Offset(1, 1),
blurRadius: 5.0,
color: Color.fromARGB(255, 0, 0, 0),
),
];
const ratio = 16 / 9;
if (!_showContent) {
return GestureDetector(
child: Stack(
children: [
if (widget.item.metadata?['thumbnail'] != null)
AspectRatio(
aspectRatio: 16 / 9,
child: AutoCacheImage(
ServiceFinder.buildUrl(
'uc',
'/attachments/${widget.item.metadata?['thumbnail']}',
),
fit: BoxFit.cover,
),
)
else
const Center(
child: Icon(Icons.radio, size: 64),
),
Align(
alignment: Alignment.bottomCenter,
child: IgnorePointer(
child: Container(
height: 56,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surface.withOpacity(0),
],
),
),
),
),
),
Positioned(
bottom: 4,
left: 16,
right: 16,
child: SizedBox(
height: 45,
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.item.alt,
style: const TextStyle(
shadows: labelShadows,
color: Colors.white,
),
),
Text(
_formatBytes(widget.item.size),
style: GoogleFonts.robotoMono(
fontSize: 12,
shadows: labelShadows,
color: Colors.white,
),
),
],
),
),
const Icon(
Icons.play_arrow,
shadows: labelShadows,
color: Colors.white,
).paddingOnly(bottom: 4, right: 8),
],
),
),
),
],
),
onTap: () {
_startLoad();
},
);
} else if (_audioPlayer == null) {
return const Center(
child: CircularProgressIndicator(),
);
}
return Stack(
children: [
if (widget.item.metadata?['thumbnail'] != null)
AspectRatio(
aspectRatio: 16 / 9,
child: AutoCacheImage(
ServiceFinder.buildUrl(
'uc',
'/attachments/${widget.item.metadata?['thumbnail']}',
),
fit: BoxFit.cover,
),
).animate().blur(
duration: 300.ms,
end: const Offset(10, 10),
curve: Curves.easeInOut,
),
AspectRatio(
aspectRatio: ratio,
child: CenteredContainer(
maxWidth: 320,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.audio_file, size: 32),
const Gap(8),
Text(
widget.item.alt,
style: const TextStyle(fontSize: 13),
textAlign: TextAlign.center,
),
const Gap(12),
Row(
children: [
Expanded(
child: Column(
children: [
SliderTheme(
data: SliderThemeData(
trackHeight: 2,
trackShape: _PlayerProgressTrackShape(),
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 8,
),
overlayShape: SliderComponentShape.noOverlay,
),
child: Slider(
secondaryTrackValue: _bufferedPosition
.inMilliseconds
.abs()
.toDouble(),
value: _draggingValue?.abs() ??
_position.inMilliseconds.toDouble().abs(),
min: 0,
max: math
.max(
_bufferedPosition.inMilliseconds.abs(),
math.max(
_position.inMilliseconds.abs(),
_duration.inMilliseconds.abs(),
),
)
.toDouble(),
onChanged: (value) {
setState(() => _draggingValue = value);
},
onChangeEnd: (value) {
_audioPlayer!.seek(
Duration(milliseconds: value.toInt()),
);
setState(() => _draggingValue = null);
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_position.toHumanReadableString(),
style: GoogleFonts.robotoMono(fontSize: 12),
),
Text(
_duration.toHumanReadableString(),
style: GoogleFonts.robotoMono(fontSize: 12),
),
],
).paddingSymmetric(horizontal: 8, vertical: 4),
],
),
),
const Gap(16),
IconButton.filled(
icon: _isPlaying
? const Icon(Icons.pause)
: const Icon(Icons.play_arrow),
onPressed: () {
_audioPlayer!.playOrPause();
},
visualDensity: const VisualDensity(
horizontal: -4,
vertical: 0,
),
),
],
),
],
),
),
),
],
);
}
@override
void dispose() {
_audioPlayer?.dispose();
super.dispose();
}
}
class _PlayerProgressTrackShape extends RoundedRectSliderTrackShape {
@override
Rect getPreferredRect({
required RenderBox parentBox,
Offset offset = Offset.zero,
required SliderThemeData sliderTheme,
bool isEnabled = false,
bool isDiscrete = false,
}) {
final trackHeight = sliderTheme.trackHeight;
final trackLeft = offset.dx;
final trackTop = offset.dy + (parentBox.size.height - trackHeight!) / 2;
final trackWidth = parentBox.size.width;
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
}
}

View File

@ -5,6 +5,7 @@ import 'package:carousel_slider/carousel_slider.dart';
import 'package:dismissible_page/dismissible_page.dart';
import 'package:flutter/material.dart' hide CarouselController;
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/widgets/attachments/attachment_item.dart';
@ -93,6 +94,8 @@ class _AttachmentListState extends State<AttachmentList> {
} else {
portrait++;
}
} else if (entry.mimetype.split('/').firstOrNull == 'audio') {
landscape++;
}
}
if (isConsistent && consistentValue != null) {
@ -138,7 +141,7 @@ class _AttachmentListState extends State<AttachmentList> {
@override
Widget build(BuildContext context) {
if (widget.attachmentsId.isEmpty) {
return const SizedBox();
return const SizedBox.shrink();
}
if (_isLoading) {
@ -171,7 +174,7 @@ class _AttachmentListState extends State<AttachmentList> {
children: widget.attachmentsId.map((x) {
final element = _attachmentsMeta[idx];
idx++;
if (element == null) return const SizedBox();
if (element == null) return const SizedBox.shrink();
double ratio = element.metadata?['ratio']?.toDouble() ?? 16 / 9;
return Container(
decoration: BoxDecoration(
@ -359,7 +362,7 @@ class AttachmentListEntry extends StatelessWidget {
color: Colors.white,
size: 32,
),
if (!isDense) const SizedBox(height: 8),
if (!isDense) const Gap(8),
if (!isDense)
Text(
'matureContent'.tr,

View File

@ -0,0 +1,113 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:solian/platform.dart';
import 'package:solian/widgets/sized_container.dart';
class AutoCacheImage extends StatelessWidget {
final String url;
final double? width, height;
final BoxFit? fit;
final bool noProgressIndicator;
final bool noErrorWidget;
const AutoCacheImage(
this.url, {
super.key,
this.width,
this.height,
this.fit,
this.noProgressIndicator = false,
this.noErrorWidget = false,
});
@override
Widget build(BuildContext context) {
if (PlatformInfo.canCacheImage) {
return CachedNetworkImage(
imageUrl: url,
width: width,
height: height,
fit: fit,
progressIndicatorBuilder: noProgressIndicator
? null
: (context, url, downloadProgress) => Center(
child: CircularProgressIndicator(
value: downloadProgress.progress,
),
),
errorWidget: noErrorWidget
? null
: (context, url, error) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: CenteredContainer(
maxWidth: 280,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.close, size: 32)
.animate(onPlay: (e) => e.repeat(reverse: true))
.fade(duration: 500.ms),
Text(
error.toString(),
textAlign: TextAlign.center,
),
],
),
),
);
},
);
}
return Image.network(
url,
width: width,
height: height,
fit: fit,
loadingBuilder: noProgressIndicator
? null
: (BuildContext context, Widget child,
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: null,
),
);
},
errorBuilder: noErrorWidget
? null
: (context, error, stackTrace) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: CenteredContainer(
maxWidth: 280,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.close, size: 32)
.animate(onPlay: (e) => e.repeat(reverse: true))
.fade(duration: 500.ms),
Text(
error.toString(),
textAlign: TextAlign.center,
),
],
),
),
);
},
);
}
static ImageProvider provider(String url) {
if (PlatformInfo.canCacheImage) {
return CachedNetworkImageProvider(url);
}
return NetworkImage(url);
}
}

View File

@ -1,15 +1,15 @@
import 'dart:convert';
import 'package:avatar_stack/avatar_stack.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/call.dart';
import 'package:solian/models/channel.dart';
import 'package:solian/platform.dart';
import 'package:solian/providers/call.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/auto_cache_image.dart';
import 'package:solian/widgets/chat/call/call_prejoin.dart';
class ChannelCallIndicator extends StatelessWidget {
@ -52,38 +52,35 @@ class ChannelCallIndicator extends StatelessWidget {
return Text('callOngoingJoined'.trParams({
'duration': call.lastDuration.value,
}));
} else if (ongoingCall.participants.isEmpty) {
} else if (ongoingCall.participants!.isEmpty) {
return Text('callOngoingEmpty'.tr);
} else {
return Text('callOngoingParticipants'.trParams({
'count': ongoingCall.participants.length.toString(),
'count': ongoingCall.participants!.length.toString(),
}));
}
}),
const SizedBox(width: 6),
const Gap(6),
Obx(() {
if (call.isInitialized.value) {
return const SizedBox();
return const SizedBox.shrink();
}
if (ongoingCall.participants.isNotEmpty) {
if (ongoingCall.participants!.isNotEmpty) {
return Container(
height: 28,
constraints: const BoxConstraints(maxWidth: 120),
child: AvatarStack(
height: 28,
borderWidth: 0,
avatars: ongoingCall.participants.map((x) {
avatars: ongoingCall.participants!.map((x) {
final userinfo =
Account.fromJson(jsonDecode(x['metadata']));
return PlatformInfo.canCacheImage
? CachedNetworkImageProvider(userinfo.avatar)
as ImageProvider
: NetworkImage(userinfo.avatar) as ImageProvider;
return AutoCacheImage.provider(userinfo.avatar);
}).toList(),
),
);
}
return const SizedBox();
return const SizedBox.shrink();
})
],
),
@ -101,18 +98,18 @@ class ChannelCallIndicator extends StatelessWidget {
child: Text('callJoin'.tr),
);
} else if (call.channel.value?.id == channel.id &&
!SolianTheme.isLargeScreen(context)) {
!AppTheme.isLargeScreen(context)) {
return TextButton(
onPressed: () => onJoin(),
child: Text('callResume'.tr),
);
} else if (!SolianTheme.isLargeScreen(context)) {
} else if (!AppTheme.isLargeScreen(context)) {
return TextButton(
onPressed: null,
child: Text('callJoin'.tr),
);
}
return const SizedBox();
return const SizedBox.shrink();
})
],
);

View File

@ -11,6 +11,7 @@ class ChannelListWidget extends StatefulWidget {
final List<Channel> channels;
final int selfId;
final bool isDense;
final bool isCollapsed;
final bool noCategory;
final bool useReplace;
final Function(Channel)? onSelected;
@ -20,6 +21,7 @@ class ChannelListWidget extends StatefulWidget {
required this.channels,
required this.selfId,
this.isDense = false,
this.isCollapsed = false,
this.noCategory = false,
this.useReplace = false,
this.onSelected,
@ -127,17 +129,28 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
: const EdgeInsets.symmetric(horizontal: 16);
if (item.type == 1) {
final otherside = item.members!
.where((e) => e.account.externalId != widget.selfId)
.first;
final otherside =
item.members!.where((e) => e.account.id != widget.selfId).first;
final avatar = AccountAvatar(
content: otherside.account.avatar,
radius: widget.isDense ? 12 : 20,
bgColor: Theme.of(context).colorScheme.primary,
feColor: Theme.of(context).colorScheme.onPrimary,
);
if (widget.isCollapsed) {
return Tooltip(
message: otherside.account.nick,
child: InkWell(
child: avatar.paddingSymmetric(vertical: 12),
onTap: () => _gotoChannel(item),
),
);
}
return ListTile(
leading: AccountAvatar(
content: otherside.account.avatar,
radius: widget.isDense ? 12 : 20,
bgColor: Theme.of(context).colorScheme.primary,
feColor: Theme.of(context).colorScheme.onPrimary,
),
leading: avatar,
contentPadding: padding,
title: Text(otherside.account.nick),
subtitle: !widget.isDense
@ -146,24 +159,42 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
onTap: () => _gotoChannel(item),
);
} else {
final avatar = CircleAvatar(
backgroundColor: item.realmId == null
? Theme.of(context).colorScheme.primary
: Colors.transparent,
radius: widget.isDense ? 12 : 20,
child: FaIcon(
FontAwesomeIcons.hashtag,
color: item.realmId == null
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.primary,
size: widget.isDense ? 12 : 16,
),
);
if (widget.isCollapsed) {
return Tooltip(
message: item.name,
child: InkWell(
child: avatar.paddingSymmetric(vertical: 12),
onTap: () => _gotoChannel(item),
),
);
}
return ListTile(
minTileHeight: widget.isDense ? 48 : null,
leading: CircleAvatar(
backgroundColor: item.realmId == null
? Theme.of(context).colorScheme.primary
: Colors.transparent,
radius: widget.isDense ? 12 : 20,
child: FaIcon(
FontAwesomeIcons.hashtag,
color: item.realmId == null
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.primary,
size: widget.isDense ? 12 : 16,
),
),
leading: avatar,
contentPadding: padding,
title: Text(item.name),
subtitle: !widget.isDense ? Text(item.description) : null,
subtitle: !widget.isDense
? Text(
item.description,
maxLines: 1,
overflow: TextOverflow.ellipsis,
)
: null,
onTap: () => _gotoChannel(item),
);
}

View File

@ -176,7 +176,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
IconButton(
color: Colors.red,
icon: const Icon(Icons.remove_circle),
onPressed: element.account.externalId == _accountId
onPressed: element.account.id == _accountId
? null
: () => removeMember(element),
),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:livekit_client/livekit_client.dart';
@ -35,7 +36,7 @@ class ParticipantInfoWidget extends StatelessWidget {
style: const TextStyle(color: Colors.white),
),
),
const SizedBox(width: 5),
const Gap(5),
isScreenShare
? const Icon(
Icons.monitor,
@ -47,7 +48,7 @@ class ParticipantInfoWidget extends StatelessWidget {
color: audioAvailable ? Colors.white : Colors.red,
size: 16,
),
const SizedBox(width: 3),
const Gap(3),
if (connectionQuality != ConnectionQuality.unknown)
Icon(
{

View File

@ -11,7 +11,7 @@ class ChatCallCurrentIndicator extends StatelessWidget {
return Obx(() {
if (call.current.value == null || call.channel.value == null) {
return const SizedBox();
return const SizedBox.shrink();
}
return ListTile(

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:solian/controllers/chat_events_controller.dart';
import 'package:solian/models/event.dart';
@ -39,7 +40,7 @@ class ChatEvent extends StatelessWidget {
}
Widget _buildLinkExpansion() {
if (item.body['text'] == null) return const SizedBox();
if (item.body['text'] == null) return const SizedBox.shrink();
return LinkExpansion(content: item.body['text']);
}
@ -48,7 +49,7 @@ class ChatEvent extends StatelessWidget {
? List<String>.from(item.body['attachments']?.whereType<String>())
: List<String>.empty();
if (attachments.isEmpty) return const SizedBox();
if (attachments.isEmpty) return const SizedBox.shrink();
if (isMinimal) {
final unFocusColor =
@ -74,9 +75,6 @@ class ChatEvent extends StatelessWidget {
key: Key('m${item.uuid}attachments-box'),
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.only(top: isMerged ? 0 : 4, bottom: 4),
constraints: const BoxConstraints(
maxHeight: 720,
),
child: AttachmentList(
key: Key('m${item.uuid}attachments'),
parentId: item.uuid,
@ -93,7 +91,7 @@ class ChatEvent extends StatelessWidget {
),
builder: (context, snapshot) {
if (!snapshot.hasData || snapshot.data == null) {
return const SizedBox();
return const SizedBox.shrink();
}
return Container(
@ -214,7 +212,7 @@ class ChatEvent extends StatelessWidget {
opacity: 0.75,
child: FaIcon(FontAwesomeIcons.quoteLeft, size: 14),
).paddingOnly(bottom: 2.75),
const SizedBox(width: 4),
const Gap(4),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
@ -226,12 +224,12 @@ class ChatEvent extends StatelessWidget {
content: item.sender.account.avatar,
radius: 9,
),
const SizedBox(width: 5),
const Gap(5),
Text(
item.sender.account.nick,
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 4),
const Gap(4),
Text(format(item.createdAt, locale: 'en_short')),
],
),
@ -275,7 +273,7 @@ class ChatEvent extends StatelessWidget {
item.sender.account.nick,
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 4),
const Gap(4),
Text(format(item.createdAt, locale: 'en_short'))
],
).paddingSymmetric(horizontal: 12),
@ -300,7 +298,10 @@ class ChatEvent extends StatelessWidget {
],
).paddingSymmetric(horizontal: 12),
_buildLinkExpansion().paddingOnly(left: 52, right: 8),
_buildAttachment(context).paddingOnly(left: 56, right: 8),
_buildAttachment(
context,
isMinimal: ['messages.edit'].contains(item.type),
).paddingOnly(left: 56, right: 8),
],
);
}

View File

@ -41,8 +41,8 @@ class _ChatEventActionState extends State<ChatEventAction> {
setState(() => _isBusy = true);
setState(() {
_canModifyContent = auth.userProfile.value!['id'] ==
widget.item.sender.account.externalId;
_canModifyContent =
auth.userProfile.value!['id'] == widget.item.sender.account.id;
_isBusy = false;
});
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
class ChatEventMessageActionLog extends StatelessWidget {
@ -25,7 +26,7 @@ class ChatEventMessageActionLog extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
icon,
const SizedBox(width: 4),
const Gap(4),
Text(text),
],
).paddingOnly(

View File

@ -59,7 +59,8 @@ class ChatEventList extends StatelessWidget {
final item = chatController.currentEvents[index].data;
return InkWell(
return GestureDetector(
behavior: HitTestBehavior.opaque,
child: ChatEvent(
key: Key('m${item.uuid}'),
item: item,
@ -95,7 +96,7 @@ class ChatEventList extends StatelessWidget {
chatController.totalEvents - chatController.currentEvents.length;
if (amount.value <= 0 || chatController.isLoading.isTrue) {
return const SliverToBoxAdapter(child: SizedBox());
return const SliverToBoxAdapter(child: SizedBox.shrink());
}
return SliverToBoxAdapter(

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