Compare commits
59 Commits
a0d8c1a9b3
...
3.1.0+118
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b3338b885 | |||
| bb00b1bc6a | |||
| 5e1a15ada2 | |||
| 9bdf8ba346 | |||
| 204c087f29 | |||
| 1def3e1895 | |||
| 550c74e544 | |||
| a39565f012 | |||
| aa9755e6a7 | |||
| b25e8d661a | |||
| 4b253ac3ec | |||
| 5d1b875d3c | |||
| e2e103fa67 | |||
| 43c90da4e3 | |||
| fa210dd98f | |||
| 43d9ca92bf | |||
| 5e592c143f | |||
| 0c59816f26 | |||
| 19c2457895 | |||
| af8d87857e | |||
| d05f63a36a | |||
| e2dc520012 | |||
| cff9c15e31 | |||
| f00135c4bf | |||
| 30b8a6c30f | |||
| b9c4ee31b1 | |||
| 87870af866 | |||
| b83cb0fb0b | |||
| 7fd1fe34e5 | |||
| 1c18330891 | |||
| d320879ad0 | |||
| 950150e119 | |||
| 3c4a9767e1 | |||
| 5df2445f3f | |||
| 56543d7b4c | |||
| 4c6fea1242 | |||
| fff43de9e3 | |||
| b31a915544 | |||
| 8956723ac5 | |||
| ccc3ac415e | |||
| 8c47a59b80 | |||
| a6d869ebf6 | |||
| f3a8699389 | |||
| d345c00e84 | |||
| a706f127b6 | |||
| 680ece0b6a | |||
| b976c6ed37 | |||
| 6ae6b132de | |||
| 95aec7c95b | |||
| edd760fbcb | |||
| ba269dbbb8 | |||
| 1aa45dd9f1 | |||
| 92685d7410 | |||
| c8e351514d | |||
| f3900825e3 | |||
| 2cc6652f75 | |||
| 4d4409de2e | |||
| e1286c797f | |||
| bec037622f |
@@ -59,7 +59,6 @@ dependencies {
|
|||||||
implementation("com.google.android.material:material:1.12.0")
|
implementation("com.google.android.material:material:1.12.0")
|
||||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||||
implementation("com.google.firebase:firebase-messaging-ktx")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
|
|||||||
@@ -12,7 +12,12 @@
|
|||||||
"package_name": "dev.solsynth.solian"
|
"package_name": "dev.solsynth.solian"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [],
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "961776991058-963m1qin2vtp8fv693b5fdrab5hmpl89.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyDvFNudXYs29uDtcCv6pFR8h5tXBs90FYk"
|
"current_key": "AIzaSyDvFNudXYs29uDtcCv6pFR8h5tXBs90FYk"
|
||||||
@@ -20,7 +25,20 @@
|
|||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
"appinvite_service": {
|
"appinvite_service": {
|
||||||
"other_platform_oauth_client": []
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "961776991058-963m1qin2vtp8fv693b5fdrab5hmpl89.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com",
|
||||||
|
"client_type": 2,
|
||||||
|
"ios_info": {
|
||||||
|
"bundle_id": "dev.solsynth.solian",
|
||||||
|
"app_store_id": "6499032345"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
@@ -116,14 +117,6 @@
|
|||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
<service
|
|
||||||
android:name=".service.MessagingService"
|
|
||||||
android:exported="false">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
||||||
</intent-filter>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="dev.solsynth.solian.provider"
|
android:authorities="dev.solsynth.solian.provider"
|
||||||
@@ -150,4 +143,4 @@
|
|||||||
<data android:mimeType="text/plain" />
|
<data android:mimeType="text/plain" />
|
||||||
</intent>
|
</intent>
|
||||||
</queries>
|
</queries>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
package dev.solsynth.solian.service
|
|
||||||
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.os.Build
|
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import androidx.core.app.NotificationManagerCompat
|
|
||||||
import androidx.core.app.RemoteInput
|
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.request.target.CustomTarget
|
|
||||||
import com.bumptech.glide.request.transition.Transition
|
|
||||||
import com.google.firebase.messaging.FirebaseMessagingService
|
|
||||||
import com.google.firebase.messaging.RemoteMessage
|
|
||||||
import dev.solsynth.solian.MainActivity
|
|
||||||
import dev.solsynth.solian.receiver.ReplyReceiver
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
class MessagingService: FirebaseMessagingService() {
|
|
||||||
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
|
||||||
val type = remoteMessage.data["type"]
|
|
||||||
if (type == "messages.new") {
|
|
||||||
handleMessageNotification(remoteMessage)
|
|
||||||
} else {
|
|
||||||
// Handle other notification types
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleMessageNotification(remoteMessage: RemoteMessage) {
|
|
||||||
val data = remoteMessage.data
|
|
||||||
val metaString = data["meta"] ?: return
|
|
||||||
val meta = JSONObject(metaString)
|
|
||||||
|
|
||||||
val pfp = meta.optString("pfp", null)
|
|
||||||
val roomId = meta.optString("room_id", null)
|
|
||||||
val messageId = meta.optString("message_id", null)
|
|
||||||
|
|
||||||
val notificationId = System.currentTimeMillis().toInt()
|
|
||||||
|
|
||||||
val replyLabel = "Reply"
|
|
||||||
val remoteInput = RemoteInput.Builder("key_text_reply")
|
|
||||||
.setLabel(replyLabel)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
val replyIntent = Intent(this, ReplyReceiver::class.java).apply {
|
|
||||||
putExtra("room_id", roomId)
|
|
||||||
putExtra("message_id", messageId)
|
|
||||||
putExtra("notification_id", notificationId)
|
|
||||||
}
|
|
||||||
|
|
||||||
val pendingIntentFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
|
||||||
} else {
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
}
|
|
||||||
|
|
||||||
val replyPendingIntent = PendingIntent.getBroadcast(
|
|
||||||
applicationContext,
|
|
||||||
notificationId,
|
|
||||||
replyIntent,
|
|
||||||
pendingIntentFlags
|
|
||||||
)
|
|
||||||
|
|
||||||
val action = NotificationCompat.Action.Builder(
|
|
||||||
android.R.drawable.ic_menu_send,
|
|
||||||
replyLabel,
|
|
||||||
replyPendingIntent
|
|
||||||
)
|
|
||||||
.addRemoteInput(remoteInput)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
intent.putExtra("room_id", roomId)
|
|
||||||
val pendingIntent = PendingIntent.getActivity(this, 0, intent, pendingIntentFlags)
|
|
||||||
|
|
||||||
val notificationBuilder = NotificationCompat.Builder(this, "messages")
|
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
||||||
.setContentTitle(remoteMessage.notification?.title)
|
|
||||||
.setContentText(remoteMessage.notification?.body)
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
||||||
.setContentIntent(pendingIntent)
|
|
||||||
.addAction(action)
|
|
||||||
|
|
||||||
if (pfp != null) {
|
|
||||||
Glide.with(applicationContext)
|
|
||||||
.asBitmap()
|
|
||||||
.load(pfp)
|
|
||||||
.into(object : CustomTarget<Bitmap>() {
|
|
||||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
|
||||||
notificationBuilder.setLargeIcon(resource)
|
|
||||||
NotificationManagerCompat.from(applicationContext).notify(notificationId, notificationBuilder.build())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLoadCleared(placeholder: Drawable?) {}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
NotificationManagerCompat.from(this).notify(notificationId, notificationBuilder.build())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -144,11 +144,15 @@
|
|||||||
"other": "{} attachments"
|
"other": "{} attachments"
|
||||||
},
|
},
|
||||||
"edited": "Edited",
|
"edited": "Edited",
|
||||||
|
"editedAt": "Edited at {}",
|
||||||
"addVideo": "Add video",
|
"addVideo": "Add video",
|
||||||
"addPhoto": "Add photo",
|
"addPhoto": "Add photo",
|
||||||
|
"addAudio": "Add audio",
|
||||||
"addFile": "Add file",
|
"addFile": "Add file",
|
||||||
|
"recordAudio": "Record Audio",
|
||||||
"linkAttachment": "Link Attachment",
|
"linkAttachment": "Link Attachment",
|
||||||
"fileIdCannotBeEmpty": "File ID cannot be empty",
|
"fileIdCannotBeEmpty": "File ID cannot be empty",
|
||||||
|
"fileIdLinkHint": "Haven't upload to the Solar Network? Tap here to open Solar Network Drive to customize your uploads.",
|
||||||
"failedToFetchFile": "Failed to fetch file: {}",
|
"failedToFetchFile": "Failed to fetch file: {}",
|
||||||
"createDirectMessage": "Send new DM",
|
"createDirectMessage": "Send new DM",
|
||||||
"gotoDirectMessage": "Go to DM",
|
"gotoDirectMessage": "Go to DM",
|
||||||
@@ -731,5 +735,57 @@
|
|||||||
"reconnecting": "Reconnecting",
|
"reconnecting": "Reconnecting",
|
||||||
"disconnected": "Disconnected",
|
"disconnected": "Disconnected",
|
||||||
"connected": "Connected",
|
"connected": "Connected",
|
||||||
"repliesLoadMore": "Load more replies"
|
"repliesLoadMore": "Load more replies",
|
||||||
|
"attachmentsRecentUploads": "Recent Uploads",
|
||||||
|
"attachmentsManualInput": "Manual Input",
|
||||||
|
"crop": "Crop",
|
||||||
|
"rename": "Rename",
|
||||||
|
"markAsSensitive": "Mark as Sensitive",
|
||||||
|
"fileName": "File name",
|
||||||
|
"sensitiveCategories.language": "Language",
|
||||||
|
"sensitiveCategories.sexualContent": "Sexual Content",
|
||||||
|
"sensitiveCategories.violence": "Violence",
|
||||||
|
"sensitiveCategories.profanity": "Profanity",
|
||||||
|
"sensitiveCategories.hateSpeech": "Hate Speech",
|
||||||
|
"sensitiveCategories.racism": "Racism",
|
||||||
|
"sensitiveCategories.adultContent": "Adult Content",
|
||||||
|
"sensitiveCategories.drugAbuse": "Drug Abuse",
|
||||||
|
"sensitiveCategories.alcoholAbuse": "Alcohol Abuse",
|
||||||
|
"sensitiveCategories.gambling": "Gambling",
|
||||||
|
"sensitiveCategories.selfHarm": "Self-harm",
|
||||||
|
"sensitiveCategories.childAbuse": "Child Abuse",
|
||||||
|
"sensitiveCategories.other": "Other",
|
||||||
|
"poll": "Poll",
|
||||||
|
"pollsRecent": "Recent Polls",
|
||||||
|
"pollCreateNew": "Create New",
|
||||||
|
"pollCreateNewHint": "Create a new poll for your post. Pick a publisher and continue.",
|
||||||
|
"publisher": "Publisher",
|
||||||
|
"publisherHint": "Enter the publisher name",
|
||||||
|
"publisherCannotBeEmpty": "Publisher cannot be empty",
|
||||||
|
"operationFailed": "Operation failed: {}",
|
||||||
|
"stickerMarketplace": "Sticker Marketplace",
|
||||||
|
"stickerPackAdded": "Sticker pack added to your collection",
|
||||||
|
"stickerPackRemoved": "Sticker pack removed from your collection",
|
||||||
|
"addPack": "Add Pack",
|
||||||
|
"removePack": "Remove Pack",
|
||||||
|
"browseAndAddStickers": "Browse and add sticker packs",
|
||||||
|
"stickerPack": "Sticker Pack",
|
||||||
|
"postCategoryTechnology": "Technology",
|
||||||
|
"postCategoryTravel": "Travel",
|
||||||
|
"postCategoryFood": "Food",
|
||||||
|
"postCategoryHealth": "Health",
|
||||||
|
"postCategoryScience": "Science",
|
||||||
|
"postCategorySports": "Sports",
|
||||||
|
"postCategoryFinance": "Finance",
|
||||||
|
"postCategoryLife": "Life",
|
||||||
|
"postCategoryArt": "Art",
|
||||||
|
"postCategoryStudy": "Study",
|
||||||
|
"postCategoryGaming": "Gaming",
|
||||||
|
"postCategoryProgramming": "Programming",
|
||||||
|
"postCategoryMusic": "Music",
|
||||||
|
"links": "Links",
|
||||||
|
"addLink": "Add link",
|
||||||
|
"linkKey": "Link Name",
|
||||||
|
"linkValue": "URL",
|
||||||
|
"debugOptions": "Debug Options"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,7 @@
|
|||||||
"other": "{}个附件"
|
"other": "{}个附件"
|
||||||
},
|
},
|
||||||
"edited": "已编辑",
|
"edited": "已编辑",
|
||||||
|
"editedAt": "编辑于 {}",
|
||||||
"addVideo": "添加视频",
|
"addVideo": "添加视频",
|
||||||
"addPhoto": "添加照片",
|
"addPhoto": "添加照片",
|
||||||
"addFile": "添加文件",
|
"addFile": "添加文件",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"flutter":{"platforms":{"android":{"default":{"projectId":"solian-0x001","appId":"1:961776991058:android:a8d3f7995b0b8e86f4188b","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"solian-0x001","appId":"1:961776991058:ios:727229d368cc47e1f4188b","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"solian-0x001","appId":"1:961776991058:ios:727229d368cc47e1f4188b","uploadDebugSymbols":false,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"solian-0x001","configurations":{"android":"1:961776991058:android:a8d3f7995b0b8e86f4188b","ios":"1:961776991058:ios:727229d368cc47e1f4188b","macos":"1:961776991058:ios:727229d368cc47e1f4188b","web":"1:961776991058:web:b91d12f2892a5609f4188b","windows":"1:961776991058:web:3a912c0eb14028e5f4188b"}}}}}}
|
{"flutter":{"platforms":{"android":{"default":{"projectId":"solian-0x001","appId":"1:961776991058:android:a8d3f7995b0b8e86f4188b","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"solian-0x001","appId":"1:961776991058:ios:727229d368cc47e1f4188b","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"solian-0x001","appId":"1:961776991058:ios:727229d368cc47e1f4188b","uploadDebugSymbols":false,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"solian-0x001","configurations":{"android":"1:961776991058:android:a8d3f7995b0b8e86f4188b","ios":"1:961776991058:ios:727229d368cc47e1f4188b","macos":"1:961776991058:ios:727229d368cc47e1f4188b","web":"1:961776991058:web:3a912c0eb14028e5f4188b","windows":"1:961776991058:web:3a912c0eb14028e5f4188b"}}}}}}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 77;
|
objectVersion = 54;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
@@ -379,8 +379,6 @@
|
|||||||
73ACDFAE2E3D0E6100B63535 /* SolianBroadcastExtension */,
|
73ACDFAE2E3D0E6100B63535 /* SolianBroadcastExtension */,
|
||||||
);
|
);
|
||||||
name = SolianBroadcastExtension;
|
name = SolianBroadcastExtension;
|
||||||
packageProductDependencies = (
|
|
||||||
);
|
|
||||||
productName = SolianBroadcastExtension;
|
productName = SolianBroadcastExtension;
|
||||||
productReference = 73ACDFAB2E3D0E6100B63535 /* SolianBroadcastExtension.appex */;
|
productReference = 73ACDFAB2E3D0E6100B63535 /* SolianBroadcastExtension.appex */;
|
||||||
productType = "com.apple.product-type.app-extension";
|
productType = "com.apple.product-type.app-extension";
|
||||||
@@ -599,14 +597,10 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
inputPaths = (
|
|
||||||
);
|
|
||||||
name = "[CP] Copy Pods Resources";
|
name = "[CP] Copy Pods Resources";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
outputPaths = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||||
@@ -664,14 +658,10 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
inputPaths = (
|
|
||||||
);
|
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
outputPaths = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>CLIENT_ID</key>
|
||||||
|
<string>961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com</string>
|
||||||
|
<key>REVERSED_CLIENT_ID</key>
|
||||||
|
<string>com.googleusercontent.apps.961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig</string>
|
||||||
|
<key>ANDROID_CLIENT_ID</key>
|
||||||
|
<string>961776991058-r4iv9qoio57ul7utbfpgfrda2etvtch8.apps.googleusercontent.com</string>
|
||||||
<key>API_KEY</key>
|
<key>API_KEY</key>
|
||||||
<string>AIzaSyCzQIyiYKoYHTpGXhN-IjgMML8z797WVD8</string>
|
<string>AIzaSyCzQIyiYKoYHTpGXhN-IjgMML8z797WVD8</string>
|
||||||
<key>GCM_SENDER_ID</key>
|
<key>GCM_SENDER_ID</key>
|
||||||
|
|||||||
@@ -29,10 +29,7 @@ class DefaultFirebaseOptions {
|
|||||||
case TargetPlatform.windows:
|
case TargetPlatform.windows:
|
||||||
return windows;
|
return windows;
|
||||||
case TargetPlatform.linux:
|
case TargetPlatform.linux:
|
||||||
throw UnsupportedError(
|
return windows;
|
||||||
'DefaultFirebaseOptions have not been configured for linux - '
|
|
||||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
throw UnsupportedError(
|
throw UnsupportedError(
|
||||||
'DefaultFirebaseOptions are not supported for this platform.',
|
'DefaultFirebaseOptions are not supported for this platform.',
|
||||||
@@ -41,13 +38,13 @@ class DefaultFirebaseOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const FirebaseOptions web = FirebaseOptions(
|
static const FirebaseOptions web = FirebaseOptions(
|
||||||
apiKey: 'AIzaSyBKfIQpTouj5rXnlzkEieSlbAzepm4mgJE',
|
apiKey: 'AIzaSyCfgOdlcr7h8x8j0WKx_S2wXnGkOopq320',
|
||||||
appId: '1:961776991058:web:b91d12f2892a5609f4188b',
|
appId: '1:961776991058:web:3a912c0eb14028e5f4188b',
|
||||||
messagingSenderId: '961776991058',
|
messagingSenderId: '961776991058',
|
||||||
projectId: 'solian-0x001',
|
projectId: 'solian-0x001',
|
||||||
authDomain: 'solian-0x001.firebaseapp.com',
|
authDomain: 'solian-0x001.firebaseapp.com',
|
||||||
storageBucket: 'solian-0x001.firebasestorage.app',
|
storageBucket: 'solian-0x001.firebasestorage.app',
|
||||||
measurementId: 'G-XY3HHKG0PE',
|
measurementId: 'G-JD1YEG9D6F',
|
||||||
);
|
);
|
||||||
|
|
||||||
static const FirebaseOptions android = FirebaseOptions(
|
static const FirebaseOptions android = FirebaseOptions(
|
||||||
@@ -64,6 +61,10 @@ class DefaultFirebaseOptions {
|
|||||||
messagingSenderId: '961776991058',
|
messagingSenderId: '961776991058',
|
||||||
projectId: 'solian-0x001',
|
projectId: 'solian-0x001',
|
||||||
storageBucket: 'solian-0x001.firebasestorage.app',
|
storageBucket: 'solian-0x001.firebasestorage.app',
|
||||||
|
androidClientId:
|
||||||
|
'961776991058-r4iv9qoio57ul7utbfpgfrda2etvtch8.apps.googleusercontent.com',
|
||||||
|
iosClientId:
|
||||||
|
'961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com',
|
||||||
iosBundleId: 'dev.solsynth.solian',
|
iosBundleId: 'dev.solsynth.solian',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -73,6 +74,10 @@ class DefaultFirebaseOptions {
|
|||||||
messagingSenderId: '961776991058',
|
messagingSenderId: '961776991058',
|
||||||
projectId: 'solian-0x001',
|
projectId: 'solian-0x001',
|
||||||
storageBucket: 'solian-0x001.firebasestorage.app',
|
storageBucket: 'solian-0x001.firebasestorage.app',
|
||||||
|
androidClientId:
|
||||||
|
'961776991058-r4iv9qoio57ul7utbfpgfrda2etvtch8.apps.googleusercontent.com',
|
||||||
|
iosClientId:
|
||||||
|
'961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com',
|
||||||
iosBundleId: 'dev.solsynth.solian',
|
iosBundleId: 'dev.solsynth.solian',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -85,5 +90,4 @@ class DefaultFirebaseOptions {
|
|||||||
storageBucket: 'solian-0x001.firebasestorage.app',
|
storageBucket: 'solian-0x001.firebasestorage.app',
|
||||||
measurementId: 'G-JD1YEG9D6F',
|
measurementId: 'G-JD1YEG9D6F',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import 'package:image_picker_platform_interface/image_picker_platform_interface.
|
|||||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
import 'package:flutter_langdetect/flutter_langdetect.dart' as langdetect;
|
import 'package:flutter_langdetect/flutter_langdetect.dart' as langdetect;
|
||||||
|
import 'package:island/services/update_service.dart';
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||||
@@ -53,10 +54,16 @@ void main() async {
|
|||||||
try {
|
try {
|
||||||
await langdetect.initLangDetect();
|
await langdetect.initLangDetect();
|
||||||
await EasyLocalization.ensureInitialized();
|
await EasyLocalization.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
|
||||||
options: DefaultFirebaseOptions.currentPlatform,
|
if (kIsWeb || !Platform.isLinux) {
|
||||||
);
|
await Firebase.initializeApp(
|
||||||
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
);
|
||||||
|
FirebaseMessaging.onBackgroundMessage(
|
||||||
|
_firebaseMessagingBackgroundHandler,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
log("[SplashScreen] Firebase is ready!");
|
log("[SplashScreen] Firebase is ready!");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showErrorAlert(err);
|
showErrorAlert(err);
|
||||||
@@ -137,6 +144,15 @@ void main() async {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Schedule update check shortly after startup, when a context is available.
|
||||||
|
// Uses the global overlay key to obtain a BuildContext safely.
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
final ctx = globalOverlay.currentContext;
|
||||||
|
if (ctx != null) {
|
||||||
|
UpdateService().checkForUpdates(ctx);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Router will be provided through Riverpod
|
// Router will be provided through Riverpod
|
||||||
|
|||||||
@@ -3,25 +3,6 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
|||||||
part 'embed.freezed.dart';
|
part 'embed.freezed.dart';
|
||||||
part 'embed.g.dart';
|
part 'embed.g.dart';
|
||||||
|
|
||||||
@freezed
|
|
||||||
sealed class SnEmbedLink with _$SnEmbedLink {
|
|
||||||
const factory SnEmbedLink({
|
|
||||||
@JsonKey(name: 'Type') required String type,
|
|
||||||
@JsonKey(name: 'Url') required String url,
|
|
||||||
@JsonKey(name: 'Title') required String title,
|
|
||||||
@JsonKey(name: 'Description') required String? description,
|
|
||||||
@JsonKey(name: 'ImageUrl') required String? imageUrl,
|
|
||||||
@JsonKey(name: 'FaviconUrl') @Default("") String faviconUrl,
|
|
||||||
@JsonKey(name: 'SiteName') @Default("") String siteName,
|
|
||||||
@JsonKey(name: 'ContentType') required String? contentType,
|
|
||||||
@JsonKey(name: 'Author') required String? author,
|
|
||||||
@JsonKey(name: 'PublishedDate') required DateTime? publishedDate,
|
|
||||||
}) = _SnEmbedLink;
|
|
||||||
|
|
||||||
factory SnEmbedLink.fromJson(Map<String, dynamic> json) =>
|
|
||||||
_$SnEmbedLinkFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
sealed class SnScrappedLink with _$SnScrappedLink {
|
sealed class SnScrappedLink with _$SnScrappedLink {
|
||||||
const factory SnScrappedLink({
|
const factory SnScrappedLink({
|
||||||
|
|||||||
@@ -12,290 +12,6 @@ part of 'embed.dart';
|
|||||||
// dart format off
|
// dart format off
|
||||||
T _$identity<T>(T value) => value;
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$SnEmbedLink {
|
|
||||||
|
|
||||||
@JsonKey(name: 'Type') String get type;@JsonKey(name: 'Url') String get url;@JsonKey(name: 'Title') String get title;@JsonKey(name: 'Description') String? get description;@JsonKey(name: 'ImageUrl') String? get imageUrl;@JsonKey(name: 'FaviconUrl') String get faviconUrl;@JsonKey(name: 'SiteName') String get siteName;@JsonKey(name: 'ContentType') String? get contentType;@JsonKey(name: 'Author') String? get author;@JsonKey(name: 'PublishedDate') DateTime? get publishedDate;
|
|
||||||
/// Create a copy of SnEmbedLink
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$SnEmbedLinkCopyWith<SnEmbedLink> get copyWith => _$SnEmbedLinkCopyWithImpl<SnEmbedLink>(this as SnEmbedLink, _$identity);
|
|
||||||
|
|
||||||
/// Serializes this SnEmbedLink to a JSON map.
|
|
||||||
Map<String, dynamic> toJson();
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnEmbedLink&&(identical(other.type, type) || other.type == type)&&(identical(other.url, url) || other.url == url)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.imageUrl, imageUrl) || other.imageUrl == imageUrl)&&(identical(other.faviconUrl, faviconUrl) || other.faviconUrl == faviconUrl)&&(identical(other.siteName, siteName) || other.siteName == siteName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.author, author) || other.author == author)&&(identical(other.publishedDate, publishedDate) || other.publishedDate == publishedDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType,type,url,title,description,imageUrl,faviconUrl,siteName,contentType,author,publishedDate);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'SnEmbedLink(type: $type, url: $url, title: $title, description: $description, imageUrl: $imageUrl, faviconUrl: $faviconUrl, siteName: $siteName, contentType: $contentType, author: $author, publishedDate: $publishedDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract mixin class $SnEmbedLinkCopyWith<$Res> {
|
|
||||||
factory $SnEmbedLinkCopyWith(SnEmbedLink value, $Res Function(SnEmbedLink) _then) = _$SnEmbedLinkCopyWithImpl;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
@JsonKey(name: 'Type') String type,@JsonKey(name: 'Url') String url,@JsonKey(name: 'Title') String title,@JsonKey(name: 'Description') String? description,@JsonKey(name: 'ImageUrl') String? imageUrl,@JsonKey(name: 'FaviconUrl') String faviconUrl,@JsonKey(name: 'SiteName') String siteName,@JsonKey(name: 'ContentType') String? contentType,@JsonKey(name: 'Author') String? author,@JsonKey(name: 'PublishedDate') DateTime? publishedDate
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/// @nodoc
|
|
||||||
class _$SnEmbedLinkCopyWithImpl<$Res>
|
|
||||||
implements $SnEmbedLinkCopyWith<$Res> {
|
|
||||||
_$SnEmbedLinkCopyWithImpl(this._self, this._then);
|
|
||||||
|
|
||||||
final SnEmbedLink _self;
|
|
||||||
final $Res Function(SnEmbedLink) _then;
|
|
||||||
|
|
||||||
/// Create a copy of SnEmbedLink
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? type = null,Object? url = null,Object? title = null,Object? description = freezed,Object? imageUrl = freezed,Object? faviconUrl = null,Object? siteName = null,Object? contentType = freezed,Object? author = freezed,Object? publishedDate = freezed,}) {
|
|
||||||
return _then(_self.copyWith(
|
|
||||||
type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,url: null == url ? _self.url : url // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,imageUrl: freezed == imageUrl ? _self.imageUrl : imageUrl // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,faviconUrl: null == faviconUrl ? _self.faviconUrl : faviconUrl // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,siteName: null == siteName ? _self.siteName : siteName // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,contentType: freezed == contentType ? _self.contentType : contentType // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,author: freezed == author ? _self.author : author // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,publishedDate: freezed == publishedDate ? _self.publishedDate : publishedDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime?,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Adds pattern-matching-related methods to [SnEmbedLink].
|
|
||||||
extension SnEmbedLinkPatterns on SnEmbedLink {
|
|
||||||
/// A variant of `map` that fallback to returning `orElse`.
|
|
||||||
///
|
|
||||||
/// It is equivalent to doing:
|
|
||||||
/// ```dart
|
|
||||||
/// switch (sealedClass) {
|
|
||||||
/// case final Subclass value:
|
|
||||||
/// return ...;
|
|
||||||
/// case _:
|
|
||||||
/// return orElse();
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SnEmbedLink value)? $default,{required TResult orElse(),}){
|
|
||||||
final _that = this;
|
|
||||||
switch (_that) {
|
|
||||||
case _SnEmbedLink() when $default != null:
|
|
||||||
return $default(_that);case _:
|
|
||||||
return orElse();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// A `switch`-like method, using callbacks.
|
|
||||||
///
|
|
||||||
/// Callbacks receives the raw object, upcasted.
|
|
||||||
/// It is equivalent to doing:
|
|
||||||
/// ```dart
|
|
||||||
/// switch (sealedClass) {
|
|
||||||
/// case final Subclass value:
|
|
||||||
/// return ...;
|
|
||||||
/// case final Subclass2 value:
|
|
||||||
/// return ...;
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
|
|
||||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SnEmbedLink value) $default,){
|
|
||||||
final _that = this;
|
|
||||||
switch (_that) {
|
|
||||||
case _SnEmbedLink():
|
|
||||||
return $default(_that);}
|
|
||||||
}
|
|
||||||
/// A variant of `map` that fallback to returning `null`.
|
|
||||||
///
|
|
||||||
/// It is equivalent to doing:
|
|
||||||
/// ```dart
|
|
||||||
/// switch (sealedClass) {
|
|
||||||
/// case final Subclass value:
|
|
||||||
/// return ...;
|
|
||||||
/// case _:
|
|
||||||
/// return null;
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
|
|
||||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SnEmbedLink value)? $default,){
|
|
||||||
final _that = this;
|
|
||||||
switch (_that) {
|
|
||||||
case _SnEmbedLink() when $default != null:
|
|
||||||
return $default(_that);case _:
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// A variant of `when` that fallback to an `orElse` callback.
|
|
||||||
///
|
|
||||||
/// It is equivalent to doing:
|
|
||||||
/// ```dart
|
|
||||||
/// switch (sealedClass) {
|
|
||||||
/// case Subclass(:final field):
|
|
||||||
/// return ...;
|
|
||||||
/// case _:
|
|
||||||
/// return orElse();
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(name: 'Type') String type, @JsonKey(name: 'Url') String url, @JsonKey(name: 'Title') String title, @JsonKey(name: 'Description') String? description, @JsonKey(name: 'ImageUrl') String? imageUrl, @JsonKey(name: 'FaviconUrl') String faviconUrl, @JsonKey(name: 'SiteName') String siteName, @JsonKey(name: 'ContentType') String? contentType, @JsonKey(name: 'Author') String? author, @JsonKey(name: 'PublishedDate') DateTime? publishedDate)? $default,{required TResult orElse(),}) {final _that = this;
|
|
||||||
switch (_that) {
|
|
||||||
case _SnEmbedLink() when $default != null:
|
|
||||||
return $default(_that.type,_that.url,_that.title,_that.description,_that.imageUrl,_that.faviconUrl,_that.siteName,_that.contentType,_that.author,_that.publishedDate);case _:
|
|
||||||
return orElse();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// A `switch`-like method, using callbacks.
|
|
||||||
///
|
|
||||||
/// As opposed to `map`, this offers destructuring.
|
|
||||||
/// It is equivalent to doing:
|
|
||||||
/// ```dart
|
|
||||||
/// switch (sealedClass) {
|
|
||||||
/// case Subclass(:final field):
|
|
||||||
/// return ...;
|
|
||||||
/// case Subclass2(:final field2):
|
|
||||||
/// return ...;
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(name: 'Type') String type, @JsonKey(name: 'Url') String url, @JsonKey(name: 'Title') String title, @JsonKey(name: 'Description') String? description, @JsonKey(name: 'ImageUrl') String? imageUrl, @JsonKey(name: 'FaviconUrl') String faviconUrl, @JsonKey(name: 'SiteName') String siteName, @JsonKey(name: 'ContentType') String? contentType, @JsonKey(name: 'Author') String? author, @JsonKey(name: 'PublishedDate') DateTime? publishedDate) $default,) {final _that = this;
|
|
||||||
switch (_that) {
|
|
||||||
case _SnEmbedLink():
|
|
||||||
return $default(_that.type,_that.url,_that.title,_that.description,_that.imageUrl,_that.faviconUrl,_that.siteName,_that.contentType,_that.author,_that.publishedDate);}
|
|
||||||
}
|
|
||||||
/// A variant of `when` that fallback to returning `null`
|
|
||||||
///
|
|
||||||
/// It is equivalent to doing:
|
|
||||||
/// ```dart
|
|
||||||
/// switch (sealedClass) {
|
|
||||||
/// case Subclass(:final field):
|
|
||||||
/// return ...;
|
|
||||||
/// case _:
|
|
||||||
/// return null;
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(name: 'Type') String type, @JsonKey(name: 'Url') String url, @JsonKey(name: 'Title') String title, @JsonKey(name: 'Description') String? description, @JsonKey(name: 'ImageUrl') String? imageUrl, @JsonKey(name: 'FaviconUrl') String faviconUrl, @JsonKey(name: 'SiteName') String siteName, @JsonKey(name: 'ContentType') String? contentType, @JsonKey(name: 'Author') String? author, @JsonKey(name: 'PublishedDate') DateTime? publishedDate)? $default,) {final _that = this;
|
|
||||||
switch (_that) {
|
|
||||||
case _SnEmbedLink() when $default != null:
|
|
||||||
return $default(_that.type,_that.url,_that.title,_that.description,_that.imageUrl,_that.faviconUrl,_that.siteName,_that.contentType,_that.author,_that.publishedDate);case _:
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
@JsonSerializable()
|
|
||||||
|
|
||||||
class _SnEmbedLink implements SnEmbedLink {
|
|
||||||
const _SnEmbedLink({@JsonKey(name: 'Type') required this.type, @JsonKey(name: 'Url') required this.url, @JsonKey(name: 'Title') required this.title, @JsonKey(name: 'Description') required this.description, @JsonKey(name: 'ImageUrl') required this.imageUrl, @JsonKey(name: 'FaviconUrl') this.faviconUrl = "", @JsonKey(name: 'SiteName') this.siteName = "", @JsonKey(name: 'ContentType') required this.contentType, @JsonKey(name: 'Author') required this.author, @JsonKey(name: 'PublishedDate') required this.publishedDate});
|
|
||||||
factory _SnEmbedLink.fromJson(Map<String, dynamic> json) => _$SnEmbedLinkFromJson(json);
|
|
||||||
|
|
||||||
@override@JsonKey(name: 'Type') final String type;
|
|
||||||
@override@JsonKey(name: 'Url') final String url;
|
|
||||||
@override@JsonKey(name: 'Title') final String title;
|
|
||||||
@override@JsonKey(name: 'Description') final String? description;
|
|
||||||
@override@JsonKey(name: 'ImageUrl') final String? imageUrl;
|
|
||||||
@override@JsonKey(name: 'FaviconUrl') final String faviconUrl;
|
|
||||||
@override@JsonKey(name: 'SiteName') final String siteName;
|
|
||||||
@override@JsonKey(name: 'ContentType') final String? contentType;
|
|
||||||
@override@JsonKey(name: 'Author') final String? author;
|
|
||||||
@override@JsonKey(name: 'PublishedDate') final DateTime? publishedDate;
|
|
||||||
|
|
||||||
/// Create a copy of SnEmbedLink
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$SnEmbedLinkCopyWith<_SnEmbedLink> get copyWith => __$SnEmbedLinkCopyWithImpl<_SnEmbedLink>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return _$SnEmbedLinkToJson(this, );
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnEmbedLink&&(identical(other.type, type) || other.type == type)&&(identical(other.url, url) || other.url == url)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.imageUrl, imageUrl) || other.imageUrl == imageUrl)&&(identical(other.faviconUrl, faviconUrl) || other.faviconUrl == faviconUrl)&&(identical(other.siteName, siteName) || other.siteName == siteName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.author, author) || other.author == author)&&(identical(other.publishedDate, publishedDate) || other.publishedDate == publishedDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType,type,url,title,description,imageUrl,faviconUrl,siteName,contentType,author,publishedDate);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'SnEmbedLink(type: $type, url: $url, title: $title, description: $description, imageUrl: $imageUrl, faviconUrl: $faviconUrl, siteName: $siteName, contentType: $contentType, author: $author, publishedDate: $publishedDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract mixin class _$SnEmbedLinkCopyWith<$Res> implements $SnEmbedLinkCopyWith<$Res> {
|
|
||||||
factory _$SnEmbedLinkCopyWith(_SnEmbedLink value, $Res Function(_SnEmbedLink) _then) = __$SnEmbedLinkCopyWithImpl;
|
|
||||||
@override @useResult
|
|
||||||
$Res call({
|
|
||||||
@JsonKey(name: 'Type') String type,@JsonKey(name: 'Url') String url,@JsonKey(name: 'Title') String title,@JsonKey(name: 'Description') String? description,@JsonKey(name: 'ImageUrl') String? imageUrl,@JsonKey(name: 'FaviconUrl') String faviconUrl,@JsonKey(name: 'SiteName') String siteName,@JsonKey(name: 'ContentType') String? contentType,@JsonKey(name: 'Author') String? author,@JsonKey(name: 'PublishedDate') DateTime? publishedDate
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/// @nodoc
|
|
||||||
class __$SnEmbedLinkCopyWithImpl<$Res>
|
|
||||||
implements _$SnEmbedLinkCopyWith<$Res> {
|
|
||||||
__$SnEmbedLinkCopyWithImpl(this._self, this._then);
|
|
||||||
|
|
||||||
final _SnEmbedLink _self;
|
|
||||||
final $Res Function(_SnEmbedLink) _then;
|
|
||||||
|
|
||||||
/// Create a copy of SnEmbedLink
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? type = null,Object? url = null,Object? title = null,Object? description = freezed,Object? imageUrl = freezed,Object? faviconUrl = null,Object? siteName = null,Object? contentType = freezed,Object? author = freezed,Object? publishedDate = freezed,}) {
|
|
||||||
return _then(_SnEmbedLink(
|
|
||||||
type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,url: null == url ? _self.url : url // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,imageUrl: freezed == imageUrl ? _self.imageUrl : imageUrl // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,faviconUrl: null == faviconUrl ? _self.faviconUrl : faviconUrl // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,siteName: null == siteName ? _self.siteName : siteName // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,contentType: freezed == contentType ? _self.contentType : contentType // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,author: freezed == author ? _self.author : author // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,publishedDate: freezed == publishedDate ? _self.publishedDate : publishedDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime?,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$SnScrappedLink {
|
mixin _$SnScrappedLink {
|
||||||
|
|
||||||
|
|||||||
@@ -6,36 +6,6 @@ part of 'embed.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
_SnEmbedLink _$SnEmbedLinkFromJson(Map<String, dynamic> json) => _SnEmbedLink(
|
|
||||||
type: json['Type'] as String,
|
|
||||||
url: json['Url'] as String,
|
|
||||||
title: json['Title'] as String,
|
|
||||||
description: json['Description'] as String?,
|
|
||||||
imageUrl: json['ImageUrl'] as String?,
|
|
||||||
faviconUrl: json['FaviconUrl'] as String? ?? "",
|
|
||||||
siteName: json['SiteName'] as String? ?? "",
|
|
||||||
contentType: json['ContentType'] as String?,
|
|
||||||
author: json['Author'] as String?,
|
|
||||||
publishedDate:
|
|
||||||
json['PublishedDate'] == null
|
|
||||||
? null
|
|
||||||
: DateTime.parse(json['PublishedDate'] as String),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$SnEmbedLinkToJson(_SnEmbedLink instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'Type': instance.type,
|
|
||||||
'Url': instance.url,
|
|
||||||
'Title': instance.title,
|
|
||||||
'Description': instance.description,
|
|
||||||
'ImageUrl': instance.imageUrl,
|
|
||||||
'FaviconUrl': instance.faviconUrl,
|
|
||||||
'SiteName': instance.siteName,
|
|
||||||
'ContentType': instance.contentType,
|
|
||||||
'Author': instance.author,
|
|
||||||
'PublishedDate': instance.publishedDate?.toIso8601String(),
|
|
||||||
};
|
|
||||||
|
|
||||||
_SnScrappedLink _$SnScrappedLinkFromJson(Map<String, dynamic> json) =>
|
_SnScrappedLink _$SnScrappedLinkFromJson(Map<String, dynamic> json) =>
|
||||||
_SnScrappedLink(
|
_SnScrappedLink(
|
||||||
type: json['type'] as String,
|
type: json['type'] as String,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ sealed class UniversalFile with _$UniversalFile {
|
|||||||
const factory UniversalFile({
|
const factory UniversalFile({
|
||||||
required dynamic data,
|
required dynamic data,
|
||||||
required UniversalFileType type,
|
required UniversalFileType type,
|
||||||
|
@Default(false) bool isLink,
|
||||||
}) = _UniversalFile;
|
}) = _UniversalFile;
|
||||||
|
|
||||||
factory UniversalFile.fromJson(Map<String, dynamic> json) =>
|
factory UniversalFile.fromJson(Map<String, dynamic> json) =>
|
||||||
@@ -41,6 +42,7 @@ sealed class SnCloudFile with _$SnCloudFile {
|
|||||||
required String? description,
|
required String? description,
|
||||||
required Map<String, dynamic>? fileMeta,
|
required Map<String, dynamic>? fileMeta,
|
||||||
required Map<String, dynamic>? userMeta,
|
required Map<String, dynamic>? userMeta,
|
||||||
|
@Default([]) List<int> sensitiveMarks,
|
||||||
required String? mimeType,
|
required String? mimeType,
|
||||||
required String? hash,
|
required String? hash,
|
||||||
required int size,
|
required int size,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$UniversalFile {
|
mixin _$UniversalFile {
|
||||||
|
|
||||||
dynamic get data; UniversalFileType get type;
|
dynamic get data; UniversalFileType get type; bool get isLink;
|
||||||
/// Create a copy of UniversalFile
|
/// Create a copy of UniversalFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -28,16 +28,16 @@ $UniversalFileCopyWith<UniversalFile> get copyWith => _$UniversalFileCopyWithImp
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UniversalFile&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.type, type) || other.type == type));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is UniversalFile&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.type, type) || other.type == type)&&(identical(other.isLink, isLink) || other.isLink == isLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(data),type);
|
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(data),type,isLink);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UniversalFile(data: $data, type: $type)';
|
return 'UniversalFile(data: $data, type: $type, isLink: $isLink)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ abstract mixin class $UniversalFileCopyWith<$Res> {
|
|||||||
factory $UniversalFileCopyWith(UniversalFile value, $Res Function(UniversalFile) _then) = _$UniversalFileCopyWithImpl;
|
factory $UniversalFileCopyWith(UniversalFile value, $Res Function(UniversalFile) _then) = _$UniversalFileCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
dynamic data, UniversalFileType type
|
dynamic data, UniversalFileType type, bool isLink
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -65,11 +65,12 @@ class _$UniversalFileCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of UniversalFile
|
/// Create a copy of UniversalFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? data = freezed,Object? type = null,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? data = freezed,Object? type = null,Object? isLink = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
|
data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
as dynamic,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||||
as UniversalFileType,
|
as UniversalFileType,isLink: null == isLink ? _self.isLink : isLink // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,10 +152,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( dynamic data, UniversalFileType type)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( dynamic data, UniversalFileType type, bool isLink)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UniversalFile() when $default != null:
|
case _UniversalFile() when $default != null:
|
||||||
return $default(_that.data,_that.type);case _:
|
return $default(_that.data,_that.type,_that.isLink);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -172,10 +173,10 @@ return $default(_that.data,_that.type);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( dynamic data, UniversalFileType type) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( dynamic data, UniversalFileType type, bool isLink) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UniversalFile():
|
case _UniversalFile():
|
||||||
return $default(_that.data,_that.type);}
|
return $default(_that.data,_that.type,_that.isLink);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
///
|
///
|
||||||
@@ -189,10 +190,10 @@ return $default(_that.data,_that.type);}
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( dynamic data, UniversalFileType type)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( dynamic data, UniversalFileType type, bool isLink)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UniversalFile() when $default != null:
|
case _UniversalFile() when $default != null:
|
||||||
return $default(_that.data,_that.type);case _:
|
return $default(_that.data,_that.type,_that.isLink);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -204,11 +205,12 @@ return $default(_that.data,_that.type);case _:
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _UniversalFile extends UniversalFile {
|
class _UniversalFile extends UniversalFile {
|
||||||
const _UniversalFile({required this.data, required this.type}): super._();
|
const _UniversalFile({required this.data, required this.type, this.isLink = false}): super._();
|
||||||
factory _UniversalFile.fromJson(Map<String, dynamic> json) => _$UniversalFileFromJson(json);
|
factory _UniversalFile.fromJson(Map<String, dynamic> json) => _$UniversalFileFromJson(json);
|
||||||
|
|
||||||
@override final dynamic data;
|
@override final dynamic data;
|
||||||
@override final UniversalFileType type;
|
@override final UniversalFileType type;
|
||||||
|
@override@JsonKey() final bool isLink;
|
||||||
|
|
||||||
/// Create a copy of UniversalFile
|
/// Create a copy of UniversalFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -223,16 +225,16 @@ Map<String, dynamic> toJson() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UniversalFile&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.type, type) || other.type == type));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UniversalFile&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.type, type) || other.type == type)&&(identical(other.isLink, isLink) || other.isLink == isLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(data),type);
|
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(data),type,isLink);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UniversalFile(data: $data, type: $type)';
|
return 'UniversalFile(data: $data, type: $type, isLink: $isLink)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -243,7 +245,7 @@ abstract mixin class _$UniversalFileCopyWith<$Res> implements $UniversalFileCopy
|
|||||||
factory _$UniversalFileCopyWith(_UniversalFile value, $Res Function(_UniversalFile) _then) = __$UniversalFileCopyWithImpl;
|
factory _$UniversalFileCopyWith(_UniversalFile value, $Res Function(_UniversalFile) _then) = __$UniversalFileCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
dynamic data, UniversalFileType type
|
dynamic data, UniversalFileType type, bool isLink
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -260,11 +262,12 @@ class __$UniversalFileCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of UniversalFile
|
/// Create a copy of UniversalFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? data = freezed,Object? type = null,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? data = freezed,Object? type = null,Object? isLink = null,}) {
|
||||||
return _then(_UniversalFile(
|
return _then(_UniversalFile(
|
||||||
data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
|
data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
as dynamic,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||||
as UniversalFileType,
|
as UniversalFileType,isLink: null == isLink ? _self.isLink : isLink // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +278,7 @@ as UniversalFileType,
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$SnCloudFile {
|
mixin _$SnCloudFile {
|
||||||
|
|
||||||
String get id; String get name; String? get description; Map<String, dynamic>? get fileMeta; Map<String, dynamic>? get userMeta; String? get mimeType; String? get hash; int get size; DateTime? get uploadedAt; String? get uploadedTo; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
String get id; String get name; String? get description; Map<String, dynamic>? get fileMeta; Map<String, dynamic>? get userMeta; List<int> get sensitiveMarks; String? get mimeType; String? get hash; int get size; DateTime? get uploadedAt; String? get uploadedTo; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
||||||
/// Create a copy of SnCloudFile
|
/// Create a copy of SnCloudFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -288,16 +291,16 @@ $SnCloudFileCopyWith<SnCloudFile> get copyWith => _$SnCloudFileCopyWithImpl<SnCl
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnCloudFile&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other.fileMeta, fileMeta)&&const DeepCollectionEquality().equals(other.userMeta, userMeta)&&(identical(other.mimeType, mimeType) || other.mimeType == mimeType)&&(identical(other.hash, hash) || other.hash == hash)&&(identical(other.size, size) || other.size == size)&&(identical(other.uploadedAt, uploadedAt) || other.uploadedAt == uploadedAt)&&(identical(other.uploadedTo, uploadedTo) || other.uploadedTo == uploadedTo)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnCloudFile&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other.fileMeta, fileMeta)&&const DeepCollectionEquality().equals(other.userMeta, userMeta)&&const DeepCollectionEquality().equals(other.sensitiveMarks, sensitiveMarks)&&(identical(other.mimeType, mimeType) || other.mimeType == mimeType)&&(identical(other.hash, hash) || other.hash == hash)&&(identical(other.size, size) || other.size == size)&&(identical(other.uploadedAt, uploadedAt) || other.uploadedAt == uploadedAt)&&(identical(other.uploadedTo, uploadedTo) || other.uploadedTo == uploadedTo)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,name,description,const DeepCollectionEquality().hash(fileMeta),const DeepCollectionEquality().hash(userMeta),mimeType,hash,size,uploadedAt,uploadedTo,createdAt,updatedAt,deletedAt);
|
int get hashCode => Object.hash(runtimeType,id,name,description,const DeepCollectionEquality().hash(fileMeta),const DeepCollectionEquality().hash(userMeta),const DeepCollectionEquality().hash(sensitiveMarks),mimeType,hash,size,uploadedAt,uploadedTo,createdAt,updatedAt,deletedAt);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnCloudFile(id: $id, name: $name, description: $description, fileMeta: $fileMeta, userMeta: $userMeta, mimeType: $mimeType, hash: $hash, size: $size, uploadedAt: $uploadedAt, uploadedTo: $uploadedTo, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnCloudFile(id: $id, name: $name, description: $description, fileMeta: $fileMeta, userMeta: $userMeta, sensitiveMarks: $sensitiveMarks, mimeType: $mimeType, hash: $hash, size: $size, uploadedAt: $uploadedAt, uploadedTo: $uploadedTo, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -308,7 +311,7 @@ abstract mixin class $SnCloudFileCopyWith<$Res> {
|
|||||||
factory $SnCloudFileCopyWith(SnCloudFile value, $Res Function(SnCloudFile) _then) = _$SnCloudFileCopyWithImpl;
|
factory $SnCloudFileCopyWith(SnCloudFile value, $Res Function(SnCloudFile) _then) = _$SnCloudFileCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, List<int> sensitiveMarks, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -325,14 +328,15 @@ class _$SnCloudFileCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnCloudFile
|
/// Create a copy of SnCloudFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = freezed,Object? fileMeta = freezed,Object? userMeta = freezed,Object? mimeType = freezed,Object? hash = freezed,Object? size = null,Object? uploadedAt = freezed,Object? uploadedTo = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = freezed,Object? fileMeta = freezed,Object? userMeta = freezed,Object? sensitiveMarks = null,Object? mimeType = freezed,Object? hash = freezed,Object? size = null,Object? uploadedAt = freezed,Object? uploadedTo = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||||
as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,fileMeta: freezed == fileMeta ? _self.fileMeta : fileMeta // ignore: cast_nullable_to_non_nullable
|
as String?,fileMeta: freezed == fileMeta ? _self.fileMeta : fileMeta // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, dynamic>?,userMeta: freezed == userMeta ? _self.userMeta : userMeta // ignore: cast_nullable_to_non_nullable
|
as Map<String, dynamic>?,userMeta: freezed == userMeta ? _self.userMeta : userMeta // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, dynamic>?,mimeType: freezed == mimeType ? _self.mimeType : mimeType // ignore: cast_nullable_to_non_nullable
|
as Map<String, dynamic>?,sensitiveMarks: null == sensitiveMarks ? _self.sensitiveMarks : sensitiveMarks // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<int>,mimeType: freezed == mimeType ? _self.mimeType : mimeType // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,hash: freezed == hash ? _self.hash : hash // ignore: cast_nullable_to_non_nullable
|
as String?,hash: freezed == hash ? _self.hash : hash // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,size: null == size ? _self.size : size // ignore: cast_nullable_to_non_nullable
|
as String?,size: null == size ? _self.size : size // ignore: cast_nullable_to_non_nullable
|
||||||
as int,uploadedAt: freezed == uploadedAt ? _self.uploadedAt : uploadedAt // ignore: cast_nullable_to_non_nullable
|
as int,uploadedAt: freezed == uploadedAt ? _self.uploadedAt : uploadedAt // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -422,10 +426,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, List<int> sensitiveMarks, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnCloudFile() when $default != null:
|
case _SnCloudFile() when $default != null:
|
||||||
return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userMeta,_that.mimeType,_that.hash,_that.size,_that.uploadedAt,_that.uploadedTo,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userMeta,_that.sensitiveMarks,_that.mimeType,_that.hash,_that.size,_that.uploadedAt,_that.uploadedTo,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -443,10 +447,10 @@ return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userM
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, List<int> sensitiveMarks, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnCloudFile():
|
case _SnCloudFile():
|
||||||
return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userMeta,_that.mimeType,_that.hash,_that.size,_that.uploadedAt,_that.uploadedTo,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userMeta,_that.sensitiveMarks,_that.mimeType,_that.hash,_that.size,_that.uploadedAt,_that.uploadedTo,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
///
|
///
|
||||||
@@ -460,10 +464,10 @@ return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userM
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, List<int> sensitiveMarks, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnCloudFile() when $default != null:
|
case _SnCloudFile() when $default != null:
|
||||||
return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userMeta,_that.mimeType,_that.hash,_that.size,_that.uploadedAt,_that.uploadedTo,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userMeta,_that.sensitiveMarks,_that.mimeType,_that.hash,_that.size,_that.uploadedAt,_that.uploadedTo,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -475,7 +479,7 @@ return $default(_that.id,_that.name,_that.description,_that.fileMeta,_that.userM
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _SnCloudFile implements SnCloudFile {
|
class _SnCloudFile implements SnCloudFile {
|
||||||
const _SnCloudFile({required this.id, required this.name, required this.description, required final Map<String, dynamic>? fileMeta, required final Map<String, dynamic>? userMeta, required this.mimeType, required this.hash, required this.size, required this.uploadedAt, required this.uploadedTo, required this.createdAt, required this.updatedAt, required this.deletedAt}): _fileMeta = fileMeta,_userMeta = userMeta;
|
const _SnCloudFile({required this.id, required this.name, required this.description, required final Map<String, dynamic>? fileMeta, required final Map<String, dynamic>? userMeta, final List<int> sensitiveMarks = const [], required this.mimeType, required this.hash, required this.size, required this.uploadedAt, required this.uploadedTo, required this.createdAt, required this.updatedAt, required this.deletedAt}): _fileMeta = fileMeta,_userMeta = userMeta,_sensitiveMarks = sensitiveMarks;
|
||||||
factory _SnCloudFile.fromJson(Map<String, dynamic> json) => _$SnCloudFileFromJson(json);
|
factory _SnCloudFile.fromJson(Map<String, dynamic> json) => _$SnCloudFileFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@@ -499,6 +503,13 @@ class _SnCloudFile implements SnCloudFile {
|
|||||||
return EqualUnmodifiableMapView(value);
|
return EqualUnmodifiableMapView(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<int> _sensitiveMarks;
|
||||||
|
@override@JsonKey() List<int> get sensitiveMarks {
|
||||||
|
if (_sensitiveMarks is EqualUnmodifiableListView) return _sensitiveMarks;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_sensitiveMarks);
|
||||||
|
}
|
||||||
|
|
||||||
@override final String? mimeType;
|
@override final String? mimeType;
|
||||||
@override final String? hash;
|
@override final String? hash;
|
||||||
@override final int size;
|
@override final int size;
|
||||||
@@ -521,16 +532,16 @@ Map<String, dynamic> toJson() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnCloudFile&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other._fileMeta, _fileMeta)&&const DeepCollectionEquality().equals(other._userMeta, _userMeta)&&(identical(other.mimeType, mimeType) || other.mimeType == mimeType)&&(identical(other.hash, hash) || other.hash == hash)&&(identical(other.size, size) || other.size == size)&&(identical(other.uploadedAt, uploadedAt) || other.uploadedAt == uploadedAt)&&(identical(other.uploadedTo, uploadedTo) || other.uploadedTo == uploadedTo)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnCloudFile&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other._fileMeta, _fileMeta)&&const DeepCollectionEquality().equals(other._userMeta, _userMeta)&&const DeepCollectionEquality().equals(other._sensitiveMarks, _sensitiveMarks)&&(identical(other.mimeType, mimeType) || other.mimeType == mimeType)&&(identical(other.hash, hash) || other.hash == hash)&&(identical(other.size, size) || other.size == size)&&(identical(other.uploadedAt, uploadedAt) || other.uploadedAt == uploadedAt)&&(identical(other.uploadedTo, uploadedTo) || other.uploadedTo == uploadedTo)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,name,description,const DeepCollectionEquality().hash(_fileMeta),const DeepCollectionEquality().hash(_userMeta),mimeType,hash,size,uploadedAt,uploadedTo,createdAt,updatedAt,deletedAt);
|
int get hashCode => Object.hash(runtimeType,id,name,description,const DeepCollectionEquality().hash(_fileMeta),const DeepCollectionEquality().hash(_userMeta),const DeepCollectionEquality().hash(_sensitiveMarks),mimeType,hash,size,uploadedAt,uploadedTo,createdAt,updatedAt,deletedAt);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnCloudFile(id: $id, name: $name, description: $description, fileMeta: $fileMeta, userMeta: $userMeta, mimeType: $mimeType, hash: $hash, size: $size, uploadedAt: $uploadedAt, uploadedTo: $uploadedTo, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnCloudFile(id: $id, name: $name, description: $description, fileMeta: $fileMeta, userMeta: $userMeta, sensitiveMarks: $sensitiveMarks, mimeType: $mimeType, hash: $hash, size: $size, uploadedAt: $uploadedAt, uploadedTo: $uploadedTo, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -541,7 +552,7 @@ abstract mixin class _$SnCloudFileCopyWith<$Res> implements $SnCloudFileCopyWith
|
|||||||
factory _$SnCloudFileCopyWith(_SnCloudFile value, $Res Function(_SnCloudFile) _then) = __$SnCloudFileCopyWithImpl;
|
factory _$SnCloudFileCopyWith(_SnCloudFile value, $Res Function(_SnCloudFile) _then) = __$SnCloudFileCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String name, String? description, Map<String, dynamic>? fileMeta, Map<String, dynamic>? userMeta, List<int> sensitiveMarks, String? mimeType, String? hash, int size, DateTime? uploadedAt, String? uploadedTo, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -558,14 +569,15 @@ class __$SnCloudFileCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnCloudFile
|
/// Create a copy of SnCloudFile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = freezed,Object? fileMeta = freezed,Object? userMeta = freezed,Object? mimeType = freezed,Object? hash = freezed,Object? size = null,Object? uploadedAt = freezed,Object? uploadedTo = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = freezed,Object? fileMeta = freezed,Object? userMeta = freezed,Object? sensitiveMarks = null,Object? mimeType = freezed,Object? hash = freezed,Object? size = null,Object? uploadedAt = freezed,Object? uploadedTo = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
||||||
return _then(_SnCloudFile(
|
return _then(_SnCloudFile(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||||
as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,fileMeta: freezed == fileMeta ? _self._fileMeta : fileMeta // ignore: cast_nullable_to_non_nullable
|
as String?,fileMeta: freezed == fileMeta ? _self._fileMeta : fileMeta // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, dynamic>?,userMeta: freezed == userMeta ? _self._userMeta : userMeta // ignore: cast_nullable_to_non_nullable
|
as Map<String, dynamic>?,userMeta: freezed == userMeta ? _self._userMeta : userMeta // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, dynamic>?,mimeType: freezed == mimeType ? _self.mimeType : mimeType // ignore: cast_nullable_to_non_nullable
|
as Map<String, dynamic>?,sensitiveMarks: null == sensitiveMarks ? _self._sensitiveMarks : sensitiveMarks // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<int>,mimeType: freezed == mimeType ? _self.mimeType : mimeType // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,hash: freezed == hash ? _self.hash : hash // ignore: cast_nullable_to_non_nullable
|
as String?,hash: freezed == hash ? _self.hash : hash // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,size: null == size ? _self.size : size // ignore: cast_nullable_to_non_nullable
|
as String?,size: null == size ? _self.size : size // ignore: cast_nullable_to_non_nullable
|
||||||
as int,uploadedAt: freezed == uploadedAt ? _self.uploadedAt : uploadedAt // ignore: cast_nullable_to_non_nullable
|
as int,uploadedAt: freezed == uploadedAt ? _self.uploadedAt : uploadedAt // ignore: cast_nullable_to_non_nullable
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ _UniversalFile _$UniversalFileFromJson(Map<String, dynamic> json) =>
|
|||||||
_UniversalFile(
|
_UniversalFile(
|
||||||
data: json['data'],
|
data: json['data'],
|
||||||
type: $enumDecode(_$UniversalFileTypeEnumMap, json['type']),
|
type: $enumDecode(_$UniversalFileTypeEnumMap, json['type']),
|
||||||
|
isLink: json['is_link'] as bool? ?? false,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$UniversalFileToJson(_UniversalFile instance) =>
|
Map<String, dynamic> _$UniversalFileToJson(_UniversalFile instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'data': instance.data,
|
'data': instance.data,
|
||||||
'type': _$UniversalFileTypeEnumMap[instance.type]!,
|
'type': _$UniversalFileTypeEnumMap[instance.type]!,
|
||||||
|
'is_link': instance.isLink,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$UniversalFileTypeEnumMap = {
|
const _$UniversalFileTypeEnumMap = {
|
||||||
@@ -31,6 +33,11 @@ _SnCloudFile _$SnCloudFileFromJson(Map<String, dynamic> json) => _SnCloudFile(
|
|||||||
description: json['description'] as String?,
|
description: json['description'] as String?,
|
||||||
fileMeta: json['file_meta'] as Map<String, dynamic>?,
|
fileMeta: json['file_meta'] as Map<String, dynamic>?,
|
||||||
userMeta: json['user_meta'] as Map<String, dynamic>?,
|
userMeta: json['user_meta'] as Map<String, dynamic>?,
|
||||||
|
sensitiveMarks:
|
||||||
|
(json['sensitive_marks'] as List<dynamic>?)
|
||||||
|
?.map((e) => (e as num).toInt())
|
||||||
|
.toList() ??
|
||||||
|
const [],
|
||||||
mimeType: json['mime_type'] as String?,
|
mimeType: json['mime_type'] as String?,
|
||||||
hash: json['hash'] as String?,
|
hash: json['hash'] as String?,
|
||||||
size: (json['size'] as num).toInt(),
|
size: (json['size'] as num).toInt(),
|
||||||
@@ -54,6 +61,7 @@ Map<String, dynamic> _$SnCloudFileToJson(_SnCloudFile instance) =>
|
|||||||
'description': instance.description,
|
'description': instance.description,
|
||||||
'file_meta': instance.fileMeta,
|
'file_meta': instance.fileMeta,
|
||||||
'user_meta': instance.userMeta,
|
'user_meta': instance.userMeta,
|
||||||
|
'sensitive_marks': instance.sensitiveMarks,
|
||||||
'mime_type': instance.mimeType,
|
'mime_type': instance.mimeType,
|
||||||
'hash': instance.hash,
|
'hash': instance.hash,
|
||||||
'size': instance.size,
|
'size': instance.size,
|
||||||
|
|||||||
108
lib/models/poll.dart
Normal file
108
lib/models/poll.dart
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:island/models/publisher.dart';
|
||||||
|
|
||||||
|
part 'poll.freezed.dart';
|
||||||
|
part 'poll.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
sealed class SnPollWithStats with _$SnPollWithStats {
|
||||||
|
const factory SnPollWithStats({
|
||||||
|
required Map<String, dynamic>? userAnswer,
|
||||||
|
required Map<String, dynamic> stats,
|
||||||
|
required String id,
|
||||||
|
required List<SnPollQuestion> questions,
|
||||||
|
String? title,
|
||||||
|
String? description,
|
||||||
|
DateTime? endedAt,
|
||||||
|
required String publisherId,
|
||||||
|
required DateTime createdAt,
|
||||||
|
required DateTime updatedAt,
|
||||||
|
DateTime? deletedAt,
|
||||||
|
}) = _SnPollWithStats;
|
||||||
|
|
||||||
|
factory SnPollWithStats.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$SnPollWithStatsFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
sealed class SnPoll with _$SnPoll {
|
||||||
|
const factory SnPoll({
|
||||||
|
required String id,
|
||||||
|
required List<SnPollQuestion> questions,
|
||||||
|
|
||||||
|
String? title,
|
||||||
|
String? description,
|
||||||
|
|
||||||
|
DateTime? endedAt,
|
||||||
|
|
||||||
|
required String publisherId,
|
||||||
|
SnPublisher? publisher,
|
||||||
|
|
||||||
|
// ModelBase fields
|
||||||
|
required DateTime createdAt,
|
||||||
|
required DateTime updatedAt,
|
||||||
|
DateTime? deletedAt,
|
||||||
|
}) = _SnPoll;
|
||||||
|
|
||||||
|
factory SnPoll.fromJson(Map<String, dynamic> json) => _$SnPollFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
sealed class SnPollQuestion with _$SnPollQuestion {
|
||||||
|
const factory SnPollQuestion({
|
||||||
|
required String id,
|
||||||
|
|
||||||
|
required SnPollQuestionType type,
|
||||||
|
List<SnPollOption>? options,
|
||||||
|
|
||||||
|
required String title,
|
||||||
|
String? description,
|
||||||
|
required int order,
|
||||||
|
required bool isRequired,
|
||||||
|
}) = _SnPollQuestion;
|
||||||
|
|
||||||
|
factory SnPollQuestion.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$SnPollQuestionFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
sealed class SnPollOption with _$SnPollOption {
|
||||||
|
const factory SnPollOption({
|
||||||
|
required String id,
|
||||||
|
required String label,
|
||||||
|
String? description,
|
||||||
|
required int order,
|
||||||
|
}) = _SnPollOption;
|
||||||
|
|
||||||
|
factory SnPollOption.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$SnPollOptionFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SnPollQuestionType {
|
||||||
|
@JsonValue(0)
|
||||||
|
singleChoice,
|
||||||
|
@JsonValue(1)
|
||||||
|
multipleChoice,
|
||||||
|
@JsonValue(2)
|
||||||
|
yesNo,
|
||||||
|
@JsonValue(3)
|
||||||
|
rating,
|
||||||
|
@JsonValue(4)
|
||||||
|
freeText,
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
sealed class SnPollAnswer with _$SnPollAnswer {
|
||||||
|
const factory SnPollAnswer({
|
||||||
|
required String id,
|
||||||
|
required Map<String, dynamic> answer,
|
||||||
|
required String accountId,
|
||||||
|
required String pollId,
|
||||||
|
required DateTime createdAt,
|
||||||
|
required DateTime updatedAt,
|
||||||
|
required DateTime? deletedAt,
|
||||||
|
}) = _SnPollAnswer;
|
||||||
|
|
||||||
|
factory SnPollAnswer.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$SnPollAnswerFromJson(json);
|
||||||
|
}
|
||||||
1467
lib/models/poll.freezed.dart
Normal file
1467
lib/models/poll.freezed.dart
Normal file
File diff suppressed because it is too large
Load Diff
158
lib/models/poll.g.dart
Normal file
158
lib/models/poll.g.dart
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'poll.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
_SnPollWithStats _$SnPollWithStatsFromJson(Map<String, dynamic> json) =>
|
||||||
|
_SnPollWithStats(
|
||||||
|
userAnswer: json['user_answer'] as Map<String, dynamic>?,
|
||||||
|
stats: json['stats'] as Map<String, dynamic>,
|
||||||
|
id: json['id'] as String,
|
||||||
|
questions:
|
||||||
|
(json['questions'] as List<dynamic>)
|
||||||
|
.map((e) => SnPollQuestion.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
title: json['title'] as String?,
|
||||||
|
description: json['description'] as String?,
|
||||||
|
endedAt:
|
||||||
|
json['ended_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['ended_at'] as String),
|
||||||
|
publisherId: json['publisher_id'] as String,
|
||||||
|
createdAt: DateTime.parse(json['created_at'] as String),
|
||||||
|
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||||
|
deletedAt:
|
||||||
|
json['deleted_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['deleted_at'] as String),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$SnPollWithStatsToJson(_SnPollWithStats instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'user_answer': instance.userAnswer,
|
||||||
|
'stats': instance.stats,
|
||||||
|
'id': instance.id,
|
||||||
|
'questions': instance.questions.map((e) => e.toJson()).toList(),
|
||||||
|
'title': instance.title,
|
||||||
|
'description': instance.description,
|
||||||
|
'ended_at': instance.endedAt?.toIso8601String(),
|
||||||
|
'publisher_id': instance.publisherId,
|
||||||
|
'created_at': instance.createdAt.toIso8601String(),
|
||||||
|
'updated_at': instance.updatedAt.toIso8601String(),
|
||||||
|
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||||
|
};
|
||||||
|
|
||||||
|
_SnPoll _$SnPollFromJson(Map<String, dynamic> json) => _SnPoll(
|
||||||
|
id: json['id'] as String,
|
||||||
|
questions:
|
||||||
|
(json['questions'] as List<dynamic>)
|
||||||
|
.map((e) => SnPollQuestion.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
title: json['title'] as String?,
|
||||||
|
description: json['description'] as String?,
|
||||||
|
endedAt:
|
||||||
|
json['ended_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['ended_at'] as String),
|
||||||
|
publisherId: json['publisher_id'] as String,
|
||||||
|
publisher:
|
||||||
|
json['publisher'] == null
|
||||||
|
? null
|
||||||
|
: SnPublisher.fromJson(json['publisher'] as Map<String, dynamic>),
|
||||||
|
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> _$SnPollToJson(_SnPoll instance) => <String, dynamic>{
|
||||||
|
'id': instance.id,
|
||||||
|
'questions': instance.questions.map((e) => e.toJson()).toList(),
|
||||||
|
'title': instance.title,
|
||||||
|
'description': instance.description,
|
||||||
|
'ended_at': instance.endedAt?.toIso8601String(),
|
||||||
|
'publisher_id': instance.publisherId,
|
||||||
|
'publisher': instance.publisher?.toJson(),
|
||||||
|
'created_at': instance.createdAt.toIso8601String(),
|
||||||
|
'updated_at': instance.updatedAt.toIso8601String(),
|
||||||
|
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||||
|
};
|
||||||
|
|
||||||
|
_SnPollQuestion _$SnPollQuestionFromJson(Map<String, dynamic> json) =>
|
||||||
|
_SnPollQuestion(
|
||||||
|
id: json['id'] as String,
|
||||||
|
type: $enumDecode(_$SnPollQuestionTypeEnumMap, json['type']),
|
||||||
|
options:
|
||||||
|
(json['options'] as List<dynamic>?)
|
||||||
|
?.map((e) => SnPollOption.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
title: json['title'] as String,
|
||||||
|
description: json['description'] as String?,
|
||||||
|
order: (json['order'] as num).toInt(),
|
||||||
|
isRequired: json['is_required'] as bool,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$SnPollQuestionToJson(_SnPollQuestion instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'id': instance.id,
|
||||||
|
'type': _$SnPollQuestionTypeEnumMap[instance.type]!,
|
||||||
|
'options': instance.options?.map((e) => e.toJson()).toList(),
|
||||||
|
'title': instance.title,
|
||||||
|
'description': instance.description,
|
||||||
|
'order': instance.order,
|
||||||
|
'is_required': instance.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
const _$SnPollQuestionTypeEnumMap = {
|
||||||
|
SnPollQuestionType.singleChoice: 0,
|
||||||
|
SnPollQuestionType.multipleChoice: 1,
|
||||||
|
SnPollQuestionType.yesNo: 2,
|
||||||
|
SnPollQuestionType.rating: 3,
|
||||||
|
SnPollQuestionType.freeText: 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
_SnPollOption _$SnPollOptionFromJson(Map<String, dynamic> json) =>
|
||||||
|
_SnPollOption(
|
||||||
|
id: json['id'] as String,
|
||||||
|
label: json['label'] as String,
|
||||||
|
description: json['description'] as String?,
|
||||||
|
order: (json['order'] as num).toInt(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$SnPollOptionToJson(_SnPollOption instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'id': instance.id,
|
||||||
|
'label': instance.label,
|
||||||
|
'description': instance.description,
|
||||||
|
'order': instance.order,
|
||||||
|
};
|
||||||
|
|
||||||
|
_SnPollAnswer _$SnPollAnswerFromJson(Map<String, dynamic> json) =>
|
||||||
|
_SnPollAnswer(
|
||||||
|
id: json['id'] as String,
|
||||||
|
answer: json['answer'] as Map<String, dynamic>,
|
||||||
|
accountId: json['account_id'] as String,
|
||||||
|
pollId: json['poll_id'] as String,
|
||||||
|
createdAt: DateTime.parse(json['created_at'] as String),
|
||||||
|
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||||
|
deletedAt:
|
||||||
|
json['deleted_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['deleted_at'] as String),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$SnPollAnswerToJson(_SnPollAnswer instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'id': instance.id,
|
||||||
|
'answer': instance.answer,
|
||||||
|
'account_id': instance.accountId,
|
||||||
|
'poll_id': instance.pollId,
|
||||||
|
'created_at': instance.createdAt.toIso8601String(),
|
||||||
|
'updated_at': instance.updatedAt.toIso8601String(),
|
||||||
|
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||||
|
};
|
||||||
@@ -36,8 +36,8 @@ sealed class SnPost with _$SnPost {
|
|||||||
@Default({}) Map<String, int> reactionsCount,
|
@Default({}) Map<String, int> reactionsCount,
|
||||||
@Default({}) Map<String, bool> reactionsMade,
|
@Default({}) Map<String, bool> reactionsMade,
|
||||||
@Default([]) List<dynamic> reactions,
|
@Default([]) List<dynamic> reactions,
|
||||||
@Default([]) List<PostTag> tags,
|
@Default([]) List<SnPostTag> tags,
|
||||||
@Default([]) List<PostCategory> categories,
|
@Default([]) List<SnPostCategory> categories,
|
||||||
@Default([]) List<dynamic> collections,
|
@Default([]) List<dynamic> collections,
|
||||||
@Default(null) DateTime? createdAt,
|
@Default(null) DateTime? createdAt,
|
||||||
@Default(null) DateTime? updatedAt,
|
@Default(null) DateTime? updatedAt,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$SnPost {
|
mixin _$SnPost {
|
||||||
|
|
||||||
String get id; String? get title; String? get description; String? get language; DateTime? get editedAt; DateTime? get publishedAt; int get visibility; String? get content; int get type; Map<String, dynamic>? get meta; int get viewsUnique; int get viewsTotal; int get upvotes; int get downvotes; int get repliesCount; String? get threadedPostId; SnPost? get threadedPost; String? get repliedPostId; SnPost? get repliedPost; String? get forwardedPostId; SnPost? get forwardedPost; List<SnCloudFile> get attachments; SnPublisher get publisher; Map<String, int> get reactionsCount; Map<String, bool> get reactionsMade; List<dynamic> get reactions; List<PostTag> get tags; List<PostCategory> get categories; List<dynamic> get collections; DateTime? get createdAt; DateTime? get updatedAt; DateTime? get deletedAt; bool get isTruncated;
|
String get id; String? get title; String? get description; String? get language; DateTime? get editedAt; DateTime? get publishedAt; int get visibility; String? get content; int get type; Map<String, dynamic>? get meta; int get viewsUnique; int get viewsTotal; int get upvotes; int get downvotes; int get repliesCount; String? get threadedPostId; SnPost? get threadedPost; String? get repliedPostId; SnPost? get repliedPost; String? get forwardedPostId; SnPost? get forwardedPost; List<SnCloudFile> get attachments; SnPublisher get publisher; Map<String, int> get reactionsCount; Map<String, bool> get reactionsMade; List<dynamic> get reactions; List<SnPostTag> get tags; List<SnPostCategory> get categories; List<dynamic> get collections; DateTime? get createdAt; DateTime? get updatedAt; DateTime? get deletedAt; bool get isTruncated;
|
||||||
/// Create a copy of SnPost
|
/// Create a copy of SnPost
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -48,7 +48,7 @@ abstract mixin class $SnPostCopyWith<$Res> {
|
|||||||
factory $SnPostCopyWith(SnPost value, $Res Function(SnPost) _then) = _$SnPostCopyWithImpl;
|
factory $SnPostCopyWith(SnPost value, $Res Function(SnPost) _then) = _$SnPostCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<PostTag> tags, List<PostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated
|
String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<SnPostTag> tags, List<SnPostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ as SnPublisher,reactionsCount: null == reactionsCount ? _self.reactionsCount : r
|
|||||||
as Map<String, int>,reactionsMade: null == reactionsMade ? _self.reactionsMade : reactionsMade // ignore: cast_nullable_to_non_nullable
|
as Map<String, int>,reactionsMade: null == reactionsMade ? _self.reactionsMade : reactionsMade // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, bool>,reactions: null == reactions ? _self.reactions : reactions // ignore: cast_nullable_to_non_nullable
|
as Map<String, bool>,reactions: null == reactions ? _self.reactions : reactions // ignore: cast_nullable_to_non_nullable
|
||||||
as List<dynamic>,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
|
as List<dynamic>,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
|
||||||
as List<PostTag>,categories: null == categories ? _self.categories : categories // ignore: cast_nullable_to_non_nullable
|
as List<SnPostTag>,categories: null == categories ? _self.categories : categories // ignore: cast_nullable_to_non_nullable
|
||||||
as List<PostCategory>,collections: null == collections ? _self.collections : collections // ignore: cast_nullable_to_non_nullable
|
as List<SnPostCategory>,collections: null == collections ? _self.collections : collections // ignore: cast_nullable_to_non_nullable
|
||||||
as List<dynamic>,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
as List<dynamic>,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime?,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -227,7 +227,7 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<PostTag> tags, List<PostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<SnPostTag> tags, List<SnPostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnPost() when $default != null:
|
case _SnPost() when $default != null:
|
||||||
return $default(_that.id,_that.title,_that.description,_that.language,_that.editedAt,_that.publishedAt,_that.visibility,_that.content,_that.type,_that.meta,_that.viewsUnique,_that.viewsTotal,_that.upvotes,_that.downvotes,_that.repliesCount,_that.threadedPostId,_that.threadedPost,_that.repliedPostId,_that.repliedPost,_that.forwardedPostId,_that.forwardedPost,_that.attachments,_that.publisher,_that.reactionsCount,_that.reactionsMade,_that.reactions,_that.tags,_that.categories,_that.collections,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.isTruncated);case _:
|
return $default(_that.id,_that.title,_that.description,_that.language,_that.editedAt,_that.publishedAt,_that.visibility,_that.content,_that.type,_that.meta,_that.viewsUnique,_that.viewsTotal,_that.upvotes,_that.downvotes,_that.repliesCount,_that.threadedPostId,_that.threadedPost,_that.repliedPostId,_that.repliedPost,_that.forwardedPostId,_that.forwardedPost,_that.attachments,_that.publisher,_that.reactionsCount,_that.reactionsMade,_that.reactions,_that.tags,_that.categories,_that.collections,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.isTruncated);case _:
|
||||||
@@ -248,7 +248,7 @@ return $default(_that.id,_that.title,_that.description,_that.language,_that.edit
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<PostTag> tags, List<PostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<SnPostTag> tags, List<SnPostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnPost():
|
case _SnPost():
|
||||||
return $default(_that.id,_that.title,_that.description,_that.language,_that.editedAt,_that.publishedAt,_that.visibility,_that.content,_that.type,_that.meta,_that.viewsUnique,_that.viewsTotal,_that.upvotes,_that.downvotes,_that.repliesCount,_that.threadedPostId,_that.threadedPost,_that.repliedPostId,_that.repliedPost,_that.forwardedPostId,_that.forwardedPost,_that.attachments,_that.publisher,_that.reactionsCount,_that.reactionsMade,_that.reactions,_that.tags,_that.categories,_that.collections,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.isTruncated);}
|
return $default(_that.id,_that.title,_that.description,_that.language,_that.editedAt,_that.publishedAt,_that.visibility,_that.content,_that.type,_that.meta,_that.viewsUnique,_that.viewsTotal,_that.upvotes,_that.downvotes,_that.repliesCount,_that.threadedPostId,_that.threadedPost,_that.repliedPostId,_that.repliedPost,_that.forwardedPostId,_that.forwardedPost,_that.attachments,_that.publisher,_that.reactionsCount,_that.reactionsMade,_that.reactions,_that.tags,_that.categories,_that.collections,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.isTruncated);}
|
||||||
@@ -265,7 +265,7 @@ return $default(_that.id,_that.title,_that.description,_that.language,_that.edit
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<PostTag> tags, List<PostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<SnPostTag> tags, List<SnPostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnPost() when $default != null:
|
case _SnPost() when $default != null:
|
||||||
return $default(_that.id,_that.title,_that.description,_that.language,_that.editedAt,_that.publishedAt,_that.visibility,_that.content,_that.type,_that.meta,_that.viewsUnique,_that.viewsTotal,_that.upvotes,_that.downvotes,_that.repliesCount,_that.threadedPostId,_that.threadedPost,_that.repliedPostId,_that.repliedPost,_that.forwardedPostId,_that.forwardedPost,_that.attachments,_that.publisher,_that.reactionsCount,_that.reactionsMade,_that.reactions,_that.tags,_that.categories,_that.collections,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.isTruncated);case _:
|
return $default(_that.id,_that.title,_that.description,_that.language,_that.editedAt,_that.publishedAt,_that.visibility,_that.content,_that.type,_that.meta,_that.viewsUnique,_that.viewsTotal,_that.upvotes,_that.downvotes,_that.repliesCount,_that.threadedPostId,_that.threadedPost,_that.repliedPostId,_that.repliedPost,_that.forwardedPostId,_that.forwardedPost,_that.attachments,_that.publisher,_that.reactionsCount,_that.reactionsMade,_that.reactions,_that.tags,_that.categories,_that.collections,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.isTruncated);case _:
|
||||||
@@ -280,7 +280,7 @@ return $default(_that.id,_that.title,_that.description,_that.language,_that.edit
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _SnPost implements SnPost {
|
class _SnPost implements SnPost {
|
||||||
const _SnPost({required this.id, this.title, this.description, this.language, this.editedAt, this.publishedAt = null, this.visibility = 0, this.content, this.type = 0, final Map<String, dynamic>? meta, this.viewsUnique = 0, this.viewsTotal = 0, this.upvotes = 0, this.downvotes = 0, this.repliesCount = 0, this.threadedPostId, this.threadedPost, this.repliedPostId, this.repliedPost, this.forwardedPostId, this.forwardedPost, final List<SnCloudFile> attachments = const [], required this.publisher, final Map<String, int> reactionsCount = const {}, final Map<String, bool> reactionsMade = const {}, final List<dynamic> reactions = const [], final List<PostTag> tags = const [], final List<PostCategory> categories = const [], final List<dynamic> collections = const [], this.createdAt = null, this.updatedAt = null, this.deletedAt, this.isTruncated = false}): _meta = meta,_attachments = attachments,_reactionsCount = reactionsCount,_reactionsMade = reactionsMade,_reactions = reactions,_tags = tags,_categories = categories,_collections = collections;
|
const _SnPost({required this.id, this.title, this.description, this.language, this.editedAt, this.publishedAt = null, this.visibility = 0, this.content, this.type = 0, final Map<String, dynamic>? meta, this.viewsUnique = 0, this.viewsTotal = 0, this.upvotes = 0, this.downvotes = 0, this.repliesCount = 0, this.threadedPostId, this.threadedPost, this.repliedPostId, this.repliedPost, this.forwardedPostId, this.forwardedPost, final List<SnCloudFile> attachments = const [], required this.publisher, final Map<String, int> reactionsCount = const {}, final Map<String, bool> reactionsMade = const {}, final List<dynamic> reactions = const [], final List<SnPostTag> tags = const [], final List<SnPostCategory> categories = const [], final List<dynamic> collections = const [], this.createdAt = null, this.updatedAt = null, this.deletedAt, this.isTruncated = false}): _meta = meta,_attachments = attachments,_reactionsCount = reactionsCount,_reactionsMade = reactionsMade,_reactions = reactions,_tags = tags,_categories = categories,_collections = collections;
|
||||||
factory _SnPost.fromJson(Map<String, dynamic> json) => _$SnPostFromJson(json);
|
factory _SnPost.fromJson(Map<String, dynamic> json) => _$SnPostFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@@ -341,15 +341,15 @@ class _SnPost implements SnPost {
|
|||||||
return EqualUnmodifiableListView(_reactions);
|
return EqualUnmodifiableListView(_reactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<PostTag> _tags;
|
final List<SnPostTag> _tags;
|
||||||
@override@JsonKey() List<PostTag> get tags {
|
@override@JsonKey() List<SnPostTag> get tags {
|
||||||
if (_tags is EqualUnmodifiableListView) return _tags;
|
if (_tags is EqualUnmodifiableListView) return _tags;
|
||||||
// ignore: implicit_dynamic_type
|
// ignore: implicit_dynamic_type
|
||||||
return EqualUnmodifiableListView(_tags);
|
return EqualUnmodifiableListView(_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<PostCategory> _categories;
|
final List<SnPostCategory> _categories;
|
||||||
@override@JsonKey() List<PostCategory> get categories {
|
@override@JsonKey() List<SnPostCategory> get categories {
|
||||||
if (_categories is EqualUnmodifiableListView) return _categories;
|
if (_categories is EqualUnmodifiableListView) return _categories;
|
||||||
// ignore: implicit_dynamic_type
|
// ignore: implicit_dynamic_type
|
||||||
return EqualUnmodifiableListView(_categories);
|
return EqualUnmodifiableListView(_categories);
|
||||||
@@ -400,7 +400,7 @@ abstract mixin class _$SnPostCopyWith<$Res> implements $SnPostCopyWith<$Res> {
|
|||||||
factory _$SnPostCopyWith(_SnPost value, $Res Function(_SnPost) _then) = __$SnPostCopyWithImpl;
|
factory _$SnPostCopyWith(_SnPost value, $Res Function(_SnPost) _then) = __$SnPostCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<PostTag> tags, List<PostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated
|
String id, String? title, String? description, String? language, DateTime? editedAt, DateTime? publishedAt, int visibility, String? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, int repliesCount, String? threadedPostId, SnPost? threadedPost, String? repliedPostId, SnPost? repliedPost, String? forwardedPostId, SnPost? forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, Map<String, int> reactionsCount, Map<String, bool> reactionsMade, List<dynamic> reactions, List<SnPostTag> tags, List<SnPostCategory> categories, List<dynamic> collections, DateTime? createdAt, DateTime? updatedAt, DateTime? deletedAt, bool isTruncated
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -446,8 +446,8 @@ as SnPublisher,reactionsCount: null == reactionsCount ? _self._reactionsCount :
|
|||||||
as Map<String, int>,reactionsMade: null == reactionsMade ? _self._reactionsMade : reactionsMade // ignore: cast_nullable_to_non_nullable
|
as Map<String, int>,reactionsMade: null == reactionsMade ? _self._reactionsMade : reactionsMade // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, bool>,reactions: null == reactions ? _self._reactions : reactions // ignore: cast_nullable_to_non_nullable
|
as Map<String, bool>,reactions: null == reactions ? _self._reactions : reactions // ignore: cast_nullable_to_non_nullable
|
||||||
as List<dynamic>,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable
|
as List<dynamic>,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable
|
||||||
as List<PostTag>,categories: null == categories ? _self._categories : categories // ignore: cast_nullable_to_non_nullable
|
as List<SnPostTag>,categories: null == categories ? _self._categories : categories // ignore: cast_nullable_to_non_nullable
|
||||||
as List<PostCategory>,collections: null == collections ? _self._collections : collections // ignore: cast_nullable_to_non_nullable
|
as List<SnPostCategory>,collections: null == collections ? _self._collections : collections // ignore: cast_nullable_to_non_nullable
|
||||||
as List<dynamic>,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
as List<dynamic>,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime?,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
|
|||||||
reactions: json['reactions'] as List<dynamic>? ?? const [],
|
reactions: json['reactions'] as List<dynamic>? ?? const [],
|
||||||
tags:
|
tags:
|
||||||
(json['tags'] as List<dynamic>?)
|
(json['tags'] as List<dynamic>?)
|
||||||
?.map((e) => PostTag.fromJson(e as Map<String, dynamic>))
|
?.map((e) => SnPostTag.fromJson(e as Map<String, dynamic>))
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const [],
|
const [],
|
||||||
categories:
|
categories:
|
||||||
(json['categories'] as List<dynamic>?)
|
(json['categories'] as List<dynamic>?)
|
||||||
?.map((e) => PostCategory.fromJson(e as Map<String, dynamic>))
|
?.map((e) => SnPostCategory.fromJson(e as Map<String, dynamic>))
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const [],
|
const [],
|
||||||
collections: json['collections'] as List<dynamic>? ?? const [],
|
collections: json['collections'] as List<dynamic>? ?? const [],
|
||||||
|
|||||||
@@ -1,19 +1,30 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:island/models/post.dart';
|
import 'package:island/models/post.dart';
|
||||||
|
import 'package:island/services/text.dart';
|
||||||
|
|
||||||
part 'post_category.freezed.dart';
|
part 'post_category.freezed.dart';
|
||||||
part 'post_category.g.dart';
|
part 'post_category.g.dart';
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
sealed class PostCategory with _$PostCategory {
|
sealed class SnPostCategory with _$SnPostCategory {
|
||||||
const factory PostCategory({
|
const SnPostCategory._();
|
||||||
|
|
||||||
|
const factory SnPostCategory({
|
||||||
required String id,
|
required String id,
|
||||||
required String slug,
|
required String slug,
|
||||||
String? name,
|
String? name,
|
||||||
@Default([]) List<SnPost> posts,
|
@Default([]) List<SnPost> posts,
|
||||||
}) = _PostCategory;
|
}) = _SnPostCategory;
|
||||||
|
|
||||||
factory PostCategory.fromJson(Map<String, dynamic> json) =>
|
factory SnPostCategory.fromJson(Map<String, dynamic> json) =>
|
||||||
_$PostCategoryFromJson(json);
|
_$SnPostCategoryFromJson(json);
|
||||||
|
|
||||||
|
String get categoryDisplayTitle {
|
||||||
|
final capitalizedSlug = slug.capitalizeEachWord();
|
||||||
|
if ('postCategory$capitalizedSlug'.trExists()) {
|
||||||
|
return 'postCategory$capitalizedSlug'.tr();
|
||||||
|
}
|
||||||
|
return name ?? slug;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,22 +13,22 @@ part of 'post_category.dart';
|
|||||||
T _$identity<T>(T value) => value;
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$PostCategory {
|
mixin _$SnPostCategory {
|
||||||
|
|
||||||
String get id; String get slug; String? get name; List<SnPost> get posts;
|
String get id; String get slug; String? get name; List<SnPost> get posts;
|
||||||
/// Create a copy of PostCategory
|
/// Create a copy of SnPostCategory
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
$PostCategoryCopyWith<PostCategory> get copyWith => _$PostCategoryCopyWithImpl<PostCategory>(this as PostCategory, _$identity);
|
$SnPostCategoryCopyWith<SnPostCategory> get copyWith => _$SnPostCategoryCopyWithImpl<SnPostCategory>(this as SnPostCategory, _$identity);
|
||||||
|
|
||||||
/// Serializes this PostCategory to a JSON map.
|
/// Serializes this SnPostCategory to a JSON map.
|
||||||
Map<String, dynamic> toJson();
|
Map<String, dynamic> toJson();
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PostCategory&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.posts, posts));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnPostCategory&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.posts, posts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -37,15 +37,15 @@ int get hashCode => Object.hash(runtimeType,id,slug,name,const DeepCollectionEqu
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PostCategory(id: $id, slug: $slug, name: $name, posts: $posts)';
|
return 'SnPostCategory(id: $id, slug: $slug, name: $name, posts: $posts)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract mixin class $PostCategoryCopyWith<$Res> {
|
abstract mixin class $SnPostCategoryCopyWith<$Res> {
|
||||||
factory $PostCategoryCopyWith(PostCategory value, $Res Function(PostCategory) _then) = _$PostCategoryCopyWithImpl;
|
factory $SnPostCategoryCopyWith(SnPostCategory value, $Res Function(SnPostCategory) _then) = _$SnPostCategoryCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String slug, String? name, List<SnPost> posts
|
String id, String slug, String? name, List<SnPost> posts
|
||||||
@@ -56,14 +56,14 @@ $Res call({
|
|||||||
|
|
||||||
}
|
}
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$PostCategoryCopyWithImpl<$Res>
|
class _$SnPostCategoryCopyWithImpl<$Res>
|
||||||
implements $PostCategoryCopyWith<$Res> {
|
implements $SnPostCategoryCopyWith<$Res> {
|
||||||
_$PostCategoryCopyWithImpl(this._self, this._then);
|
_$SnPostCategoryCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
final PostCategory _self;
|
final SnPostCategory _self;
|
||||||
final $Res Function(PostCategory) _then;
|
final $Res Function(SnPostCategory) _then;
|
||||||
|
|
||||||
/// Create a copy of PostCategory
|
/// Create a copy of SnPostCategory
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
@@ -78,8 +78,8 @@ as List<SnPost>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Adds pattern-matching-related methods to [PostCategory].
|
/// Adds pattern-matching-related methods to [SnPostCategory].
|
||||||
extension PostCategoryPatterns on PostCategory {
|
extension SnPostCategoryPatterns on SnPostCategory {
|
||||||
/// A variant of `map` that fallback to returning `orElse`.
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
///
|
///
|
||||||
/// It is equivalent to doing:
|
/// It is equivalent to doing:
|
||||||
@@ -92,10 +92,10 @@ extension PostCategoryPatterns on PostCategory {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PostCategory value)? $default,{required TResult orElse(),}){
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SnPostCategory value)? $default,{required TResult orElse(),}){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostCategory() when $default != null:
|
case _SnPostCategory() when $default != null:
|
||||||
return $default(_that);case _:
|
return $default(_that);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -114,10 +114,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PostCategory value) $default,){
|
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SnPostCategory value) $default,){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostCategory():
|
case _SnPostCategory():
|
||||||
return $default(_that);}
|
return $default(_that);}
|
||||||
}
|
}
|
||||||
/// A variant of `map` that fallback to returning `null`.
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
@@ -132,10 +132,10 @@ return $default(_that);}
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PostCategory value)? $default,){
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SnPostCategory value)? $default,){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostCategory() when $default != null:
|
case _SnPostCategory() when $default != null:
|
||||||
return $default(_that);case _:
|
return $default(_that);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ return $default(_that);case _:
|
|||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostCategory() when $default != null:
|
case _SnPostCategory() when $default != null:
|
||||||
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
|||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostCategory():
|
case _SnPostCategory():
|
||||||
return $default(_that.id,_that.slug,_that.name,_that.posts);}
|
return $default(_that.id,_that.slug,_that.name,_that.posts);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
@@ -193,7 +193,7 @@ return $default(_that.id,_that.slug,_that.name,_that.posts);}
|
|||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String slug, String? name, List<SnPost> posts)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String slug, String? name, List<SnPost> posts)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostCategory() when $default != null:
|
case _SnPostCategory() when $default != null:
|
||||||
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -205,9 +205,9 @@ return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _PostCategory implements PostCategory {
|
class _SnPostCategory extends SnPostCategory {
|
||||||
const _PostCategory({required this.id, required this.slug, this.name, final List<SnPost> posts = const []}): _posts = posts;
|
const _SnPostCategory({required this.id, required this.slug, this.name, final List<SnPost> posts = const []}): _posts = posts,super._();
|
||||||
factory _PostCategory.fromJson(Map<String, dynamic> json) => _$PostCategoryFromJson(json);
|
factory _SnPostCategory.fromJson(Map<String, dynamic> json) => _$SnPostCategoryFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@override final String slug;
|
@override final String slug;
|
||||||
@@ -220,20 +220,20 @@ class _PostCategory implements PostCategory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Create a copy of PostCategory
|
/// Create a copy of SnPostCategory
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
_$PostCategoryCopyWith<_PostCategory> get copyWith => __$PostCategoryCopyWithImpl<_PostCategory>(this, _$identity);
|
_$SnPostCategoryCopyWith<_SnPostCategory> get copyWith => __$SnPostCategoryCopyWithImpl<_SnPostCategory>(this, _$identity);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return _$PostCategoryToJson(this, );
|
return _$SnPostCategoryToJson(this, );
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PostCategory&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other._posts, _posts));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPostCategory&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other._posts, _posts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -242,15 +242,15 @@ int get hashCode => Object.hash(runtimeType,id,slug,name,const DeepCollectionEqu
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PostCategory(id: $id, slug: $slug, name: $name, posts: $posts)';
|
return 'SnPostCategory(id: $id, slug: $slug, name: $name, posts: $posts)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract mixin class _$PostCategoryCopyWith<$Res> implements $PostCategoryCopyWith<$Res> {
|
abstract mixin class _$SnPostCategoryCopyWith<$Res> implements $SnPostCategoryCopyWith<$Res> {
|
||||||
factory _$PostCategoryCopyWith(_PostCategory value, $Res Function(_PostCategory) _then) = __$PostCategoryCopyWithImpl;
|
factory _$SnPostCategoryCopyWith(_SnPostCategory value, $Res Function(_SnPostCategory) _then) = __$SnPostCategoryCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String slug, String? name, List<SnPost> posts
|
String id, String slug, String? name, List<SnPost> posts
|
||||||
@@ -261,17 +261,17 @@ $Res call({
|
|||||||
|
|
||||||
}
|
}
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$PostCategoryCopyWithImpl<$Res>
|
class __$SnPostCategoryCopyWithImpl<$Res>
|
||||||
implements _$PostCategoryCopyWith<$Res> {
|
implements _$SnPostCategoryCopyWith<$Res> {
|
||||||
__$PostCategoryCopyWithImpl(this._self, this._then);
|
__$SnPostCategoryCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
final _PostCategory _self;
|
final _SnPostCategory _self;
|
||||||
final $Res Function(_PostCategory) _then;
|
final $Res Function(_SnPostCategory) _then;
|
||||||
|
|
||||||
/// Create a copy of PostCategory
|
/// Create a copy of SnPostCategory
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
||||||
return _then(_PostCategory(
|
return _then(_SnPostCategory(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
||||||
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ part of 'post_category.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
_PostCategory _$PostCategoryFromJson(Map<String, dynamic> json) =>
|
_SnPostCategory _$SnPostCategoryFromJson(Map<String, dynamic> json) =>
|
||||||
_PostCategory(
|
_SnPostCategory(
|
||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
slug: json['slug'] as String,
|
slug: json['slug'] as String,
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
@@ -18,7 +18,7 @@ _PostCategory _$PostCategoryFromJson(Map<String, dynamic> json) =>
|
|||||||
const [],
|
const [],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$PostCategoryToJson(_PostCategory instance) =>
|
Map<String, dynamic> _$SnPostCategoryToJson(_SnPostCategory instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'id': instance.id,
|
'id': instance.id,
|
||||||
'slug': instance.slug,
|
'slug': instance.slug,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:island/models/post.dart';
|
import 'package:island/models/post.dart';
|
||||||
|
|
||||||
@@ -6,14 +5,14 @@ part 'post_tag.freezed.dart';
|
|||||||
part 'post_tag.g.dart';
|
part 'post_tag.g.dart';
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
sealed class PostTag with _$PostTag {
|
sealed class SnPostTag with _$SnPostTag {
|
||||||
const factory PostTag({
|
const factory SnPostTag({
|
||||||
required String id,
|
required String id,
|
||||||
required String slug,
|
required String slug,
|
||||||
String? name,
|
String? name,
|
||||||
@Default([]) List<SnPost> posts,
|
@Default([]) List<SnPost> posts,
|
||||||
}) = _PostTag;
|
}) = _SnPostTag;
|
||||||
|
|
||||||
factory PostTag.fromJson(Map<String, dynamic> json) =>
|
factory SnPostTag.fromJson(Map<String, dynamic> json) =>
|
||||||
_$PostTagFromJson(json);
|
_$SnPostTagFromJson(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,22 +13,22 @@ part of 'post_tag.dart';
|
|||||||
T _$identity<T>(T value) => value;
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$PostTag {
|
mixin _$SnPostTag {
|
||||||
|
|
||||||
String get id; String get slug; String? get name; List<SnPost> get posts;
|
String get id; String get slug; String? get name; List<SnPost> get posts;
|
||||||
/// Create a copy of PostTag
|
/// Create a copy of SnPostTag
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
$PostTagCopyWith<PostTag> get copyWith => _$PostTagCopyWithImpl<PostTag>(this as PostTag, _$identity);
|
$SnPostTagCopyWith<SnPostTag> get copyWith => _$SnPostTagCopyWithImpl<SnPostTag>(this as SnPostTag, _$identity);
|
||||||
|
|
||||||
/// Serializes this PostTag to a JSON map.
|
/// Serializes this SnPostTag to a JSON map.
|
||||||
Map<String, dynamic> toJson();
|
Map<String, dynamic> toJson();
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PostTag&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.posts, posts));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnPostTag&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.posts, posts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -37,15 +37,15 @@ int get hashCode => Object.hash(runtimeType,id,slug,name,const DeepCollectionEqu
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PostTag(id: $id, slug: $slug, name: $name, posts: $posts)';
|
return 'SnPostTag(id: $id, slug: $slug, name: $name, posts: $posts)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract mixin class $PostTagCopyWith<$Res> {
|
abstract mixin class $SnPostTagCopyWith<$Res> {
|
||||||
factory $PostTagCopyWith(PostTag value, $Res Function(PostTag) _then) = _$PostTagCopyWithImpl;
|
factory $SnPostTagCopyWith(SnPostTag value, $Res Function(SnPostTag) _then) = _$SnPostTagCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String slug, String? name, List<SnPost> posts
|
String id, String slug, String? name, List<SnPost> posts
|
||||||
@@ -56,14 +56,14 @@ $Res call({
|
|||||||
|
|
||||||
}
|
}
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$PostTagCopyWithImpl<$Res>
|
class _$SnPostTagCopyWithImpl<$Res>
|
||||||
implements $PostTagCopyWith<$Res> {
|
implements $SnPostTagCopyWith<$Res> {
|
||||||
_$PostTagCopyWithImpl(this._self, this._then);
|
_$SnPostTagCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
final PostTag _self;
|
final SnPostTag _self;
|
||||||
final $Res Function(PostTag) _then;
|
final $Res Function(SnPostTag) _then;
|
||||||
|
|
||||||
/// Create a copy of PostTag
|
/// Create a copy of SnPostTag
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
@@ -78,8 +78,8 @@ as List<SnPost>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Adds pattern-matching-related methods to [PostTag].
|
/// Adds pattern-matching-related methods to [SnPostTag].
|
||||||
extension PostTagPatterns on PostTag {
|
extension SnPostTagPatterns on SnPostTag {
|
||||||
/// A variant of `map` that fallback to returning `orElse`.
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
///
|
///
|
||||||
/// It is equivalent to doing:
|
/// It is equivalent to doing:
|
||||||
@@ -92,10 +92,10 @@ extension PostTagPatterns on PostTag {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PostTag value)? $default,{required TResult orElse(),}){
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SnPostTag value)? $default,{required TResult orElse(),}){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostTag() when $default != null:
|
case _SnPostTag() when $default != null:
|
||||||
return $default(_that);case _:
|
return $default(_that);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -114,10 +114,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PostTag value) $default,){
|
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SnPostTag value) $default,){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostTag():
|
case _SnPostTag():
|
||||||
return $default(_that);}
|
return $default(_that);}
|
||||||
}
|
}
|
||||||
/// A variant of `map` that fallback to returning `null`.
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
@@ -132,10 +132,10 @@ return $default(_that);}
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PostTag value)? $default,){
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SnPostTag value)? $default,){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostTag() when $default != null:
|
case _SnPostTag() when $default != null:
|
||||||
return $default(_that);case _:
|
return $default(_that);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ return $default(_that);case _:
|
|||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostTag() when $default != null:
|
case _SnPostTag() when $default != null:
|
||||||
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
|||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String slug, String? name, List<SnPost> posts) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostTag():
|
case _SnPostTag():
|
||||||
return $default(_that.id,_that.slug,_that.name,_that.posts);}
|
return $default(_that.id,_that.slug,_that.name,_that.posts);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
@@ -193,7 +193,7 @@ return $default(_that.id,_that.slug,_that.name,_that.posts);}
|
|||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String slug, String? name, List<SnPost> posts)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String slug, String? name, List<SnPost> posts)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _PostTag() when $default != null:
|
case _SnPostTag() when $default != null:
|
||||||
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -205,9 +205,9 @@ return $default(_that.id,_that.slug,_that.name,_that.posts);case _:
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _PostTag implements PostTag {
|
class _SnPostTag implements SnPostTag {
|
||||||
const _PostTag({required this.id, required this.slug, this.name, final List<SnPost> posts = const []}): _posts = posts;
|
const _SnPostTag({required this.id, required this.slug, this.name, final List<SnPost> posts = const []}): _posts = posts;
|
||||||
factory _PostTag.fromJson(Map<String, dynamic> json) => _$PostTagFromJson(json);
|
factory _SnPostTag.fromJson(Map<String, dynamic> json) => _$SnPostTagFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@override final String slug;
|
@override final String slug;
|
||||||
@@ -220,20 +220,20 @@ class _PostTag implements PostTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Create a copy of PostTag
|
/// Create a copy of SnPostTag
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
_$PostTagCopyWith<_PostTag> get copyWith => __$PostTagCopyWithImpl<_PostTag>(this, _$identity);
|
_$SnPostTagCopyWith<_SnPostTag> get copyWith => __$SnPostTagCopyWithImpl<_SnPostTag>(this, _$identity);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return _$PostTagToJson(this, );
|
return _$SnPostTagToJson(this, );
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PostTag&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other._posts, _posts));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPostTag&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other._posts, _posts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -242,15 +242,15 @@ int get hashCode => Object.hash(runtimeType,id,slug,name,const DeepCollectionEqu
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PostTag(id: $id, slug: $slug, name: $name, posts: $posts)';
|
return 'SnPostTag(id: $id, slug: $slug, name: $name, posts: $posts)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract mixin class _$PostTagCopyWith<$Res> implements $PostTagCopyWith<$Res> {
|
abstract mixin class _$SnPostTagCopyWith<$Res> implements $SnPostTagCopyWith<$Res> {
|
||||||
factory _$PostTagCopyWith(_PostTag value, $Res Function(_PostTag) _then) = __$PostTagCopyWithImpl;
|
factory _$SnPostTagCopyWith(_SnPostTag value, $Res Function(_SnPostTag) _then) = __$SnPostTagCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String slug, String? name, List<SnPost> posts
|
String id, String slug, String? name, List<SnPost> posts
|
||||||
@@ -261,17 +261,17 @@ $Res call({
|
|||||||
|
|
||||||
}
|
}
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$PostTagCopyWithImpl<$Res>
|
class __$SnPostTagCopyWithImpl<$Res>
|
||||||
implements _$PostTagCopyWith<$Res> {
|
implements _$SnPostTagCopyWith<$Res> {
|
||||||
__$PostTagCopyWithImpl(this._self, this._then);
|
__$SnPostTagCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
final _PostTag _self;
|
final _SnPostTag _self;
|
||||||
final $Res Function(_PostTag) _then;
|
final $Res Function(_SnPostTag) _then;
|
||||||
|
|
||||||
/// Create a copy of PostTag
|
/// Create a copy of SnPostTag
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = freezed,Object? posts = null,}) {
|
||||||
return _then(_PostTag(
|
return _then(_SnPostTag(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
||||||
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'post_tag.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
_PostTag _$PostTagFromJson(Map<String, dynamic> json) => _PostTag(
|
_SnPostTag _$SnPostTagFromJson(Map<String, dynamic> json) => _SnPostTag(
|
||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
slug: json['slug'] as String,
|
slug: json['slug'] as String,
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
@@ -17,9 +17,10 @@ _PostTag _$PostTagFromJson(Map<String, dynamic> json) => _PostTag(
|
|||||||
const [],
|
const [],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$PostTagToJson(_PostTag instance) => <String, dynamic>{
|
Map<String, dynamic> _$SnPostTagToJson(_SnPostTag instance) =>
|
||||||
'id': instance.id,
|
<String, dynamic>{
|
||||||
'slug': instance.slug,
|
'id': instance.id,
|
||||||
'name': instance.name,
|
'slug': instance.slug,
|
||||||
'posts': instance.posts.map((e) => e.toJson()).toList(),
|
'name': instance.name,
|
||||||
};
|
'posts': instance.posts.map((e) => e.toJson()).toList(),
|
||||||
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ sealed class SnStickerPack with _$SnStickerPack {
|
|||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
required DateTime updatedAt,
|
required DateTime updatedAt,
|
||||||
required DateTime? deletedAt,
|
required DateTime? deletedAt,
|
||||||
|
@Default([]) List<SnSticker> stickers,
|
||||||
}) = _SnStickerPack;
|
}) = _SnStickerPack;
|
||||||
|
|
||||||
factory SnStickerPack.fromJson(Map<String, dynamic> json) =>
|
factory SnStickerPack.fromJson(Map<String, dynamic> json) =>
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ $SnStickerPackCopyWith<$Res>? get pack {
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$SnStickerPack {
|
mixin _$SnStickerPack {
|
||||||
|
|
||||||
String get id; String get name; String get description; String get prefix; String get publisherId; SnPublisher? get publisher; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
String get id; String get name; String get description; String get prefix; String get publisherId; SnPublisher? get publisher; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; List<SnSticker> get stickers;
|
||||||
/// Create a copy of SnStickerPack
|
/// Create a copy of SnStickerPack
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -351,16 +351,16 @@ $SnStickerPackCopyWith<SnStickerPack> get copyWith => _$SnStickerPackCopyWithImp
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnStickerPack&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.prefix, prefix) || other.prefix == prefix)&&(identical(other.publisherId, publisherId) || other.publisherId == publisherId)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnStickerPack&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.prefix, prefix) || other.prefix == prefix)&&(identical(other.publisherId, publisherId) || other.publisherId == publisherId)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)&&const DeepCollectionEquality().equals(other.stickers, stickers));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,name,description,prefix,publisherId,publisher,createdAt,updatedAt,deletedAt);
|
int get hashCode => Object.hash(runtimeType,id,name,description,prefix,publisherId,publisher,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(stickers));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnStickerPack(id: $id, name: $name, description: $description, prefix: $prefix, publisherId: $publisherId, publisher: $publisher, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnStickerPack(id: $id, name: $name, description: $description, prefix: $prefix, publisherId: $publisherId, publisher: $publisher, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, stickers: $stickers)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ abstract mixin class $SnStickerPackCopyWith<$Res> {
|
|||||||
factory $SnStickerPackCopyWith(SnStickerPack value, $Res Function(SnStickerPack) _then) = _$SnStickerPackCopyWithImpl;
|
factory $SnStickerPackCopyWith(SnStickerPack value, $Res Function(SnStickerPack) _then) = _$SnStickerPackCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnSticker> stickers
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -388,7 +388,7 @@ class _$SnStickerPackCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnStickerPack
|
/// Create a copy of SnStickerPack
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? prefix = null,Object? publisherId = null,Object? publisher = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? prefix = null,Object? publisherId = null,Object? publisher = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? stickers = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -399,7 +399,8 @@ as String,publisher: freezed == publisher ? _self.publisher : publisher // ignor
|
|||||||
as SnPublisher?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
as SnPublisher?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,
|
as DateTime?,stickers: null == stickers ? _self.stickers : stickers // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<SnSticker>,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
/// Create a copy of SnStickerPack
|
/// Create a copy of SnStickerPack
|
||||||
@@ -493,10 +494,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnSticker> stickers)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnStickerPack() when $default != null:
|
case _SnStickerPack() when $default != null:
|
||||||
return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publisherId,_that.publisher,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publisherId,_that.publisher,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.stickers);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -514,10 +515,10 @@ return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publish
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnSticker> stickers) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnStickerPack():
|
case _SnStickerPack():
|
||||||
return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publisherId,_that.publisher,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publisherId,_that.publisher,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.stickers);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
///
|
///
|
||||||
@@ -531,10 +532,10 @@ return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publish
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnSticker> stickers)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnStickerPack() when $default != null:
|
case _SnStickerPack() when $default != null:
|
||||||
return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publisherId,_that.publisher,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publisherId,_that.publisher,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.stickers);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -546,7 +547,7 @@ return $default(_that.id,_that.name,_that.description,_that.prefix,_that.publish
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _SnStickerPack implements SnStickerPack {
|
class _SnStickerPack implements SnStickerPack {
|
||||||
const _SnStickerPack({required this.id, required this.name, required this.description, required this.prefix, required this.publisherId, required this.publisher, required this.createdAt, required this.updatedAt, required this.deletedAt});
|
const _SnStickerPack({required this.id, required this.name, required this.description, required this.prefix, required this.publisherId, required this.publisher, required this.createdAt, required this.updatedAt, required this.deletedAt, final List<SnSticker> stickers = const []}): _stickers = stickers;
|
||||||
factory _SnStickerPack.fromJson(Map<String, dynamic> json) => _$SnStickerPackFromJson(json);
|
factory _SnStickerPack.fromJson(Map<String, dynamic> json) => _$SnStickerPackFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@@ -558,6 +559,13 @@ class _SnStickerPack implements SnStickerPack {
|
|||||||
@override final DateTime createdAt;
|
@override final DateTime createdAt;
|
||||||
@override final DateTime updatedAt;
|
@override final DateTime updatedAt;
|
||||||
@override final DateTime? deletedAt;
|
@override final DateTime? deletedAt;
|
||||||
|
final List<SnSticker> _stickers;
|
||||||
|
@override@JsonKey() List<SnSticker> get stickers {
|
||||||
|
if (_stickers is EqualUnmodifiableListView) return _stickers;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_stickers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Create a copy of SnStickerPack
|
/// Create a copy of SnStickerPack
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -572,16 +580,16 @@ Map<String, dynamic> toJson() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnStickerPack&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.prefix, prefix) || other.prefix == prefix)&&(identical(other.publisherId, publisherId) || other.publisherId == publisherId)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnStickerPack&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.prefix, prefix) || other.prefix == prefix)&&(identical(other.publisherId, publisherId) || other.publisherId == publisherId)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)&&const DeepCollectionEquality().equals(other._stickers, _stickers));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,name,description,prefix,publisherId,publisher,createdAt,updatedAt,deletedAt);
|
int get hashCode => Object.hash(runtimeType,id,name,description,prefix,publisherId,publisher,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(_stickers));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnStickerPack(id: $id, name: $name, description: $description, prefix: $prefix, publisherId: $publisherId, publisher: $publisher, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnStickerPack(id: $id, name: $name, description: $description, prefix: $prefix, publisherId: $publisherId, publisher: $publisher, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, stickers: $stickers)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -592,7 +600,7 @@ abstract mixin class _$SnStickerPackCopyWith<$Res> implements $SnStickerPackCopy
|
|||||||
factory _$SnStickerPackCopyWith(_SnStickerPack value, $Res Function(_SnStickerPack) _then) = __$SnStickerPackCopyWithImpl;
|
factory _$SnStickerPackCopyWith(_SnStickerPack value, $Res Function(_SnStickerPack) _then) = __$SnStickerPackCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String name, String description, String prefix, String publisherId, SnPublisher? publisher, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnSticker> stickers
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -609,7 +617,7 @@ class __$SnStickerPackCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnStickerPack
|
/// Create a copy of SnStickerPack
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? prefix = null,Object? publisherId = null,Object? publisher = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? prefix = null,Object? publisherId = null,Object? publisher = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? stickers = null,}) {
|
||||||
return _then(_SnStickerPack(
|
return _then(_SnStickerPack(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -620,7 +628,8 @@ as String,publisher: freezed == publisher ? _self.publisher : publisher // ignor
|
|||||||
as SnPublisher?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
as SnPublisher?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,
|
as DateTime?,stickers: null == stickers ? _self._stickers : stickers // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<SnSticker>,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ _SnStickerPack _$SnStickerPackFromJson(Map<String, dynamic> json) =>
|
|||||||
json['deleted_at'] == null
|
json['deleted_at'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json['deleted_at'] as String),
|
: DateTime.parse(json['deleted_at'] as String),
|
||||||
|
stickers:
|
||||||
|
(json['stickers'] as List<dynamic>?)
|
||||||
|
?.map((e) => SnSticker.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList() ??
|
||||||
|
const [],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$SnStickerPackToJson(_SnStickerPack instance) =>
|
Map<String, dynamic> _$SnStickerPackToJson(_SnStickerPack instance) =>
|
||||||
@@ -67,4 +72,5 @@ Map<String, dynamic> _$SnStickerPackToJson(_SnStickerPack instance) =>
|
|||||||
'created_at': instance.createdAt.toIso8601String(),
|
'created_at': instance.createdAt.toIso8601String(),
|
||||||
'updated_at': instance.updatedAt.toIso8601String(),
|
'updated_at': instance.updatedAt.toIso8601String(),
|
||||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||||
|
'stickers': instance.stickers.map((e) => e.toJson()).toList(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ sealed class SnAccountProfile with _$SnAccountProfile {
|
|||||||
@Default('') String location,
|
@Default('') String location,
|
||||||
@Default('') String timeZone,
|
@Default('') String timeZone,
|
||||||
DateTime? birthday,
|
DateTime? birthday,
|
||||||
|
@Default({}) Map<String, String> links,
|
||||||
DateTime? lastSeenAt,
|
DateTime? lastSeenAt,
|
||||||
SnAccountBadge? activeBadge,
|
SnAccountBadge? activeBadge,
|
||||||
required int experience,
|
required int experience,
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ $SnWalletSubscriptionRefCopyWith<$Res>? get perkSubscription {
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$SnAccountProfile {
|
mixin _$SnAccountProfile {
|
||||||
|
|
||||||
String get id; String get firstName; String get middleName; String get lastName; String get bio; String get gender; String get pronouns; String get location; String get timeZone; DateTime? get birthday; DateTime? get lastSeenAt; SnAccountBadge? get activeBadge; int get experience; int get level; double get levelingProgress; SnCloudFile? get picture; SnCloudFile? get background; SnVerificationMark? get verification; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
String get id; String get firstName; String get middleName; String get lastName; String get bio; String get gender; String get pronouns; String get location; String get timeZone; DateTime? get birthday; Map<String, String> get links; DateTime? get lastSeenAt; SnAccountBadge? get activeBadge; int get experience; int get level; double get levelingProgress; SnCloudFile? get picture; SnCloudFile? get background; SnVerificationMark? get verification; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
||||||
/// Create a copy of SnAccountProfile
|
/// Create a copy of SnAccountProfile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -363,16 +363,16 @@ $SnAccountProfileCopyWith<SnAccountProfile> get copyWith => _$SnAccountProfileCo
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.gender, gender) || other.gender == gender)&&(identical(other.pronouns, pronouns) || other.pronouns == pronouns)&&(identical(other.location, location) || other.location == location)&&(identical(other.timeZone, timeZone) || other.timeZone == timeZone)&&(identical(other.birthday, birthday) || other.birthday == birthday)&&(identical(other.lastSeenAt, lastSeenAt) || other.lastSeenAt == lastSeenAt)&&(identical(other.activeBadge, activeBadge) || other.activeBadge == activeBadge)&&(identical(other.experience, experience) || other.experience == experience)&&(identical(other.level, level) || other.level == level)&&(identical(other.levelingProgress, levelingProgress) || other.levelingProgress == levelingProgress)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.verification, verification) || other.verification == verification)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.gender, gender) || other.gender == gender)&&(identical(other.pronouns, pronouns) || other.pronouns == pronouns)&&(identical(other.location, location) || other.location == location)&&(identical(other.timeZone, timeZone) || other.timeZone == timeZone)&&(identical(other.birthday, birthday) || other.birthday == birthday)&&const DeepCollectionEquality().equals(other.links, links)&&(identical(other.lastSeenAt, lastSeenAt) || other.lastSeenAt == lastSeenAt)&&(identical(other.activeBadge, activeBadge) || other.activeBadge == activeBadge)&&(identical(other.experience, experience) || other.experience == experience)&&(identical(other.level, level) || other.level == level)&&(identical(other.levelingProgress, levelingProgress) || other.levelingProgress == levelingProgress)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.verification, verification) || other.verification == verification)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hashAll([runtimeType,id,firstName,middleName,lastName,bio,gender,pronouns,location,timeZone,birthday,lastSeenAt,activeBadge,experience,level,levelingProgress,picture,background,verification,createdAt,updatedAt,deletedAt]);
|
int get hashCode => Object.hashAll([runtimeType,id,firstName,middleName,lastName,bio,gender,pronouns,location,timeZone,birthday,const DeepCollectionEquality().hash(links),lastSeenAt,activeBadge,experience,level,levelingProgress,picture,background,verification,createdAt,updatedAt,deletedAt]);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, gender: $gender, pronouns: $pronouns, location: $location, timeZone: $timeZone, birthday: $birthday, lastSeenAt: $lastSeenAt, activeBadge: $activeBadge, experience: $experience, level: $level, levelingProgress: $levelingProgress, picture: $picture, background: $background, verification: $verification, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, gender: $gender, pronouns: $pronouns, location: $location, timeZone: $timeZone, birthday: $birthday, links: $links, lastSeenAt: $lastSeenAt, activeBadge: $activeBadge, experience: $experience, level: $level, levelingProgress: $levelingProgress, picture: $picture, background: $background, verification: $verification, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ abstract mixin class $SnAccountProfileCopyWith<$Res> {
|
|||||||
factory $SnAccountProfileCopyWith(SnAccountProfile value, $Res Function(SnAccountProfile) _then) = _$SnAccountProfileCopyWithImpl;
|
factory $SnAccountProfileCopyWith(SnAccountProfile value, $Res Function(SnAccountProfile) _then) = _$SnAccountProfileCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, Map<String, String> links, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ class _$SnAccountProfileCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnAccountProfile
|
/// Create a copy of SnAccountProfile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? firstName = null,Object? middleName = null,Object? lastName = null,Object? bio = null,Object? gender = null,Object? pronouns = null,Object? location = null,Object? timeZone = null,Object? birthday = freezed,Object? lastSeenAt = freezed,Object? activeBadge = freezed,Object? experience = null,Object? level = null,Object? levelingProgress = null,Object? picture = freezed,Object? background = freezed,Object? verification = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? firstName = null,Object? middleName = null,Object? lastName = null,Object? bio = null,Object? gender = null,Object? pronouns = null,Object? location = null,Object? timeZone = null,Object? birthday = freezed,Object? links = null,Object? lastSeenAt = freezed,Object? activeBadge = freezed,Object? experience = null,Object? level = null,Object? levelingProgress = null,Object? picture = freezed,Object? background = freezed,Object? verification = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -412,7 +412,8 @@ as String,pronouns: null == pronouns ? _self.pronouns : pronouns // ignore: cast
|
|||||||
as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable
|
as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable
|
||||||
as String,timeZone: null == timeZone ? _self.timeZone : timeZone // ignore: cast_nullable_to_non_nullable
|
as String,timeZone: null == timeZone ? _self.timeZone : timeZone // ignore: cast_nullable_to_non_nullable
|
||||||
as String,birthday: freezed == birthday ? _self.birthday : birthday // ignore: cast_nullable_to_non_nullable
|
as String,birthday: freezed == birthday ? _self.birthday : birthday // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,lastSeenAt: freezed == lastSeenAt ? _self.lastSeenAt : lastSeenAt // ignore: cast_nullable_to_non_nullable
|
as DateTime?,links: null == links ? _self.links : links // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, String>,lastSeenAt: freezed == lastSeenAt ? _self.lastSeenAt : lastSeenAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,activeBadge: freezed == activeBadge ? _self.activeBadge : activeBadge // ignore: cast_nullable_to_non_nullable
|
as DateTime?,activeBadge: freezed == activeBadge ? _self.activeBadge : activeBadge // ignore: cast_nullable_to_non_nullable
|
||||||
as SnAccountBadge?,experience: null == experience ? _self.experience : experience // ignore: cast_nullable_to_non_nullable
|
as SnAccountBadge?,experience: null == experience ? _self.experience : experience // ignore: cast_nullable_to_non_nullable
|
||||||
as int,level: null == level ? _self.level : level // ignore: cast_nullable_to_non_nullable
|
as int,level: null == level ? _self.level : level // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -553,10 +554,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, Map<String, String> links, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnAccountProfile() when $default != null:
|
case _SnAccountProfile() when $default != null:
|
||||||
return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.bio,_that.gender,_that.pronouns,_that.location,_that.timeZone,_that.birthday,_that.lastSeenAt,_that.activeBadge,_that.experience,_that.level,_that.levelingProgress,_that.picture,_that.background,_that.verification,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.bio,_that.gender,_that.pronouns,_that.location,_that.timeZone,_that.birthday,_that.links,_that.lastSeenAt,_that.activeBadge,_that.experience,_that.level,_that.levelingProgress,_that.picture,_that.background,_that.verification,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -574,10 +575,10 @@ return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.b
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, Map<String, String> links, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnAccountProfile():
|
case _SnAccountProfile():
|
||||||
return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.bio,_that.gender,_that.pronouns,_that.location,_that.timeZone,_that.birthday,_that.lastSeenAt,_that.activeBadge,_that.experience,_that.level,_that.levelingProgress,_that.picture,_that.background,_that.verification,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.bio,_that.gender,_that.pronouns,_that.location,_that.timeZone,_that.birthday,_that.links,_that.lastSeenAt,_that.activeBadge,_that.experience,_that.level,_that.levelingProgress,_that.picture,_that.background,_that.verification,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
///
|
///
|
||||||
@@ -591,10 +592,10 @@ return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.b
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, Map<String, String> links, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnAccountProfile() when $default != null:
|
case _SnAccountProfile() when $default != null:
|
||||||
return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.bio,_that.gender,_that.pronouns,_that.location,_that.timeZone,_that.birthday,_that.lastSeenAt,_that.activeBadge,_that.experience,_that.level,_that.levelingProgress,_that.picture,_that.background,_that.verification,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.bio,_that.gender,_that.pronouns,_that.location,_that.timeZone,_that.birthday,_that.links,_that.lastSeenAt,_that.activeBadge,_that.experience,_that.level,_that.levelingProgress,_that.picture,_that.background,_that.verification,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -606,7 +607,7 @@ return $default(_that.id,_that.firstName,_that.middleName,_that.lastName,_that.b
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _SnAccountProfile implements SnAccountProfile {
|
class _SnAccountProfile implements SnAccountProfile {
|
||||||
const _SnAccountProfile({required this.id, this.firstName = '', this.middleName = '', this.lastName = '', this.bio = '', this.gender = '', this.pronouns = '', this.location = '', this.timeZone = '', this.birthday, this.lastSeenAt, this.activeBadge, required this.experience, required this.level, required this.levelingProgress, required this.picture, required this.background, required this.verification, required this.createdAt, required this.updatedAt, required this.deletedAt});
|
const _SnAccountProfile({required this.id, this.firstName = '', this.middleName = '', this.lastName = '', this.bio = '', this.gender = '', this.pronouns = '', this.location = '', this.timeZone = '', this.birthday, final Map<String, String> links = const {}, this.lastSeenAt, this.activeBadge, required this.experience, required this.level, required this.levelingProgress, required this.picture, required this.background, required this.verification, required this.createdAt, required this.updatedAt, required this.deletedAt}): _links = links;
|
||||||
factory _SnAccountProfile.fromJson(Map<String, dynamic> json) => _$SnAccountProfileFromJson(json);
|
factory _SnAccountProfile.fromJson(Map<String, dynamic> json) => _$SnAccountProfileFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@@ -619,6 +620,13 @@ class _SnAccountProfile implements SnAccountProfile {
|
|||||||
@override@JsonKey() final String location;
|
@override@JsonKey() final String location;
|
||||||
@override@JsonKey() final String timeZone;
|
@override@JsonKey() final String timeZone;
|
||||||
@override final DateTime? birthday;
|
@override final DateTime? birthday;
|
||||||
|
final Map<String, String> _links;
|
||||||
|
@override@JsonKey() Map<String, String> get links {
|
||||||
|
if (_links is EqualUnmodifiableMapView) return _links;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableMapView(_links);
|
||||||
|
}
|
||||||
|
|
||||||
@override final DateTime? lastSeenAt;
|
@override final DateTime? lastSeenAt;
|
||||||
@override final SnAccountBadge? activeBadge;
|
@override final SnAccountBadge? activeBadge;
|
||||||
@override final int experience;
|
@override final int experience;
|
||||||
@@ -644,16 +652,16 @@ Map<String, dynamic> toJson() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.gender, gender) || other.gender == gender)&&(identical(other.pronouns, pronouns) || other.pronouns == pronouns)&&(identical(other.location, location) || other.location == location)&&(identical(other.timeZone, timeZone) || other.timeZone == timeZone)&&(identical(other.birthday, birthday) || other.birthday == birthday)&&(identical(other.lastSeenAt, lastSeenAt) || other.lastSeenAt == lastSeenAt)&&(identical(other.activeBadge, activeBadge) || other.activeBadge == activeBadge)&&(identical(other.experience, experience) || other.experience == experience)&&(identical(other.level, level) || other.level == level)&&(identical(other.levelingProgress, levelingProgress) || other.levelingProgress == levelingProgress)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.verification, verification) || other.verification == verification)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.gender, gender) || other.gender == gender)&&(identical(other.pronouns, pronouns) || other.pronouns == pronouns)&&(identical(other.location, location) || other.location == location)&&(identical(other.timeZone, timeZone) || other.timeZone == timeZone)&&(identical(other.birthday, birthday) || other.birthday == birthday)&&const DeepCollectionEquality().equals(other._links, _links)&&(identical(other.lastSeenAt, lastSeenAt) || other.lastSeenAt == lastSeenAt)&&(identical(other.activeBadge, activeBadge) || other.activeBadge == activeBadge)&&(identical(other.experience, experience) || other.experience == experience)&&(identical(other.level, level) || other.level == level)&&(identical(other.levelingProgress, levelingProgress) || other.levelingProgress == levelingProgress)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.verification, verification) || other.verification == verification)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hashAll([runtimeType,id,firstName,middleName,lastName,bio,gender,pronouns,location,timeZone,birthday,lastSeenAt,activeBadge,experience,level,levelingProgress,picture,background,verification,createdAt,updatedAt,deletedAt]);
|
int get hashCode => Object.hashAll([runtimeType,id,firstName,middleName,lastName,bio,gender,pronouns,location,timeZone,birthday,const DeepCollectionEquality().hash(_links),lastSeenAt,activeBadge,experience,level,levelingProgress,picture,background,verification,createdAt,updatedAt,deletedAt]);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, gender: $gender, pronouns: $pronouns, location: $location, timeZone: $timeZone, birthday: $birthday, lastSeenAt: $lastSeenAt, activeBadge: $activeBadge, experience: $experience, level: $level, levelingProgress: $levelingProgress, picture: $picture, background: $background, verification: $verification, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, gender: $gender, pronouns: $pronouns, location: $location, timeZone: $timeZone, birthday: $birthday, links: $links, lastSeenAt: $lastSeenAt, activeBadge: $activeBadge, experience: $experience, level: $level, levelingProgress: $levelingProgress, picture: $picture, background: $background, verification: $verification, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -664,7 +672,7 @@ abstract mixin class _$SnAccountProfileCopyWith<$Res> implements $SnAccountProfi
|
|||||||
factory _$SnAccountProfileCopyWith(_SnAccountProfile value, $Res Function(_SnAccountProfile) _then) = __$SnAccountProfileCopyWithImpl;
|
factory _$SnAccountProfileCopyWith(_SnAccountProfile value, $Res Function(_SnAccountProfile) _then) = __$SnAccountProfileCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String firstName, String middleName, String lastName, String bio, String gender, String pronouns, String location, String timeZone, DateTime? birthday, Map<String, String> links, DateTime? lastSeenAt, SnAccountBadge? activeBadge, int experience, int level, double levelingProgress, SnCloudFile? picture, SnCloudFile? background, SnVerificationMark? verification, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -681,7 +689,7 @@ class __$SnAccountProfileCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnAccountProfile
|
/// Create a copy of SnAccountProfile
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? firstName = null,Object? middleName = null,Object? lastName = null,Object? bio = null,Object? gender = null,Object? pronouns = null,Object? location = null,Object? timeZone = null,Object? birthday = freezed,Object? lastSeenAt = freezed,Object? activeBadge = freezed,Object? experience = null,Object? level = null,Object? levelingProgress = null,Object? picture = freezed,Object? background = freezed,Object? verification = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? firstName = null,Object? middleName = null,Object? lastName = null,Object? bio = null,Object? gender = null,Object? pronouns = null,Object? location = null,Object? timeZone = null,Object? birthday = freezed,Object? links = null,Object? lastSeenAt = freezed,Object? activeBadge = freezed,Object? experience = null,Object? level = null,Object? levelingProgress = null,Object? picture = freezed,Object? background = freezed,Object? verification = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
||||||
return _then(_SnAccountProfile(
|
return _then(_SnAccountProfile(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -693,7 +701,8 @@ as String,pronouns: null == pronouns ? _self.pronouns : pronouns // ignore: cast
|
|||||||
as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable
|
as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable
|
||||||
as String,timeZone: null == timeZone ? _self.timeZone : timeZone // ignore: cast_nullable_to_non_nullable
|
as String,timeZone: null == timeZone ? _self.timeZone : timeZone // ignore: cast_nullable_to_non_nullable
|
||||||
as String,birthday: freezed == birthday ? _self.birthday : birthday // ignore: cast_nullable_to_non_nullable
|
as String,birthday: freezed == birthday ? _self.birthday : birthday // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,lastSeenAt: freezed == lastSeenAt ? _self.lastSeenAt : lastSeenAt // ignore: cast_nullable_to_non_nullable
|
as DateTime?,links: null == links ? _self._links : links // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Map<String, String>,lastSeenAt: freezed == lastSeenAt ? _self.lastSeenAt : lastSeenAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime?,activeBadge: freezed == activeBadge ? _self.activeBadge : activeBadge // ignore: cast_nullable_to_non_nullable
|
as DateTime?,activeBadge: freezed == activeBadge ? _self.activeBadge : activeBadge // ignore: cast_nullable_to_non_nullable
|
||||||
as SnAccountBadge?,experience: null == experience ? _self.experience : experience // ignore: cast_nullable_to_non_nullable
|
as SnAccountBadge?,experience: null == experience ? _self.experience : experience // ignore: cast_nullable_to_non_nullable
|
||||||
as int,level: null == level ? _self.level : level // ignore: cast_nullable_to_non_nullable
|
as int,level: null == level ? _self.level : level // ignore: cast_nullable_to_non_nullable
|
||||||
|
|||||||
@@ -62,6 +62,11 @@ _SnAccountProfile _$SnAccountProfileFromJson(Map<String, dynamic> json) =>
|
|||||||
json['birthday'] == null
|
json['birthday'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json['birthday'] as String),
|
: DateTime.parse(json['birthday'] as String),
|
||||||
|
links:
|
||||||
|
(json['links'] as Map<String, dynamic>?)?.map(
|
||||||
|
(k, e) => MapEntry(k, e as String),
|
||||||
|
) ??
|
||||||
|
const {},
|
||||||
lastSeenAt:
|
lastSeenAt:
|
||||||
json['last_seen_at'] == null
|
json['last_seen_at'] == null
|
||||||
? null
|
? null
|
||||||
@@ -111,6 +116,7 @@ Map<String, dynamic> _$SnAccountProfileToJson(_SnAccountProfile instance) =>
|
|||||||
'location': instance.location,
|
'location': instance.location,
|
||||||
'time_zone': instance.timeZone,
|
'time_zone': instance.timeZone,
|
||||||
'birthday': instance.birthday?.toIso8601String(),
|
'birthday': instance.birthday?.toIso8601String(),
|
||||||
|
'links': instance.links,
|
||||||
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
|
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
|
||||||
'active_badge': instance.activeBadge?.toJson(),
|
'active_badge': instance.activeBadge?.toJson(),
|
||||||
'experience': instance.experience,
|
'experience': instance.experience,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'call.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$callNotifierHash() => r'333a1cd566a339644c83932e15dae03f1c5cc24b';
|
String _$callNotifierHash() => r'18fb807f067eecd3ea42631c1426c3e5f1fb4280';
|
||||||
|
|
||||||
/// See also [CallNotifier].
|
/// See also [CallNotifier].
|
||||||
@ProviderFor(CallNotifier)
|
@ProviderFor(CallNotifier)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
@@ -18,6 +17,8 @@ sealed class WebSocketState with _$WebSocketState {
|
|||||||
const factory WebSocketState.connected() = _Connected;
|
const factory WebSocketState.connected() = _Connected;
|
||||||
const factory WebSocketState.connecting() = _Connecting;
|
const factory WebSocketState.connecting() = _Connecting;
|
||||||
const factory WebSocketState.disconnected() = _Disconnected;
|
const factory WebSocketState.disconnected() = _Disconnected;
|
||||||
|
const factory WebSocketState.serverDown() = _ServerDown;
|
||||||
|
const factory WebSocketState.duplicateDevice() = _DuplicateDevice;
|
||||||
const factory WebSocketState.error(String message) = _Error;
|
const factory WebSocketState.error(String message) = _Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ class WebSocketService {
|
|||||||
Timer? _heartbeatTimer;
|
Timer? _heartbeatTimer;
|
||||||
|
|
||||||
DateTime? _heartbeatAt;
|
DateTime? _heartbeatAt;
|
||||||
Duration? _heartbeatDelay;
|
Duration? heartbeatDelay;
|
||||||
|
|
||||||
Stream<WebSocketPacket> get dataStream => _streamController.stream;
|
Stream<WebSocketPacket> get dataStream => _streamController.stream;
|
||||||
Stream<WebSocketState> get statusStream => _statusStreamController.stream;
|
Stream<WebSocketState> get statusStream => _statusStreamController.stream;
|
||||||
@@ -81,15 +82,20 @@ class WebSocketService {
|
|||||||
final dataStr =
|
final dataStr =
|
||||||
data is Uint8List ? utf8.decode(data) : data.toString();
|
data is Uint8List ? utf8.decode(data) : data.toString();
|
||||||
final packet = WebSocketPacket.fromJson(jsonDecode(dataStr));
|
final packet = WebSocketPacket.fromJson(jsonDecode(dataStr));
|
||||||
|
if (packet.type == 'error.dupe') {
|
||||||
|
_statusStreamController.sink.add(WebSocketState.duplicateDevice());
|
||||||
|
_channel!.sink.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
_streamController.sink.add(packet);
|
_streamController.sink.add(packet);
|
||||||
log(
|
log(
|
||||||
"[WebSocket] Received packet: ${packet.type} ${packet.errorMessage}",
|
"[WebSocket] Received packet: ${packet.type} ${packet.errorMessage}",
|
||||||
);
|
);
|
||||||
if (packet.type == 'pong' && _heartbeatAt != null) {
|
if (packet.type == 'pong' && _heartbeatAt != null) {
|
||||||
var now = DateTime.now();
|
var now = DateTime.now();
|
||||||
_heartbeatDelay = now.difference(_heartbeatAt!);
|
heartbeatDelay = now.difference(_heartbeatAt!);
|
||||||
log(
|
log(
|
||||||
"[WebSocket] Server respond last heartbeat for ${_heartbeatDelay!.inMilliseconds} ms",
|
"[WebSocket] Server respond last heartbeat for ${heartbeatDelay!.inMilliseconds} ms",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,13 +61,15 @@ extension WebSocketStatePatterns on WebSocketState {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Connected value)? connected,TResult Function( _Connecting value)? connecting,TResult Function( _Disconnected value)? disconnected,TResult Function( _Error value)? error,required TResult orElse(),}){
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Connected value)? connected,TResult Function( _Connecting value)? connecting,TResult Function( _Disconnected value)? disconnected,TResult Function( _ServerDown value)? serverDown,TResult Function( _DuplicateDevice value)? duplicateDevice,TResult Function( _Error value)? error,required TResult orElse(),}){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _Connected() when connected != null:
|
case _Connected() when connected != null:
|
||||||
return connected(_that);case _Connecting() when connecting != null:
|
return connected(_that);case _Connecting() when connecting != null:
|
||||||
return connecting(_that);case _Disconnected() when disconnected != null:
|
return connecting(_that);case _Disconnected() when disconnected != null:
|
||||||
return disconnected(_that);case _Error() when error != null:
|
return disconnected(_that);case _ServerDown() when serverDown != null:
|
||||||
|
return serverDown(_that);case _DuplicateDevice() when duplicateDevice != null:
|
||||||
|
return duplicateDevice(_that);case _Error() when error != null:
|
||||||
return error(_that);case _:
|
return error(_that);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -86,13 +88,15 @@ return error(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Connected value) connected,required TResult Function( _Connecting value) connecting,required TResult Function( _Disconnected value) disconnected,required TResult Function( _Error value) error,}){
|
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Connected value) connected,required TResult Function( _Connecting value) connecting,required TResult Function( _Disconnected value) disconnected,required TResult Function( _ServerDown value) serverDown,required TResult Function( _DuplicateDevice value) duplicateDevice,required TResult Function( _Error value) error,}){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _Connected():
|
case _Connected():
|
||||||
return connected(_that);case _Connecting():
|
return connected(_that);case _Connecting():
|
||||||
return connecting(_that);case _Disconnected():
|
return connecting(_that);case _Disconnected():
|
||||||
return disconnected(_that);case _Error():
|
return disconnected(_that);case _ServerDown():
|
||||||
|
return serverDown(_that);case _DuplicateDevice():
|
||||||
|
return duplicateDevice(_that);case _Error():
|
||||||
return error(_that);}
|
return error(_that);}
|
||||||
}
|
}
|
||||||
/// A variant of `map` that fallback to returning `null`.
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
@@ -107,13 +111,15 @@ return error(_that);}
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Connected value)? connected,TResult? Function( _Connecting value)? connecting,TResult? Function( _Disconnected value)? disconnected,TResult? Function( _Error value)? error,}){
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Connected value)? connected,TResult? Function( _Connecting value)? connecting,TResult? Function( _Disconnected value)? disconnected,TResult? Function( _ServerDown value)? serverDown,TResult? Function( _DuplicateDevice value)? duplicateDevice,TResult? Function( _Error value)? error,}){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _Connected() when connected != null:
|
case _Connected() when connected != null:
|
||||||
return connected(_that);case _Connecting() when connecting != null:
|
return connected(_that);case _Connecting() when connecting != null:
|
||||||
return connecting(_that);case _Disconnected() when disconnected != null:
|
return connecting(_that);case _Disconnected() when disconnected != null:
|
||||||
return disconnected(_that);case _Error() when error != null:
|
return disconnected(_that);case _ServerDown() when serverDown != null:
|
||||||
|
return serverDown(_that);case _DuplicateDevice() when duplicateDevice != null:
|
||||||
|
return duplicateDevice(_that);case _Error() when error != null:
|
||||||
return error(_that);case _:
|
return error(_that);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -131,12 +137,14 @@ return error(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? connected,TResult Function()? connecting,TResult Function()? disconnected,TResult Function( String message)? error,required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? connected,TResult Function()? connecting,TResult Function()? disconnected,TResult Function()? serverDown,TResult Function()? duplicateDevice,TResult Function( String message)? error,required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _Connected() when connected != null:
|
case _Connected() when connected != null:
|
||||||
return connected();case _Connecting() when connecting != null:
|
return connected();case _Connecting() when connecting != null:
|
||||||
return connecting();case _Disconnected() when disconnected != null:
|
return connecting();case _Disconnected() when disconnected != null:
|
||||||
return disconnected();case _Error() when error != null:
|
return disconnected();case _ServerDown() when serverDown != null:
|
||||||
|
return serverDown();case _DuplicateDevice() when duplicateDevice != null:
|
||||||
|
return duplicateDevice();case _Error() when error != null:
|
||||||
return error(_that.message);case _:
|
return error(_that.message);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -155,12 +163,14 @@ return error(_that.message);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() connected,required TResult Function() connecting,required TResult Function() disconnected,required TResult Function( String message) error,}) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() connected,required TResult Function() connecting,required TResult Function() disconnected,required TResult Function() serverDown,required TResult Function() duplicateDevice,required TResult Function( String message) error,}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _Connected():
|
case _Connected():
|
||||||
return connected();case _Connecting():
|
return connected();case _Connecting():
|
||||||
return connecting();case _Disconnected():
|
return connecting();case _Disconnected():
|
||||||
return disconnected();case _Error():
|
return disconnected();case _ServerDown():
|
||||||
|
return serverDown();case _DuplicateDevice():
|
||||||
|
return duplicateDevice();case _Error():
|
||||||
return error(_that.message);}
|
return error(_that.message);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
@@ -175,12 +185,14 @@ return error(_that.message);}
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? connected,TResult? Function()? connecting,TResult? Function()? disconnected,TResult? Function( String message)? error,}) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? connected,TResult? Function()? connecting,TResult? Function()? disconnected,TResult? Function()? serverDown,TResult? Function()? duplicateDevice,TResult? Function( String message)? error,}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _Connected() when connected != null:
|
case _Connected() when connected != null:
|
||||||
return connected();case _Connecting() when connecting != null:
|
return connected();case _Connecting() when connecting != null:
|
||||||
return connecting();case _Disconnected() when disconnected != null:
|
return connecting();case _Disconnected() when disconnected != null:
|
||||||
return disconnected();case _Error() when error != null:
|
return disconnected();case _ServerDown() when serverDown != null:
|
||||||
|
return serverDown();case _DuplicateDevice() when duplicateDevice != null:
|
||||||
|
return duplicateDevice();case _Error() when error != null:
|
||||||
return error(_that.message);case _:
|
return error(_that.message);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -303,6 +315,82 @@ String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _ServerDown with DiagnosticableTreeMixin implements WebSocketState {
|
||||||
|
const _ServerDown();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('type', 'WebSocketState.serverDown'))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
|
||||||
|
return 'WebSocketState.serverDown()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _DuplicateDevice with DiagnosticableTreeMixin implements WebSocketState {
|
||||||
|
const _DuplicateDevice();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('type', 'WebSocketState.duplicateDevice'))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DuplicateDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
|
||||||
|
return 'WebSocketState.duplicateDevice()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:island/screens/developers/edit_app.dart';
|
|||||||
import 'package:island/screens/developers/new_app.dart';
|
import 'package:island/screens/developers/new_app.dart';
|
||||||
import 'package:island/screens/developers/hub.dart';
|
import 'package:island/screens/developers/hub.dart';
|
||||||
import 'package:island/screens/discovery/articles.dart';
|
import 'package:island/screens/discovery/articles.dart';
|
||||||
|
import 'package:island/screens/posts/post_category_detail.dart';
|
||||||
import 'package:island/screens/posts/post_search.dart';
|
import 'package:island/screens/posts/post_search.dart';
|
||||||
import 'package:island/widgets/app_wrapper.dart';
|
import 'package:island/widgets/app_wrapper.dart';
|
||||||
import 'package:island/screens/tabs.dart';
|
import 'package:island/screens/tabs.dart';
|
||||||
@@ -28,9 +29,13 @@ import 'package:island/screens/creators/hub.dart';
|
|||||||
import 'package:island/screens/creators/posts/post_manage_list.dart';
|
import 'package:island/screens/creators/posts/post_manage_list.dart';
|
||||||
import 'package:island/screens/creators/stickers/stickers.dart';
|
import 'package:island/screens/creators/stickers/stickers.dart';
|
||||||
import 'package:island/screens/creators/stickers/pack_detail.dart';
|
import 'package:island/screens/creators/stickers/pack_detail.dart';
|
||||||
|
import 'package:island/screens/stickers/marketplace.dart';
|
||||||
|
import 'package:island/screens/stickers/pack_detail.dart';
|
||||||
|
import 'package:island/screens/creators/poll/poll_list.dart';
|
||||||
import 'package:island/screens/creators/publishers.dart';
|
import 'package:island/screens/creators/publishers.dart';
|
||||||
import 'package:island/screens/creators/webfeed/webfeed_list.dart';
|
import 'package:island/screens/creators/webfeed/webfeed_list.dart';
|
||||||
import 'package:island/screens/creators/webfeed/webfeed_edit.dart';
|
import 'package:island/screens/creators/webfeed/webfeed_edit.dart';
|
||||||
|
import 'package:island/screens/poll/poll_editor.dart';
|
||||||
import 'package:island/screens/posts/compose.dart';
|
import 'package:island/screens/posts/compose.dart';
|
||||||
import 'package:island/screens/posts/post_detail.dart';
|
import 'package:island/screens/posts/post_detail.dart';
|
||||||
import 'package:island/screens/posts/pub_profile.dart';
|
import 'package:island/screens/posts/pub_profile.dart';
|
||||||
@@ -144,6 +149,37 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
return CreatorPostListScreen(pubName: name);
|
return CreatorPostListScreen(pubName: name);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
// Poll list route
|
||||||
|
GoRoute(
|
||||||
|
name: 'creatorPolls',
|
||||||
|
path: '/creators/:name/polls',
|
||||||
|
builder: (context, state) {
|
||||||
|
final name = state.pathParameters['name']!;
|
||||||
|
return CreatorPollListScreen(pubName: name);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// Poll routes
|
||||||
|
GoRoute(
|
||||||
|
name: 'creatorPollNew',
|
||||||
|
path: '/creators/:name/polls/new',
|
||||||
|
builder: (context, state) {
|
||||||
|
final name = state.pathParameters['name']!;
|
||||||
|
// initialPollId left null for create; initialPublisher prefilled
|
||||||
|
return PollEditorScreen(initialPublisher: name);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
name: 'creatorPollEdit',
|
||||||
|
path: '/creators/:name/polls/:id/edit',
|
||||||
|
builder: (context, state) {
|
||||||
|
final name = state.pathParameters['name']!;
|
||||||
|
final id = state.pathParameters['id']!;
|
||||||
|
return PollEditorScreen(
|
||||||
|
initialPollId: id,
|
||||||
|
initialPublisher: name,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
name: 'creatorStickers',
|
name: 'creatorStickers',
|
||||||
path: '/creators/:name/stickers',
|
path: '/creators/:name/stickers',
|
||||||
@@ -287,15 +323,6 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
builder: (context, state) => const AboutScreen(),
|
builder: (context, state) => const AboutScreen(),
|
||||||
),
|
),
|
||||||
|
|
||||||
GoRoute(
|
|
||||||
name: 'reportDetail',
|
|
||||||
path: '/safety/reports/me/:id',
|
|
||||||
builder: (context, state) {
|
|
||||||
final id = state.pathParameters['id']!;
|
|
||||||
return AbuseReportDetailScreen(reportId: id);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
// Main tabs with TabsScreen shell
|
// Main tabs with TabsScreen shell
|
||||||
ShellRoute(
|
ShellRoute(
|
||||||
navigatorKey: _tabsShellKey,
|
navigatorKey: _tabsShellKey,
|
||||||
@@ -322,6 +349,25 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
return PostDetailScreen(id: id);
|
return PostDetailScreen(id: id);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
name: 'postCategoryDetail',
|
||||||
|
path: '/posts/categories/:slug',
|
||||||
|
builder: (context, state) {
|
||||||
|
final slug = state.pathParameters['slug']!;
|
||||||
|
return PostCategoryDetailScreen(slug: slug, isCategory: true);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
name: 'postTagDetail',
|
||||||
|
path: '/posts/tags/:slug',
|
||||||
|
builder: (context, state) {
|
||||||
|
final slug = state.pathParameters['slug']!;
|
||||||
|
return PostCategoryDetailScreen(
|
||||||
|
slug: slug,
|
||||||
|
isCategory: false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
name: 'publisherProfile',
|
name: 'publisherProfile',
|
||||||
path: '/publishers/:name',
|
path: '/publishers/:name',
|
||||||
@@ -418,6 +464,23 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
path: '/account',
|
path: '/account',
|
||||||
builder: (context, state) => const AccountScreen(),
|
builder: (context, state) => const AccountScreen(),
|
||||||
),
|
),
|
||||||
|
// Sticker marketplace (user-facing, no publisher)
|
||||||
|
GoRoute(
|
||||||
|
name: 'stickerMarketplace',
|
||||||
|
path: '/stickers',
|
||||||
|
builder:
|
||||||
|
(context, state) => const MarketplaceStickersScreen(),
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
name: 'stickerPackDetail',
|
||||||
|
path: ':packId',
|
||||||
|
builder: (context, state) {
|
||||||
|
final packId = state.pathParameters['packId']!;
|
||||||
|
return MarketplaceStickerPackDetailScreen(id: packId);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
name: 'notifications',
|
name: 'notifications',
|
||||||
path: '/account/notifications',
|
path: '/account/notifications',
|
||||||
@@ -453,6 +516,14 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
path: '/safety/reports/me',
|
path: '/safety/reports/me',
|
||||||
builder: (context, state) => const AbuseReportListScreen(),
|
builder: (context, state) => const AbuseReportListScreen(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
name: 'reportDetail',
|
||||||
|
path: '/safety/reports/me/:id',
|
||||||
|
builder: (context, state) {
|
||||||
|
final id = state.pathParameters['id']!;
|
||||||
|
return AbuseReportDetailScreen(reportId: id);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import 'package:island/widgets/app_scaffold.dart';
|
|||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:island/services/update_service.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
@@ -100,196 +102,243 @@ class _AboutScreenState extends ConsumerState<AboutScreen> {
|
|||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: _errorMessage != null
|
: _errorMessage != null
|
||||||
? Center(child: Text(_errorMessage!))
|
? Center(child: Text(_errorMessage!))
|
||||||
: SingleChildScrollView(
|
: Center(
|
||||||
child: Column(
|
child: ConstrainedBox(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
constraints: const BoxConstraints(maxWidth: 540),
|
||||||
children: [
|
child: SingleChildScrollView(
|
||||||
const SizedBox(height: 24),
|
child: Column(
|
||||||
// App Icon and Name
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
CircleAvatar(
|
|
||||||
radius: 50,
|
|
||||||
backgroundColor: theme.colorScheme.primary.withOpacity(
|
|
||||||
0.1,
|
|
||||||
),
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/icons/icon.png',
|
|
||||||
width: 56,
|
|
||||||
height: 56,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Text(
|
|
||||||
_packageInfo.appName,
|
|
||||||
style: theme.textTheme.headlineSmall?.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'aboutScreenVersionInfo'.tr(
|
|
||||||
args: [_packageInfo.version, _packageInfo.buildNumber],
|
|
||||||
),
|
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: theme.textTheme.bodySmall?.color,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
|
|
||||||
// App Info Card
|
|
||||||
_buildSection(
|
|
||||||
context,
|
|
||||||
title: 'aboutScreenAppInfoSectionTitle'.tr(),
|
|
||||||
children: [
|
children: [
|
||||||
_buildInfoItem(
|
const SizedBox(height: 24),
|
||||||
context,
|
// App Icon and Name
|
||||||
icon: Symbols.info,
|
CircleAvatar(
|
||||||
label: 'aboutScreenPackageNameLabel'.tr(),
|
radius: 50,
|
||||||
value: _packageInfo.packageName,
|
backgroundColor: theme.colorScheme.primary
|
||||||
),
|
.withOpacity(0.1),
|
||||||
_buildInfoItem(
|
child: Image.asset(
|
||||||
context,
|
'assets/icons/icon.png',
|
||||||
icon: Symbols.update,
|
width: 56,
|
||||||
label: 'aboutScreenVersionLabel'.tr(),
|
height: 56,
|
||||||
value: _packageInfo.version,
|
|
||||||
),
|
|
||||||
_buildInfoItem(
|
|
||||||
context,
|
|
||||||
icon: Symbols.build,
|
|
||||||
label: 'aboutScreenBuildNumberLabel'.tr(),
|
|
||||||
value: _packageInfo.buildNumber,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
if (_deviceInfo != null) const SizedBox(height: 16),
|
|
||||||
|
|
||||||
if (_deviceInfo != null)
|
|
||||||
_buildSection(
|
|
||||||
context,
|
|
||||||
title: 'Device Information',
|
|
||||||
children: [
|
|
||||||
_buildInfoItem(
|
|
||||||
context,
|
|
||||||
icon: Symbols.label,
|
|
||||||
label: 'aboutDeviceName'.tr(),
|
|
||||||
value: _deviceInfo?.data['name'],
|
|
||||||
),
|
),
|
||||||
_buildInfoItem(
|
),
|
||||||
context,
|
const SizedBox(height: 16),
|
||||||
icon: Symbols.fingerprint,
|
Text(
|
||||||
label: 'aboutDeviceIdentifier'.tr(),
|
_packageInfo.appName,
|
||||||
value: _deviceUdid ?? 'N/A',
|
style: theme.textTheme.headlineSmall?.copyWith(
|
||||||
copyable: true,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
// Links Card
|
|
||||||
_buildSection(
|
|
||||||
context,
|
|
||||||
title: 'aboutScreenLinksSectionTitle'.tr(),
|
|
||||||
children: [
|
|
||||||
_buildListTile(
|
|
||||||
context,
|
|
||||||
icon: Symbols.privacy_tip,
|
|
||||||
title: 'aboutScreenPrivacyPolicyTitle'.tr(),
|
|
||||||
onTap:
|
|
||||||
() => _launchURL(
|
|
||||||
'https://solsynth.dev/terms/privacy-policy',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
_buildListTile(
|
Text(
|
||||||
context,
|
'aboutScreenVersionInfo'.tr(
|
||||||
icon: Symbols.description,
|
args: [
|
||||||
title: 'aboutScreenTermsOfServiceTitle'.tr(),
|
_packageInfo.version,
|
||||||
onTap:
|
_packageInfo.buildNumber,
|
||||||
() => _launchURL(
|
],
|
||||||
'https://solsynth.dev/terms/basic-law',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_buildListTile(
|
|
||||||
context,
|
|
||||||
icon: Symbols.code,
|
|
||||||
title: 'aboutScreenOpenSourceLicensesTitle'.tr(),
|
|
||||||
onTap: () {
|
|
||||||
showLicensePage(
|
|
||||||
context: context,
|
|
||||||
applicationName: _packageInfo.appName,
|
|
||||||
applicationVersion:
|
|
||||||
'Version ${_packageInfo.version}',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
// Developer Info
|
|
||||||
_buildSection(
|
|
||||||
context,
|
|
||||||
title: 'aboutScreenDeveloperSectionTitle'.tr(),
|
|
||||||
children: [
|
|
||||||
_buildListTile(
|
|
||||||
context,
|
|
||||||
icon: Symbols.email,
|
|
||||||
title: 'aboutScreenContactUsTitle'.tr(),
|
|
||||||
subtitle: 'lily@solsynth.dev',
|
|
||||||
onTap: () => _launchURL('mailto:lily@solsynth.dev'),
|
|
||||||
),
|
|
||||||
_buildListTile(
|
|
||||||
context,
|
|
||||||
icon: Symbols.copyright,
|
|
||||||
title: 'aboutScreenLicenseTitle'.tr(),
|
|
||||||
subtitle: 'aboutScreenLicenseContent'.tr(
|
|
||||||
args: [DateTime.now().year.toString()],
|
|
||||||
),
|
),
|
||||||
onTap:
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
() => _launchURL(
|
color: theme.textTheme.bodySmall?.color,
|
||||||
'https://github.com/Solsynth/Solian/blob/v3/LICENSE.txt',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (kIsWeb || !(Platform.isMacOS || Platform.isIOS))
|
|
||||||
_buildListTile(
|
|
||||||
context,
|
|
||||||
icon: Symbols.favorite,
|
|
||||||
title: 'donate'.tr(),
|
|
||||||
subtitle: 'donateDescription'.tr(),
|
|
||||||
onTap: () {
|
|
||||||
launchUrlString(
|
|
||||||
'https://afdian.com/@littlesheep',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
const SizedBox(height: 32),
|
// App Info Card
|
||||||
|
_buildSection(
|
||||||
// Copyright
|
context,
|
||||||
Padding(
|
title: 'aboutScreenAppInfoSectionTitle'.tr(),
|
||||||
padding: const EdgeInsets.all(16.0),
|
children: [
|
||||||
child: Column(
|
_buildInfoItem(
|
||||||
children: [
|
context,
|
||||||
Text(
|
icon: Symbols.info,
|
||||||
'aboutScreenCopyright'.tr(
|
label: 'aboutScreenPackageNameLabel'.tr(),
|
||||||
args: [DateTime.now().year.toString()],
|
value: _packageInfo.packageName,
|
||||||
),
|
),
|
||||||
style: theme.textTheme.bodySmall,
|
_buildInfoItem(
|
||||||
textAlign: TextAlign.center,
|
context,
|
||||||
),
|
icon: Symbols.update,
|
||||||
const Gap(1),
|
label: 'aboutScreenVersionLabel'.tr(),
|
||||||
Text(
|
value: _packageInfo.version,
|
||||||
'aboutScreenMadeWith'.tr(),
|
),
|
||||||
textAlign: TextAlign.center,
|
_buildInfoItem(
|
||||||
).fontSize(10).opacity(0.8),
|
context,
|
||||||
],
|
icon: Symbols.build,
|
||||||
),
|
label: 'aboutScreenBuildNumberLabel'.tr(),
|
||||||
),
|
value: _packageInfo.buildNumber,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
Gap(MediaQuery.of(context).padding.bottom + 16),
|
if (_deviceInfo != null) const SizedBox(height: 16),
|
||||||
],
|
|
||||||
|
if (_deviceInfo != null)
|
||||||
|
_buildSection(
|
||||||
|
context,
|
||||||
|
title: 'Device Information',
|
||||||
|
children: [
|
||||||
|
_buildInfoItem(
|
||||||
|
context,
|
||||||
|
icon: Symbols.label,
|
||||||
|
label: 'aboutDeviceName'.tr(),
|
||||||
|
value: _deviceInfo?.data['name'],
|
||||||
|
),
|
||||||
|
_buildInfoItem(
|
||||||
|
context,
|
||||||
|
icon: Symbols.fingerprint,
|
||||||
|
label: 'aboutDeviceIdentifier'.tr(),
|
||||||
|
value: _deviceUdid ?? 'N/A',
|
||||||
|
copyable: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Links Card
|
||||||
|
_buildSection(
|
||||||
|
context,
|
||||||
|
title: 'aboutScreenLinksSectionTitle'.tr(),
|
||||||
|
children: [
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.system_update,
|
||||||
|
title: 'Check for updates',
|
||||||
|
onTap: () async {
|
||||||
|
// Fetch latest release and show the unified sheet
|
||||||
|
final svc = UpdateService();
|
||||||
|
// Reuse service fetch + compare to decide content
|
||||||
|
final release = await svc.fetchLatestRelease();
|
||||||
|
if (release != null) {
|
||||||
|
await svc.showUpdateSheet(context, release);
|
||||||
|
} else {
|
||||||
|
// Fallback: show a simple sheet indicating no info
|
||||||
|
// Use your SheetScaffold for consistent styling
|
||||||
|
// Show a minimal message
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
useSafeArea: true,
|
||||||
|
showDragHandle: true,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.surface,
|
||||||
|
builder:
|
||||||
|
(_) => const SheetScaffold(
|
||||||
|
titleText: 'Update',
|
||||||
|
child: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(24),
|
||||||
|
child: Text(
|
||||||
|
'Unable to fetch release info at this time.',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.privacy_tip,
|
||||||
|
title: 'aboutScreenPrivacyPolicyTitle'.tr(),
|
||||||
|
onTap:
|
||||||
|
() => _launchURL(
|
||||||
|
'https://solsynth.dev/terms/privacy-policy',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.description,
|
||||||
|
title: 'aboutScreenTermsOfServiceTitle'.tr(),
|
||||||
|
onTap:
|
||||||
|
() => _launchURL(
|
||||||
|
'https://solsynth.dev/terms/user-agreement',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.code,
|
||||||
|
title: 'aboutScreenOpenSourceLicensesTitle'.tr(),
|
||||||
|
onTap: () {
|
||||||
|
showLicensePage(
|
||||||
|
context: context,
|
||||||
|
applicationName: _packageInfo.appName,
|
||||||
|
applicationVersion:
|
||||||
|
'Version ${_packageInfo.version}',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Developer Info
|
||||||
|
_buildSection(
|
||||||
|
context,
|
||||||
|
title: 'aboutScreenDeveloperSectionTitle'.tr(),
|
||||||
|
children: [
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.email,
|
||||||
|
title: 'aboutScreenContactUsTitle'.tr(),
|
||||||
|
subtitle: 'lily@solsynth.dev',
|
||||||
|
onTap:
|
||||||
|
() => _launchURL('mailto:lily@solsynth.dev'),
|
||||||
|
),
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.copyright,
|
||||||
|
title: 'aboutScreenLicenseTitle'.tr(),
|
||||||
|
subtitle: 'aboutScreenLicenseContent'.tr(
|
||||||
|
args: [DateTime.now().year.toString()],
|
||||||
|
),
|
||||||
|
onTap:
|
||||||
|
() => _launchURL(
|
||||||
|
'https://github.com/Solsynth/Solian/blob/v3/LICENSE.txt',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (kIsWeb || !(Platform.isMacOS || Platform.isIOS))
|
||||||
|
_buildListTile(
|
||||||
|
context,
|
||||||
|
icon: Symbols.favorite,
|
||||||
|
title: 'donate'.tr(),
|
||||||
|
subtitle: 'donateDescription'.tr(),
|
||||||
|
onTap: () {
|
||||||
|
launchUrlString(
|
||||||
|
'https://afdian.com/@littlesheep',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
|
// Copyright
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'aboutScreenCopyright'.tr(
|
||||||
|
args: [DateTime.now().year.toString()],
|
||||||
|
),
|
||||||
|
style: theme.textTheme.bodySmall,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const Gap(1),
|
||||||
|
Text(
|
||||||
|
'aboutScreenMadeWith'.tr(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
).fontSize(10).opacity(0.8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Gap(MediaQuery.of(context).padding.bottom + 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/pods/message.dart';
|
|
||||||
import 'package:island/pods/network.dart';
|
|
||||||
import 'package:island/pods/userinfo.dart';
|
import 'package:island/pods/userinfo.dart';
|
||||||
import 'package:island/screens/notification.dart';
|
import 'package:island/screens/notification.dart';
|
||||||
import 'package:island/services/responsive.dart';
|
import 'package:island/services/responsive.dart';
|
||||||
@@ -15,6 +11,7 @@ import 'package:island/widgets/account/status.dart';
|
|||||||
import 'package:island/widgets/account/leveling_progress.dart';
|
import 'package:island/widgets/account/leveling_progress.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/debug_sheet.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
@@ -189,7 +186,6 @@ class AccountScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
).padding(horizontal: 8),
|
).padding(horizontal: 8),
|
||||||
const Gap(8),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
leading: const Icon(Symbols.notifications),
|
leading: const Icon(Symbols.notifications),
|
||||||
@@ -228,6 +224,16 @@ class AccountScreen extends HookConsumerWidget {
|
|||||||
context.pushNamed('relationships');
|
context.pushNamed('relationships');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.emoji_emotions),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
title: Text('stickers').tr(),
|
||||||
|
onTap: () {
|
||||||
|
context.pushNamed('stickerMarketplace');
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
title: Text('abuseReports').tr(),
|
title: Text('abuseReports').tr(),
|
||||||
@@ -267,30 +273,6 @@ class AccountScreen extends HookConsumerWidget {
|
|||||||
context.pushNamed('accountSettings');
|
context.pushNamed('accountSettings');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (kDebugMode) const Divider(height: 1).padding(vertical: 8),
|
|
||||||
if (kDebugMode)
|
|
||||||
ListTile(
|
|
||||||
minTileHeight: 48,
|
|
||||||
leading: const Icon(Symbols.copy_all),
|
|
||||||
trailing: const Icon(Symbols.chevron_right),
|
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
title: Text('Copy access token'),
|
|
||||||
onTap: () async {
|
|
||||||
final tk = ref.watch(tokenProvider);
|
|
||||||
Clipboard.setData(ClipboardData(text: tk!.token));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (kDebugMode)
|
|
||||||
ListTile(
|
|
||||||
minTileHeight: 48,
|
|
||||||
leading: const Icon(Symbols.delete),
|
|
||||||
trailing: const Icon(Symbols.chevron_right),
|
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
title: Text('Reset database'),
|
|
||||||
onTap: () async {
|
|
||||||
resetDatabase(ref);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Divider(height: 1).padding(vertical: 8),
|
const Divider(height: 1).padding(vertical: 8),
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
@@ -302,6 +284,19 @@ class AccountScreen extends HookConsumerWidget {
|
|||||||
context.pushNamed('about');
|
context.pushNamed('about');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.bug_report),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
title: Text('debugOptions').tr(),
|
||||||
|
onTap: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => DebugSheet(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
leading: const Icon(Symbols.logout),
|
leading: const Icon(Symbols.logout),
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ class LevelingScreen extends HookConsumerWidget {
|
|||||||
try {
|
try {
|
||||||
showLoadingModal(context);
|
showLoadingModal(context);
|
||||||
final client = ref.watch(apiClientProvider);
|
final client = ref.watch(apiClientProvider);
|
||||||
await client.post('/subscriptions/${membership.identifier}/cancel');
|
await client.post('/id/subscriptions/${membership.identifier}/cancel');
|
||||||
ref.invalidate(accountStellarSubscriptionProvider);
|
ref.invalidate(accountStellarSubscriptionProvider);
|
||||||
ref.read(userInfoProvider.notifier).fetchUser();
|
ref.read(userInfoProvider.notifier).fetchUser();
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
@@ -603,7 +603,7 @@ class LevelingScreen extends HookConsumerWidget {
|
|||||||
try {
|
try {
|
||||||
showLoadingModal(context);
|
showLoadingModal(context);
|
||||||
final resp = await client.post(
|
final resp = await client.post(
|
||||||
'/subscriptions',
|
'/id/subscriptions',
|
||||||
data: {
|
data: {
|
||||||
'identifier': tierId,
|
'identifier': tierId,
|
||||||
'payment_method': 'solian.wallet',
|
'payment_method': 'solian.wallet',
|
||||||
@@ -615,7 +615,7 @@ class LevelingScreen extends HookConsumerWidget {
|
|||||||
final subscription = SnWalletSubscription.fromJson(resp.data);
|
final subscription = SnWalletSubscription.fromJson(resp.data);
|
||||||
if (subscription.status == 1) return;
|
if (subscription.status == 1) return;
|
||||||
final orderResp = await client.post(
|
final orderResp = await client.post(
|
||||||
'/subscriptions/${subscription.identifier}/order',
|
'/id/subscriptions/${subscription.identifier}/order',
|
||||||
);
|
);
|
||||||
final order = SnWalletOrder.fromJson(orderResp.data);
|
final order = SnWalletOrder.fromJson(orderResp.data);
|
||||||
|
|
||||||
@@ -633,7 +633,7 @@ class LevelingScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
if (paidOrder != null) {
|
if (paidOrder != null) {
|
||||||
await client.post(
|
await client.post(
|
||||||
'/subscriptions/order/handle',
|
'/id/subscriptions/order/handle',
|
||||||
data: {'order_id': paidOrder.id},
|
data: {'order_id': paidOrder.id},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:dropdown_button2/dropdown_button2.dart';
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
@@ -94,6 +95,11 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
|||||||
final usernameController = useTextEditingController(text: user.value!.name);
|
final usernameController = useTextEditingController(text: user.value!.name);
|
||||||
final nicknameController = useTextEditingController(text: user.value!.nick);
|
final nicknameController = useTextEditingController(text: user.value!.nick);
|
||||||
final language = useState(user.value!.language);
|
final language = useState(user.value!.language);
|
||||||
|
final links = useState<List<Map<String, String>>>(
|
||||||
|
user.value!.profile.links.entries
|
||||||
|
.map((e) => {'key': e.key, 'value': e.value})
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
|
||||||
void updateBasicInfo() async {
|
void updateBasicInfo() async {
|
||||||
if (!formKeyBasicInfo.currentState!.validate()) return;
|
if (!formKeyBasicInfo.currentState!.validate()) return;
|
||||||
@@ -165,6 +171,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
|||||||
'location': locationController.text,
|
'location': locationController.text,
|
||||||
'time_zone': timeZoneController.text,
|
'time_zone': timeZoneController.text,
|
||||||
'birthday': birthday.value?.toUtc().toIso8601String(),
|
'birthday': birthday.value?.toUtc().toIso8601String(),
|
||||||
|
'links': {for (var e in links.value) e['key']!: e['value']!},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
final userNotifier = ref.read(userInfoProvider.notifier);
|
final userNotifier = ref.read(userInfoProvider.notifier);
|
||||||
@@ -558,6 +565,69 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Text('links').tr().bold().fontSize(18).padding(top: 16),
|
||||||
|
Column(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
for (var i = 0; i < links.value.length; i++)
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextFormField(
|
||||||
|
initialValue: links.value[i]['key'],
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'linkKey'.tr(),
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
links.value[i]['key'] = value;
|
||||||
|
},
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus
|
||||||
|
?.unfocus(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
Expanded(
|
||||||
|
child: TextFormField(
|
||||||
|
initialValue: links.value[i]['value'],
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'linkValue'.tr(),
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
links.value[i]['value'] = value;
|
||||||
|
},
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus
|
||||||
|
?.unfocus(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Symbols.delete),
|
||||||
|
onPressed: () {
|
||||||
|
links.value = List.from(links.value)
|
||||||
|
..removeAt(i);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: FilledButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
links.value = List.from(links.value)
|
||||||
|
..add({'key': '', 'value': ''});
|
||||||
|
},
|
||||||
|
label: Text('addLink').tr(),
|
||||||
|
icon: const Icon(Symbols.add),
|
||||||
|
).padding(top: 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import 'package:island/pods/network.dart';
|
|||||||
import 'package:island/pods/userinfo.dart';
|
import 'package:island/pods/userinfo.dart';
|
||||||
import 'package:island/services/color.dart';
|
import 'package:island/services/color.dart';
|
||||||
import 'package:island/services/responsive.dart';
|
import 'package:island/services/responsive.dart';
|
||||||
|
import 'package:island/services/text.dart';
|
||||||
import 'package:island/services/time.dart';
|
import 'package:island/services/time.dart';
|
||||||
import 'package:island/services/timezone/native.dart';
|
import 'package:island/services/timezone/native.dart';
|
||||||
import 'package:island/widgets/account/account_name.dart';
|
import 'package:island/widgets/account/account_name.dart';
|
||||||
@@ -23,11 +24,14 @@ import 'package:island/widgets/account/status.dart';
|
|||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/markdown.dart';
|
||||||
import 'package:island/widgets/safety/abuse_report_helper.dart';
|
import 'package:island/widgets/safety/abuse_report_helper.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:palette_generator/palette_generator.dart';
|
import 'package:palette_generator/palette_generator.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
part 'profile.g.dart';
|
part 'profile.g.dart';
|
||||||
|
|
||||||
@@ -264,66 +268,111 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
AccountName(account: data, style: TextStyle(fontSize: 20)),
|
AccountName(account: data, style: TextStyle(fontSize: 20)),
|
||||||
const Gap(6),
|
const Gap(6),
|
||||||
Text('@${data.name}').fontSize(14).opacity(0.85),
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
'@${data.name}',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
).fontSize(14).opacity(0.85),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
AccountStatusWidget(uname: name, padding: EdgeInsets.zero),
|
AccountStatusWidget(uname: name, padding: EdgeInsets.zero),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
SharePlus.instance.share(
|
||||||
|
ShareParams(
|
||||||
|
uri: Uri.parse('https://id.solian.app/@${data.name}'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(Symbols.share),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget accountProfileDetail(SnAccount data) => Column(
|
Widget accountProfileBio(SnAccount data) => Card(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
child: Column(
|
||||||
spacing: 24,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (buildSubcolumn(data).isNotEmpty)
|
Text('bio').tr().bold().fontSize(15).padding(bottom: 8),
|
||||||
Column(
|
if (data.profile.bio.isEmpty)
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Text('descriptionNone').tr().italic()
|
||||||
spacing: 2,
|
else
|
||||||
children: buildSubcolumn(data),
|
MarkdownTextContent(
|
||||||
),
|
content: data.profile.bio,
|
||||||
Column(
|
linesMargin: EdgeInsets.zero,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text('bio').tr().bold(),
|
|
||||||
Text(
|
|
||||||
data.profile.bio.isEmpty
|
|
||||||
? 'descriptionNone'.tr()
|
|
||||||
: data.profile.bio,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
).padding(horizontal: 24, vertical: 20),
|
||||||
if (data.profile.timeZone.isNotEmpty)
|
);
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Widget accountProfileDetail(SnAccount data) => Card(
|
||||||
children: [
|
child: Column(
|
||||||
Text('timeZone').tr().bold(),
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
Row(
|
spacing: 24,
|
||||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
children: [
|
||||||
textBaseline: TextBaseline.alphabetic,
|
if (buildSubcolumn(data).isNotEmpty)
|
||||||
spacing: 6,
|
Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(data.profile.timeZone),
|
spacing: 2,
|
||||||
Text(
|
children: buildSubcolumn(data),
|
||||||
getTzInfo(
|
),
|
||||||
data.profile.timeZone,
|
if (data.profile.timeZone.isNotEmpty)
|
||||||
).$2.formatCustomGlobal('HH:mm'),
|
Column(
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(
|
children: [
|
||||||
getTzInfo(data.profile.timeZone).$1.formatOffsetLocal(),
|
Text('timeZone').tr().bold(),
|
||||||
).fontSize(11),
|
Row(
|
||||||
Text(
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
'UTC${getTzInfo(data.profile.timeZone).$1.formatOffset()}',
|
textBaseline: TextBaseline.alphabetic,
|
||||||
).fontSize(11).opacity(0.75),
|
spacing: 6,
|
||||||
],
|
children: [
|
||||||
|
Text(data.profile.timeZone),
|
||||||
|
Text(
|
||||||
|
getTzInfo(
|
||||||
|
data.profile.timeZone,
|
||||||
|
).$2.formatCustomGlobal('HH:mm'),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
getTzInfo(data.profile.timeZone).$1.formatOffsetLocal(),
|
||||||
|
).fontSize(11),
|
||||||
|
Text(
|
||||||
|
'UTC${getTzInfo(data.profile.timeZone).$1.formatOffset()}',
|
||||||
|
).fontSize(11).opacity(0.75),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 16),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget accountProfileLinks(SnAccount data) => Card(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('links').tr().bold().padding(horizontal: 24, top: 12, bottom: 4),
|
||||||
|
for (final link in data.profile.links.entries)
|
||||||
|
ListTile(
|
||||||
|
title: Text(link.key.capitalizeEachWord()),
|
||||||
|
subtitle: Text(link.value),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
),
|
),
|
||||||
],
|
onTap: () {
|
||||||
),
|
launchUrlString(link.value);
|
||||||
],
|
},
|
||||||
).padding(horizontal: 24);
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Widget accountAction(SnAccount data) => Card(
|
Widget accountAction(SnAccount data) => Card(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -390,7 +439,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).padding(horizontal: 16),
|
),
|
||||||
Row(
|
Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
@@ -427,7 +476,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).padding(horizontal: 16, vertical: 8),
|
).padding(horizontal: 16, vertical: 12),
|
||||||
);
|
);
|
||||||
|
|
||||||
return account.when(
|
return account.when(
|
||||||
@@ -484,9 +533,11 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
SliverToBoxAdapter(child: accountBasicInfo(data)),
|
SliverToBoxAdapter(child: accountBasicInfo(data)),
|
||||||
if (data.badges.isNotEmpty)
|
if (data.badges.isNotEmpty)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: BadgeList(
|
child: Card(
|
||||||
badges: data.badges,
|
child: BadgeList(
|
||||||
).padding(horizontal: 24, bottom: 24),
|
badges: data.badges,
|
||||||
|
).padding(horizontal: 26, vertical: 20),
|
||||||
|
).padding(left: 2, right: 4),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -496,13 +547,25 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
level: data.profile.level,
|
level: data.profile.level,
|
||||||
experience: data.profile.experience,
|
experience: data.profile.experience,
|
||||||
progress: data.profile.levelingProgress,
|
progress: data.profile.levelingProgress,
|
||||||
),
|
).padding(left: 2, right: 4),
|
||||||
if (data.profile.verification != null)
|
if (data.profile.verification != null)
|
||||||
VerificationStatusCard(
|
Card(
|
||||||
mark: data.profile.verification!,
|
margin: EdgeInsets.zero,
|
||||||
|
child: VerificationStatusCard(
|
||||||
|
mark: data.profile.verification!,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).padding(horizontal: 20),
|
).padding(horizontal: 4, top: 8),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: accountProfileBio(data).padding(top: 4),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: accountProfileLinks(data),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: accountProfileDetail(data),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -510,10 +573,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverToBoxAdapter(
|
SliverGap(24),
|
||||||
child: accountProfileDetail(data),
|
|
||||||
),
|
|
||||||
|
|
||||||
if (user.value != null)
|
if (user.value != null)
|
||||||
SliverToBoxAdapter(child: accountAction(data)),
|
SliverToBoxAdapter(child: accountAction(data)),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
@@ -521,14 +581,15 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
child: FortuneGraphWidget(
|
child: FortuneGraphWidget(
|
||||||
events: accountEvents,
|
events: accountEvents,
|
||||||
eventCalanderUser: data.name,
|
eventCalanderUser: data.name,
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
),
|
),
|
||||||
).padding(all: 8),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
).padding(horizontal: 24)
|
||||||
: CustomScrollView(
|
: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverAppBar(
|
SliverAppBar(
|
||||||
@@ -573,40 +634,53 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
SliverToBoxAdapter(child: accountBasicInfo(data)),
|
SliverToBoxAdapter(child: accountBasicInfo(data)),
|
||||||
if (data.badges.isNotEmpty)
|
if (data.badges.isNotEmpty)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: BadgeList(
|
child: Card(
|
||||||
badges: data.badges,
|
child: BadgeList(
|
||||||
).padding(horizontal: 24, bottom: 24),
|
badges: data.badges,
|
||||||
|
).padding(horizontal: 26, vertical: 20),
|
||||||
|
).padding(horizontal: 4),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Column(
|
child: Column(
|
||||||
spacing: 12,
|
|
||||||
children: [
|
children: [
|
||||||
LevelingProgressCard(
|
LevelingProgressCard(
|
||||||
level: data.profile.level,
|
level: data.profile.level,
|
||||||
experience: data.profile.experience,
|
experience: data.profile.experience,
|
||||||
progress: data.profile.levelingProgress,
|
progress: data.profile.levelingProgress,
|
||||||
),
|
).padding(top: 8, horizontal: 8, bottom: 4),
|
||||||
if (data.profile.verification != null)
|
if (data.profile.verification != null)
|
||||||
VerificationStatusCard(
|
Card(
|
||||||
mark: data.profile.verification!,
|
child: VerificationStatusCard(
|
||||||
),
|
mark: data.profile.verification!,
|
||||||
|
),
|
||||||
|
).padding(horizontal: 4),
|
||||||
],
|
],
|
||||||
).padding(horizontal: 20),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SliverToBoxAdapter(child: accountProfileDetail(data)),
|
|
||||||
|
|
||||||
if (user.value != null)
|
|
||||||
SliverToBoxAdapter(child: accountAction(data)),
|
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Column(
|
child: accountProfileBio(data).padding(horizontal: 4),
|
||||||
children: [
|
),
|
||||||
FortuneGraphWidget(
|
SliverToBoxAdapter(
|
||||||
events: accountEvents,
|
child: accountProfileLinks(
|
||||||
eventCalanderUser: data.name,
|
data,
|
||||||
),
|
).padding(horizontal: 4),
|
||||||
],
|
),
|
||||||
).padding(all: 8),
|
SliverToBoxAdapter(
|
||||||
|
child: accountProfileDetail(
|
||||||
|
data,
|
||||||
|
).padding(horizontal: 4),
|
||||||
|
),
|
||||||
|
if (user.value != null)
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: accountAction(data).padding(horizontal: 4),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Card(
|
||||||
|
child: FortuneGraphWidget(
|
||||||
|
events: accountEvents,
|
||||||
|
eventCalanderUser: data.name,
|
||||||
|
),
|
||||||
|
).padding(horizontal: 4),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class _OidcScreenState extends ConsumerState<OidcScreen> {
|
|||||||
: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
||||||
),
|
),
|
||||||
initialUrlRequest: URLRequest(
|
initialUrlRequest: URLRequest(
|
||||||
url: WebUri('$serverUrl/auth/login/${widget.provider}'),
|
url: WebUri('$serverUrl/id/auth/login/${widget.provider}'),
|
||||||
headers: {
|
headers: {
|
||||||
if (token?.token.isNotEmpty ?? false)
|
if (token?.token.isNotEmpty ?? false)
|
||||||
'Authorization': 'AtField ${token!.token}',
|
'Authorization': 'AtField ${token!.token}',
|
||||||
@@ -120,7 +120,7 @@ class _OidcScreenState extends ConsumerState<OidcScreen> {
|
|||||||
final queryParams = url.queryParameters;
|
final queryParams = url.queryParameters;
|
||||||
|
|
||||||
// Check if we're on the token page
|
// Check if we're on the token page
|
||||||
if (path.endsWith('/id/auth/callback')) {
|
if (path.endsWith('/auth/callback')) {
|
||||||
// Extract token from URL
|
// Extract token from URL
|
||||||
final challenge = queryParams['challenge'];
|
final challenge = queryParams['challenge'];
|
||||||
// Return the token and close the webview
|
// Return the token and close the webview
|
||||||
@@ -205,7 +205,7 @@ class _OidcScreenState extends ConsumerState<OidcScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (currentUrl != null) {
|
if (currentUrl != null) {
|
||||||
Clipboard.setData(ClipboardData(text: currentUrl!));
|
Clipboard.setData(ClipboardData(text: currentUrl!));
|
||||||
showSnackBar('copyToClipboard');
|
showSnackBar('copyToClipboard'.tr());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import 'package:material_symbols_icons/symbols.dart';
|
|||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'chat.dart';
|
import 'chat.dart';
|
||||||
import 'package:island/widgets/chat/call_button.dart';
|
import 'package:island/widgets/chat/call_button.dart';
|
||||||
|
import 'package:island/widgets/stickers/picker.dart';
|
||||||
|
|
||||||
part 'room.g.dart';
|
part 'room.g.dart';
|
||||||
|
|
||||||
@@ -1066,11 +1067,19 @@ class _ChatInput extends HookConsumerWidget {
|
|||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: attachments.length,
|
itemCount: attachments.length,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return AttachmentPreview(
|
return SizedBox(
|
||||||
item: attachments[idx],
|
height: 280,
|
||||||
onRequestUpload: () => onUploadAttachment(idx),
|
width: 280,
|
||||||
onDelete: () => onDeleteAttachment(idx),
|
child: AttachmentPreview(
|
||||||
onMove: (delta) => onMoveAttachment(idx, delta),
|
item: attachments[idx],
|
||||||
|
onRequestUpload: () => onUploadAttachment(idx),
|
||||||
|
onDelete: () => onDeleteAttachment(idx),
|
||||||
|
onUpdate: (value) {
|
||||||
|
attachments[idx] = value;
|
||||||
|
onAttachmentsChanged(attachments);
|
||||||
|
},
|
||||||
|
onMove: (delta) => onMoveAttachment(idx, delta),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (_, _) => const Gap(8),
|
separatorBuilder: (_, _) => const Gap(8),
|
||||||
@@ -1125,31 +1134,76 @@ class _ChatInput extends HookConsumerWidget {
|
|||||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 8),
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
PopupMenuButton(
|
Row(
|
||||||
icon: const Icon(Symbols.photo_library),
|
mainAxisSize: MainAxisSize.min,
|
||||||
itemBuilder:
|
children: [
|
||||||
(context) => [
|
IconButton(
|
||||||
PopupMenuItem(
|
tooltip: 'stickers'.tr(),
|
||||||
onTap: () => onPickFile(true),
|
icon: const Icon(Symbols.emoji_symbols),
|
||||||
child: Row(
|
onPressed: () {
|
||||||
spacing: 12,
|
final size = MediaQuery.of(context).size;
|
||||||
children: [
|
showStickerPickerPopover(
|
||||||
const Icon(Symbols.photo),
|
context,
|
||||||
Text('addPhoto').tr(),
|
Offset(
|
||||||
],
|
20,
|
||||||
|
size.height -
|
||||||
|
480 -
|
||||||
|
MediaQuery.of(context).padding.bottom,
|
||||||
),
|
),
|
||||||
),
|
onPick: (placeholder) {
|
||||||
PopupMenuItem(
|
// Insert placeholder at current cursor position
|
||||||
onTap: () => onPickFile(false),
|
final text = messageController.text;
|
||||||
child: Row(
|
final selection = messageController.selection;
|
||||||
spacing: 12,
|
final start =
|
||||||
children: [
|
selection.start >= 0
|
||||||
const Icon(Symbols.video_call),
|
? selection.start
|
||||||
Text('addVideo').tr(),
|
: text.length;
|
||||||
],
|
final end =
|
||||||
),
|
selection.end >= 0
|
||||||
),
|
? selection.end
|
||||||
],
|
: text.length;
|
||||||
|
final newText = text.replaceRange(
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
placeholder,
|
||||||
|
);
|
||||||
|
messageController.value = TextEditingValue(
|
||||||
|
text: newText,
|
||||||
|
selection: TextSelection.collapsed(
|
||||||
|
offset: start + placeholder.length,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
PopupMenuButton(
|
||||||
|
icon: const Icon(Symbols.photo_library),
|
||||||
|
itemBuilder:
|
||||||
|
(context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
onTap: () => onPickFile(true),
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.photo),
|
||||||
|
Text('addPhoto').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
onTap: () => onPickFile(false),
|
||||||
|
child: Row(
|
||||||
|
spacing: 12,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.video_call),
|
||||||
|
Text('addVideo').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: RawKeyboardListener(
|
child: RawKeyboardListener(
|
||||||
|
|||||||
@@ -380,6 +380,23 @@ class CreatorHubScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
title: const Text('Polls'),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
leading: const Icon(Symbols.poll),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
context.pushNamed(
|
||||||
|
'creatorPolls',
|
||||||
|
pathParameters: {
|
||||||
|
'name': currentPublisher.value!.name,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
title: Text('publisherMembers').tr(),
|
title: Text('publisherMembers').tr(),
|
||||||
|
|||||||
179
lib/screens/creators/poll/poll_list.dart
Normal file
179
lib/screens/creators/poll/poll_list.dart
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/poll.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/widgets/poll/poll_feedback.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:riverpod_paging_utils/riverpod_paging_utils.dart';
|
||||||
|
|
||||||
|
part 'poll_list.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
class PollListNotifier extends _$PollListNotifier
|
||||||
|
with CursorPagingNotifierMixin<SnPoll> {
|
||||||
|
static const int _pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnPoll>> build(String? pubName) {
|
||||||
|
// immediately load first page
|
||||||
|
return fetch(cursor: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnPoll>> fetch({required String? cursor}) async {
|
||||||
|
final client = ref.read(apiClientProvider);
|
||||||
|
final offset = cursor == null ? 0 : int.parse(cursor);
|
||||||
|
|
||||||
|
// read the current family argument passed to provider
|
||||||
|
final currentPub = pubName;
|
||||||
|
final queryParams = {
|
||||||
|
'offset': offset,
|
||||||
|
'take': _pageSize,
|
||||||
|
if (currentPub != null) 'pub': currentPub,
|
||||||
|
};
|
||||||
|
|
||||||
|
final response = await client.get(
|
||||||
|
'/sphere/polls/me',
|
||||||
|
queryParameters: queryParams,
|
||||||
|
);
|
||||||
|
final total = int.parse(response.headers.value('X-Total') ?? '0');
|
||||||
|
final List<dynamic> data = response.data;
|
||||||
|
final items = data.map((json) => SnPoll.fromJson(json)).toList();
|
||||||
|
|
||||||
|
final hasMore = offset + items.length < total;
|
||||||
|
final nextCursor = hasMore ? (offset + items.length).toString() : null;
|
||||||
|
|
||||||
|
return CursorPagingData(
|
||||||
|
items: items,
|
||||||
|
hasMore: hasMore,
|
||||||
|
nextCursor: nextCursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CreatorPollListScreen extends HookConsumerWidget {
|
||||||
|
const CreatorPollListScreen({super.key, required this.pubName});
|
||||||
|
|
||||||
|
final String pubName;
|
||||||
|
|
||||||
|
Future<void> _createPoll(BuildContext context) async {
|
||||||
|
final result = await GoRouter.of(
|
||||||
|
context,
|
||||||
|
).pushNamed('creatorPollNew', pathParameters: {'name': pubName});
|
||||||
|
if (result is SnPoll && context.mounted) {
|
||||||
|
Navigator.of(context).maybePop(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Polls')),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () => _createPoll(context),
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
),
|
||||||
|
body: RefreshIndicator(
|
||||||
|
onRefresh: () => ref.refresh(pollListNotifierProvider(pubName).future),
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
PagingHelperSliverView(
|
||||||
|
provider: pollListNotifierProvider(pubName),
|
||||||
|
futureRefreshable: pollListNotifierProvider(pubName).future,
|
||||||
|
notifierRefreshable: pollListNotifierProvider(pubName).notifier,
|
||||||
|
contentBuilder:
|
||||||
|
(data, widgetCount, endItemView) => SliverList.builder(
|
||||||
|
itemCount: widgetCount,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == widgetCount - 1) {
|
||||||
|
return endItemView;
|
||||||
|
}
|
||||||
|
final poll = data.items[index];
|
||||||
|
return _CreatorPollItem(poll: poll, pubName: pubName);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreatorPollItem extends StatelessWidget {
|
||||||
|
final String pubName;
|
||||||
|
const _CreatorPollItem({required this.poll, required this.pubName});
|
||||||
|
|
||||||
|
final SnPoll poll;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final ended = poll.endedAt;
|
||||||
|
final endedText =
|
||||||
|
ended == null
|
||||||
|
? 'No end'
|
||||||
|
: MaterialLocalizations.of(context).formatFullDate(ended);
|
||||||
|
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(poll.title ?? 'Untitled poll'),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (poll.description != null && poll.description!.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: Text(
|
||||||
|
poll.description!,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: Text(
|
||||||
|
'Questions: ${poll.questions.length} · Ends: $endedText',
|
||||||
|
style: theme.textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: PopupMenuButton<String>(
|
||||||
|
itemBuilder:
|
||||||
|
(context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.edit),
|
||||||
|
const Gap(16),
|
||||||
|
Text('Edit'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed(
|
||||||
|
'creatorPollEdit',
|
||||||
|
pathParameters: {'name': pubName, 'id': poll.id},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
useRootNavigator: true,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder:
|
||||||
|
(context) => PollFeedbackSheet(pollId: poll.id, poll: poll),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
179
lib/screens/creators/poll/poll_list.g.dart
Normal file
179
lib/screens/creators/poll/poll_list.g.dart
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'poll_list.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$pollListNotifierHash() => r'd3da24ff6bbb8f35b06d57fc41625dc0312508e4';
|
||||||
|
|
||||||
|
/// Copied from Dart SDK
|
||||||
|
class _SystemHash {
|
||||||
|
_SystemHash._();
|
||||||
|
|
||||||
|
static int combine(int hash, int value) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + value);
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||||
|
return hash ^ (hash >> 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int finish(int hash) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = hash ^ (hash >> 11);
|
||||||
|
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _$PollListNotifier
|
||||||
|
extends BuildlessAutoDisposeAsyncNotifier<CursorPagingData<SnPoll>> {
|
||||||
|
late final String? pubName;
|
||||||
|
|
||||||
|
FutureOr<CursorPagingData<SnPoll>> build(String? pubName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [PollListNotifier].
|
||||||
|
@ProviderFor(PollListNotifier)
|
||||||
|
const pollListNotifierProvider = PollListNotifierFamily();
|
||||||
|
|
||||||
|
/// See also [PollListNotifier].
|
||||||
|
class PollListNotifierFamily
|
||||||
|
extends Family<AsyncValue<CursorPagingData<SnPoll>>> {
|
||||||
|
/// See also [PollListNotifier].
|
||||||
|
const PollListNotifierFamily();
|
||||||
|
|
||||||
|
/// See also [PollListNotifier].
|
||||||
|
PollListNotifierProvider call(String? pubName) {
|
||||||
|
return PollListNotifierProvider(pubName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
PollListNotifierProvider getProviderOverride(
|
||||||
|
covariant PollListNotifierProvider provider,
|
||||||
|
) {
|
||||||
|
return call(provider.pubName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'pollListNotifierProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [PollListNotifier].
|
||||||
|
class PollListNotifierProvider
|
||||||
|
extends
|
||||||
|
AutoDisposeAsyncNotifierProviderImpl<
|
||||||
|
PollListNotifier,
|
||||||
|
CursorPagingData<SnPoll>
|
||||||
|
> {
|
||||||
|
/// See also [PollListNotifier].
|
||||||
|
PollListNotifierProvider(String? pubName)
|
||||||
|
: this._internal(
|
||||||
|
() => PollListNotifier()..pubName = pubName,
|
||||||
|
from: pollListNotifierProvider,
|
||||||
|
name: r'pollListNotifierProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$pollListNotifierHash,
|
||||||
|
dependencies: PollListNotifierFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
PollListNotifierFamily._allTransitiveDependencies,
|
||||||
|
pubName: pubName,
|
||||||
|
);
|
||||||
|
|
||||||
|
PollListNotifierProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.pubName,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String? pubName;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<CursorPagingData<SnPoll>> runNotifierBuild(
|
||||||
|
covariant PollListNotifier notifier,
|
||||||
|
) {
|
||||||
|
return notifier.build(pubName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(PollListNotifier Function() create) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: PollListNotifierProvider._internal(
|
||||||
|
() => create()..pubName = pubName,
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
pubName: pubName,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeAsyncNotifierProviderElement<
|
||||||
|
PollListNotifier,
|
||||||
|
CursorPagingData<SnPoll>
|
||||||
|
>
|
||||||
|
createElement() {
|
||||||
|
return _PollListNotifierProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is PollListNotifierProvider && other.pubName == pubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, pubName.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin PollListNotifierRef
|
||||||
|
on AutoDisposeAsyncNotifierProviderRef<CursorPagingData<SnPoll>> {
|
||||||
|
/// The parameter `pubName` of this provider.
|
||||||
|
String? get pubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PollListNotifierProviderElement
|
||||||
|
extends
|
||||||
|
AutoDisposeAsyncNotifierProviderElement<
|
||||||
|
PollListNotifier,
|
||||||
|
CursorPagingData<SnPoll>
|
||||||
|
>
|
||||||
|
with PollListNotifierRef {
|
||||||
|
_PollListNotifierProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get pubName => (origin as PollListNotifierProvider).pubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
@@ -18,7 +18,7 @@ part 'apps.g.dart';
|
|||||||
@riverpod
|
@riverpod
|
||||||
Future<List<CustomApp>> customApps(Ref ref, String publisherName) async {
|
Future<List<CustomApp>> customApps(Ref ref, String publisherName) async {
|
||||||
final client = ref.watch(apiClientProvider);
|
final client = ref.watch(apiClientProvider);
|
||||||
final resp = await client.get('/developers/$publisherName/apps');
|
final resp = await client.get('/develop/developers/$publisherName/apps');
|
||||||
return resp.data.map((e) => CustomApp.fromJson(e)).cast<CustomApp>().toList();
|
return resp.data.map((e) => CustomApp.fromJson(e)).cast<CustomApp>().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,10 @@ class CustomAppsScreen extends HookConsumerWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Symbols.add),
|
icon: const Icon(Symbols.add),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.pushNamed('developerAppNew', pathParameters: {'name': publisherName});
|
context.pushNamed(
|
||||||
|
'developerAppNew',
|
||||||
|
pathParameters: {'name': publisherName},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -121,7 +124,13 @@ class CustomAppsScreen extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
onSelected: (value) {
|
onSelected: (value) {
|
||||||
if (value == 'edit') {
|
if (value == 'edit') {
|
||||||
context.pushNamed('developerAppEdit', pathParameters: {'name': publisherName, 'id': app.id});
|
context.pushNamed(
|
||||||
|
'developerAppEdit',
|
||||||
|
pathParameters: {
|
||||||
|
'name': publisherName,
|
||||||
|
'id': app.id,
|
||||||
|
},
|
||||||
|
);
|
||||||
} else if (value == 'delete') {
|
} else if (value == 'delete') {
|
||||||
showConfirmAlert(
|
showConfirmAlert(
|
||||||
'deleteCustomAppHint'.tr(),
|
'deleteCustomAppHint'.tr(),
|
||||||
@@ -130,7 +139,7 @@ class CustomAppsScreen extends HookConsumerWidget {
|
|||||||
if (confirm) {
|
if (confirm) {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
client.delete(
|
client.delete(
|
||||||
'/developers/$publisherName/apps/${app.id}',
|
'/develop/developers/$publisherName/apps/${app.id}',
|
||||||
);
|
);
|
||||||
ref.invalidate(
|
ref.invalidate(
|
||||||
customAppsProvider(publisherName),
|
customAppsProvider(publisherName),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'apps.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$customAppsHash() => r'1dec11573b9d987c3adbdf4732b3781a6f40172a';
|
String _$customAppsHash() => r'c6ac78060eb51a2b208a749a81ecbe0a9c608ce1';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ part 'edit_app.g.dart';
|
|||||||
@riverpod
|
@riverpod
|
||||||
Future<CustomApp?> customApp(Ref ref, String publisherName, String id) async {
|
Future<CustomApp?> customApp(Ref ref, String publisherName, String id) async {
|
||||||
final client = ref.watch(apiClientProvider);
|
final client = ref.watch(apiClientProvider);
|
||||||
final resp = await client.get('/developers/$publisherName/apps/$id');
|
final resp = await client.get('/develop/developers/$publisherName/apps/$id');
|
||||||
return CustomApp.fromJson(resp.data);
|
return CustomApp.fromJson(resp.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,9 +282,15 @@ class EditAppScreen extends HookConsumerWidget {
|
|||||||
: null,
|
: null,
|
||||||
};
|
};
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
await client.post('/developers/$publisherName/apps', data: data);
|
await client.post(
|
||||||
|
'/develop/developers/$publisherName/apps',
|
||||||
|
data: data,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
await client.patch('/developers/$publisherName/apps/$id', data: data);
|
await client.patch(
|
||||||
|
'/develop/developers/$publisherName/apps/$id',
|
||||||
|
data: data,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
ref.invalidate(customAppsProvider(publisherName));
|
ref.invalidate(customAppsProvider(publisherName));
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'edit_app.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$customAppHash() => r'aa4d1fb803c47a99cbacf6d91481f4fce3fda457';
|
String _$customAppHash() => r'42ad937b8439c793e3c5c35568bb5fa4da017df3';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ part 'hub.g.dart';
|
|||||||
Future<DeveloperStats?> developerStats(Ref ref, String? uname) async {
|
Future<DeveloperStats?> developerStats(Ref ref, String? uname) async {
|
||||||
if (uname == null) return null;
|
if (uname == null) return null;
|
||||||
final apiClient = ref.watch(apiClientProvider);
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
final resp = await apiClient.get('/sphere/developers/$uname/stats');
|
final resp = await apiClient.get('/develop/developers/$uname/stats');
|
||||||
return DeveloperStats.fromJson(resp.data);
|
return DeveloperStats.fromJson(resp.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@riverpod
|
@riverpod
|
||||||
Future<List<SnPublisher>> developers(Ref ref) async {
|
Future<List<SnPublisher>> developers(Ref ref) async {
|
||||||
final client = ref.watch(apiClientProvider);
|
final client = ref.watch(apiClientProvider);
|
||||||
final resp = await client.get('/sphere/developers');
|
final resp = await client.get('/develop/developers');
|
||||||
return resp.data
|
return resp.data
|
||||||
.map((e) => SnPublisher.fromJson(e))
|
.map((e) => SnPublisher.fromJson(e))
|
||||||
.cast<SnPublisher>()
|
.cast<SnPublisher>()
|
||||||
@@ -336,7 +336,7 @@ class _DeveloperEnrollmentSheet extends HookConsumerWidget {
|
|||||||
Future<void> enroll(SnPublisher publisher) async {
|
Future<void> enroll(SnPublisher publisher) async {
|
||||||
try {
|
try {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
await client.post('/sphere/developers/${publisher.name}/enroll');
|
await client.post('/develop/developers/${publisher.name}/enroll');
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'hub.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$developerStatsHash() => r'baa708f3586e8987e221cc8ab825d759658c0f55';
|
String _$developerStatsHash() => r'45546f29ec7cd1a9c3a4e0f4e39275e78bf34755';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
@@ -149,7 +149,7 @@ class _DeveloperStatsProviderElement
|
|||||||
String? get uname => (origin as DeveloperStatsProvider).uname;
|
String? get uname => (origin as DeveloperStatsProvider).uname;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$developersHash() => r'f11335fdf553c661110281edeec70ef89c64727d';
|
String _$developersHash() => r'04f25db31f511f651a5add128d56631236ed0b39';
|
||||||
|
|
||||||
/// See also [developers].
|
/// See also [developers].
|
||||||
@ProviderFor(developers)
|
@ProviderFor(developers)
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ import 'package:island/models/webfeed.dart';
|
|||||||
import 'package:island/pods/event_calendar.dart';
|
import 'package:island/pods/event_calendar.dart';
|
||||||
import 'package:island/pods/userinfo.dart';
|
import 'package:island/pods/userinfo.dart';
|
||||||
import 'package:island/services/responsive.dart';
|
import 'package:island/services/responsive.dart';
|
||||||
import 'package:island/widgets/account/event_calendar.dart';
|
|
||||||
import 'package:island/widgets/account/fortune_graph.dart';
|
import 'package:island/widgets/account/fortune_graph.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
import 'package:island/models/post.dart';
|
import 'package:island/models/post.dart';
|
||||||
import 'package:island/widgets/check_in.dart';
|
import 'package:island/widgets/check_in.dart';
|
||||||
|
import 'package:island/widgets/post/post_featured.dart';
|
||||||
import 'package:island/widgets/post/post_item.dart';
|
import 'package:island/widgets/post/post_item.dart';
|
||||||
import 'package:island/screens/tabs.dart';
|
import 'package:island/screens/tabs.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
@@ -70,15 +70,6 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
final events = ref.watch(eventCalendarProvider(query.value));
|
final events = ref.watch(eventCalendarProvider(query.value));
|
||||||
|
|
||||||
final selectedDay = useState(now);
|
final selectedDay = useState(now);
|
||||||
|
|
||||||
void onMonthChanged(int year, int month) {
|
|
||||||
query.value = EventCalendarQuery(
|
|
||||||
uname: query.value.uname,
|
|
||||||
year: year,
|
|
||||||
month: month,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to handle day selection for synchronizing between widgets
|
// Function to handle day selection for synchronizing between widgets
|
||||||
void onDaySelected(DateTime day) {
|
void onDaySelected(DateTime day) {
|
||||||
selectedDay.value = day;
|
selectedDay.value = day;
|
||||||
@@ -218,21 +209,16 @@ class ExploreScreen extends HookConsumerWidget {
|
|||||||
right: 12,
|
right: 12,
|
||||||
top: 16,
|
top: 16,
|
||||||
),
|
),
|
||||||
|
onChecked: () {
|
||||||
|
ref.invalidate(
|
||||||
|
eventCalendarProvider(query.value),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
Card(
|
PostFeaturedList().padding(
|
||||||
margin: EdgeInsets.only(left: 8, right: 12, top: 8),
|
left: 8,
|
||||||
child: Column(
|
right: 12,
|
||||||
children: [
|
top: 8,
|
||||||
// Use the reusable EventCalendarWidget
|
|
||||||
EventCalendarWidget(
|
|
||||||
events: events,
|
|
||||||
initialDate: now,
|
|
||||||
showEventDetails: true,
|
|
||||||
onMonthChanged: onMonthChanged,
|
|
||||||
onDaySelected: onDaySelected,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
FortuneGraphWidget(
|
FortuneGraphWidget(
|
||||||
margin: EdgeInsets.only(left: 8, right: 12, top: 8),
|
margin: EdgeInsets.only(left: 8, right: 12, top: 8),
|
||||||
@@ -403,6 +389,10 @@ class _ActivityListView extends HookConsumerWidget {
|
|||||||
margin: EdgeInsets.only(left: 8, right: 8, bottom: 4),
|
margin: EdgeInsets.only(left: 8, right: 8, bottom: 4),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!contentOnly)
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: PostFeaturedList().padding(horizontal: 8, bottom: 4, top: 4),
|
||||||
|
),
|
||||||
SliverList.builder(
|
SliverList.builder(
|
||||||
itemCount: widgetCount,
|
itemCount: widgetCount,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
|||||||
1094
lib/screens/poll/poll_editor.dart
Normal file
1094
lib/screens/poll/poll_editor.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -205,17 +205,7 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder:
|
builder: (context) => ComposeSettingsSheet(state: state),
|
||||||
(context) => ComposeSettingsSheet(
|
|
||||||
titleController: state.titleController,
|
|
||||||
descriptionController: state.descriptionController,
|
|
||||||
visibility: state.visibility,
|
|
||||||
tagsController: state.tagsController,
|
|
||||||
categoriesController: state.categoriesController,
|
|
||||||
onVisibilityChanged: () {
|
|
||||||
// Trigger rebuild if needed
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +228,8 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
onRequestUpload:
|
onRequestUpload:
|
||||||
() => ComposeLogic.uploadAttachment(ref, state, idx),
|
() => ComposeLogic.uploadAttachment(ref, state, idx),
|
||||||
onDelete: () => ComposeLogic.deleteAttachment(ref, state, idx),
|
onDelete: () => ComposeLogic.deleteAttachment(ref, state, idx),
|
||||||
|
onUpdate:
|
||||||
|
(value) => ComposeLogic.updateAttachment(state, value, idx),
|
||||||
onMove: (delta) {
|
onMove: (delta) {
|
||||||
state.attachments.value = ComposeLogic.moveAttachment(
|
state.attachments.value = ComposeLogic.moveAttachment(
|
||||||
state.attachments.value,
|
state.attachments.value,
|
||||||
@@ -265,6 +257,9 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
() => ComposeLogic.uploadAttachment(ref, state, idx),
|
() => ComposeLogic.uploadAttachment(ref, state, idx),
|
||||||
onDelete:
|
onDelete:
|
||||||
() => ComposeLogic.deleteAttachment(ref, state, idx),
|
() => ComposeLogic.deleteAttachment(ref, state, idx),
|
||||||
|
onUpdate:
|
||||||
|
(value) =>
|
||||||
|
ComposeLogic.updateAttachment(state, value, idx),
|
||||||
onMove: (delta) {
|
onMove: (delta) {
|
||||||
state.attachments.value = ComposeLogic.moveAttachment(
|
state.attachments.value = ComposeLogic.moveAttachment(
|
||||||
state.attachments.value,
|
state.attachments.value,
|
||||||
@@ -364,31 +359,73 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
// Post content form
|
// Post content form
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: KeyboardListener(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
focusNode: FocusNode(),
|
||||||
child: Column(
|
onKeyEvent:
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
(event) => ComposeLogic.handleKeyPress(
|
||||||
children: [
|
event,
|
||||||
// Content field with borderless design
|
state,
|
||||||
RawKeyboardListener(
|
ref,
|
||||||
focusNode: FocusNode(),
|
context,
|
||||||
onKey:
|
originalPost: originalPost,
|
||||||
(event) => ComposeLogic.handleKeyPress(
|
repliedPost: repliedPost,
|
||||||
event,
|
forwardedPost: forwardedPost,
|
||||||
state,
|
),
|
||||||
ref,
|
child: SingleChildScrollView(
|
||||||
context,
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
originalPost: originalPost,
|
child: Column(
|
||||||
repliedPost: repliedPost,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
forwardedPost: forwardedPost,
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: state.titleController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postTitle'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
),
|
),
|
||||||
child: TextField(
|
),
|
||||||
|
style: theme.textTheme.titleMedium,
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus
|
||||||
|
?.unfocus(),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: state.descriptionController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postDescription'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(
|
||||||
|
8,
|
||||||
|
4,
|
||||||
|
8,
|
||||||
|
12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 3,
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus
|
||||||
|
?.unfocus(),
|
||||||
|
),
|
||||||
|
// Content field with borderless design
|
||||||
|
TextField(
|
||||||
controller: state.contentController,
|
controller: state.contentController,
|
||||||
style: theme.textTheme.bodyMedium,
|
style: theme.textTheme.bodyMedium,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
hintText: 'postContent'.tr(),
|
hintText: 'postContent'.tr(),
|
||||||
contentPadding: const EdgeInsets.all(8),
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
onTapOutside:
|
onTapOutside:
|
||||||
@@ -396,23 +433,23 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
FocusManager.instance.primaryFocus
|
FocusManager.instance.primaryFocus
|
||||||
?.unfocus(),
|
?.unfocus(),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
|
|
||||||
const Gap(8),
|
const Gap(8),
|
||||||
|
|
||||||
// Attachments preview
|
// Attachments preview
|
||||||
if (state.attachments.value.isNotEmpty)
|
if (state.attachments.value.isNotEmpty)
|
||||||
LayoutBuilder(
|
LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final isWide = isWideScreen(context);
|
final isWide = isWideScreen(context);
|
||||||
return isWide
|
return isWide
|
||||||
? buildWideAttachmentGrid()
|
? buildWideAttachmentGrid()
|
||||||
: buildNarrowAttachmentList();
|
: buildNarrowAttachmentList();
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
const SizedBox.shrink(),
|
const SizedBox.shrink(),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -138,17 +138,7 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder:
|
builder: (context) => ComposeSettingsSheet(state: state),
|
||||||
(context) => ComposeSettingsSheet(
|
|
||||||
titleController: state.titleController,
|
|
||||||
descriptionController: state.descriptionController,
|
|
||||||
visibility: state.visibility,
|
|
||||||
tagsController: state.tagsController,
|
|
||||||
categoriesController: state.categoriesController,
|
|
||||||
onVisibilityChanged: () {
|
|
||||||
// Trigger rebuild if needed
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,10 +232,39 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: state.titleController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postTitle'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.titleMedium,
|
||||||
|
onTapOutside:
|
||||||
|
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: state.descriptionController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postDescription'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(8, 4, 8, 12),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 3,
|
||||||
|
onTapOutside:
|
||||||
|
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: RawKeyboardListener(
|
child: KeyboardListener(
|
||||||
focusNode: FocusNode(),
|
focusNode: FocusNode(),
|
||||||
onKey:
|
onKeyEvent:
|
||||||
(event) => _handleKeyPress(
|
(event) => _handleKeyPress(
|
||||||
event,
|
event,
|
||||||
state,
|
state,
|
||||||
@@ -308,6 +327,13 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
state,
|
state,
|
||||||
idx,
|
idx,
|
||||||
),
|
),
|
||||||
|
onUpdate:
|
||||||
|
(value) =>
|
||||||
|
ComposeLogic.updateAttachment(
|
||||||
|
state,
|
||||||
|
value,
|
||||||
|
idx,
|
||||||
|
),
|
||||||
onDelete:
|
onDelete:
|
||||||
() => ComposeLogic.deleteAttachment(
|
() => ComposeLogic.deleteAttachment(
|
||||||
ref,
|
ref,
|
||||||
@@ -447,7 +473,7 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
flex: showPreview.value ? 1 : 2,
|
flex: showPreview.value ? 1 : 2,
|
||||||
child: buildEditorPane(),
|
child: buildEditorPane(),
|
||||||
),
|
),
|
||||||
const VerticalDivider(),
|
if (showPreview.value) const VerticalDivider(),
|
||||||
if (showPreview.value)
|
if (showPreview.value)
|
||||||
Expanded(child: buildPreviewPane()),
|
Expanded(child: buildPreviewPane()),
|
||||||
],
|
],
|
||||||
@@ -468,7 +494,7 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
// Helper method to handle keyboard shortcuts
|
// Helper method to handle keyboard shortcuts
|
||||||
void _handleKeyPress(
|
void _handleKeyPress(
|
||||||
RawKeyEvent event,
|
KeyEvent event,
|
||||||
ComposeState state,
|
ComposeState state,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
@@ -478,7 +504,9 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
||||||
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
||||||
final isModifierPressed = event.isMetaPressed || event.isControlPressed;
|
final isModifierPressed =
|
||||||
|
HardwareKeyboard.instance.isMetaPressed ||
|
||||||
|
HardwareKeyboard.instance.isControlPressed;
|
||||||
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
||||||
|
|
||||||
if (isPaste && isModifierPressed) {
|
if (isPaste && isModifierPressed) {
|
||||||
|
|||||||
107
lib/screens/posts/post_category_detail.dart
Normal file
107
lib/screens/posts/post_category_detail.dart
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/post_category.dart';
|
||||||
|
import 'package:island/models/post_tag.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
|
import 'package:island/widgets/post/post_list.dart';
|
||||||
|
import 'package:island/widgets/response.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
|
part 'post_category_detail.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
Future<SnPostCategory> postCategory(Ref ref, String slug) async {
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
final resp = await apiClient.get('/sphere/posts/categories/$slug');
|
||||||
|
return SnPostCategory.fromJson(resp.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
Future<SnPostTag> postTag(Ref ref, String slug) async {
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
final resp = await apiClient.get('/sphere/posts/tags/$slug');
|
||||||
|
return SnPostTag.fromJson(resp.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
class PostCategoryDetailScreen extends HookConsumerWidget {
|
||||||
|
final String slug;
|
||||||
|
final bool isCategory;
|
||||||
|
const PostCategoryDetailScreen({
|
||||||
|
super.key,
|
||||||
|
required this.slug,
|
||||||
|
required this.isCategory,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final postCategory =
|
||||||
|
isCategory ? ref.watch(postCategoryProvider(slug)) : null;
|
||||||
|
final postTag = isCategory ? null : ref.watch(postTagProvider(slug));
|
||||||
|
|
||||||
|
final postFilterTitle =
|
||||||
|
isCategory
|
||||||
|
? postCategory?.value?.categoryDisplayTitle ?? 'loading'
|
||||||
|
: postTag?.value?.name ?? postTag?.value?.slug ?? 'loading';
|
||||||
|
|
||||||
|
return AppScaffold(
|
||||||
|
isNoBackground: false,
|
||||||
|
appBar: AppBar(title: Text(postFilterTitle).tr()),
|
||||||
|
body: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (isCategory)
|
||||||
|
postCategory!.when(
|
||||||
|
data:
|
||||||
|
(category) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(category.categoryDisplayTitle).bold().fontSize(15),
|
||||||
|
Text('A category'),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 16),
|
||||||
|
error:
|
||||||
|
(error, _) => ResponseErrorWidget(
|
||||||
|
error: error,
|
||||||
|
onRetry: () => ref.invalidate(postCategoryProvider(slug)),
|
||||||
|
),
|
||||||
|
loading: () => ResponseLoadingWidget(),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
postTag!.when(
|
||||||
|
data:
|
||||||
|
(tag) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(tag.name ?? '#${tag.slug}').bold().fontSize(15),
|
||||||
|
Text('A tag'),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 16),
|
||||||
|
error:
|
||||||
|
(error, _) => ResponseErrorWidget(
|
||||||
|
error: error,
|
||||||
|
onRetry: () => ref.invalidate(postTagProvider(slug)),
|
||||||
|
),
|
||||||
|
loading: () => ResponseLoadingWidget(),
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
Expanded(
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
const SliverGap(4),
|
||||||
|
SliverPostList(
|
||||||
|
categories: isCategory ? [slug] : null,
|
||||||
|
tags: isCategory ? null : [slug],
|
||||||
|
),
|
||||||
|
SliverGap(MediaQuery.of(context).padding.bottom + 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
270
lib/screens/posts/post_category_detail.g.dart
Normal file
270
lib/screens/posts/post_category_detail.g.dart
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'post_category_detail.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$postCategoryHash() => r'0df2de729ba96819ee37377314615abef0c99547';
|
||||||
|
|
||||||
|
/// Copied from Dart SDK
|
||||||
|
class _SystemHash {
|
||||||
|
_SystemHash._();
|
||||||
|
|
||||||
|
static int combine(int hash, int value) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + value);
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||||
|
return hash ^ (hash >> 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int finish(int hash) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = hash ^ (hash >> 11);
|
||||||
|
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [postCategory].
|
||||||
|
@ProviderFor(postCategory)
|
||||||
|
const postCategoryProvider = PostCategoryFamily();
|
||||||
|
|
||||||
|
/// See also [postCategory].
|
||||||
|
class PostCategoryFamily extends Family<AsyncValue<SnPostCategory>> {
|
||||||
|
/// See also [postCategory].
|
||||||
|
const PostCategoryFamily();
|
||||||
|
|
||||||
|
/// See also [postCategory].
|
||||||
|
PostCategoryProvider call(String slug) {
|
||||||
|
return PostCategoryProvider(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
PostCategoryProvider getProviderOverride(
|
||||||
|
covariant PostCategoryProvider provider,
|
||||||
|
) {
|
||||||
|
return call(provider.slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'postCategoryProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [postCategory].
|
||||||
|
class PostCategoryProvider extends AutoDisposeFutureProvider<SnPostCategory> {
|
||||||
|
/// See also [postCategory].
|
||||||
|
PostCategoryProvider(String slug)
|
||||||
|
: this._internal(
|
||||||
|
(ref) => postCategory(ref as PostCategoryRef, slug),
|
||||||
|
from: postCategoryProvider,
|
||||||
|
name: r'postCategoryProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$postCategoryHash,
|
||||||
|
dependencies: PostCategoryFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
PostCategoryFamily._allTransitiveDependencies,
|
||||||
|
slug: slug,
|
||||||
|
);
|
||||||
|
|
||||||
|
PostCategoryProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.slug,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String slug;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<SnPostCategory> Function(PostCategoryRef provider) create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: PostCategoryProvider._internal(
|
||||||
|
(ref) => create(ref as PostCategoryRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
slug: slug,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<SnPostCategory> createElement() {
|
||||||
|
return _PostCategoryProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is PostCategoryProvider && other.slug == slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, slug.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin PostCategoryRef on AutoDisposeFutureProviderRef<SnPostCategory> {
|
||||||
|
/// The parameter `slug` of this provider.
|
||||||
|
String get slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PostCategoryProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<SnPostCategory>
|
||||||
|
with PostCategoryRef {
|
||||||
|
_PostCategoryProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get slug => (origin as PostCategoryProvider).slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$postTagHash() => r'e050fdf9af81a843a9abd9cf979dd2672e0a2b93';
|
||||||
|
|
||||||
|
/// See also [postTag].
|
||||||
|
@ProviderFor(postTag)
|
||||||
|
const postTagProvider = PostTagFamily();
|
||||||
|
|
||||||
|
/// See also [postTag].
|
||||||
|
class PostTagFamily extends Family<AsyncValue<SnPostTag>> {
|
||||||
|
/// See also [postTag].
|
||||||
|
const PostTagFamily();
|
||||||
|
|
||||||
|
/// See also [postTag].
|
||||||
|
PostTagProvider call(String slug) {
|
||||||
|
return PostTagProvider(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
PostTagProvider getProviderOverride(covariant PostTagProvider provider) {
|
||||||
|
return call(provider.slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'postTagProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [postTag].
|
||||||
|
class PostTagProvider extends AutoDisposeFutureProvider<SnPostTag> {
|
||||||
|
/// See also [postTag].
|
||||||
|
PostTagProvider(String slug)
|
||||||
|
: this._internal(
|
||||||
|
(ref) => postTag(ref as PostTagRef, slug),
|
||||||
|
from: postTagProvider,
|
||||||
|
name: r'postTagProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$postTagHash,
|
||||||
|
dependencies: PostTagFamily._dependencies,
|
||||||
|
allTransitiveDependencies: PostTagFamily._allTransitiveDependencies,
|
||||||
|
slug: slug,
|
||||||
|
);
|
||||||
|
|
||||||
|
PostTagProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.slug,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String slug;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<SnPostTag> Function(PostTagRef provider) create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: PostTagProvider._internal(
|
||||||
|
(ref) => create(ref as PostTagRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
slug: slug,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<SnPostTag> createElement() {
|
||||||
|
return _PostTagProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is PostTagProvider && other.slug == slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, slug.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin PostTagRef on AutoDisposeFutureProviderRef<SnPostTag> {
|
||||||
|
/// The parameter `slug` of this provider.
|
||||||
|
String get slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PostTagProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<SnPostTag>
|
||||||
|
with PostTagRef {
|
||||||
|
_PostTagProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get slug => (origin as PostTagProvider).slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
@@ -18,6 +18,7 @@ import 'package:island/widgets/account/status.dart';
|
|||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/markdown.dart';
|
||||||
import 'package:island/widgets/post/post_list.dart';
|
import 'package:island/widgets/post/post_list.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:palette_generator/palette_generator.dart';
|
import 'package:palette_generator/palette_generator.dart';
|
||||||
@@ -86,13 +87,22 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
|||||||
publisherAppbarForcegroundColorProvider(name),
|
publisherAppbarForcegroundColorProvider(name),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final categoryTabController = useTabController(initialLength: 3);
|
||||||
|
final categoryTab = useState(0);
|
||||||
|
categoryTabController.addListener(() {
|
||||||
|
categoryTab.value = categoryTabController.index;
|
||||||
|
});
|
||||||
|
|
||||||
final subscribing = useState(false);
|
final subscribing = useState(false);
|
||||||
|
|
||||||
Future<void> subscribe() async {
|
Future<void> subscribe() async {
|
||||||
final apiClient = ref.watch(apiClientProvider);
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
subscribing.value = true;
|
subscribing.value = true;
|
||||||
try {
|
try {
|
||||||
await apiClient.post("/publishers/$name/subscribe", data: {'tier': 0});
|
await apiClient.post(
|
||||||
|
"/sphere/publishers/$name/subscribe",
|
||||||
|
data: {'tier': 0},
|
||||||
|
);
|
||||||
ref.invalidate(publisherSubscriptionStatusProvider(name));
|
ref.invalidate(publisherSubscriptionStatusProvider(name));
|
||||||
HapticFeedback.heavyImpact();
|
HapticFeedback.heavyImpact();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -106,7 +116,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
|||||||
final apiClient = ref.watch(apiClientProvider);
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
subscribing.value = true;
|
subscribing.value = true;
|
||||||
try {
|
try {
|
||||||
await apiClient.post("/publishers/$name/unsubscribe");
|
await apiClient.post("/sphere/publishers/$name/unsubscribe");
|
||||||
ref.invalidate(publisherSubscriptionStatusProvider(name));
|
ref.invalidate(publisherSubscriptionStatusProvider(name));
|
||||||
HapticFeedback.heavyImpact();
|
HapticFeedback.heavyImpact();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -233,29 +243,50 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
).padding(horizontal: 24, top: 24);
|
).padding(horizontal: 24, top: 24);
|
||||||
|
|
||||||
Widget publisherVerificationWidget(SnPublisher data) => Card(
|
Widget publisherBadgesWidget(SnPublisher data) =>
|
||||||
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
(badges.value?.isNotEmpty ?? false)
|
||||||
child: Column(
|
? Card(
|
||||||
children: [
|
child: BadgeList(
|
||||||
if (badges.value?.isNotEmpty ?? false)
|
badges: badges.value!,
|
||||||
BadgeList(badges: badges.value!).padding(top: 16),
|
).padding(horizontal: 26, vertical: 20),
|
||||||
if (data.verification != null)
|
).padding(horizontal: 4)
|
||||||
VerificationStatusCard(mark: data.verification!),
|
: const SizedBox.shrink();
|
||||||
],
|
|
||||||
),
|
|
||||||
).padding(top: 16);
|
|
||||||
|
|
||||||
Widget publisherDetailWidget(SnPublisher data) => Card(
|
Widget publisherVerificationWidget(SnPublisher data) =>
|
||||||
|
(data.verification != null)
|
||||||
|
? Card(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
child: VerificationStatusCard(mark: data.verification!),
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink();
|
||||||
|
|
||||||
|
Widget publisherBioWidget(SnPublisher data) => Card(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Text('bio').tr().bold().padding(bottom: 2),
|
Text('bio').tr().bold().fontSize(15).padding(bottom: 8),
|
||||||
Text(data.bio.isEmpty ? 'descriptionNone'.tr() : data.bio),
|
if (data.bio.isEmpty)
|
||||||
|
Text('descriptionNone').tr().italic()
|
||||||
|
else
|
||||||
|
MarkdownTextContent(
|
||||||
|
content: data.bio,
|
||||||
|
linesMargin: EdgeInsets.zero,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
).padding(horizontal: 20, vertical: 16),
|
).padding(horizontal: 20, vertical: 16),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Widget publisherCategoryTabWidget() => Card(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
child: TabBar(
|
||||||
|
controller: categoryTabController,
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
splashBorderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
tabs: [Tab(text: 'All'), Tab(text: 'Posts'), Tab(text: 'Articles')],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return publisher.when(
|
return publisher.when(
|
||||||
data:
|
data:
|
||||||
(data) => AppScaffold(
|
(data) => AppScaffold(
|
||||||
@@ -309,7 +340,18 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverGap(16),
|
SliverGap(16),
|
||||||
SliverPostList(pubName: name),
|
SliverToBoxAdapter(
|
||||||
|
child: publisherCategoryTabWidget(),
|
||||||
|
),
|
||||||
|
SliverPostList(
|
||||||
|
key: ValueKey(categoryTab.value),
|
||||||
|
pubName: name,
|
||||||
|
type: switch (categoryTab.value) {
|
||||||
|
1 => 0,
|
||||||
|
2 => 1,
|
||||||
|
_ => null,
|
||||||
|
},
|
||||||
|
),
|
||||||
SliverGap(
|
SliverGap(
|
||||||
MediaQuery.of(context).padding.bottom + 16,
|
MediaQuery.of(context).padding.bottom + 16,
|
||||||
),
|
),
|
||||||
@@ -322,11 +364,12 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
|||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
publisherBasisWidget(data),
|
publisherBasisWidget(data).padding(bottom: 8),
|
||||||
|
publisherBadgesWidget(data),
|
||||||
publisherVerificationWidget(data),
|
publisherVerificationWidget(data),
|
||||||
publisherDetailWidget(data),
|
publisherBioWidget(data),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -377,12 +420,24 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(child: publisherBasisWidget(data)),
|
SliverToBoxAdapter(
|
||||||
|
child: publisherBasisWidget(data).padding(bottom: 8),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(child: publisherBadgesWidget(data)),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: publisherVerificationWidget(data),
|
child: publisherVerificationWidget(data),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(child: publisherDetailWidget(data)),
|
SliverToBoxAdapter(child: publisherBioWidget(data)),
|
||||||
SliverPostList(pubName: name),
|
SliverToBoxAdapter(child: publisherCategoryTabWidget()),
|
||||||
|
SliverPostList(
|
||||||
|
key: ValueKey(categoryTab.value),
|
||||||
|
pubName: name,
|
||||||
|
type: switch (categoryTab.value) {
|
||||||
|
1 => 0,
|
||||||
|
2 => 1,
|
||||||
|
_ => null,
|
||||||
|
},
|
||||||
|
),
|
||||||
SliverGap(MediaQuery.of(context).padding.bottom + 16),
|
SliverGap(MediaQuery.of(context).padding.bottom + 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
103
lib/screens/stickers/marketplace.dart
Normal file
103
lib/screens/stickers/marketplace.dart
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/sticker.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:riverpod_paging_utils/riverpod_paging_utils.dart';
|
||||||
|
|
||||||
|
part 'marketplace.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
class MarketplaceStickerPacksNotifier extends _$MarketplaceStickerPacksNotifier
|
||||||
|
with CursorPagingNotifierMixin<SnStickerPack> {
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnStickerPack>> build() {
|
||||||
|
return fetch(cursor: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnStickerPack>> fetch({
|
||||||
|
required String? cursor,
|
||||||
|
}) async {
|
||||||
|
final client = ref.read(apiClientProvider);
|
||||||
|
final offset = cursor == null ? 0 : int.parse(cursor);
|
||||||
|
|
||||||
|
final response = await client.get(
|
||||||
|
'/sphere/stickers',
|
||||||
|
queryParameters: {'offset': offset, 'take': 20},
|
||||||
|
);
|
||||||
|
|
||||||
|
final total = int.parse(response.headers.value('X-Total') ?? '0');
|
||||||
|
final List<dynamic> data = response.data;
|
||||||
|
final stickers = data.map((e) => SnStickerPack.fromJson(e)).toList();
|
||||||
|
|
||||||
|
final hasMore = offset + stickers.length < total;
|
||||||
|
final nextCursor = hasMore ? (offset + stickers.length).toString() : null;
|
||||||
|
|
||||||
|
return CursorPagingData(
|
||||||
|
items: stickers,
|
||||||
|
hasMore: hasMore,
|
||||||
|
nextCursor: nextCursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// User-facing marketplace screen for browsing sticker packs.
|
||||||
|
/// This version does NOT rely on publisher name (no pubName).
|
||||||
|
class MarketplaceStickersScreen extends HookConsumerWidget {
|
||||||
|
const MarketplaceStickersScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return AppScaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('stickers').tr(),
|
||||||
|
actions: const [Gap(8)],
|
||||||
|
),
|
||||||
|
body: const SliverMarketplaceStickerPacksList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SliverMarketplaceStickerPacksList extends HookConsumerWidget {
|
||||||
|
const SliverMarketplaceStickerPacksList({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return PagingHelperView(
|
||||||
|
provider: marketplaceStickerPacksNotifierProvider,
|
||||||
|
futureRefreshable: marketplaceStickerPacksNotifierProvider.future,
|
||||||
|
notifierRefreshable: marketplaceStickerPacksNotifierProvider.notifier,
|
||||||
|
contentBuilder:
|
||||||
|
(data, widgetCount, endItemView) => ListView.builder(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
itemCount: widgetCount,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == widgetCount - 1) {
|
||||||
|
return endItemView;
|
||||||
|
}
|
||||||
|
|
||||||
|
final pack = data.items[index];
|
||||||
|
return ListTile(
|
||||||
|
title: Text(pack.name),
|
||||||
|
subtitle: Text(pack.description),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
onTap: () {
|
||||||
|
// Navigate to user-facing sticker pack detail page.
|
||||||
|
// Adjust the route name/parameters if your app uses different ones.
|
||||||
|
context.pushNamed(
|
||||||
|
'stickerPackDetail',
|
||||||
|
pathParameters: {'packId': pack.id},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
lib/screens/stickers/marketplace.g.dart
Normal file
32
lib/screens/stickers/marketplace.g.dart
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'marketplace.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$marketplaceStickerPacksNotifierHash() =>
|
||||||
|
r'b62ae8b7f5c4f8bb3be8c17fc005ea26da355187';
|
||||||
|
|
||||||
|
/// See also [MarketplaceStickerPacksNotifier].
|
||||||
|
@ProviderFor(MarketplaceStickerPacksNotifier)
|
||||||
|
final marketplaceStickerPacksNotifierProvider =
|
||||||
|
AutoDisposeAsyncNotifierProvider<
|
||||||
|
MarketplaceStickerPacksNotifier,
|
||||||
|
CursorPagingData<SnStickerPack>
|
||||||
|
>.internal(
|
||||||
|
MarketplaceStickerPacksNotifier.new,
|
||||||
|
name: r'marketplaceStickerPacksNotifierProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$marketplaceStickerPacksNotifierHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef _$MarketplaceStickerPacksNotifier =
|
||||||
|
AutoDisposeAsyncNotifier<CursorPagingData<SnStickerPack>>;
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
230
lib/screens/stickers/pack_detail.dart
Normal file
230
lib/screens/stickers/pack_detail.dart
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/sticker.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/screens/creators/stickers/stickers.dart';
|
||||||
|
import 'package:island/widgets/alert.dart';
|
||||||
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
|
part 'pack_detail.g.dart'; // generated by riverpod_annotation build_runner
|
||||||
|
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
@riverpod
|
||||||
|
Future<List<SnSticker>> marketplaceStickerPackContent(
|
||||||
|
Ref ref, {
|
||||||
|
required String packId,
|
||||||
|
}) async {
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
final resp = await apiClient.get('/sphere/stickers/$packId/content');
|
||||||
|
return (resp.data as List).map((e) => SnSticker.fromJson(e)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
Future<bool> marketplaceStickerPackOwnership(
|
||||||
|
Ref ref, {
|
||||||
|
required String packId,
|
||||||
|
}) async {
|
||||||
|
final api = ref.watch(apiClientProvider);
|
||||||
|
try {
|
||||||
|
await api.get('/sphere/stickers/$packId/own');
|
||||||
|
// If not 404, consider owned
|
||||||
|
return true;
|
||||||
|
} on Object catch (e) {
|
||||||
|
// Dio error handling agnostic: treat 404 as not-owned, rethrow others
|
||||||
|
final msg = e.toString();
|
||||||
|
if (msg.contains('404')) return false;
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
|
||||||
|
final String id;
|
||||||
|
const MarketplaceStickerPackDetailScreen({super.key, required this.id});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
// Pack metadata provider exists globally in creators file; reuse it.
|
||||||
|
final pack = ref.watch(stickerPackProvider(id));
|
||||||
|
final packContent = ref.watch(
|
||||||
|
marketplaceStickerPackContentProvider(packId: id),
|
||||||
|
);
|
||||||
|
final owned = ref.watch(
|
||||||
|
marketplaceStickerPackOwnershipProvider(packId: id),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add entire pack to user's collection
|
||||||
|
Future<void> addPackToMyCollection() async {
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
await apiClient.post('/sphere/stickers/$id/own');
|
||||||
|
HapticFeedback.selectionClick();
|
||||||
|
ref.invalidate(marketplaceStickerPackOwnershipProvider(packId: id));
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showSnackBar('stickerPackAdded'.tr());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove ownership of the pack
|
||||||
|
Future<void> removePackFromMyCollection() async {
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
await apiClient.delete('/sphere/stickers/$id/own');
|
||||||
|
HapticFeedback.selectionClick();
|
||||||
|
ref.invalidate(marketplaceStickerPackOwnershipProvider(packId: id));
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showSnackBar('stickerPackRemoved'.tr());
|
||||||
|
}
|
||||||
|
|
||||||
|
return AppScaffold(
|
||||||
|
appBar: AppBar(title: Text(pack.value?.name ?? 'loading'.tr())),
|
||||||
|
body: pack.when(
|
||||||
|
data: (p) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
// Pack meta
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Text(p?.description ?? ''),
|
||||||
|
Row(
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.folder, size: 16),
|
||||||
|
Text(
|
||||||
|
'${packContent.value?.length ?? 0}/24',
|
||||||
|
style: GoogleFonts.robotoMono(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).opacity(0.85),
|
||||||
|
Row(
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.sell, size: 16),
|
||||||
|
Text(p?.prefix ?? '', style: GoogleFonts.robotoMono()),
|
||||||
|
],
|
||||||
|
).opacity(0.85),
|
||||||
|
Row(
|
||||||
|
spacing: 4,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.tag, size: 16),
|
||||||
|
SelectableText(
|
||||||
|
p?.id ?? id,
|
||||||
|
style: GoogleFonts.robotoMono(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).opacity(0.85),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 24),
|
||||||
|
const Divider(height: 1),
|
||||||
|
// Stickers grid
|
||||||
|
Expanded(
|
||||||
|
child: packContent.when(
|
||||||
|
data:
|
||||||
|
(stickers) => RefreshIndicator(
|
||||||
|
onRefresh:
|
||||||
|
() => ref.refresh(
|
||||||
|
marketplaceStickerPackContentProvider(
|
||||||
|
packId: id,
|
||||||
|
).future,
|
||||||
|
),
|
||||||
|
child: GridView.builder(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
vertical: 20,
|
||||||
|
),
|
||||||
|
gridDelegate:
|
||||||
|
const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
|
maxCrossAxisExtent: 96,
|
||||||
|
mainAxisSpacing: 12,
|
||||||
|
crossAxisSpacing: 12,
|
||||||
|
),
|
||||||
|
itemCount: stickers.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final sticker = stickers[index];
|
||||||
|
return Tooltip(
|
||||||
|
message: ':${p?.prefix ?? ''}${sticker.slug}:',
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
Radius.circular(8),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color:
|
||||||
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceContainer,
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
Radius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 1,
|
||||||
|
child: CloudImageWidget(
|
||||||
|
fileId: sticker.imageId,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
error:
|
||||||
|
(err, _) =>
|
||||||
|
Text(
|
||||||
|
'Error: $err',
|
||||||
|
).textAlignment(TextAlign.center).center(),
|
||||||
|
loading: () => const CircularProgressIndicator().center(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||||
|
child: owned.when(
|
||||||
|
data:
|
||||||
|
(isOwned) => FilledButton.icon(
|
||||||
|
onPressed:
|
||||||
|
isOwned
|
||||||
|
? removePackFromMyCollection
|
||||||
|
: addPackToMyCollection,
|
||||||
|
icon: Icon(
|
||||||
|
isOwned ? Symbols.remove_circle : Symbols.add_circle,
|
||||||
|
),
|
||||||
|
label: Text(
|
||||||
|
isOwned ? 'removePack'.tr() : 'addPack'.tr(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
loading:
|
||||||
|
() => const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
),
|
||||||
|
error:
|
||||||
|
(_, _) => OutlinedButton.icon(
|
||||||
|
onPressed: addPackToMyCollection,
|
||||||
|
icon: const Icon(Symbols.add_circle),
|
||||||
|
label: Text('addPack').tr(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Gap(MediaQuery.of(context).padding.bottom),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
error:
|
||||||
|
(err, _) =>
|
||||||
|
Text('Error: $err').textAlignment(TextAlign.center).center(),
|
||||||
|
loading: () => const CircularProgressIndicator().center(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
317
lib/screens/stickers/pack_detail.g.dart
Normal file
317
lib/screens/stickers/pack_detail.g.dart
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'pack_detail.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$marketplaceStickerPackContentHash() =>
|
||||||
|
r'886f8305c978dbea6e5d990a7d555048ac704a5d';
|
||||||
|
|
||||||
|
/// Copied from Dart SDK
|
||||||
|
class _SystemHash {
|
||||||
|
_SystemHash._();
|
||||||
|
|
||||||
|
static int combine(int hash, int value) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + value);
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||||
|
return hash ^ (hash >> 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int finish(int hash) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = hash ^ (hash >> 11);
|
||||||
|
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
///
|
||||||
|
/// Copied from [marketplaceStickerPackContent].
|
||||||
|
@ProviderFor(marketplaceStickerPackContent)
|
||||||
|
const marketplaceStickerPackContentProvider =
|
||||||
|
MarketplaceStickerPackContentFamily();
|
||||||
|
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
///
|
||||||
|
/// Copied from [marketplaceStickerPackContent].
|
||||||
|
class MarketplaceStickerPackContentFamily
|
||||||
|
extends Family<AsyncValue<List<SnSticker>>> {
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
///
|
||||||
|
/// Copied from [marketplaceStickerPackContent].
|
||||||
|
const MarketplaceStickerPackContentFamily();
|
||||||
|
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
///
|
||||||
|
/// Copied from [marketplaceStickerPackContent].
|
||||||
|
MarketplaceStickerPackContentProvider call({required String packId}) {
|
||||||
|
return MarketplaceStickerPackContentProvider(packId: packId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
MarketplaceStickerPackContentProvider getProviderOverride(
|
||||||
|
covariant MarketplaceStickerPackContentProvider provider,
|
||||||
|
) {
|
||||||
|
return call(packId: provider.packId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'marketplaceStickerPackContentProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
///
|
||||||
|
/// Copied from [marketplaceStickerPackContent].
|
||||||
|
class MarketplaceStickerPackContentProvider
|
||||||
|
extends AutoDisposeFutureProvider<List<SnSticker>> {
|
||||||
|
/// Marketplace version of sticker pack detail page (no publisher dependency).
|
||||||
|
/// Shows all stickers in the pack and provides a button to add the sticker.
|
||||||
|
/// API interactions are intentionally left blank per request.
|
||||||
|
///
|
||||||
|
/// Copied from [marketplaceStickerPackContent].
|
||||||
|
MarketplaceStickerPackContentProvider({required String packId})
|
||||||
|
: this._internal(
|
||||||
|
(ref) => marketplaceStickerPackContent(
|
||||||
|
ref as MarketplaceStickerPackContentRef,
|
||||||
|
packId: packId,
|
||||||
|
),
|
||||||
|
from: marketplaceStickerPackContentProvider,
|
||||||
|
name: r'marketplaceStickerPackContentProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$marketplaceStickerPackContentHash,
|
||||||
|
dependencies: MarketplaceStickerPackContentFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
MarketplaceStickerPackContentFamily._allTransitiveDependencies,
|
||||||
|
packId: packId,
|
||||||
|
);
|
||||||
|
|
||||||
|
MarketplaceStickerPackContentProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.packId,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String packId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<List<SnSticker>> Function(
|
||||||
|
MarketplaceStickerPackContentRef provider,
|
||||||
|
)
|
||||||
|
create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: MarketplaceStickerPackContentProvider._internal(
|
||||||
|
(ref) => create(ref as MarketplaceStickerPackContentRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
packId: packId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<List<SnSticker>> createElement() {
|
||||||
|
return _MarketplaceStickerPackContentProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is MarketplaceStickerPackContentProvider &&
|
||||||
|
other.packId == packId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, packId.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin MarketplaceStickerPackContentRef
|
||||||
|
on AutoDisposeFutureProviderRef<List<SnSticker>> {
|
||||||
|
/// The parameter `packId` of this provider.
|
||||||
|
String get packId;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MarketplaceStickerPackContentProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<List<SnSticker>>
|
||||||
|
with MarketplaceStickerPackContentRef {
|
||||||
|
_MarketplaceStickerPackContentProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get packId => (origin as MarketplaceStickerPackContentProvider).packId;
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$marketplaceStickerPackOwnershipHash() =>
|
||||||
|
r'e5dd301c309fac958729d13d984ce7a77edbe7e6';
|
||||||
|
|
||||||
|
/// See also [marketplaceStickerPackOwnership].
|
||||||
|
@ProviderFor(marketplaceStickerPackOwnership)
|
||||||
|
const marketplaceStickerPackOwnershipProvider =
|
||||||
|
MarketplaceStickerPackOwnershipFamily();
|
||||||
|
|
||||||
|
/// See also [marketplaceStickerPackOwnership].
|
||||||
|
class MarketplaceStickerPackOwnershipFamily extends Family<AsyncValue<bool>> {
|
||||||
|
/// See also [marketplaceStickerPackOwnership].
|
||||||
|
const MarketplaceStickerPackOwnershipFamily();
|
||||||
|
|
||||||
|
/// See also [marketplaceStickerPackOwnership].
|
||||||
|
MarketplaceStickerPackOwnershipProvider call({required String packId}) {
|
||||||
|
return MarketplaceStickerPackOwnershipProvider(packId: packId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
MarketplaceStickerPackOwnershipProvider getProviderOverride(
|
||||||
|
covariant MarketplaceStickerPackOwnershipProvider provider,
|
||||||
|
) {
|
||||||
|
return call(packId: provider.packId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'marketplaceStickerPackOwnershipProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [marketplaceStickerPackOwnership].
|
||||||
|
class MarketplaceStickerPackOwnershipProvider
|
||||||
|
extends AutoDisposeFutureProvider<bool> {
|
||||||
|
/// See also [marketplaceStickerPackOwnership].
|
||||||
|
MarketplaceStickerPackOwnershipProvider({required String packId})
|
||||||
|
: this._internal(
|
||||||
|
(ref) => marketplaceStickerPackOwnership(
|
||||||
|
ref as MarketplaceStickerPackOwnershipRef,
|
||||||
|
packId: packId,
|
||||||
|
),
|
||||||
|
from: marketplaceStickerPackOwnershipProvider,
|
||||||
|
name: r'marketplaceStickerPackOwnershipProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$marketplaceStickerPackOwnershipHash,
|
||||||
|
dependencies: MarketplaceStickerPackOwnershipFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
MarketplaceStickerPackOwnershipFamily._allTransitiveDependencies,
|
||||||
|
packId: packId,
|
||||||
|
);
|
||||||
|
|
||||||
|
MarketplaceStickerPackOwnershipProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.packId,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String packId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<bool> Function(MarketplaceStickerPackOwnershipRef provider) create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: MarketplaceStickerPackOwnershipProvider._internal(
|
||||||
|
(ref) => create(ref as MarketplaceStickerPackOwnershipRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
packId: packId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<bool> createElement() {
|
||||||
|
return _MarketplaceStickerPackOwnershipProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is MarketplaceStickerPackOwnershipProvider &&
|
||||||
|
other.packId == packId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, packId.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin MarketplaceStickerPackOwnershipRef on AutoDisposeFutureProviderRef<bool> {
|
||||||
|
/// The parameter `packId` of this provider.
|
||||||
|
String get packId;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MarketplaceStickerPackOwnershipProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<bool>
|
||||||
|
with MarketplaceStickerPackOwnershipRef {
|
||||||
|
_MarketplaceStickerPackOwnershipProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get packId =>
|
||||||
|
(origin as MarketplaceStickerPackOwnershipProvider).packId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
@@ -15,6 +15,7 @@ Future<XFile?> cropImage(
|
|||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required XFile image,
|
required XFile image,
|
||||||
List<CropAspectRatio?>? allowedAspectRatios,
|
List<CropAspectRatio?>? allowedAspectRatios,
|
||||||
|
bool replacePath = false,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await showMaterialImageCropper(
|
final result = await showMaterialImageCropper(
|
||||||
context,
|
context,
|
||||||
@@ -34,7 +35,7 @@ Future<XFile?> cropImage(
|
|||||||
croppedFile.dispose();
|
croppedFile.dispose();
|
||||||
return XFile.fromData(
|
return XFile.fromData(
|
||||||
croppedBytes.buffer.asUint8List(),
|
croppedBytes.buffer.asUint8List(),
|
||||||
path: image.path,
|
path: !replacePath ? image.path : null,
|
||||||
mimeType: image.mimeType,
|
mimeType: image.mimeType,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,33 @@ extension DurationFormatter on Duration {
|
|||||||
return '${isNegative ? '-' : ''}$hours:$minutes:$seconds';
|
return '${isNegative ? '-' : ''}$hours:$minutes:$seconds';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String formatShortDuration() {
|
||||||
|
final isNegative = inMicroseconds < 0;
|
||||||
|
final positiveDuration = isNegative ? -this : this;
|
||||||
|
|
||||||
|
final hours = positiveDuration.inHours;
|
||||||
|
final minutes = (positiveDuration.inMinutes % 60).toString().padLeft(
|
||||||
|
2,
|
||||||
|
'0',
|
||||||
|
);
|
||||||
|
final seconds = (positiveDuration.inSeconds % 60).toString().padLeft(
|
||||||
|
2,
|
||||||
|
'0',
|
||||||
|
);
|
||||||
|
final milliseconds = (positiveDuration.inMilliseconds % 1000)
|
||||||
|
.toString()
|
||||||
|
.padLeft(3, '0');
|
||||||
|
|
||||||
|
String result;
|
||||||
|
if (hours > 0) {
|
||||||
|
result =
|
||||||
|
'${isNegative ? '-' : ''}${hours.toString().padLeft(2, '0')}:$minutes:$seconds.$milliseconds';
|
||||||
|
} else {
|
||||||
|
result = '${isNegative ? '-' : ''}$minutes:$seconds.$milliseconds';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
String formatOffset() {
|
String formatOffset() {
|
||||||
final isNegative = inMicroseconds < 0;
|
final isNegative = inMicroseconds < 0;
|
||||||
final positiveDuration = isNegative ? -this : this;
|
final positiveDuration = isNegative ? -this : this;
|
||||||
|
|||||||
228
lib/services/update_service.dart
Normal file
228
lib/services/update_service.dart
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
|
||||||
|
/// Data model for a GitHub release we care about
|
||||||
|
class GithubReleaseInfo {
|
||||||
|
final String tagName; // e.g. 3.1.0+118
|
||||||
|
final String name; // release title
|
||||||
|
final String body; // changelog markdown
|
||||||
|
final String htmlUrl; // release page
|
||||||
|
final DateTime createdAt;
|
||||||
|
|
||||||
|
const GithubReleaseInfo({
|
||||||
|
required this.tagName,
|
||||||
|
required this.name,
|
||||||
|
required this.body,
|
||||||
|
required this.htmlUrl,
|
||||||
|
required this.createdAt,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parses version and build number from "x.y.z+build"
|
||||||
|
class _ParsedVersion implements Comparable<_ParsedVersion> {
|
||||||
|
final int major;
|
||||||
|
final int minor;
|
||||||
|
final int patch;
|
||||||
|
final int build;
|
||||||
|
|
||||||
|
const _ParsedVersion(this.major, this.minor, this.patch, this.build);
|
||||||
|
|
||||||
|
static _ParsedVersion? tryParse(String input) {
|
||||||
|
// Expect format like 0.0.0+00 (build after '+'). Allow missing build as 0.
|
||||||
|
final partsPlus = input.split('+');
|
||||||
|
final core = partsPlus[0].trim();
|
||||||
|
final buildStr = partsPlus.length > 1 ? partsPlus[1].trim() : '0';
|
||||||
|
final coreParts = core.split('.');
|
||||||
|
if (coreParts.length != 3) return null;
|
||||||
|
|
||||||
|
final major = int.tryParse(coreParts[0]) ?? 0;
|
||||||
|
final minor = int.tryParse(coreParts[1]) ?? 0;
|
||||||
|
final patch = int.tryParse(coreParts[2]) ?? 0;
|
||||||
|
final build = int.tryParse(buildStr) ?? 0;
|
||||||
|
|
||||||
|
return _ParsedVersion(major, minor, patch, build);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int compareTo(_ParsedVersion other) {
|
||||||
|
if (major != other.major) return major.compareTo(other.major);
|
||||||
|
if (minor != other.minor) return minor.compareTo(other.minor);
|
||||||
|
if (patch != other.patch) return patch.compareTo(other.patch);
|
||||||
|
return build.compareTo(other.build);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => '$major.$minor.$patch+$build';
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdateService {
|
||||||
|
UpdateService({Dio? dio})
|
||||||
|
: _dio =
|
||||||
|
dio ??
|
||||||
|
Dio(
|
||||||
|
BaseOptions(
|
||||||
|
headers: {
|
||||||
|
// Identify the app to GitHub; avoids some rate-limits and adds clarity
|
||||||
|
'Accept': 'application/vnd.github+json',
|
||||||
|
'User-Agent': 'solian-update-checker',
|
||||||
|
},
|
||||||
|
connectTimeout: const Duration(seconds: 10),
|
||||||
|
receiveTimeout: const Duration(seconds: 15),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Dio _dio;
|
||||||
|
|
||||||
|
static const _releasesLatestApi =
|
||||||
|
'https://api.github.com/repos/solsynth/solian/releases/latest';
|
||||||
|
|
||||||
|
/// Checks GitHub for the latest release and compares against the current app version.
|
||||||
|
/// If update is available, shows a bottom sheet with changelog and an action to open release page.
|
||||||
|
Future<void> checkForUpdates(BuildContext context) async {
|
||||||
|
try {
|
||||||
|
final release = await fetchLatestRelease();
|
||||||
|
if (release == null) return;
|
||||||
|
|
||||||
|
final info = await PackageInfo.fromPlatform();
|
||||||
|
final localVersionStr = '${info.version}+${info.buildNumber}';
|
||||||
|
|
||||||
|
final latest = _ParsedVersion.tryParse(release.tagName);
|
||||||
|
final local = _ParsedVersion.tryParse(localVersionStr);
|
||||||
|
|
||||||
|
if (latest == null || local == null) {
|
||||||
|
// If parsing fails, do nothing silently
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final needsUpdate = latest.compareTo(local) > 0;
|
||||||
|
if (!needsUpdate) return;
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
|
// Delay to ensure UI is ready (if called at startup)
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
|
||||||
|
await showUpdateSheet(context, release);
|
||||||
|
} catch (_) {
|
||||||
|
// Ignore errors (network, api, etc.)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Manually show the update sheet with a provided release.
|
||||||
|
/// Useful for About page or testing.
|
||||||
|
Future<void> showUpdateSheet(
|
||||||
|
BuildContext context,
|
||||||
|
GithubReleaseInfo release,
|
||||||
|
) async {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
useRootNavigator: true,
|
||||||
|
builder:
|
||||||
|
(ctx) => _UpdateSheet(
|
||||||
|
release: release,
|
||||||
|
onOpen: () async {
|
||||||
|
final uri = Uri.parse(release.htmlUrl);
|
||||||
|
if (await canLaunchUrl(uri)) {
|
||||||
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch the latest release info from GitHub.
|
||||||
|
/// Public so other screens (e.g., About) can manually trigger update checks.
|
||||||
|
Future<GithubReleaseInfo?> fetchLatestRelease() async {
|
||||||
|
final resp = await _dio.get(_releasesLatestApi);
|
||||||
|
if (resp.statusCode != 200) return null;
|
||||||
|
final data = resp.data as Map<String, dynamic>;
|
||||||
|
|
||||||
|
final tagName = (data['tag_name'] ?? '').toString();
|
||||||
|
final name = (data['name'] ?? tagName).toString();
|
||||||
|
final body = (data['body'] ?? '').toString();
|
||||||
|
final htmlUrl = (data['html_url'] ?? '').toString();
|
||||||
|
final createdAtStr = (data['created_at'] ?? '').toString();
|
||||||
|
final createdAt = DateTime.tryParse(createdAtStr) ?? DateTime.now();
|
||||||
|
|
||||||
|
if (tagName.isEmpty || htmlUrl.isEmpty) return null;
|
||||||
|
|
||||||
|
return GithubReleaseInfo(
|
||||||
|
tagName: tagName,
|
||||||
|
name: name,
|
||||||
|
body: body,
|
||||||
|
htmlUrl: htmlUrl,
|
||||||
|
createdAt: createdAt,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UpdateSheet extends StatelessWidget {
|
||||||
|
const _UpdateSheet({required this.release, required this.onOpen});
|
||||||
|
|
||||||
|
final GithubReleaseInfo release;
|
||||||
|
final VoidCallback onOpen;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return SheetScaffold(
|
||||||
|
titleText: 'Update available',
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: 16 + MediaQuery.of(context).padding.bottom,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(release.name, style: theme.textTheme.titleMedium).bold(),
|
||||||
|
Text(release.tagName).fontSize(12),
|
||||||
|
],
|
||||||
|
).padding(vertical: 16, horizontal: 16),
|
||||||
|
const Divider(height: 1),
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 16,
|
||||||
|
),
|
||||||
|
child: SelectableText(
|
||||||
|
release.body.isEmpty
|
||||||
|
? 'No changelog provided.'
|
||||||
|
: release.body,
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: FilledButton.icon(
|
||||||
|
onPressed: onOpen,
|
||||||
|
icon: const Icon(Icons.open_in_new),
|
||||||
|
label: const Text('Open release page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
lib/utils/mapping.dart
Normal file
30
lib/utils/mapping.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
String _upperCamelToLowerSnake(String input) {
|
||||||
|
final regex = RegExp(r'(?<=[a-z0-9])([A-Z])');
|
||||||
|
return input
|
||||||
|
.replaceAllMapped(regex, (match) => '_${match.group(0)}')
|
||||||
|
.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> convertMapKeysToSnakeCase(Map<String, dynamic> input) {
|
||||||
|
final result = <String, dynamic>{};
|
||||||
|
|
||||||
|
input.forEach((key, value) {
|
||||||
|
final newKey = _upperCamelToLowerSnake(key);
|
||||||
|
|
||||||
|
if (value is Map<String, dynamic>) {
|
||||||
|
result[newKey] = convertMapKeysToSnakeCase(value);
|
||||||
|
} else if (value is List) {
|
||||||
|
result[newKey] =
|
||||||
|
value.map((item) {
|
||||||
|
if (item is Map<String, dynamic>) {
|
||||||
|
return convertMapKeysToSnakeCase(item);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}).toList();
|
||||||
|
} else {
|
||||||
|
result[newKey] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -32,12 +32,12 @@ class BadgeItem extends StatelessWidget {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: (template?.color ?? Colors.blue).withOpacity(0.1),
|
color: (template?.color ?? Colors.blue).withOpacity(0.2),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
template?.icon ?? Icons.stars,
|
template?.icon ?? Icons.stars,
|
||||||
color: template?.color ?? Colors.orange,
|
color: template?.color ?? Colors.blue,
|
||||||
size: 20,
|
size: 20,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class RestorePurchaseSheet extends HookConsumerWidget {
|
|||||||
try {
|
try {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
await client.post(
|
await client.post(
|
||||||
'/subscriptions/order/restore/${selectedProvider.value!}',
|
'/id/subscriptions/order/restore/${selectedProvider.value!}',
|
||||||
data: {'order_id': orderIdController.text.trim()},
|
data: {'order_id': orderIdController.text.trim()},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class AccountStatusCreationWidget extends HookConsumerWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
builder:
|
builder:
|
||||||
(context) => AccountStatusCreationSheet(
|
(context) => AccountStatusCreationSheet(
|
||||||
@@ -129,9 +130,22 @@ class AccountStatusWidget extends HookConsumerWidget {
|
|||||||
size: 16,
|
size: 16,
|
||||||
).padding(right: 4),
|
).padding(right: 4),
|
||||||
if (status.value?.isCustomized ?? false)
|
if (status.value?.isCustomized ?? false)
|
||||||
Text(status.value?.label ?? 'unknown'.tr())
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
status.value?.label ?? 'unknown'.tr(),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
)
|
||||||
else
|
else
|
||||||
Text((status.value?.label ?? 'offline').toLowerCase()).tr(),
|
Flexible(
|
||||||
|
child:
|
||||||
|
Text(
|
||||||
|
(status.value?.label ?? 'offline').toLowerCase(),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
).tr(),
|
||||||
|
),
|
||||||
if (!(status.value?.isOnline ?? false) &&
|
if (!(status.value?.isOnline ?? false) &&
|
||||||
account.value?.profile.lastSeenAt != null)
|
account.value?.profile.lastSeenAt != null)
|
||||||
Flexible(
|
Flexible(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:island/pods/network.dart';
|
|||||||
import 'package:island/pods/userinfo.dart';
|
import 'package:island/pods/userinfo.dart';
|
||||||
import 'package:island/widgets/account/status.dart';
|
import 'package:island/widgets/account/status.dart';
|
||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
|
||||||
class AccountStatusCreationSheet extends HookConsumerWidget {
|
class AccountStatusCreationSheet extends HookConsumerWidget {
|
||||||
@@ -71,178 +72,145 @@ class AccountStatusCreationSheet extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Container(
|
return SheetScaffold(
|
||||||
constraints: BoxConstraints(
|
heightFactor: 0.6,
|
||||||
maxHeight: MediaQuery.of(context).size.height * 0.8,
|
titleText:
|
||||||
),
|
initialStatus == null ? 'statusCreate'.tr() : 'statusUpdate'.tr(),
|
||||||
child: Column(
|
actions: [
|
||||||
children: [
|
TextButton.icon(
|
||||||
Padding(
|
onPressed:
|
||||||
padding: EdgeInsets.only(top: 16, left: 20, right: 16, bottom: 12),
|
submitting.value
|
||||||
child: Row(
|
? null
|
||||||
children: [
|
: () {
|
||||||
Text(
|
submitStatus();
|
||||||
initialStatus == null
|
},
|
||||||
? 'statusCreate'.tr()
|
icon: const Icon(Symbols.upload),
|
||||||
: 'statusUpdate'.tr(),
|
label: Text(initialStatus == null ? 'create' : 'update').tr(),
|
||||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
style: ButtonStyle(
|
||||||
fontWeight: FontWeight.w600,
|
visualDensity: VisualDensity(
|
||||||
letterSpacing: -0.5,
|
horizontal: VisualDensity.minimumDensity,
|
||||||
),
|
),
|
||||||
|
foregroundColor: WidgetStatePropertyAll(
|
||||||
|
Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (initialStatus != null)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Symbols.delete),
|
||||||
|
onPressed: submitting.value ? null : () => clearStatus(),
|
||||||
|
style: IconButton.styleFrom(minimumSize: const Size(36, 36)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
const Gap(24),
|
||||||
|
TextField(
|
||||||
|
controller: labelController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'statusLabel'.tr(),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
),
|
||||||
TextButton.icon(
|
onTapOutside:
|
||||||
onPressed:
|
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
submitting.value
|
),
|
||||||
? null
|
const SizedBox(height: 24),
|
||||||
: () {
|
Text(
|
||||||
submitStatus();
|
'statusAttitude'.tr(),
|
||||||
},
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
icon: const Icon(Symbols.upload),
|
),
|
||||||
label: Text(initialStatus == null ? 'create' : 'update').tr(),
|
const SizedBox(height: 8),
|
||||||
style: ButtonStyle(
|
SegmentedButton(
|
||||||
visualDensity: VisualDensity(
|
segments: [
|
||||||
horizontal: VisualDensity.minimumDensity,
|
ButtonSegment(
|
||||||
),
|
value: 0,
|
||||||
foregroundColor: WidgetStatePropertyAll(
|
icon: const Icon(Symbols.sentiment_satisfied),
|
||||||
Theme.of(context).colorScheme.onSurface,
|
label: Text('attitudePositive'.tr()),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (initialStatus != null)
|
ButtonSegment(
|
||||||
IconButton(
|
value: 1,
|
||||||
icon: const Icon(Symbols.delete),
|
icon: const Icon(Symbols.sentiment_stressed),
|
||||||
onPressed: submitting.value ? null : () => clearStatus(),
|
label: Text('attitudeNeutral'.tr()),
|
||||||
style: IconButton.styleFrom(
|
),
|
||||||
minimumSize: const Size(36, 36),
|
ButtonSegment(
|
||||||
),
|
value: 2,
|
||||||
),
|
icon: const Icon(Symbols.sentiment_sad),
|
||||||
IconButton(
|
label: Text('attitudeNegative'.tr()),
|
||||||
icon: const Icon(Symbols.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
style: IconButton.styleFrom(minimumSize: const Size(36, 36)),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
selected: {attitude.value},
|
||||||
|
onSelectionChanged: (Set<int> newSelection) {
|
||||||
|
attitude.value = newSelection.first;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
const Gap(12),
|
||||||
const Divider(height: 1),
|
SwitchListTile(
|
||||||
Expanded(
|
title: Text('statusInvisible'.tr()),
|
||||||
child: SingleChildScrollView(
|
subtitle: Text('statusInvisibleDescription'.tr()),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
value: isInvisible.value,
|
||||||
child: Column(
|
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
onChanged: (bool value) {
|
||||||
children: [
|
isInvisible.value = value;
|
||||||
const Gap(24),
|
},
|
||||||
TextField(
|
),
|
||||||
controller: labelController,
|
SwitchListTile(
|
||||||
decoration: InputDecoration(
|
title: Text('statusNotDisturb'.tr()),
|
||||||
labelText: 'statusLabel'.tr(),
|
subtitle: Text('statusNotDisturbDescription'.tr()),
|
||||||
border: const OutlineInputBorder(
|
value: isNotDisturb.value,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
),
|
onChanged: (bool value) {
|
||||||
),
|
isNotDisturb.value = value;
|
||||||
onTapOutside:
|
},
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
),
|
||||||
),
|
const SizedBox(height: 24),
|
||||||
const SizedBox(height: 24),
|
Text(
|
||||||
Text(
|
'statusClearTime'.tr(),
|
||||||
'statusAttitude'.tr(),
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
ListTile(
|
||||||
SegmentedButton(
|
title: Text(
|
||||||
segments: [
|
clearedAt.value == null
|
||||||
ButtonSegment(
|
? 'statusNoAutoClear'.tr()
|
||||||
value: 0,
|
: DateFormat.yMMMd().add_jm().format(clearedAt.value!),
|
||||||
icon: const Icon(Symbols.sentiment_satisfied),
|
|
||||||
label: Text('attitudePositive'.tr()),
|
|
||||||
),
|
|
||||||
ButtonSegment(
|
|
||||||
value: 1,
|
|
||||||
icon: const Icon(Symbols.sentiment_stressed),
|
|
||||||
label: Text('attitudeNeutral'.tr()),
|
|
||||||
),
|
|
||||||
ButtonSegment(
|
|
||||||
value: 2,
|
|
||||||
icon: const Icon(Symbols.sentiment_sad),
|
|
||||||
label: Text('attitudeNegative'.tr()),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
selected: {attitude.value},
|
|
||||||
onSelectionChanged: (Set<int> newSelection) {
|
|
||||||
attitude.value = newSelection.first;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Gap(12),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text('statusInvisible'.tr()),
|
|
||||||
subtitle: Text('statusInvisibleDescription'.tr()),
|
|
||||||
value: isInvisible.value,
|
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
onChanged: (bool value) {
|
|
||||||
isInvisible.value = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text('statusNotDisturb'.tr()),
|
|
||||||
subtitle: Text('statusNotDisturbDescription'.tr()),
|
|
||||||
value: isNotDisturb.value,
|
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
onChanged: (bool value) {
|
|
||||||
isNotDisturb.value = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
Text(
|
|
||||||
'statusClearTime'.tr(),
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
clearedAt.value == null
|
|
||||||
? 'statusNoAutoClear'.tr()
|
|
||||||
: DateFormat.yMMMd().add_jm().format(
|
|
||||||
clearedAt.value!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: const Icon(Symbols.schedule),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
final now = DateTime.now();
|
|
||||||
final date = await showDatePicker(
|
|
||||||
context: context,
|
|
||||||
initialDate: now,
|
|
||||||
firstDate: now,
|
|
||||||
lastDate: now.add(const Duration(days: 365)),
|
|
||||||
);
|
|
||||||
if (date == null) return;
|
|
||||||
if (!context.mounted) return;
|
|
||||||
final time = await showTimePicker(
|
|
||||||
context: context,
|
|
||||||
initialTime: TimeOfDay.now(),
|
|
||||||
);
|
|
||||||
if (time == null) return;
|
|
||||||
clearedAt.value = DateTime(
|
|
||||||
date.year,
|
|
||||||
date.month,
|
|
||||||
date.day,
|
|
||||||
time.hour,
|
|
||||||
time.minute,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Gap(MediaQuery.of(context).padding.bottom + 24),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
trailing: const Icon(Symbols.schedule),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
final now = DateTime.now();
|
||||||
|
final date = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate: now,
|
||||||
|
firstDate: now,
|
||||||
|
lastDate: now.add(const Duration(days: 365)),
|
||||||
|
);
|
||||||
|
if (date == null) return;
|
||||||
|
if (!context.mounted) return;
|
||||||
|
final time = await showTimePicker(
|
||||||
|
context: context,
|
||||||
|
initialTime: TimeOfDay.now(),
|
||||||
|
);
|
||||||
|
if (time == null) return;
|
||||||
|
clearedAt.value = DateTime(
|
||||||
|
date.year,
|
||||||
|
date.month,
|
||||||
|
date.day,
|
||||||
|
time.hour,
|
||||||
|
time.minute,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
Gap(MediaQuery.of(context).padding.bottom + 24),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ class _WebSocketIndicator extends HookConsumerWidget {
|
|||||||
final user = ref.watch(userInfoProvider);
|
final user = ref.watch(userInfoProvider);
|
||||||
final websocketState = ref.watch(websocketStateProvider);
|
final websocketState = ref.watch(websocketStateProvider);
|
||||||
final indicatorHeight =
|
final indicatorHeight =
|
||||||
MediaQuery.of(context).padding.top + (isDesktop ? 27.5 : 60);
|
MediaQuery.of(context).padding.top + (isDesktop ? 27.5 : 20);
|
||||||
|
|
||||||
Color indicatorColor;
|
Color indicatorColor;
|
||||||
String indicatorText;
|
String indicatorText;
|
||||||
@@ -343,7 +343,7 @@ class _WebSocketIndicator extends HookConsumerWidget {
|
|||||||
indicatorColor = Colors.teal;
|
indicatorColor = Colors.teal;
|
||||||
indicatorText = 'connectionReconnecting';
|
indicatorText = 'connectionReconnecting';
|
||||||
} else {
|
} else {
|
||||||
indicatorColor = Colors.orange;
|
indicatorColor = Colors.red;
|
||||||
indicatorText = 'connectionDisconnected';
|
indicatorText = 'connectionDisconnected';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import 'dart:async';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/pods/websocket.dart';
|
||||||
import 'package:island/services/notify.dart';
|
import 'package:island/services/notify.dart';
|
||||||
import 'package:island/services/sharing_intent.dart';
|
import 'package:island/services/sharing_intent.dart';
|
||||||
|
import 'package:island/widgets/content/network_status_sheet.dart';
|
||||||
import 'package:island/widgets/tour/tour.dart';
|
import 'package:island/widgets/tour/tour.dart';
|
||||||
|
|
||||||
class AppWrapper extends HookConsumerWidget {
|
class AppWrapper extends HookConsumerWidget {
|
||||||
@@ -25,6 +27,27 @@ class AppWrapper extends HookConsumerWidget {
|
|||||||
};
|
};
|
||||||
}, const []);
|
}, const []);
|
||||||
|
|
||||||
|
final wsNotifier = ref.watch(websocketStateProvider.notifier);
|
||||||
|
final websocketState = ref.watch(websocketStateProvider);
|
||||||
|
|
||||||
|
final networkStateShowing = useState(false);
|
||||||
|
|
||||||
|
if (websocketState == WebSocketState.duplicateDevice()) {
|
||||||
|
if (!networkStateShowing.value) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
networkStateShowing.value = true;
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
isDismissible: false,
|
||||||
|
builder:
|
||||||
|
(context) =>
|
||||||
|
NetworkStatusSheet(onReconnect: () => wsNotifier.connect()),
|
||||||
|
).then((_) => networkStateShowing.value = false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TourTriggerWidget(child: child);
|
return TourTriggerWidget(child: child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class CallParticipantCard extends HookConsumerWidget {
|
|||||||
const Gap(8),
|
const Gap(8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Slider(
|
child: Slider(
|
||||||
|
max: 2,
|
||||||
value: volumeSliderValue.value,
|
value: volumeSliderValue.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
volumeSliderValue.value = value;
|
volumeSliderValue.value = value;
|
||||||
@@ -52,9 +53,12 @@ class CallParticipantCard extends HookConsumerWidget {
|
|||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Gap(8),
|
const Gap(16),
|
||||||
Text(
|
SizedBox(
|
||||||
'${(volumeSliderValue.value * 100).toStringAsFixed(0)}%',
|
width: 40,
|
||||||
|
child: Text(
|
||||||
|
'${(volumeSliderValue.value * 100).toStringAsFixed(0)}%',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:island/models/embed.dart';
|
|||||||
import 'package:island/pods/call.dart';
|
import 'package:island/pods/call.dart';
|
||||||
import 'package:island/pods/translate.dart';
|
import 'package:island/pods/translate.dart';
|
||||||
import 'package:island/screens/chat/room.dart';
|
import 'package:island/screens/chat/room.dart';
|
||||||
|
import 'package:island/utils/mapping.dart';
|
||||||
import 'package:island/widgets/account/account_name.dart';
|
import 'package:island/widgets/account/account_name.dart';
|
||||||
import 'package:island/widgets/account/account_pfc.dart';
|
import 'package:island/widgets/account/account_pfc.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
@@ -292,12 +293,11 @@ class MessageItem extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
if (remoteMessage.meta['embeds'] != null)
|
if (remoteMessage.meta['embeds'] != null)
|
||||||
...((remoteMessage.meta['embeds'] as List<dynamic>)
|
...((remoteMessage.meta['embeds'] as List<dynamic>)
|
||||||
.where((embed) => embed['Type'] == 'link')
|
|
||||||
.map(
|
.map(
|
||||||
(embed) => SnEmbedLink.fromJson(
|
(embed) => convertMapKeysToSnakeCase(embed),
|
||||||
embed as Map<String, dynamic>,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
.where((embed) => embed['type'] == 'link')
|
||||||
|
.map((embed) => SnScrappedLink.fromJson(embed))
|
||||||
.map(
|
.map(
|
||||||
(link) => LayoutBuilder(
|
(link) => LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ Future<SnCheckInResult?> checkInResultToday(Ref ref) async {
|
|||||||
|
|
||||||
class CheckInWidget extends HookConsumerWidget {
|
class CheckInWidget extends HookConsumerWidget {
|
||||||
final EdgeInsets? margin;
|
final EdgeInsets? margin;
|
||||||
const CheckInWidget({super.key, this.margin});
|
final VoidCallback? onChecked;
|
||||||
|
const CheckInWidget({super.key, this.margin, this.onChecked});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -52,6 +53,7 @@ class CheckInWidget extends HookConsumerWidget {
|
|||||||
ref.invalidate(checkInResultTodayProvider);
|
ref.invalidate(checkInResultTodayProvider);
|
||||||
final userNotifier = ref.read(userInfoProvider.notifier);
|
final userNotifier = ref.read(userInfoProvider.notifier);
|
||||||
userNotifier.fetchUser();
|
userNotifier.fetchUser();
|
||||||
|
onChecked?.call();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err is DioException) {
|
if (err is DioException) {
|
||||||
if (err.response?.statusCode == 423 && context.mounted) {
|
if (err.response?.statusCode == 423 && context.mounted) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cross_file/cross_file.dart';
|
import 'package:cross_file/cross_file.dart';
|
||||||
@@ -5,18 +6,89 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/services/file.dart';
|
||||||
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:super_context_menu/super_context_menu.dart';
|
||||||
|
|
||||||
class AttachmentPreview extends StatelessWidget {
|
import 'sensitive.dart';
|
||||||
|
|
||||||
|
class SensitiveMarksSelector extends StatefulWidget {
|
||||||
|
final List<int> initial;
|
||||||
|
final ValueChanged<List<int>>? onChanged;
|
||||||
|
|
||||||
|
const SensitiveMarksSelector({
|
||||||
|
super.key,
|
||||||
|
required this.initial,
|
||||||
|
this.onChanged,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SensitiveMarksSelector> createState() => SensitiveMarksSelectorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SensitiveMarksSelectorState extends State<SensitiveMarksSelector> {
|
||||||
|
late List<int> _selected;
|
||||||
|
|
||||||
|
List<int> get current => _selected;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_selected = [...widget.initial];
|
||||||
|
}
|
||||||
|
|
||||||
|
void _toggle(int value) {
|
||||||
|
setState(() {
|
||||||
|
if (_selected.contains(value)) {
|
||||||
|
_selected.remove(value);
|
||||||
|
} else {
|
||||||
|
_selected.add(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
widget.onChanged?.call([..._selected]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// Build a list of all categories in fixed order as int list indices
|
||||||
|
final categories = kSensitiveCategoriesOrdered;
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
for (var i = 0; i < categories.length; i++)
|
||||||
|
FilterChip(
|
||||||
|
label: Text(categories[i].i18nKey.tr()),
|
||||||
|
avatar: Text(categories[i].symbol),
|
||||||
|
selected: _selected.contains(i),
|
||||||
|
onSelected: (_) => _toggle(i),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AttachmentPreview extends HookConsumerWidget {
|
||||||
final UniversalFile item;
|
final UniversalFile item;
|
||||||
final double? progress;
|
final double? progress;
|
||||||
final Function(int)? onMove;
|
final Function(int)? onMove;
|
||||||
final Function? onDelete;
|
final Function? onDelete;
|
||||||
final Function? onInsert;
|
final Function? onInsert;
|
||||||
|
final Function(UniversalFile)? onUpdate;
|
||||||
final Function? onRequestUpload;
|
final Function? onRequestUpload;
|
||||||
|
|
||||||
const AttachmentPreview({
|
const AttachmentPreview({
|
||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
@@ -24,11 +96,170 @@ class AttachmentPreview extends StatelessWidget {
|
|||||||
this.onRequestUpload,
|
this.onRequestUpload,
|
||||||
this.onMove,
|
this.onMove,
|
||||||
this.onDelete,
|
this.onDelete,
|
||||||
|
this.onUpdate,
|
||||||
this.onInsert,
|
this.onInsert,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// GlobalKey for selector
|
||||||
|
static final GlobalKey<SensitiveMarksSelectorState> _sensitiveSelectorKey =
|
||||||
|
GlobalKey<SensitiveMarksSelectorState>();
|
||||||
|
|
||||||
|
Future<void> _showRenameDialog(BuildContext context, WidgetRef ref) async {
|
||||||
|
final nameController = TextEditingController(text: item.data.name);
|
||||||
|
String? errorMessage;
|
||||||
|
|
||||||
|
await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder:
|
||||||
|
(context) => SheetScaffold(
|
||||||
|
heightFactor: 0.6,
|
||||||
|
titleText: 'rename'.tr(),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
vertical: 24,
|
||||||
|
),
|
||||||
|
child: TextField(
|
||||||
|
controller: nameController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'fileName'.tr(),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
errorText: errorMessage,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: Text('cancel'.tr()),
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final newName = nameController.text.trim();
|
||||||
|
if (newName.isEmpty) {
|
||||||
|
errorMessage = 'fieldCannotBeEmpty'.tr();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
showLoadingModal(context);
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
await apiClient.patch(
|
||||||
|
'/drive/files/${item.data.id}/name',
|
||||||
|
data: jsonEncode(newName),
|
||||||
|
);
|
||||||
|
final newData = item.data;
|
||||||
|
newData.name = newName;
|
||||||
|
final updatedFile = item.copyWith(data: newData);
|
||||||
|
onUpdate?.call(item.copyWith(data: updatedFile));
|
||||||
|
if (context.mounted) Navigator.pop(context);
|
||||||
|
} catch (err) {
|
||||||
|
showErrorAlert(err);
|
||||||
|
} finally {
|
||||||
|
if (context.mounted) hideLoadingModal(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text('rename'.tr()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 16, vertical: 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showSensitiveDialog(BuildContext context, WidgetRef ref) async {
|
||||||
|
await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder:
|
||||||
|
(context) => SheetScaffold(
|
||||||
|
heightFactor: 0.6,
|
||||||
|
titleText: 'markAsSensitive'.tr(),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
vertical: 24,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Sensitive categories checklist
|
||||||
|
SensitiveMarksSelector(
|
||||||
|
key: _sensitiveSelectorKey,
|
||||||
|
initial:
|
||||||
|
(item.data.sensitiveMarks ?? [])
|
||||||
|
.map((e) => e as int)
|
||||||
|
.cast<int>()
|
||||||
|
.toList(),
|
||||||
|
onChanged: (marks) {
|
||||||
|
// Update local data immediately (optimistic)
|
||||||
|
final newData = item.data;
|
||||||
|
newData.sensitiveMarks = marks;
|
||||||
|
final updatedFile = item.copyWith(data: newData);
|
||||||
|
onUpdate?.call(item.copyWith(data: updatedFile));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: Text('cancel'.tr()),
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
try {
|
||||||
|
showLoadingModal(context);
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
// Use the current selections from stateful selector via GlobalKey
|
||||||
|
final selectorState =
|
||||||
|
_sensitiveSelectorKey.currentState;
|
||||||
|
final marks = selectorState?.current ?? <int>[];
|
||||||
|
await apiClient.put(
|
||||||
|
'/drive/files/${item.data.id}/marks',
|
||||||
|
data: jsonEncode({'sensitive_marks': marks}),
|
||||||
|
);
|
||||||
|
final newData = item.data as SnCloudFile;
|
||||||
|
final updatedFile = item.copyWith(
|
||||||
|
data: newData.copyWith(sensitiveMarks: marks),
|
||||||
|
);
|
||||||
|
onUpdate?.call(updatedFile);
|
||||||
|
if (context.mounted) Navigator.pop(context);
|
||||||
|
} catch (err) {
|
||||||
|
showErrorAlert(err);
|
||||||
|
} finally {
|
||||||
|
if (context.mounted) hideLoadingModal(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text('confirm'.tr()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 16, vertical: 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
var ratio =
|
var ratio =
|
||||||
item.isOnCloud
|
item.isOnCloud
|
||||||
? (item.data.fileMeta?['ratio'] is num
|
? (item.data.fileMeta?['ratio'] is num
|
||||||
@@ -37,217 +268,265 @@ class AttachmentPreview extends StatelessWidget {
|
|||||||
: 1.0;
|
: 1.0;
|
||||||
if (ratio == 0) ratio = 1.0;
|
if (ratio == 0) ratio = 1.0;
|
||||||
|
|
||||||
return AspectRatio(
|
final contentWidget = ClipRRect(
|
||||||
aspectRatio: ratio,
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: ClipRRect(
|
child: Container(
|
||||||
borderRadius: BorderRadius.circular(8),
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
fit: StackFit.expand,
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
AspectRatio(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
aspectRatio: ratio,
|
||||||
child: Builder(
|
child: Stack(
|
||||||
builder: (context) {
|
fit: StackFit.expand,
|
||||||
if (item.isOnCloud) {
|
children: [
|
||||||
return CloudFileWidget(item: item.data);
|
Builder(
|
||||||
} else if (item.data is XFile) {
|
key: ValueKey(item.hashCode),
|
||||||
if (item.type == UniversalFileType.image) {
|
builder: (context) {
|
||||||
final file = item.data as XFile;
|
if (item.isOnCloud) {
|
||||||
if (file.path.isEmpty) {
|
return CloudFileWidget(item: item.data);
|
||||||
return FutureBuilder<Uint8List>(
|
} else if (item.data is XFile) {
|
||||||
future: file.readAsBytes(),
|
final file = item.data as XFile;
|
||||||
builder: (context, snapshot) {
|
if (file.path.isEmpty) {
|
||||||
if (snapshot.hasData) {
|
return FutureBuilder<Uint8List>(
|
||||||
return Image.memory(snapshot.data!);
|
future: file.readAsBytes(),
|
||||||
}
|
builder: (context, snapshot) {
|
||||||
return const Center(
|
if (snapshot.hasData) {
|
||||||
child: CircularProgressIndicator(),
|
return Image.memory(snapshot.data!);
|
||||||
|
}
|
||||||
|
return const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item.type) {
|
||||||
|
case UniversalFileType.image:
|
||||||
|
return kIsWeb
|
||||||
|
? Image.network(file.path)
|
||||||
|
: Image.file(File(file.path));
|
||||||
|
default:
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.document_scanner),
|
||||||
|
Text(file.name),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
);
|
} else if (item is List<int> || item is Uint8List) {
|
||||||
|
switch (item.type) {
|
||||||
|
case UniversalFileType.image:
|
||||||
|
return Image.memory(item.data);
|
||||||
|
default:
|
||||||
|
return Column(
|
||||||
|
children: [const Icon(Symbols.document_scanner)],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return kIsWeb
|
return Placeholder();
|
||||||
? Image.network(file.path)
|
},
|
||||||
: Image.file(File(file.path));
|
),
|
||||||
} else {
|
if (progress != null)
|
||||||
return Center(
|
Positioned.fill(
|
||||||
child: Text(
|
child: Container(
|
||||||
'Preview is not supported for ${item.type}',
|
color: Colors.black.withOpacity(0.3),
|
||||||
textAlign: TextAlign.center,
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 40,
|
||||||
|
vertical: 16,
|
||||||
),
|
),
|
||||||
);
|
child: Column(
|
||||||
}
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
} else if (item is List<int> || item is Uint8List) {
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
if (item.type == UniversalFileType.image) {
|
children: [
|
||||||
return Image.memory(item.data);
|
if (progress != null)
|
||||||
} else {
|
Text(
|
||||||
return Center(
|
'${progress!.toStringAsFixed(2)}%',
|
||||||
child: Text(
|
style: TextStyle(color: Colors.white),
|
||||||
'Preview is not supported for ${item.type}',
|
)
|
||||||
textAlign: TextAlign.center,
|
else
|
||||||
),
|
Text(
|
||||||
);
|
'uploading'.tr(),
|
||||||
}
|
style: TextStyle(color: Colors.white),
|
||||||
}
|
),
|
||||||
return Placeholder();
|
Gap(6),
|
||||||
},
|
Center(
|
||||||
),
|
child: LinearProgressIndicator(
|
||||||
),
|
value:
|
||||||
if (progress != null)
|
progress != null ? progress! / 100.0 : null,
|
||||||
Positioned.fill(
|
),
|
||||||
child: Container(
|
),
|
||||||
color: Colors.black.withOpacity(0.3),
|
],
|
||||||
padding: EdgeInsets.symmetric(horizontal: 40, vertical: 16),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
if (progress != null)
|
|
||||||
Text(
|
|
||||||
'${progress!.toStringAsFixed(2)}%',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
Text(
|
|
||||||
'uploading'.tr(),
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
Gap(6),
|
|
||||||
Center(
|
|
||||||
child: LinearProgressIndicator(
|
|
||||||
value: progress != null ? progress! / 100.0 : null,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 8,
|
|
||||||
top: 8,
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.withOpacity(0.5),
|
|
||||||
child: Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (onDelete != null)
|
|
||||||
InkWell(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: const Icon(
|
|
||||||
Symbols.delete,
|
|
||||||
size: 14,
|
|
||||||
color: Colors.white,
|
|
||||||
).padding(horizontal: 8, vertical: 6),
|
|
||||||
onTap: () {
|
|
||||||
onDelete?.call();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (onDelete != null && onMove != null)
|
|
||||||
SizedBox(
|
|
||||||
height: 26,
|
|
||||||
child: const VerticalDivider(
|
|
||||||
width: 0.3,
|
|
||||||
color: Colors.white,
|
|
||||||
thickness: 0.3,
|
|
||||||
),
|
|
||||||
).padding(horizontal: 2),
|
|
||||||
if (onMove != null)
|
|
||||||
InkWell(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: const Icon(
|
|
||||||
Symbols.keyboard_arrow_up,
|
|
||||||
size: 14,
|
|
||||||
color: Colors.white,
|
|
||||||
).padding(horizontal: 8, vertical: 6),
|
|
||||||
onTap: () {
|
|
||||||
onMove?.call(-1);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (onMove != null)
|
|
||||||
InkWell(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: const Icon(
|
|
||||||
Symbols.keyboard_arrow_down,
|
|
||||||
size: 14,
|
|
||||||
color: Colors.white,
|
|
||||||
).padding(horizontal: 8, vertical: 6),
|
|
||||||
onTap: () {
|
|
||||||
onMove?.call(1);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (onInsert != null)
|
|
||||||
InkWell(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: const Icon(
|
|
||||||
Symbols.add,
|
|
||||||
size: 14,
|
|
||||||
color: Colors.white,
|
|
||||||
).padding(horizontal: 8, vertical: 6),
|
|
||||||
onTap: () {
|
|
||||||
onInsert?.call();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (onRequestUpload != null)
|
Row(
|
||||||
Positioned(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
top: 8,
|
children: [
|
||||||
right: 8,
|
ClipRRect(
|
||||||
child: InkWell(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
onTap: () => onRequestUpload?.call(),
|
child: Container(
|
||||||
child: ClipRRect(
|
color: Colors.black.withOpacity(0.5),
|
||||||
borderRadius: BorderRadius.circular(8),
|
child: Material(
|
||||||
child: Container(
|
color: Colors.transparent,
|
||||||
color: Colors.black.withOpacity(0.5),
|
child: Row(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child:
|
children: [
|
||||||
(item.isOnCloud)
|
if (onDelete != null)
|
||||||
? Row(
|
InkWell(
|
||||||
mainAxisSize: MainAxisSize.min,
|
borderRadius: BorderRadius.circular(8),
|
||||||
children: [
|
child: Icon(
|
||||||
Icon(
|
item.isLink ? Symbols.link_off : Symbols.delete,
|
||||||
Symbols.cloud,
|
size: 14,
|
||||||
size: 16,
|
color: Colors.white,
|
||||||
color: Colors.white,
|
).padding(horizontal: 8, vertical: 6),
|
||||||
),
|
onTap: () {
|
||||||
const Gap(8),
|
onDelete?.call();
|
||||||
Text(
|
},
|
||||||
'On-cloud',
|
),
|
||||||
style: TextStyle(color: Colors.white),
|
if (onDelete != null && onMove != null)
|
||||||
),
|
SizedBox(
|
||||||
],
|
height: 26,
|
||||||
)
|
child: const VerticalDivider(
|
||||||
: Row(
|
width: 0.3,
|
||||||
mainAxisSize: MainAxisSize.min,
|
color: Colors.white,
|
||||||
children: [
|
thickness: 0.3,
|
||||||
Icon(
|
|
||||||
Symbols.cloud_off,
|
|
||||||
size: 16,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
Text(
|
|
||||||
'On-device',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
).padding(horizontal: 2),
|
||||||
|
if (onMove != null)
|
||||||
|
InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: const Icon(
|
||||||
|
Symbols.keyboard_arrow_up,
|
||||||
|
size: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
).padding(horizontal: 8, vertical: 6),
|
||||||
|
onTap: () {
|
||||||
|
onMove?.call(-1);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (onMove != null)
|
||||||
|
InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: const Icon(
|
||||||
|
Symbols.keyboard_arrow_down,
|
||||||
|
size: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
).padding(horizontal: 8, vertical: 6),
|
||||||
|
onTap: () {
|
||||||
|
onMove?.call(1);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (onInsert != null)
|
||||||
|
InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: const Icon(
|
||||||
|
Symbols.add,
|
||||||
|
size: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
).padding(horizontal: 8, vertical: 6),
|
||||||
|
onTap: () {
|
||||||
|
onInsert?.call();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (onRequestUpload != null)
|
||||||
|
InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
onTap: () => onRequestUpload?.call(),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.black.withOpacity(0.5),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
(item.isOnCloud)
|
||||||
|
? Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Symbols.cloud,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
Text(
|
||||||
|
'On-cloud',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Symbols.cloud_off,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
Text(
|
||||||
|
'On-device',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 12, vertical: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return ContextMenuWidget(
|
||||||
|
menuProvider:
|
||||||
|
(MenuRequest request) => Menu(
|
||||||
|
children: [
|
||||||
|
if (item.isOnDevice && item.type == UniversalFileType.image)
|
||||||
|
MenuAction(
|
||||||
|
title: 'crop'.tr(),
|
||||||
|
image: MenuImage.icon(Symbols.crop),
|
||||||
|
callback: () async {
|
||||||
|
final result = await cropImage(
|
||||||
|
context,
|
||||||
|
image: item.data,
|
||||||
|
replacePath: true,
|
||||||
|
);
|
||||||
|
if (result == null) return;
|
||||||
|
onUpdate?.call(item.copyWith(data: result));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (item.isOnCloud)
|
||||||
|
MenuAction(
|
||||||
|
title: 'rename'.tr(),
|
||||||
|
image: MenuImage.icon(Symbols.edit),
|
||||||
|
callback: () async {
|
||||||
|
await _showRenameDialog(context, ref);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (item.isOnCloud)
|
||||||
|
MenuAction(
|
||||||
|
title: 'markAsSensitive'.tr(),
|
||||||
|
image: MenuImage.icon(Symbols.no_adult_content),
|
||||||
|
callback: () async {
|
||||||
|
await _showSensitiveDialog(context, ref);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: contentWidget,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
168
lib/widgets/content/audio.dart
Normal file
168
lib/widgets/content/audio.dart
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/services/time.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:media_kit/media_kit.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
|
class UniversalAudio extends ConsumerStatefulWidget {
|
||||||
|
final String uri;
|
||||||
|
final String filename;
|
||||||
|
final bool autoplay;
|
||||||
|
const UniversalAudio({
|
||||||
|
super.key,
|
||||||
|
required this.uri,
|
||||||
|
required this.filename,
|
||||||
|
this.autoplay = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<UniversalAudio> createState() => _UniversalAudioState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UniversalAudioState extends ConsumerState<UniversalAudio> {
|
||||||
|
Player? _player;
|
||||||
|
|
||||||
|
Duration _duration = Duration(seconds: 1);
|
||||||
|
Duration _duartionBuffered = Duration(seconds: 1);
|
||||||
|
Duration _position = Duration(seconds: 0);
|
||||||
|
|
||||||
|
bool _sliderWorking = false;
|
||||||
|
Duration _sliderPosition = Duration(seconds: 0);
|
||||||
|
|
||||||
|
void _openAudio() async {
|
||||||
|
final url = widget.uri;
|
||||||
|
MediaKit.ensureInitialized();
|
||||||
|
|
||||||
|
_player = Player();
|
||||||
|
_player!.stream.position.listen((value) {
|
||||||
|
_position = value;
|
||||||
|
if (!_sliderWorking) _sliderPosition = _position;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
_player!.stream.buffer.listen((value) {
|
||||||
|
_duartionBuffered = value;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
_player!.stream.duration.listen((value) {
|
||||||
|
_duration = value;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
String? uri;
|
||||||
|
final inCacheInfo = await DefaultCacheManager().getFileFromCache(url);
|
||||||
|
if (inCacheInfo == null) {
|
||||||
|
log('[MediaPlayer] Miss cache: $url');
|
||||||
|
final token = ref.watch(tokenProvider)?.token;
|
||||||
|
DefaultCacheManager().downloadFile(
|
||||||
|
url,
|
||||||
|
authHeaders: {'Authorization': 'AtField $token'},
|
||||||
|
);
|
||||||
|
uri = url;
|
||||||
|
} else {
|
||||||
|
uri = inCacheInfo.file.path;
|
||||||
|
log('[MediaPlayer] Hit cache: $url');
|
||||||
|
}
|
||||||
|
|
||||||
|
_player!.open(Media(uri), play: widget.autoplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_openAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_player?.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (_player == null) {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Card(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
_player!.playOrPause().then((_) {
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon:
|
||||||
|
_player!.state.playing
|
||||||
|
? const Icon(Symbols.pause, fill: 1, color: Colors.white)
|
||||||
|
: const Icon(
|
||||||
|
Symbols.play_arrow,
|
||||||
|
fill: 1,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(20),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
child:
|
||||||
|
(_player!.state.playing || _sliderWorking)
|
||||||
|
? SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
key: const ValueKey('playing'),
|
||||||
|
child: Text(
|
||||||
|
'${_position.formatShortDuration()} / ${_duration.formatShortDuration()}',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
key: const ValueKey('filename'),
|
||||||
|
child: Text(
|
||||||
|
widget.filename.isEmpty
|
||||||
|
? 'Audio'
|
||||||
|
: widget.filename,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Slider(
|
||||||
|
value: _sliderPosition.inMilliseconds.toDouble(),
|
||||||
|
secondaryTrackValue:
|
||||||
|
_duartionBuffered.inMilliseconds.toDouble(),
|
||||||
|
max: _duration.inMilliseconds.toDouble(),
|
||||||
|
onChangeStart: (_) {
|
||||||
|
_sliderWorking = true;
|
||||||
|
},
|
||||||
|
onChanged: (value) {
|
||||||
|
_sliderPosition = Duration(milliseconds: value.toInt());
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onChangeEnd: (value) {
|
||||||
|
_sliderPosition = Duration(milliseconds: value.toInt());
|
||||||
|
_sliderWorking = false;
|
||||||
|
_player!.seek(_sliderPosition);
|
||||||
|
},
|
||||||
|
year2023: true,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 16),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import 'dart:math' as math;
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:dismissible_page/dismissible_page.dart';
|
import 'package:dismissible_page/dismissible_page.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_blurhash/flutter_blurhash.dart';
|
import 'package:flutter_blurhash/flutter_blurhash.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
@@ -13,6 +14,7 @@ import 'package:island/pods/config.dart';
|
|||||||
import 'package:island/pods/network.dart';
|
import 'package:island/pods/network.dart';
|
||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/sensitive.dart';
|
||||||
import 'package:island/widgets/content/sheet.dart';
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:path/path.dart' show extension;
|
import 'package:path/path.dart' show extension;
|
||||||
@@ -63,6 +65,27 @@ class CloudFileList extends HookConsumerWidget {
|
|||||||
if (files.isEmpty) return const SizedBox.shrink();
|
if (files.isEmpty) return const SizedBox.shrink();
|
||||||
if (files.length == 1) {
|
if (files.length == 1) {
|
||||||
final isImage = files.first.mimeType?.startsWith('image') ?? false;
|
final isImage = files.first.mimeType?.startsWith('image') ?? false;
|
||||||
|
final isAudio = files.first.mimeType?.startsWith('audio') ?? false;
|
||||||
|
final widgetItem = ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
child: _CloudFileListEntry(
|
||||||
|
file: files.first,
|
||||||
|
heroTag: heroTags.first,
|
||||||
|
isImage: isImage,
|
||||||
|
disableZoomIn: disableZoomIn,
|
||||||
|
onTap: () {
|
||||||
|
if (!isImage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!disableZoomIn) {
|
||||||
|
context.pushTransparentRoute(
|
||||||
|
CloudFileZoomIn(item: files.first, heroTag: heroTags.first),
|
||||||
|
rootNavigator: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
return Container(
|
return Container(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
@@ -70,29 +93,14 @@ class CloudFileList extends HookConsumerWidget {
|
|||||||
minWidth: minWidth ?? 0,
|
minWidth: minWidth ?? 0,
|
||||||
maxWidth: files.length == 1 ? maxWidth : double.infinity,
|
maxWidth: files.length == 1 ? maxWidth : double.infinity,
|
||||||
),
|
),
|
||||||
child: AspectRatio(
|
height: isAudio ? 120 : null,
|
||||||
aspectRatio: calculateAspectRatio(),
|
child:
|
||||||
child: ClipRRect(
|
isAudio
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
? widgetItem
|
||||||
child: _CloudFileListEntry(
|
: AspectRatio(
|
||||||
file: files.first,
|
aspectRatio: calculateAspectRatio(),
|
||||||
heroTag: heroTags.first,
|
child: widgetItem,
|
||||||
isImage: isImage,
|
),
|
||||||
disableZoomIn: disableZoomIn,
|
|
||||||
onTap: () {
|
|
||||||
if (!isImage) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!disableZoomIn) {
|
|
||||||
context.pushTransparentRoute(
|
|
||||||
CloudFileZoomIn(item: files.first, heroTag: heroTags.first),
|
|
||||||
rootNavigator: true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,51 +114,57 @@ class CloudFileList extends HookConsumerWidget {
|
|||||||
constraints: BoxConstraints(maxHeight: maxHeight, minWidth: maxWidth),
|
constraints: BoxConstraints(maxHeight: maxHeight, minWidth: maxWidth),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: calculateAspectRatio(),
|
aspectRatio: calculateAspectRatio(),
|
||||||
child: CarouselView(
|
child: Padding(
|
||||||
padding: padding,
|
padding: padding ?? EdgeInsets.zero,
|
||||||
itemSnapping: true,
|
child: CarouselView(
|
||||||
itemExtent: math.min(
|
itemSnapping: true,
|
||||||
MediaQuery.of(context).size.width * 0.85,
|
itemExtent: math.min(
|
||||||
maxWidth * 0.85,
|
math.min(
|
||||||
),
|
MediaQuery.of(context).size.width * 0.75,
|
||||||
shape: RoundedRectangleBorder(
|
maxWidth * 0.75,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
|
||||||
),
|
|
||||||
children: [
|
|
||||||
for (var i = 0; i < files.length; i++)
|
|
||||||
Stack(
|
|
||||||
children: [
|
|
||||||
_CloudFileListEntry(
|
|
||||||
file: files[i],
|
|
||||||
heroTag: heroTags[i],
|
|
||||||
isImage: files[i].mimeType?.startsWith('image') ?? false,
|
|
||||||
disableZoomIn: disableZoomIn,
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 12,
|
|
||||||
left: 16,
|
|
||||||
child: Text('${i + 1}/${files.length}')
|
|
||||||
.textColor(Colors.white)
|
|
||||||
.textShadow(
|
|
||||||
color: Colors.black54,
|
|
||||||
offset: Offset(1, 1),
|
|
||||||
blurRadius: 3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
640,
|
||||||
onTap: (i) {
|
),
|
||||||
if (!(files[i].mimeType?.startsWith('image') ?? false)) {
|
shape: RoundedRectangleBorder(
|
||||||
return;
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
}
|
),
|
||||||
if (!disableZoomIn) {
|
children: [
|
||||||
context.pushTransparentRoute(
|
for (var i = 0; i < files.length; i++)
|
||||||
CloudFileZoomIn(item: files[i], heroTag: heroTags[i]),
|
Stack(
|
||||||
rootNavigator: true,
|
children: [
|
||||||
);
|
_CloudFileListEntry(
|
||||||
}
|
file: files[i],
|
||||||
},
|
heroTag: heroTags[i],
|
||||||
|
isImage:
|
||||||
|
files[i].mimeType?.startsWith('image') ?? false,
|
||||||
|
disableZoomIn: disableZoomIn,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 12,
|
||||||
|
left: 16,
|
||||||
|
child: Text('${i + 1}/${files.length}')
|
||||||
|
.textColor(Colors.white)
|
||||||
|
.textShadow(
|
||||||
|
color: Colors.black54,
|
||||||
|
offset: Offset(1, 1),
|
||||||
|
blurRadius: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onTap: (i) {
|
||||||
|
if (!(files[i].mimeType?.startsWith('image') ?? false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!disableZoomIn) {
|
||||||
|
context.pushTransparentRoute(
|
||||||
|
CloudFileZoomIn(item: files[i], heroTag: heroTags[i]),
|
||||||
|
rootNavigator: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -434,9 +448,8 @@ class CloudFileZoomIn extends HookConsumerWidget {
|
|||||||
showOriginal.value = !showOriginal.value;
|
showOriginal.value = !showOriginal.value;
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
showOriginal.value ? Symbols.raw_on : Symbols.raw_off,
|
showOriginal.value ? Symbols.hd : Symbols.sd,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
size: 24,
|
|
||||||
shadows: [
|
shadows: [
|
||||||
Shadow(
|
Shadow(
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
@@ -547,7 +560,7 @@ class CloudFileZoomIn extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CloudFileListEntry extends StatelessWidget {
|
class _CloudFileListEntry extends HookConsumerWidget {
|
||||||
final SnCloudFile file;
|
final SnCloudFile file;
|
||||||
final String heroTag;
|
final String heroTag;
|
||||||
final bool isImage;
|
final bool isImage;
|
||||||
@@ -563,8 +576,10 @@ class _CloudFileListEntry extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final content = Stack(
|
final showMature = useState(false);
|
||||||
|
|
||||||
|
var content = Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
if (isImage)
|
if (isImage)
|
||||||
@@ -589,10 +604,133 @@ class _CloudFileListEntry extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (file.sensitiveMarks.isNotEmpty) {
|
||||||
|
// Show a blurred overlay only when not revealed yet, with a smooth transition
|
||||||
|
content = Stack(
|
||||||
|
children: [
|
||||||
|
content,
|
||||||
|
// Toggle blur overlay with animation
|
||||||
|
Positioned.fill(
|
||||||
|
child: AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
|
switchInCurve: Curves.easeOut,
|
||||||
|
switchOutCurve: Curves.easeIn,
|
||||||
|
layoutBuilder:
|
||||||
|
(currentChild, previousChildren) => Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
...previousChildren,
|
||||||
|
if (currentChild != null) currentChild,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
showMature.value
|
||||||
|
? const SizedBox.shrink(key: ValueKey('revealed'))
|
||||||
|
: ColoredBox(
|
||||||
|
key: const ValueKey('blurred'),
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(sigmaX: 64, sigmaY: 64),
|
||||||
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
const ColoredBox(color: Colors.transparent),
|
||||||
|
Center(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.all(12),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black54,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 280,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.warning,
|
||||||
|
color: Colors.white,
|
||||||
|
fill: 1,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
const Gap(4),
|
||||||
|
Text(
|
||||||
|
file.sensitiveMarks
|
||||||
|
.map(
|
||||||
|
(e) =>
|
||||||
|
SensitiveCategory
|
||||||
|
.values[e]
|
||||||
|
.i18nKey
|
||||||
|
.tr(),
|
||||||
|
)
|
||||||
|
.join(' · '),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Sensitive Content',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(4),
|
||||||
|
Text(
|
||||||
|
'Tap to Reveal',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 11,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).padding(horizontal: 24, vertical: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// When revealed (no blur), show a small control at top-left to re-enable blur
|
||||||
|
if (showMature.value)
|
||||||
|
Positioned(
|
||||||
|
top: 3,
|
||||||
|
left: 4,
|
||||||
|
child: IconButton(
|
||||||
|
iconSize: 16,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
icon: const Icon(Icons.visibility_off, color: Colors.white),
|
||||||
|
tooltip: 'Blur content',
|
||||||
|
onPressed: () {
|
||||||
|
showMature.value = false;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (onTap != null) {
|
if (onTap != null) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
onTap: onTap,
|
onTap: () {
|
||||||
|
if (!showMature.value) {
|
||||||
|
showMature.value = true;
|
||||||
|
} else {
|
||||||
|
onTap?.call();
|
||||||
|
}
|
||||||
|
},
|
||||||
child: content,
|
child: content,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
@@ -5,13 +7,14 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
import 'package:island/pods/config.dart';
|
import 'package:island/pods/config.dart';
|
||||||
import 'package:island/services/time.dart';
|
import 'package:island/services/time.dart';
|
||||||
|
import 'package:island/widgets/content/audio.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
import 'image.dart';
|
import 'image.dart';
|
||||||
import 'video.dart';
|
import 'video.dart';
|
||||||
|
|
||||||
class CloudFileWidget extends ConsumerWidget {
|
class CloudFileWidget extends HookConsumerWidget {
|
||||||
final SnCloudFile item;
|
final SnCloudFile item;
|
||||||
final BoxFit fit;
|
final BoxFit fit;
|
||||||
final String? heroTag;
|
final String? heroTag;
|
||||||
@@ -34,7 +37,7 @@ class CloudFileWidget extends ConsumerWidget {
|
|||||||
? item.fileMeta!['ratio'].toDouble()
|
? item.fileMeta!['ratio'].toDouble()
|
||||||
: 1.0;
|
: 1.0;
|
||||||
if (ratio == 0) ratio = 1.0;
|
if (ratio == 0) ratio = 1.0;
|
||||||
final content = switch (item.mimeType?.split('/').firstOrNull) {
|
var content = switch (item.mimeType?.split('/').firstOrNull) {
|
||||||
"image" => AspectRatio(
|
"image" => AspectRatio(
|
||||||
aspectRatio: ratio,
|
aspectRatio: ratio,
|
||||||
child: UniversalImage(
|
child: UniversalImage(
|
||||||
@@ -49,11 +52,19 @@ class CloudFileWidget extends ConsumerWidget {
|
|||||||
aspectRatio: ratio,
|
aspectRatio: ratio,
|
||||||
child: CloudVideoWidget(item: item),
|
child: CloudVideoWidget(item: item),
|
||||||
),
|
),
|
||||||
|
"audio" => Center(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: math.min(360, MediaQuery.of(context).size.width * 0.8),
|
||||||
|
),
|
||||||
|
child: UniversalAudio(uri: uri, filename: item.name),
|
||||||
|
),
|
||||||
|
),
|
||||||
_ => Text('Unable render for ${item.mimeType}'),
|
_ => Text('Unable render for ${item.mimeType}'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (heroTag != null) {
|
if (heroTag != null) {
|
||||||
return Hero(tag: heroTag!, child: content);
|
content = Hero(tag: heroTag!, child: content);
|
||||||
}
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
@@ -91,6 +102,7 @@ class CloudVideoWidget extends HookConsumerWidget {
|
|||||||
Symbols.play_arrow,
|
Symbols.play_arrow,
|
||||||
fill: 1,
|
fill: 1,
|
||||||
size: 32,
|
size: 32,
|
||||||
|
color: Colors.white,
|
||||||
shadows: [
|
shadows: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
@@ -102,6 +114,26 @@ class CloudVideoWidget extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: Container(
|
||||||
|
height: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.bottomCenter,
|
||||||
|
end: Alignment.topCenter,
|
||||||
|
colors: [
|
||||||
|
Theme.of(context).colorScheme.surface.withOpacity(0.85),
|
||||||
|
Colors.transparent,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
@@ -121,6 +153,7 @@ class CloudVideoWidget extends HookConsumerWidget {
|
|||||||
.toInt(),
|
.toInt(),
|
||||||
).formatDuration(),
|
).formatDuration(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
shadows: [
|
shadows: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
@@ -135,6 +168,7 @@ class CloudVideoWidget extends HookConsumerWidget {
|
|||||||
Text(
|
Text(
|
||||||
'${int.parse(item.fileMeta?['bit_rate'] as String) ~/ 1000} Kbps',
|
'${int.parse(item.fileMeta?['bit_rate'] as String) ~/ 1000} Kbps',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
shadows: [
|
shadows: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
@@ -149,7 +183,10 @@ class CloudVideoWidget extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
item.name,
|
item.name,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
shadows: [
|
shadows: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'package:material_symbols_icons/symbols.dart';
|
|||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class EmbedLinkWidget extends StatelessWidget {
|
class EmbedLinkWidget extends StatelessWidget {
|
||||||
final SnEmbedLink link;
|
final SnScrappedLink link;
|
||||||
final double? maxWidth;
|
final double? maxWidth;
|
||||||
final EdgeInsetsGeometry? margin;
|
final EdgeInsetsGeometry? margin;
|
||||||
|
|
||||||
@@ -116,7 +116,8 @@ class EmbedLinkWidget extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
if (link.description != null && link.description!.isNotEmpty) ...[
|
if (link.description != null &&
|
||||||
|
link.description!.isNotEmpty) ...[
|
||||||
Text(
|
Text(
|
||||||
link.description!,
|
link.description!,
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
@@ -191,7 +192,7 @@ class EmbedLinkWidget extends StatelessWidget {
|
|||||||
try {
|
try {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final difference = now.difference(date);
|
final difference = now.difference(date);
|
||||||
|
|
||||||
if (difference.inDays == 0) {
|
if (difference.inDays == 0) {
|
||||||
return 'Today';
|
return 'Today';
|
||||||
} else if (difference.inDays == 1) {
|
} else if (difference.inDays == 1) {
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ class MarkdownTextContent extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
case 'stickers':
|
case 'stickers':
|
||||||
final size = doesEnlargeSticker ? 96.0 : 24.0;
|
final size = doesEnlargeSticker ? 96.0 : 24.0;
|
||||||
|
final stickerUri =
|
||||||
|
'$baseUrl/sphere/stickers/lookup/${uri.pathSegments[0]}/open';
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -155,8 +157,7 @@ class MarkdownTextContent extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: UniversalImage(
|
child: UniversalImage(
|
||||||
uri:
|
uri: stickerUri,
|
||||||
'$baseUrl/sphere/stickers/lookup/${uri.pathSegments[0]}/open',
|
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
|
|||||||
81
lib/widgets/content/network_status_sheet.dart
Normal file
81
lib/widgets/content/network_status_sheet.dart
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/pods/websocket.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
|
||||||
|
class NetworkStatusSheet extends HookConsumerWidget {
|
||||||
|
final VoidCallback onReconnect;
|
||||||
|
|
||||||
|
const NetworkStatusSheet({super.key, required this.onReconnect});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final ws = ref.watch(websocketProvider);
|
||||||
|
final wsState = ref.watch(websocketStateProvider);
|
||||||
|
|
||||||
|
return SheetScaffold(
|
||||||
|
titleText:
|
||||||
|
wsState == WebSocketState.connected()
|
||||||
|
? 'Connection Status'
|
||||||
|
: 'Connection Issue',
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
wsState.when(
|
||||||
|
connected:
|
||||||
|
() => Text(
|
||||||
|
'Connected to server',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
connecting:
|
||||||
|
() => Text(
|
||||||
|
'Connecting to server...',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
disconnected:
|
||||||
|
() => Text(
|
||||||
|
'Disconnected from server',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
serverDown:
|
||||||
|
() => Text(
|
||||||
|
'The server is not available right now... Please try again later...',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
duplicateDevice:
|
||||||
|
() => Text(
|
||||||
|
'Another device has connected with the same account.',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
error:
|
||||||
|
(message) => Text(
|
||||||
|
'Connection error: $message',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
if (ws.heartbeatDelay != null)
|
||||||
|
Text(
|
||||||
|
'Last heartbeat: ${ws.heartbeatDelay!.inMilliseconds}ms',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
Center(
|
||||||
|
child: FilledButton.icon(
|
||||||
|
icon: const Icon(Symbols.wifi),
|
||||||
|
label: const Text('Reconnect'),
|
||||||
|
onPressed: () {
|
||||||
|
onReconnect();
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
71
lib/widgets/content/sensitive.dart
Normal file
71
lib/widgets/content/sensitive.dart
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
// Copyright (c) Solsynth
|
||||||
|
// Sensitive content categories for content warnings, in fixed order.
|
||||||
|
|
||||||
|
enum SensitiveCategory {
|
||||||
|
language,
|
||||||
|
sexualContent,
|
||||||
|
violence,
|
||||||
|
profanity,
|
||||||
|
hateSpeech,
|
||||||
|
racism,
|
||||||
|
adultContent,
|
||||||
|
drugAbuse,
|
||||||
|
alcoholAbuse,
|
||||||
|
gambling,
|
||||||
|
selfHarm,
|
||||||
|
childAbuse,
|
||||||
|
other,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension SensitiveCategoryI18n on SensitiveCategory {
|
||||||
|
/// i18n key to look up localized label
|
||||||
|
String get i18nKey => switch (this) {
|
||||||
|
SensitiveCategory.language => 'sensitiveCategories.language',
|
||||||
|
SensitiveCategory.sexualContent => 'sensitiveCategories.sexualContent',
|
||||||
|
SensitiveCategory.violence => 'sensitiveCategories.violence',
|
||||||
|
SensitiveCategory.profanity => 'sensitiveCategories.profanity',
|
||||||
|
SensitiveCategory.hateSpeech => 'sensitiveCategories.hateSpeech',
|
||||||
|
SensitiveCategory.racism => 'sensitiveCategories.racism',
|
||||||
|
SensitiveCategory.adultContent => 'sensitiveCategories.adultContent',
|
||||||
|
SensitiveCategory.drugAbuse => 'sensitiveCategories.drugAbuse',
|
||||||
|
SensitiveCategory.alcoholAbuse => 'sensitiveCategories.alcoholAbuse',
|
||||||
|
SensitiveCategory.gambling => 'sensitiveCategories.gambling',
|
||||||
|
SensitiveCategory.selfHarm => 'sensitiveCategories.selfHarm',
|
||||||
|
SensitiveCategory.childAbuse => 'sensitiveCategories.childAbuse',
|
||||||
|
SensitiveCategory.other => 'sensitiveCategories.other',
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Optional symbol you can use alongside the label in UI
|
||||||
|
String get symbol => switch (this) {
|
||||||
|
SensitiveCategory.language => '🌐',
|
||||||
|
SensitiveCategory.sexualContent => '🔞',
|
||||||
|
SensitiveCategory.violence => '⚠️',
|
||||||
|
SensitiveCategory.profanity => '🗯️',
|
||||||
|
SensitiveCategory.hateSpeech => '🚫',
|
||||||
|
SensitiveCategory.racism => '✋',
|
||||||
|
SensitiveCategory.adultContent => '🍑',
|
||||||
|
SensitiveCategory.drugAbuse => '💊',
|
||||||
|
SensitiveCategory.alcoholAbuse => '🍺',
|
||||||
|
SensitiveCategory.gambling => '🎲',
|
||||||
|
SensitiveCategory.selfHarm => '🆘',
|
||||||
|
SensitiveCategory.childAbuse => '🛑',
|
||||||
|
SensitiveCategory.other => '❗',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ordered list for UI consumption, matching enum declaration order.
|
||||||
|
const List<SensitiveCategory> kSensitiveCategoriesOrdered = [
|
||||||
|
SensitiveCategory.language,
|
||||||
|
SensitiveCategory.sexualContent,
|
||||||
|
SensitiveCategory.violence,
|
||||||
|
SensitiveCategory.profanity,
|
||||||
|
SensitiveCategory.hateSpeech,
|
||||||
|
SensitiveCategory.racism,
|
||||||
|
SensitiveCategory.adultContent,
|
||||||
|
SensitiveCategory.drugAbuse,
|
||||||
|
SensitiveCategory.alcoholAbuse,
|
||||||
|
SensitiveCategory.gambling,
|
||||||
|
SensitiveCategory.selfHarm,
|
||||||
|
SensitiveCategory.childAbuse,
|
||||||
|
SensitiveCategory.other,
|
||||||
|
];
|
||||||
@@ -33,6 +33,7 @@ class SheetScaffold extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
|
padding: MediaQuery.of(context).viewInsets,
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxHeight: height ?? MediaQuery.of(context).size.height * heightFactor,
|
maxHeight: height ?? MediaQuery.of(context).size.height * heightFactor,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
|
|
||||||
typedef ContextMenuBuilder =
|
|
||||||
Widget Function(BuildContext context, Offset offset);
|
|
||||||
|
|
||||||
class ContextMenuRegion extends HookWidget {
|
|
||||||
final Offset? mobileAnchor;
|
|
||||||
final Widget child;
|
|
||||||
final ContextMenuBuilder contextMenuBuilder;
|
|
||||||
const ContextMenuRegion({
|
|
||||||
super.key,
|
|
||||||
required this.child,
|
|
||||||
required this.contextMenuBuilder,
|
|
||||||
this.mobileAnchor,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final contextMenuController = useMemoized(() => ContextMenuController());
|
|
||||||
final mobileOffset = useState<Offset?>(null);
|
|
||||||
|
|
||||||
bool canBeTouchScreen = switch (defaultTargetPlatform) {
|
|
||||||
TargetPlatform.android || TargetPlatform.iOS => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
void showMenu(Offset position) {
|
|
||||||
contextMenuController.show(
|
|
||||||
context: context,
|
|
||||||
contextMenuBuilder: (BuildContext context) {
|
|
||||||
return contextMenuBuilder(context, position);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hideMenu() {
|
|
||||||
contextMenuController.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onSecondaryTapUp(TapUpDetails details) {
|
|
||||||
showMenu(details.globalPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onTap() {
|
|
||||||
if (!contextMenuController.isShown) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hideMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onLongPressStart(LongPressStartDetails details) {
|
|
||||||
mobileOffset.value = details.globalPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onLongPress() {
|
|
||||||
assert(mobileOffset.value != null);
|
|
||||||
showMenu(mobileAnchor ?? mobileOffset.value!);
|
|
||||||
mobileOffset.value = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() {
|
|
||||||
return () {
|
|
||||||
hideMenu();
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return TapRegion(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
child: GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onSecondaryTapUp: onSecondaryTapUp,
|
|
||||||
onTap: onTap,
|
|
||||||
onLongPress: canBeTouchScreen ? onLongPress : null,
|
|
||||||
onLongPressStart: canBeTouchScreen ? onLongPressStart : null,
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
onTapOutside: (_) {
|
|
||||||
hideMenu();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
76
lib/widgets/debug_sheet.dart
Normal file
76
lib/widgets/debug_sheet.dart
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/pods/message.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/pods/websocket.dart';
|
||||||
|
import 'package:island/widgets/content/network_status_sheet.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
|
||||||
|
class DebugSheet extends HookConsumerWidget {
|
||||||
|
const DebugSheet({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final wsNotifier = ref.watch(websocketStateProvider.notifier);
|
||||||
|
|
||||||
|
return SheetScaffold(
|
||||||
|
titleText: 'Debug',
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.wifi),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
title: Text('Connection Status'),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
onTap: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder:
|
||||||
|
(context) => NetworkStatusSheet(
|
||||||
|
onReconnect: () => wsNotifier.connect(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.copy_all),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
title: Text('Copy access token'),
|
||||||
|
onTap: () async {
|
||||||
|
final tk = ref.watch(tokenProvider);
|
||||||
|
Clipboard.setData(ClipboardData(text: tk!.token));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.delete),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
title: Text('Reset database'),
|
||||||
|
onTap: () async {
|
||||||
|
resetDatabase(ref);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.clear),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
title: Text('Clear cache'),
|
||||||
|
onTap: () async {
|
||||||
|
DefaultCacheManager().emptyCache();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
236
lib/widgets/poll/poll_feedback.dart
Normal file
236
lib/widgets/poll/poll_feedback.dart
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/poll.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/services/time.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:riverpod_paging_utils/riverpod_paging_utils.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
|
part 'poll_feedback.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
class PollFeedbackNotifier extends _$PollFeedbackNotifier
|
||||||
|
with CursorPagingNotifierMixin<SnPollAnswer> {
|
||||||
|
static const int _pageSize = 20;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnPollAnswer>> build(String id) {
|
||||||
|
// immediately load first page
|
||||||
|
return fetch(cursor: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnPollAnswer>> fetch({
|
||||||
|
required String? cursor,
|
||||||
|
}) async {
|
||||||
|
final client = ref.read(apiClientProvider);
|
||||||
|
final offset = cursor == null ? 0 : int.parse(cursor);
|
||||||
|
|
||||||
|
final queryParams = {'offset': offset, 'take': _pageSize};
|
||||||
|
|
||||||
|
final response = await client.get(
|
||||||
|
'/sphere/polls/$id/feedback',
|
||||||
|
queryParameters: queryParams,
|
||||||
|
);
|
||||||
|
final total = int.parse(response.headers.value('X-Total') ?? '0');
|
||||||
|
final List<dynamic> data = response.data;
|
||||||
|
final items = data.map((json) => SnPollAnswer.fromJson(json)).toList();
|
||||||
|
|
||||||
|
final hasMore = offset + items.length < total;
|
||||||
|
final nextCursor = hasMore ? (offset + items.length).toString() : null;
|
||||||
|
|
||||||
|
return CursorPagingData(
|
||||||
|
items: items,
|
||||||
|
hasMore: hasMore,
|
||||||
|
nextCursor: nextCursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PollFeedbackSheet extends HookConsumerWidget {
|
||||||
|
final String pollId;
|
||||||
|
final String? title;
|
||||||
|
final SnPoll poll;
|
||||||
|
final Map<String, dynamic>? stats; // stats object similar to PollSubmit
|
||||||
|
const PollFeedbackSheet({
|
||||||
|
super.key,
|
||||||
|
required this.pollId,
|
||||||
|
required this.poll,
|
||||||
|
this.title,
|
||||||
|
this.stats,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return SheetScaffold(
|
||||||
|
titleText: title ?? 'Poll feedback',
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
_PollHeader(poll: poll, stats: stats),
|
||||||
|
const Divider(height: 1),
|
||||||
|
Expanded(
|
||||||
|
child: PagingHelperView(
|
||||||
|
provider: pollFeedbackNotifierProvider(pollId),
|
||||||
|
futureRefreshable: pollFeedbackNotifierProvider(pollId).future,
|
||||||
|
notifierRefreshable:
|
||||||
|
pollFeedbackNotifierProvider(pollId).notifier,
|
||||||
|
contentBuilder:
|
||||||
|
(data, widgetCount, endItemView) => ListView.separated(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
itemCount: widgetCount,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == widgetCount - 1) {
|
||||||
|
// Provided by PagingHelperView to indicate end/loading
|
||||||
|
return endItemView;
|
||||||
|
}
|
||||||
|
final answer = data.items[index];
|
||||||
|
return _PollAnswerTile(answer: answer, poll: poll);
|
||||||
|
},
|
||||||
|
separatorBuilder:
|
||||||
|
(context, index) =>
|
||||||
|
const Divider(height: 1).padding(vertical: 4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PollHeader extends StatelessWidget {
|
||||||
|
const _PollHeader({required this.poll, this.stats});
|
||||||
|
final SnPoll poll;
|
||||||
|
final Map<String, dynamic>? stats;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (poll.title != null)
|
||||||
|
Text(poll.title!, style: theme.textTheme.titleLarge),
|
||||||
|
if (poll.description != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 2),
|
||||||
|
child: Text(
|
||||||
|
poll.description!,
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: theme.textTheme.bodyMedium?.color?.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 20, vertical: 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PollAnswerTile extends StatelessWidget {
|
||||||
|
final SnPollAnswer answer;
|
||||||
|
final SnPoll poll;
|
||||||
|
const _PollAnswerTile({required this.answer, required this.poll});
|
||||||
|
|
||||||
|
String _formatPerQuestionAnswer(
|
||||||
|
SnPollQuestion q,
|
||||||
|
Map<String, dynamic> ansMap,
|
||||||
|
) {
|
||||||
|
switch (q.type) {
|
||||||
|
case SnPollQuestionType.singleChoice:
|
||||||
|
final val = ansMap[q.id];
|
||||||
|
if (val is String) {
|
||||||
|
final opt = q.options?.firstWhere(
|
||||||
|
(o) => o.id == val,
|
||||||
|
orElse: () => SnPollOption(id: val, label: '#$val', order: 0),
|
||||||
|
);
|
||||||
|
return opt?.label ?? '#$val';
|
||||||
|
}
|
||||||
|
return '—';
|
||||||
|
case SnPollQuestionType.multipleChoice:
|
||||||
|
final val = ansMap[q.id];
|
||||||
|
if (val is List) {
|
||||||
|
final ids = val.whereType<String>().toList();
|
||||||
|
if (ids.isEmpty) return '—';
|
||||||
|
final labels =
|
||||||
|
ids.map((id) {
|
||||||
|
final opt = q.options?.firstWhere(
|
||||||
|
(o) => o.id == id,
|
||||||
|
orElse: () => SnPollOption(id: id, label: '#$id', order: 0),
|
||||||
|
);
|
||||||
|
return opt?.label ?? '#$id';
|
||||||
|
}).toList();
|
||||||
|
return labels.join(', ');
|
||||||
|
}
|
||||||
|
return '—';
|
||||||
|
case SnPollQuestionType.yesNo:
|
||||||
|
final val = ansMap[q.id];
|
||||||
|
if (val is bool) {
|
||||||
|
return val ? 'Yes' : 'No';
|
||||||
|
}
|
||||||
|
return '—';
|
||||||
|
case SnPollQuestionType.rating:
|
||||||
|
final val = ansMap[q.id];
|
||||||
|
if (val is int) return val.toString();
|
||||||
|
if (val is num) return val.toString();
|
||||||
|
return '—';
|
||||||
|
case SnPollQuestionType.freeText:
|
||||||
|
final val = ansMap[q.id];
|
||||||
|
if (val is String && val.trim().isNotEmpty) return val;
|
||||||
|
return '—';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// Submit date/time (title)
|
||||||
|
final submitText = answer.createdAt.formatSystem();
|
||||||
|
|
||||||
|
// Compose content from poll questions if provided, otherwise fallback to joined key-values
|
||||||
|
String content;
|
||||||
|
if (poll.questions.isNotEmpty) {
|
||||||
|
final questions = [...poll.questions]
|
||||||
|
..sort((a, b) => a.order.compareTo(b.order));
|
||||||
|
final buffer = StringBuffer();
|
||||||
|
for (final q in questions) {
|
||||||
|
final formatted = _formatPerQuestionAnswer(q, answer.answer);
|
||||||
|
buffer.writeln('${q.title}: $formatted');
|
||||||
|
}
|
||||||
|
content = buffer.toString().trimRight();
|
||||||
|
} else {
|
||||||
|
// Fallback formatting without poll context. We still want to show the question title
|
||||||
|
// instead of the raw question id key if we can derive it from the answer map itself.
|
||||||
|
// Since we don't have poll metadata here, we cannot resolve the title; therefore we
|
||||||
|
// will show only values line-by-line without exposing the raw id.
|
||||||
|
if (answer.answer.isEmpty) {
|
||||||
|
content = '—';
|
||||||
|
} else {
|
||||||
|
final parts = <String>[];
|
||||||
|
answer.answer.forEach((key, value) {
|
||||||
|
var question = poll.questions.firstWhere((q) => q.id == key);
|
||||||
|
if (value is List) {
|
||||||
|
parts.add('${question.title}: ${value.join(', ')}');
|
||||||
|
} else {
|
||||||
|
parts.add('${question.title}: $value');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
content = parts.join('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
isThreeLine: true,
|
||||||
|
leading: const CircleAvatar(
|
||||||
|
radius: 16,
|
||||||
|
child: Icon(Icons.how_to_vote, size: 16),
|
||||||
|
),
|
||||||
|
title: Text(submitText),
|
||||||
|
subtitle: Text(content),
|
||||||
|
trailing: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
180
lib/widgets/poll/poll_feedback.g.dart
Normal file
180
lib/widgets/poll/poll_feedback.g.dart
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'poll_feedback.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$pollFeedbackNotifierHash() =>
|
||||||
|
r'1bf3925b5b751cfd1a9abafb75274f1e95e7f27e';
|
||||||
|
|
||||||
|
/// Copied from Dart SDK
|
||||||
|
class _SystemHash {
|
||||||
|
_SystemHash._();
|
||||||
|
|
||||||
|
static int combine(int hash, int value) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + value);
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||||
|
return hash ^ (hash >> 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int finish(int hash) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = hash ^ (hash >> 11);
|
||||||
|
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _$PollFeedbackNotifier
|
||||||
|
extends BuildlessAutoDisposeAsyncNotifier<CursorPagingData<SnPollAnswer>> {
|
||||||
|
late final String id;
|
||||||
|
|
||||||
|
FutureOr<CursorPagingData<SnPollAnswer>> build(String id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [PollFeedbackNotifier].
|
||||||
|
@ProviderFor(PollFeedbackNotifier)
|
||||||
|
const pollFeedbackNotifierProvider = PollFeedbackNotifierFamily();
|
||||||
|
|
||||||
|
/// See also [PollFeedbackNotifier].
|
||||||
|
class PollFeedbackNotifierFamily
|
||||||
|
extends Family<AsyncValue<CursorPagingData<SnPollAnswer>>> {
|
||||||
|
/// See also [PollFeedbackNotifier].
|
||||||
|
const PollFeedbackNotifierFamily();
|
||||||
|
|
||||||
|
/// See also [PollFeedbackNotifier].
|
||||||
|
PollFeedbackNotifierProvider call(String id) {
|
||||||
|
return PollFeedbackNotifierProvider(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
PollFeedbackNotifierProvider getProviderOverride(
|
||||||
|
covariant PollFeedbackNotifierProvider provider,
|
||||||
|
) {
|
||||||
|
return call(provider.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'pollFeedbackNotifierProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [PollFeedbackNotifier].
|
||||||
|
class PollFeedbackNotifierProvider
|
||||||
|
extends
|
||||||
|
AutoDisposeAsyncNotifierProviderImpl<
|
||||||
|
PollFeedbackNotifier,
|
||||||
|
CursorPagingData<SnPollAnswer>
|
||||||
|
> {
|
||||||
|
/// See also [PollFeedbackNotifier].
|
||||||
|
PollFeedbackNotifierProvider(String id)
|
||||||
|
: this._internal(
|
||||||
|
() => PollFeedbackNotifier()..id = id,
|
||||||
|
from: pollFeedbackNotifierProvider,
|
||||||
|
name: r'pollFeedbackNotifierProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$pollFeedbackNotifierHash,
|
||||||
|
dependencies: PollFeedbackNotifierFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
PollFeedbackNotifierFamily._allTransitiveDependencies,
|
||||||
|
id: id,
|
||||||
|
);
|
||||||
|
|
||||||
|
PollFeedbackNotifierProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.id,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<CursorPagingData<SnPollAnswer>> runNotifierBuild(
|
||||||
|
covariant PollFeedbackNotifier notifier,
|
||||||
|
) {
|
||||||
|
return notifier.build(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(PollFeedbackNotifier Function() create) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: PollFeedbackNotifierProvider._internal(
|
||||||
|
() => create()..id = id,
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
id: id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeAsyncNotifierProviderElement<
|
||||||
|
PollFeedbackNotifier,
|
||||||
|
CursorPagingData<SnPollAnswer>
|
||||||
|
>
|
||||||
|
createElement() {
|
||||||
|
return _PollFeedbackNotifierProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is PollFeedbackNotifierProvider && other.id == id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, id.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin PollFeedbackNotifierRef
|
||||||
|
on AutoDisposeAsyncNotifierProviderRef<CursorPagingData<SnPollAnswer>> {
|
||||||
|
/// The parameter `id` of this provider.
|
||||||
|
String get id;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PollFeedbackNotifierProviderElement
|
||||||
|
extends
|
||||||
|
AutoDisposeAsyncNotifierProviderElement<
|
||||||
|
PollFeedbackNotifier,
|
||||||
|
CursorPagingData<SnPollAnswer>
|
||||||
|
>
|
||||||
|
with PollFeedbackNotifierRef {
|
||||||
|
_PollFeedbackNotifierProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get id => (origin as PollFeedbackNotifierProvider).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
714
lib/widgets/poll/poll_submit.dart
Normal file
714
lib/widgets/poll/poll_submit.dart
Normal file
@@ -0,0 +1,714 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:island/models/poll.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/widgets/alert.dart';
|
||||||
|
|
||||||
|
class PollSubmit extends ConsumerStatefulWidget {
|
||||||
|
const PollSubmit({
|
||||||
|
super.key,
|
||||||
|
required this.poll,
|
||||||
|
required this.onSubmit,
|
||||||
|
required this.stats,
|
||||||
|
this.initialAnswers,
|
||||||
|
this.onCancel,
|
||||||
|
this.showProgress = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
final SnPollWithStats poll;
|
||||||
|
|
||||||
|
/// Callback when user submits all answers. Map questionId -> answer.
|
||||||
|
final void Function(Map<String, dynamic> answers) onSubmit;
|
||||||
|
|
||||||
|
/// Optional initial answers, keyed by questionId.
|
||||||
|
final Map<String, dynamic>? initialAnswers;
|
||||||
|
final Map<String, dynamic>? stats;
|
||||||
|
|
||||||
|
/// Optional cancel callback.
|
||||||
|
final VoidCallback? onCancel;
|
||||||
|
|
||||||
|
/// Whether to show a progress indicator (e.g., "2 / N").
|
||||||
|
final bool showProgress;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<PollSubmit> createState() => _PollSubmitState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PollSubmitState extends ConsumerState<PollSubmit> {
|
||||||
|
late final List<SnPollQuestion> _questions;
|
||||||
|
int _index = 0;
|
||||||
|
bool _submitting = false;
|
||||||
|
|
||||||
|
/// Collected answers, keyed by questionId
|
||||||
|
late Map<String, dynamic> _answers;
|
||||||
|
|
||||||
|
/// Local controller for free text input
|
||||||
|
final TextEditingController _textController = TextEditingController();
|
||||||
|
|
||||||
|
/// Local state holders for inputs to avoid rebuilding whole list
|
||||||
|
String? _singleChoiceSelected; // optionId
|
||||||
|
final Set<String> _multiChoiceSelected = {};
|
||||||
|
bool? _yesNoSelected;
|
||||||
|
int? _ratingSelected; // 1..5
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// Ensure questions are ordered by `order`
|
||||||
|
_questions = [...widget.poll.questions]
|
||||||
|
..sort((a, b) => a.order.compareTo(b.order));
|
||||||
|
_answers = Map<String, dynamic>.from(widget.initialAnswers ?? {});
|
||||||
|
_loadCurrentIntoLocalState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant PollSubmit oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.poll.id != widget.poll.id) {
|
||||||
|
_index = 0;
|
||||||
|
_answers = Map<String, dynamic>.from(widget.initialAnswers ?? {});
|
||||||
|
_questions
|
||||||
|
..clear()
|
||||||
|
..addAll(
|
||||||
|
[...widget.poll.questions]
|
||||||
|
..sort((a, b) => a.order.compareTo(b.order)),
|
||||||
|
);
|
||||||
|
_loadCurrentIntoLocalState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_textController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
SnPollQuestion get _current => _questions[_index];
|
||||||
|
|
||||||
|
void _loadCurrentIntoLocalState() {
|
||||||
|
final q = _current;
|
||||||
|
final saved = _answers[q.id];
|
||||||
|
|
||||||
|
_singleChoiceSelected = null;
|
||||||
|
_multiChoiceSelected.clear();
|
||||||
|
_yesNoSelected = null;
|
||||||
|
_ratingSelected = null;
|
||||||
|
_textController.text = '';
|
||||||
|
|
||||||
|
switch (q.type) {
|
||||||
|
case SnPollQuestionType.singleChoice:
|
||||||
|
if (saved is String) _singleChoiceSelected = saved;
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.multipleChoice:
|
||||||
|
if (saved is List) {
|
||||||
|
_multiChoiceSelected.addAll(saved.whereType<String>());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.yesNo:
|
||||||
|
if (saved is bool) _yesNoSelected = saved;
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.rating:
|
||||||
|
if (saved is int) _ratingSelected = saved;
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.freeText:
|
||||||
|
if (saved is String) _textController.text = saved;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isCurrentAnswered() {
|
||||||
|
final q = _current;
|
||||||
|
if (!q.isRequired) return true;
|
||||||
|
|
||||||
|
switch (q.type) {
|
||||||
|
case SnPollQuestionType.singleChoice:
|
||||||
|
return _singleChoiceSelected != null;
|
||||||
|
case SnPollQuestionType.multipleChoice:
|
||||||
|
return _multiChoiceSelected.isNotEmpty;
|
||||||
|
case SnPollQuestionType.yesNo:
|
||||||
|
return _yesNoSelected != null;
|
||||||
|
case SnPollQuestionType.rating:
|
||||||
|
return (_ratingSelected ?? 0) > 0;
|
||||||
|
case SnPollQuestionType.freeText:
|
||||||
|
return _textController.text.trim().isNotEmpty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _persistCurrentAnswer() {
|
||||||
|
final q = _current;
|
||||||
|
switch (q.type) {
|
||||||
|
case SnPollQuestionType.singleChoice:
|
||||||
|
if (_singleChoiceSelected == null) {
|
||||||
|
_answers.remove(q.id);
|
||||||
|
} else {
|
||||||
|
_answers[q.id] = _singleChoiceSelected!;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.multipleChoice:
|
||||||
|
if (_multiChoiceSelected.isEmpty) {
|
||||||
|
_answers.remove(q.id);
|
||||||
|
} else {
|
||||||
|
_answers[q.id] = _multiChoiceSelected.toList(growable: false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.yesNo:
|
||||||
|
if (_yesNoSelected == null) {
|
||||||
|
_answers.remove(q.id);
|
||||||
|
} else {
|
||||||
|
_answers[q.id] = _yesNoSelected!;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.rating:
|
||||||
|
if (_ratingSelected == null) {
|
||||||
|
_answers.remove(q.id);
|
||||||
|
} else {
|
||||||
|
_answers[q.id] = _ratingSelected!;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SnPollQuestionType.freeText:
|
||||||
|
final text = _textController.text.trim();
|
||||||
|
if (text.isEmpty) {
|
||||||
|
_answers.remove(q.id);
|
||||||
|
} else {
|
||||||
|
_answers[q.id] = text;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _submitToServer() async {
|
||||||
|
// Persist current question before final submit
|
||||||
|
_persistCurrentAnswer();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_submitting = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
final dio = ref.read(apiClientProvider);
|
||||||
|
|
||||||
|
await dio.post(
|
||||||
|
'/sphere/polls/${widget.poll.id}/answer',
|
||||||
|
data: {'answer': _answers},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Only call onSubmit after server accepts
|
||||||
|
widget.onSubmit(Map<String, dynamic>.unmodifiable(_answers));
|
||||||
|
|
||||||
|
showSnackBar('Poll answer has been submitted.');
|
||||||
|
HapticFeedback.heavyImpact();
|
||||||
|
} catch (e) {
|
||||||
|
showErrorAlert(e);
|
||||||
|
} finally {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_submitting = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _next() {
|
||||||
|
if (_submitting) return;
|
||||||
|
_persistCurrentAnswer();
|
||||||
|
if (_index < _questions.length - 1) {
|
||||||
|
setState(() {
|
||||||
|
_index++;
|
||||||
|
_loadCurrentIntoLocalState();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Final submit to API
|
||||||
|
_submitToServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _back() {
|
||||||
|
if (_submitting) return;
|
||||||
|
_persistCurrentAnswer();
|
||||||
|
if (_index > 0) {
|
||||||
|
setState(() {
|
||||||
|
_index--;
|
||||||
|
_loadCurrentIntoLocalState();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// at the first question; allow cancel if provided
|
||||||
|
widget.onCancel?.call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHeader(BuildContext context) {
|
||||||
|
final q = _current;
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (widget.poll.title != null || widget.poll.description != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (widget.poll.title != null)
|
||||||
|
Text(
|
||||||
|
widget.poll.title!,
|
||||||
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
|
),
|
||||||
|
if (widget.poll.description != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: Text(
|
||||||
|
widget.poll.description!,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodyMedium?.color?.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.showProgress)
|
||||||
|
Text(
|
||||||
|
'${_index + 1} / ${_questions.length}',
|
||||||
|
style: Theme.of(context).textTheme.labelMedium,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
q.title,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (q.isRequired)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8),
|
||||||
|
child: Text(
|
||||||
|
'*',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (q.description != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: Text(
|
||||||
|
q.description!,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodySmall?.color?.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStats(BuildContext context, SnPollQuestion q) {
|
||||||
|
if (widget.stats == null) return const SizedBox.shrink();
|
||||||
|
final raw = widget.stats![q.id];
|
||||||
|
if (raw == null) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
Widget? body;
|
||||||
|
|
||||||
|
switch (q.type) {
|
||||||
|
case SnPollQuestionType.rating:
|
||||||
|
// rating: avg score (double or int)
|
||||||
|
final avg = (raw['rating'] as num?)?.toDouble();
|
||||||
|
if (avg == null) break;
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
body = Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.star, color: Colors.amber.shade600, size: 18),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
avg.toStringAsFixed(1),
|
||||||
|
style: theme.textTheme.labelMedium?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SnPollQuestionType.yesNo:
|
||||||
|
// yes/no: map {true: count, false: count}
|
||||||
|
if (raw is Map) {
|
||||||
|
final int yes =
|
||||||
|
(raw[true] is int)
|
||||||
|
? raw[true] as int
|
||||||
|
: int.tryParse('${raw[true]}') ?? 0;
|
||||||
|
final int no =
|
||||||
|
(raw[false] is int)
|
||||||
|
? raw[false] as int
|
||||||
|
: int.tryParse('${raw[false]}') ?? 0;
|
||||||
|
final total = (yes + no).clamp(0, 1 << 31);
|
||||||
|
final yesPct = total == 0 ? 0.0 : yes / total;
|
||||||
|
final noPct = total == 0 ? 0.0 : no / total;
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
body = Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_BarStatRow(
|
||||||
|
label: 'Yes',
|
||||||
|
count: yes,
|
||||||
|
fraction: yesPct,
|
||||||
|
color: Colors.green.shade600,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
_BarStatRow(
|
||||||
|
label: 'No',
|
||||||
|
count: no,
|
||||||
|
fraction: noPct,
|
||||||
|
color: Colors.red.shade600,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
'Total: $total',
|
||||||
|
style: theme.textTheme.labelSmall?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SnPollQuestionType.singleChoice:
|
||||||
|
case SnPollQuestionType.multipleChoice:
|
||||||
|
// map optionId -> count
|
||||||
|
if (raw is Map) {
|
||||||
|
final options = [...?q.options]
|
||||||
|
..sort((a, b) => a.order.compareTo(b.order));
|
||||||
|
final List<_OptionCount> items = [];
|
||||||
|
int total = 0;
|
||||||
|
for (final opt in options) {
|
||||||
|
final dynamic v = raw[opt.id];
|
||||||
|
final int count = v is int ? v : int.tryParse('$v') ?? 0;
|
||||||
|
total += count;
|
||||||
|
items.add(_OptionCount(id: opt.id, label: opt.label, count: count));
|
||||||
|
}
|
||||||
|
if (items.isNotEmpty) {
|
||||||
|
items.sort(
|
||||||
|
(a, b) => b.count.compareTo(a.count),
|
||||||
|
); // show highest first
|
||||||
|
}
|
||||||
|
body = Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
for (final it in items)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 6),
|
||||||
|
child: _BarStatRow(
|
||||||
|
label: it.label,
|
||||||
|
count: it.count,
|
||||||
|
fraction: total == 0 ? 0 : it.count / total,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (items.isNotEmpty)
|
||||||
|
Text(
|
||||||
|
'Total: $total',
|
||||||
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SnPollQuestionType.freeText:
|
||||||
|
// No stats
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body == null) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.35),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Stats',
|
||||||
|
style: Theme.of(context).textTheme.labelLarge?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
body,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBody(BuildContext context) {
|
||||||
|
final q = _current;
|
||||||
|
switch (q.type) {
|
||||||
|
case SnPollQuestionType.singleChoice:
|
||||||
|
return _buildSingleChoice(context, q);
|
||||||
|
case SnPollQuestionType.multipleChoice:
|
||||||
|
return _buildMultipleChoice(context, q);
|
||||||
|
case SnPollQuestionType.yesNo:
|
||||||
|
return _buildYesNo(context, q);
|
||||||
|
case SnPollQuestionType.rating:
|
||||||
|
return _buildRating(context, q);
|
||||||
|
case SnPollQuestionType.freeText:
|
||||||
|
return _buildFreeText(context, q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSingleChoice(BuildContext context, SnPollQuestion q) {
|
||||||
|
final options = [...?q.options]..sort((a, b) => a.order.compareTo(b.order));
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
for (final opt in options)
|
||||||
|
RadioListTile<String>(
|
||||||
|
value: opt.id,
|
||||||
|
groupValue: _singleChoiceSelected,
|
||||||
|
onChanged: (val) => setState(() => _singleChoiceSelected = val),
|
||||||
|
title: Text(opt.label),
|
||||||
|
subtitle: opt.description != null ? Text(opt.description!) : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMultipleChoice(BuildContext context, SnPollQuestion q) {
|
||||||
|
final options = [...?q.options]..sort((a, b) => a.order.compareTo(b.order));
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
for (final opt in options)
|
||||||
|
CheckboxListTile(
|
||||||
|
value: _multiChoiceSelected.contains(opt.id),
|
||||||
|
onChanged: (val) {
|
||||||
|
setState(() {
|
||||||
|
if (val == true) {
|
||||||
|
_multiChoiceSelected.add(opt.id);
|
||||||
|
} else {
|
||||||
|
_multiChoiceSelected.remove(opt.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
title: Text(opt.label),
|
||||||
|
subtitle: opt.description != null ? Text(opt.description!) : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildYesNo(BuildContext context, SnPollQuestion q) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SegmentedButton<bool>(
|
||||||
|
segments: const [
|
||||||
|
ButtonSegment(value: true, label: Text('Yes')),
|
||||||
|
ButtonSegment(value: false, label: Text('No')),
|
||||||
|
],
|
||||||
|
selected: _yesNoSelected == null ? {} : {_yesNoSelected!},
|
||||||
|
onSelectionChanged: (sel) {
|
||||||
|
setState(() {
|
||||||
|
_yesNoSelected = sel.isEmpty ? null : sel.first;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
multiSelectionEnabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRating(BuildContext context, SnPollQuestion q) {
|
||||||
|
const max = 5;
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: List.generate(max, (i) {
|
||||||
|
final value = i + 1;
|
||||||
|
final selected = (_ratingSelected ?? 0) >= value;
|
||||||
|
return IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
selected ? Icons.star : Icons.star_border,
|
||||||
|
color: selected ? Colors.amber : null,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_ratingSelected = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFreeText(BuildContext context, SnPollQuestion q) {
|
||||||
|
return TextField(
|
||||||
|
controller: _textController,
|
||||||
|
maxLines: 6,
|
||||||
|
decoration: const InputDecoration(border: OutlineInputBorder()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNavBar(BuildContext context) {
|
||||||
|
final isLast = _index == _questions.length - 1;
|
||||||
|
final canProceed = _isCurrentAnswered() && !_submitting;
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
label: Text(_index == 0 ? 'Cancel' : 'Back'),
|
||||||
|
onPressed: _submitting ? null : _back,
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
FilledButton.icon(
|
||||||
|
icon:
|
||||||
|
_submitting
|
||||||
|
? const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: Icon(isLast ? Icons.check : Icons.arrow_forward),
|
||||||
|
label: Text(isLast ? 'Submit' : 'Next'),
|
||||||
|
onPressed: canProceed ? _next : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (_questions.isEmpty) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
_buildHeader(context),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_AnimatedStep(
|
||||||
|
key: ValueKey(_current.id),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [_buildBody(context), _buildStats(context, _current)],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildNavBar(context),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OptionCount {
|
||||||
|
final String id;
|
||||||
|
final String label;
|
||||||
|
final int count;
|
||||||
|
const _OptionCount({
|
||||||
|
required this.id,
|
||||||
|
required this.label,
|
||||||
|
required this.count,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BarStatRow extends StatelessWidget {
|
||||||
|
const _BarStatRow({
|
||||||
|
required this.label,
|
||||||
|
required this.count,
|
||||||
|
required this.fraction,
|
||||||
|
this.color,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final int count;
|
||||||
|
final double fraction;
|
||||||
|
final Color? color;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final barColor = color ?? Theme.of(context).colorScheme.primary;
|
||||||
|
final bgColor = Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceVariant.withOpacity(0.6);
|
||||||
|
final fg =
|
||||||
|
(fraction.isNaN || fraction.isInfinite)
|
||||||
|
? 0.0
|
||||||
|
: fraction.clamp(0.0, 1.0);
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('$label · $count', style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final width = constraints.maxWidth;
|
||||||
|
final filled = width * fg;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 8,
|
||||||
|
width: width,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: bgColor,
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 8,
|
||||||
|
width: filled,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: barColor,
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Simple fade/slide transition between questions.
|
||||||
|
class _AnimatedStep extends StatelessWidget {
|
||||||
|
const _AnimatedStep({super.key, required this.child});
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
|
transitionBuilder: (child, anim) {
|
||||||
|
final offset = Tween<Offset>(
|
||||||
|
begin: const Offset(0.1, 0),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(anim);
|
||||||
|
final fade = CurvedAnimation(parent: anim, curve: Curves.easeInOut);
|
||||||
|
return FadeTransition(
|
||||||
|
opacity: fade,
|
||||||
|
child: SlideTransition(position: offset, child: child),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
204
lib/widgets/post/compose_link_attachments.dart
Normal file
204
lib/widgets/post/compose_link_attachments.dart
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/file.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:riverpod_paging_utils/riverpod_paging_utils.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
|
part 'compose_link_attachments.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
class CloudFileListNotifier extends _$CloudFileListNotifier
|
||||||
|
with CursorPagingNotifierMixin<SnCloudFile> {
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnCloudFile>> build() => fetch(cursor: null);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CursorPagingData<SnCloudFile>> fetch({required String? cursor}) async {
|
||||||
|
final client = ref.read(apiClientProvider);
|
||||||
|
final offset = cursor == null ? 0 : int.parse(cursor);
|
||||||
|
final take = 20;
|
||||||
|
|
||||||
|
final queryParameters = {'offset': offset, 'take': take};
|
||||||
|
|
||||||
|
final response = await client.get(
|
||||||
|
'/drive/files/me',
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
);
|
||||||
|
|
||||||
|
final List<SnCloudFile> items =
|
||||||
|
(response.data as List)
|
||||||
|
.map((e) => SnCloudFile.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
final total = int.parse(response.headers.value('X-Total') ?? '0');
|
||||||
|
|
||||||
|
final hasMore = offset + items.length < total;
|
||||||
|
final nextCursor = hasMore ? (offset + items.length).toString() : null;
|
||||||
|
|
||||||
|
return CursorPagingData(
|
||||||
|
items: items,
|
||||||
|
hasMore: hasMore,
|
||||||
|
nextCursor: nextCursor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ComposeLinkAttachment extends HookConsumerWidget {
|
||||||
|
const ComposeLinkAttachment({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final idController = useTextEditingController();
|
||||||
|
final errorMessage = useState<String?>(null);
|
||||||
|
|
||||||
|
return SheetScaffold(
|
||||||
|
heightFactor: 0.6,
|
||||||
|
titleText: 'linkAttachment'.tr(),
|
||||||
|
child: DefaultTabController(
|
||||||
|
length: 2,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
TabBar(
|
||||||
|
tabs: [
|
||||||
|
Tab(text: 'attachmentsRecentUploads'.tr()),
|
||||||
|
Tab(text: 'attachmentsManualInput'.tr()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
children: [
|
||||||
|
PagingHelperView(
|
||||||
|
provider: cloudFileListNotifierProvider,
|
||||||
|
futureRefreshable: cloudFileListNotifierProvider.future,
|
||||||
|
notifierRefreshable: cloudFileListNotifierProvider.notifier,
|
||||||
|
contentBuilder:
|
||||||
|
(data, widgetCount, endItemView) => ListView.builder(
|
||||||
|
padding: EdgeInsets.only(top: 8),
|
||||||
|
itemCount: widgetCount,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == widgetCount - 1) {
|
||||||
|
return endItemView;
|
||||||
|
}
|
||||||
|
|
||||||
|
final item = data.items[index];
|
||||||
|
final itemType =
|
||||||
|
item.mimeType?.split('/').firstOrNull;
|
||||||
|
return ListTile(
|
||||||
|
leading: ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
Radius.circular(8),
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
child: switch (itemType) {
|
||||||
|
'image' => CloudImageWidget(file: item),
|
||||||
|
'audio' =>
|
||||||
|
const Icon(
|
||||||
|
Symbols.audio_file,
|
||||||
|
fill: 1,
|
||||||
|
).center(),
|
||||||
|
'video' =>
|
||||||
|
const Icon(
|
||||||
|
Symbols.video_file,
|
||||||
|
fill: 1,
|
||||||
|
).center(),
|
||||||
|
_ =>
|
||||||
|
const Icon(
|
||||||
|
Symbols.body_system,
|
||||||
|
fill: 1,
|
||||||
|
).center(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title:
|
||||||
|
item.name.isEmpty
|
||||||
|
? Text('untitled').tr().italic()
|
||||||
|
: Text(item.name),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context, item);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: idController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'fileId'.tr(),
|
||||||
|
helperText: 'fileIdHint'.tr(),
|
||||||
|
helperMaxLines: 3,
|
||||||
|
errorText: errorMessage.value,
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
|
const Gap(16),
|
||||||
|
InkWell(
|
||||||
|
child: Text(
|
||||||
|
'fileIdLinkHint',
|
||||||
|
).tr().fontSize(13).opacity(0.85),
|
||||||
|
onTap: () {
|
||||||
|
launchUrlString('https://fs.solian.app');
|
||||||
|
},
|
||||||
|
).padding(horizontal: 14),
|
||||||
|
const Gap(16),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: TextButton.icon(
|
||||||
|
icon: const Icon(Symbols.add),
|
||||||
|
label: Text('add'.tr()),
|
||||||
|
onPressed: () async {
|
||||||
|
final fileId = idController.text.trim();
|
||||||
|
if (fileId.isEmpty) {
|
||||||
|
errorMessage.value = 'fileIdCannotBeEmpty'.tr();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final client = ref.read(apiClientProvider);
|
||||||
|
final response = await client.get(
|
||||||
|
'/drive/files/$fileId/info',
|
||||||
|
);
|
||||||
|
final SnCloudFile cloudFile =
|
||||||
|
SnCloudFile.fromJson(response.data);
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context).pop(cloudFile);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
errorMessage.value = 'failedToFetchFile'.tr(
|
||||||
|
args: [e.toString()],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 24),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
31
lib/widgets/post/compose_link_attachments.g.dart
Normal file
31
lib/widgets/post/compose_link_attachments.g.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'compose_link_attachments.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$cloudFileListNotifierHash() =>
|
||||||
|
r'e2c8a076a9e635c7b43a87d00f78775427ba6334';
|
||||||
|
|
||||||
|
/// See also [CloudFileListNotifier].
|
||||||
|
@ProviderFor(CloudFileListNotifier)
|
||||||
|
final cloudFileListNotifierProvider = AutoDisposeAsyncNotifierProvider<
|
||||||
|
CloudFileListNotifier,
|
||||||
|
CursorPagingData<SnCloudFile>
|
||||||
|
>.internal(
|
||||||
|
CloudFileListNotifier.new,
|
||||||
|
name: r'cloudFileListNotifierProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$cloudFileListNotifierHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef _$CloudFileListNotifier =
|
||||||
|
AutoDisposeAsyncNotifier<CursorPagingData<SnCloudFile>>;
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
201
lib/widgets/post/compose_poll.dart
Normal file
201
lib/widgets/post/compose_poll.dart
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/poll.dart';
|
||||||
|
import 'package:island/models/publisher.dart';
|
||||||
|
import 'package:island/screens/creators/poll/poll_list.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:riverpod_paging_utils/riverpod_paging_utils.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:island/widgets/post/publishers_modal.dart';
|
||||||
|
|
||||||
|
/// Bottom sheet for selecting or creating a poll. Returns SnPoll via Navigator.pop.
|
||||||
|
class ComposePollSheet extends HookConsumerWidget {
|
||||||
|
/// Optional publisher name to filter polls and prefill creation.
|
||||||
|
final String? pubName;
|
||||||
|
|
||||||
|
const ComposePollSheet({super.key, this.pubName});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final selectedPublisher = useState<String?>(pubName);
|
||||||
|
final isPushing = useState(false);
|
||||||
|
final errorText = useState<String?>(null);
|
||||||
|
|
||||||
|
return SheetScaffold(
|
||||||
|
heightFactor: 0.6,
|
||||||
|
titleText: 'poll'.tr(),
|
||||||
|
child: DefaultTabController(
|
||||||
|
length: 2,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
TabBar(
|
||||||
|
tabs: [
|
||||||
|
Tab(text: 'pollsRecent'.tr()),
|
||||||
|
Tab(text: 'pollCreateNew'.tr()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
children: [
|
||||||
|
// Link/Select existing poll list
|
||||||
|
PagingHelperView(
|
||||||
|
provider: pollListNotifierProvider(pubName),
|
||||||
|
futureRefreshable: pollListNotifierProvider(pubName).future,
|
||||||
|
notifierRefreshable:
|
||||||
|
pollListNotifierProvider(pubName).notifier,
|
||||||
|
contentBuilder:
|
||||||
|
(data, widgetCount, endItemView) => ListView.builder(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
itemCount: widgetCount,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == widgetCount - 1) {
|
||||||
|
return endItemView;
|
||||||
|
}
|
||||||
|
|
||||||
|
final poll = data.items[index];
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
leading: const Icon(Symbols.how_to_vote, fill: 1),
|
||||||
|
title: Text(poll.title ?? 'untitled'.tr()),
|
||||||
|
subtitle: _buildPollSubtitle(poll),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop(poll);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Create new poll and return it
|
||||||
|
SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'pollCreateNewHint',
|
||||||
|
).tr().fontSize(13).opacity(0.85).padding(bottom: 8),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
selectedPublisher.value == null
|
||||||
|
? 'publisher'.tr()
|
||||||
|
: '@${selectedPublisher.value}',
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
selectedPublisher.value == null
|
||||||
|
? 'publisherHint'.tr()
|
||||||
|
: 'selected'.tr(),
|
||||||
|
),
|
||||||
|
leading: const Icon(Symbols.account_circle),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
onTap: () async {
|
||||||
|
final picked =
|
||||||
|
await showModalBottomSheet<SnPublisher>(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (context) => const PublisherModal(),
|
||||||
|
);
|
||||||
|
if (picked != null) {
|
||||||
|
try {
|
||||||
|
final name = picked.name;
|
||||||
|
if (name.isNotEmpty) {
|
||||||
|
selectedPublisher.value = name;
|
||||||
|
errorText.value = null;
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (errorText.value != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
top: 4,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
errorText.value!,
|
||||||
|
style: TextStyle(color: Colors.red[700]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(16),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: FilledButton.icon(
|
||||||
|
icon:
|
||||||
|
isPushing.value
|
||||||
|
? const SizedBox(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(Symbols.add_circle),
|
||||||
|
label: Text('create'.tr()),
|
||||||
|
onPressed:
|
||||||
|
isPushing.value
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
final pub = selectedPublisher.value ?? '';
|
||||||
|
if (pub.isEmpty) {
|
||||||
|
errorText.value =
|
||||||
|
'publisherCannotBeEmpty'.tr();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
errorText.value = null;
|
||||||
|
|
||||||
|
isPushing.value = true;
|
||||||
|
// Push to creatorPollNew route and await result
|
||||||
|
final result = await GoRouter.of(
|
||||||
|
context,
|
||||||
|
).push<SnPoll>(
|
||||||
|
'/creators/$pub/polls/new',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
isPushing.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
|
// Return created poll to caller of this bottom sheet
|
||||||
|
Navigator.of(context).pop(result);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, vertical: 24),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _buildPollSubtitle(SnPoll poll) {
|
||||||
|
try {
|
||||||
|
final SnPoll dyn = poll;
|
||||||
|
final List<SnPollQuestion> options = dyn.questions;
|
||||||
|
if (options.isEmpty) return null;
|
||||||
|
final preview = options.take(3).map((e) => e.title).join(' · ');
|
||||||
|
if (preview.trim().isEmpty) return null;
|
||||||
|
return Text(preview);
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
147
lib/widgets/post/compose_recorder.dart
Normal file
147
lib/widgets/post/compose_recorder.dart
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/services/time.dart';
|
||||||
|
import 'package:island/widgets/alert.dart';
|
||||||
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:record/record.dart' hide Amplitude;
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
import 'package:waveform_flutter/waveform_flutter.dart';
|
||||||
|
|
||||||
|
class ComposeRecorder extends HookConsumerWidget {
|
||||||
|
const ComposeRecorder({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final recording = useState(false);
|
||||||
|
final recordingStartAt = useState<DateTime?>(null);
|
||||||
|
final recordingDuration = useState<Duration>(Duration(seconds: 0));
|
||||||
|
|
||||||
|
StreamSubscription? originalAmplitude;
|
||||||
|
StreamController<Amplitude> amplitudeStream = StreamController();
|
||||||
|
var record = AudioRecorder();
|
||||||
|
|
||||||
|
final resultPath = useState<String?>(null);
|
||||||
|
|
||||||
|
Future<void> startRecord() async {
|
||||||
|
recording.value = true;
|
||||||
|
|
||||||
|
// Check and request permission if needed
|
||||||
|
final tempPath = !kIsWeb ? (await getTemporaryDirectory()).path : 'temp';
|
||||||
|
final uuid = const Uuid().v4().substring(0, 8);
|
||||||
|
if (!await record.hasPermission()) return;
|
||||||
|
|
||||||
|
const recordConfig = RecordConfig(
|
||||||
|
encoder: AudioEncoder.pcm16bits,
|
||||||
|
autoGain: true,
|
||||||
|
echoCancel: true,
|
||||||
|
noiseSuppress: true,
|
||||||
|
);
|
||||||
|
resultPath.value = '$tempPath/solar-network-record-$uuid.m4a';
|
||||||
|
await record.start(recordConfig, path: resultPath.value!);
|
||||||
|
|
||||||
|
recordingStartAt.value = DateTime.now();
|
||||||
|
originalAmplitude = record
|
||||||
|
.onAmplitudeChanged(const Duration(milliseconds: 100))
|
||||||
|
.listen((value) async {
|
||||||
|
amplitudeStream.add(
|
||||||
|
Amplitude(current: value.current, max: value.max),
|
||||||
|
);
|
||||||
|
recordingDuration.value = DateTime.now().difference(
|
||||||
|
recordingStartAt.value!,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() {
|
||||||
|
return () {
|
||||||
|
// Called when widget is unmounted
|
||||||
|
log('[Recorder] Clean up!');
|
||||||
|
originalAmplitude?.cancel();
|
||||||
|
amplitudeStream.close();
|
||||||
|
record.dispose();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
Future<void> stopRecord() async {
|
||||||
|
recording.value = false;
|
||||||
|
await record.pause();
|
||||||
|
final newResult = await record.stop();
|
||||||
|
await record.cancel();
|
||||||
|
if (newResult != null) resultPath.value = newResult;
|
||||||
|
|
||||||
|
if (context.mounted) Navigator.of(context).pop(resultPath.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addExistingAudio() async {
|
||||||
|
var result = await FilePicker.platform.pickFiles(
|
||||||
|
type: FileType.custom,
|
||||||
|
allowedExtensions: ['mp3', 'm4a', 'wav', 'aac', 'flac', 'ogg', 'opus'],
|
||||||
|
onFileLoading: (status) {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
if (status == FilePickerStatus.picking) {
|
||||||
|
showLoadingModal(context);
|
||||||
|
} else {
|
||||||
|
hideLoadingModal(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result == null || result.count == 0) return;
|
||||||
|
if (context.mounted) Navigator.of(context).pop(result.files.first.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SheetScaffold(
|
||||||
|
titleText: "recordAudio".tr(),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: addExistingAudio,
|
||||||
|
icon: const Icon(Symbols.upload),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Gap(32),
|
||||||
|
Text(
|
||||||
|
recordingDuration.value.formatShortDuration(),
|
||||||
|
).fontSize(20).bold().padding(bottom: 8),
|
||||||
|
SizedBox(
|
||||||
|
height: 120,
|
||||||
|
child: Center(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 480),
|
||||||
|
child: Card(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: AnimatedWaveList(stream: amplitudeStream.stream),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).padding(horizontal: 24),
|
||||||
|
const Gap(12),
|
||||||
|
IconButton.filled(
|
||||||
|
onPressed: recording.value ? stopRecord : startRecord,
|
||||||
|
iconSize: 32,
|
||||||
|
icon:
|
||||||
|
recording.value
|
||||||
|
? const Icon(Symbols.stop, fill: 1, color: Colors.white)
|
||||||
|
: const Icon(
|
||||||
|
Symbols.play_arrow,
|
||||||
|
fill: 1,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,29 @@
|
|||||||
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/post_category.dart';
|
||||||
|
import 'package:island/pods/network.dart';
|
||||||
import 'package:island/widgets/content/sheet.dart';
|
import 'package:island/widgets/content/sheet.dart';
|
||||||
|
import 'package:island/widgets/post/compose_shared.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:textfield_tags/textfield_tags.dart';
|
import 'package:textfield_tags/textfield_tags.dart';
|
||||||
|
|
||||||
|
part 'compose_settings_sheet.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
Future<List<SnPostCategory>> postCategories(Ref ref) async {
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
final resp = await apiClient.get('/sphere/posts/categories');
|
||||||
|
return resp.data
|
||||||
|
.map((e) => SnPostCategory.fromJson(e))
|
||||||
|
.cast<SnPostCategory>()
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
/// A reusable widget for tag input fields with chip display
|
/// A reusable widget for tag input fields with chip display
|
||||||
class ChipTagInputField extends StatelessWidget {
|
class ChipTagInputField extends StatelessWidget {
|
||||||
final InputFieldValues inputFieldValues;
|
final InputFieldValues inputFieldValues;
|
||||||
@@ -98,31 +116,20 @@ class ChipTagInputField extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ComposeSettingsSheet extends HookWidget {
|
class ComposeSettingsSheet extends HookConsumerWidget {
|
||||||
final TextEditingController titleController;
|
final ComposeState state;
|
||||||
final TextEditingController descriptionController;
|
|
||||||
final ValueNotifier<int> visibility;
|
|
||||||
final VoidCallback? onVisibilityChanged;
|
|
||||||
final StringTagController tagsController;
|
|
||||||
final StringTagController categoriesController;
|
|
||||||
|
|
||||||
const ComposeSettingsSheet({
|
const ComposeSettingsSheet({super.key, required this.state});
|
||||||
super.key,
|
|
||||||
required this.titleController,
|
|
||||||
required this.descriptionController,
|
|
||||||
required this.visibility,
|
|
||||||
this.onVisibilityChanged,
|
|
||||||
required this.tagsController,
|
|
||||||
required this.categoriesController,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final colorScheme = theme.colorScheme;
|
final colorScheme = theme.colorScheme;
|
||||||
|
|
||||||
// Listen to visibility changes to trigger rebuilds
|
// Listen to visibility changes to trigger rebuilds
|
||||||
final currentVisibility = useValueListenable(visibility);
|
final currentVisibility = useValueListenable(state.visibility);
|
||||||
|
final currentCategories = useValueListenable(state.categories);
|
||||||
|
final postCategories = ref.watch(postCategoriesProvider);
|
||||||
|
|
||||||
IconData getVisibilityIcon(int visibilityValue) {
|
IconData getVisibilityIcon(int visibilityValue) {
|
||||||
switch (visibilityValue) {
|
switch (visibilityValue) {
|
||||||
@@ -160,11 +167,10 @@ class ComposeSettingsSheet extends HookWidget {
|
|||||||
leading: Icon(icon),
|
leading: Icon(icon),
|
||||||
title: Text(textKey.tr()),
|
title: Text(textKey.tr()),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
visibility.value = value;
|
state.visibility.value = value;
|
||||||
onVisibilityChanged?.call();
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
selected: visibility.value == value,
|
selected: state.visibility.value == value,
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -210,48 +216,16 @@ class ComposeSettingsSheet extends HookWidget {
|
|||||||
|
|
||||||
return SheetScaffold(
|
return SheetScaffold(
|
||||||
titleText: 'postSettings'.tr(),
|
titleText: 'postSettings'.tr(),
|
||||||
|
heightFactor: 0.6,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
// Title field
|
|
||||||
TextField(
|
|
||||||
controller: titleController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'postTitle'.tr(),
|
|
||||||
hintText: 'postTitle'.tr(),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.all(16),
|
|
||||||
),
|
|
||||||
style: theme.textTheme.titleMedium,
|
|
||||||
onTapOutside:
|
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Description field
|
|
||||||
TextField(
|
|
||||||
controller: descriptionController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'postDescription'.tr(),
|
|
||||||
hintText: 'postDescription'.tr(),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.all(16),
|
|
||||||
),
|
|
||||||
style: theme.textTheme.bodyMedium,
|
|
||||||
maxLines: 3,
|
|
||||||
onTapOutside:
|
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Tags field
|
// Tags field
|
||||||
TextFieldTags(
|
TextFieldTags(
|
||||||
textfieldTagsController: tagsController,
|
textfieldTagsController: state.tagsController,
|
||||||
textSeparators: const [' ', ','],
|
textSeparators: const [' ', ','],
|
||||||
letterCase: LetterCase.normal,
|
letterCase: LetterCase.normal,
|
||||||
validator: (String tag) {
|
validator: (String tag) {
|
||||||
@@ -270,22 +244,105 @@ class ComposeSettingsSheet extends HookWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// Categories field
|
// Categories field
|
||||||
TextFieldTags(
|
// FIXME: Sometimes the entire dropdown crashes: 'package:flutter/src/rendering/stack.dart': Failed assertion: line 799 pos 12: 'firstChild == null || child != null': is not true.
|
||||||
textfieldTagsController: categoriesController,
|
DropdownButtonFormField2<SnPostCategory>(
|
||||||
textSeparators: const [' ', ','],
|
isExpanded: true,
|
||||||
letterCase: LetterCase.small,
|
decoration: InputDecoration(
|
||||||
validator: (String tag) {
|
contentPadding: const EdgeInsets.symmetric(vertical: 9),
|
||||||
if (tag.isEmpty) return 'No, cannot be empty';
|
border: OutlineInputBorder(
|
||||||
if (tag.contains(' ')) return 'Tags should be URL-safe';
|
borderRadius: BorderRadius.circular(12),
|
||||||
return null;
|
),
|
||||||
},
|
),
|
||||||
inputFieldBuilder: (context, inputFieldValues) {
|
hint: Text('categories'.tr(), style: TextStyle(fontSize: 15)),
|
||||||
return ChipTagInputField(
|
items:
|
||||||
inputFieldValues: inputFieldValues,
|
(postCategories.value ?? <SnPostCategory>[]).map((item) {
|
||||||
labelText: 'categories',
|
return DropdownMenuItem(
|
||||||
hintText: 'categoriesHint',
|
value: item,
|
||||||
);
|
enabled: false,
|
||||||
|
child: StatefulBuilder(
|
||||||
|
builder: (context, menuSetState) {
|
||||||
|
final isSelected = state.categories.value.contains(
|
||||||
|
item,
|
||||||
|
);
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
isSelected
|
||||||
|
? state.categories.value =
|
||||||
|
state.categories.value
|
||||||
|
.where((e) => e != item)
|
||||||
|
.toList()
|
||||||
|
: state.categories.value = [
|
||||||
|
...state.categories.value,
|
||||||
|
item,
|
||||||
|
];
|
||||||
|
menuSetState(() {});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (isSelected)
|
||||||
|
const Icon(Icons.check_box_outlined)
|
||||||
|
else
|
||||||
|
const Icon(Icons.check_box_outline_blank),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
item.categoryDisplayTitle,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
value: currentCategories.isEmpty ? null : currentCategories.last,
|
||||||
|
onChanged: (_) {},
|
||||||
|
selectedItemBuilder: (context) {
|
||||||
|
return currentCategories.map((item) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
for (final category in currentCategories)
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
|
margin: const EdgeInsets.only(right: 4),
|
||||||
|
child: Text(
|
||||||
|
category.categoryDisplayTitle,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
},
|
},
|
||||||
|
buttonStyleData: const ButtonStyleData(
|
||||||
|
padding: EdgeInsets.only(left: 16, right: 8),
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
menuItemStyleData: const MenuItemStyleData(
|
||||||
|
height: 40,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Visibility setting
|
// Visibility setting
|
||||||
|
|||||||
29
lib/widgets/post/compose_settings_sheet.g.dart
Normal file
29
lib/widgets/post/compose_settings_sheet.g.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'compose_settings_sheet.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$postCategoriesHash() => r'24337fe806d088b6468a350f62d5a5d40232a73c';
|
||||||
|
|
||||||
|
/// See also [postCategories].
|
||||||
|
@ProviderFor(postCategories)
|
||||||
|
final postCategoriesProvider =
|
||||||
|
AutoDisposeFutureProvider<List<SnPostCategory>>.internal(
|
||||||
|
postCategories,
|
||||||
|
name: r'postCategoriesProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$postCategoriesHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
typedef PostCategoriesRef = AutoDisposeFutureProviderRef<List<SnPostCategory>>;
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
@@ -3,26 +3,25 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gap/gap.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
import 'package:island/models/post.dart';
|
import 'package:island/models/post.dart';
|
||||||
|
import 'package:island/models/post_category.dart';
|
||||||
import 'package:island/models/publisher.dart';
|
import 'package:island/models/publisher.dart';
|
||||||
import 'package:island/pods/config.dart';
|
import 'package:island/pods/config.dart';
|
||||||
import 'package:island/pods/network.dart';
|
import 'package:island/pods/network.dart';
|
||||||
import 'package:island/services/file.dart';
|
import 'package:island/services/file.dart';
|
||||||
import 'package:island/services/compose_storage_db.dart';
|
import 'package:island/services/compose_storage_db.dart';
|
||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/content/sheet.dart';
|
import 'package:island/widgets/post/compose_link_attachments.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:island/widgets/post/compose_poll.dart';
|
||||||
|
import 'package:island/widgets/post/compose_recorder.dart';
|
||||||
import 'package:pasteboard/pasteboard.dart';
|
import 'package:pasteboard/pasteboard.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:textfield_tags/textfield_tags.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:textfield_tags/textfield_tags.dart';
|
|
||||||
|
|
||||||
class ComposeState {
|
class ComposeState {
|
||||||
final TextEditingController titleController;
|
final TextEditingController titleController;
|
||||||
final TextEditingController descriptionController;
|
final TextEditingController descriptionController;
|
||||||
@@ -32,10 +31,12 @@ class ComposeState {
|
|||||||
final ValueNotifier<Map<int, double>> attachmentProgress;
|
final ValueNotifier<Map<int, double>> attachmentProgress;
|
||||||
final ValueNotifier<SnPublisher?> currentPublisher;
|
final ValueNotifier<SnPublisher?> currentPublisher;
|
||||||
final ValueNotifier<bool> submitting;
|
final ValueNotifier<bool> submitting;
|
||||||
|
final ValueNotifier<List<SnPostCategory>> categories;
|
||||||
StringTagController tagsController;
|
StringTagController tagsController;
|
||||||
StringTagController categoriesController;
|
|
||||||
final String draftId;
|
final String draftId;
|
||||||
int postType;
|
int postType;
|
||||||
|
// Linked poll id for this compose session (nullable)
|
||||||
|
final ValueNotifier<String?> pollId;
|
||||||
Timer? _autoSaveTimer;
|
Timer? _autoSaveTimer;
|
||||||
|
|
||||||
ComposeState({
|
ComposeState({
|
||||||
@@ -48,10 +49,11 @@ class ComposeState {
|
|||||||
required this.currentPublisher,
|
required this.currentPublisher,
|
||||||
required this.submitting,
|
required this.submitting,
|
||||||
required this.tagsController,
|
required this.tagsController,
|
||||||
required this.categoriesController,
|
required this.categories,
|
||||||
required this.draftId,
|
required this.draftId,
|
||||||
this.postType = 0,
|
this.postType = 0,
|
||||||
});
|
String? pollId,
|
||||||
|
}) : pollId = ValueNotifier<String?>(pollId);
|
||||||
|
|
||||||
void startAutoSave(WidgetRef ref) {
|
void startAutoSave(WidgetRef ref) {
|
||||||
_autoSaveTimer?.cancel();
|
_autoSaveTimer?.cancel();
|
||||||
@@ -79,11 +81,7 @@ class ComposeLogic {
|
|||||||
}) {
|
}) {
|
||||||
final id = draftId ?? DateTime.now().millisecondsSinceEpoch.toString();
|
final id = draftId ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
final tagsController = StringTagController();
|
final tagsController = StringTagController();
|
||||||
final categoriesController = StringTagController();
|
|
||||||
originalPost?.tags.forEach((x) => tagsController.addTag(x.slug));
|
originalPost?.tags.forEach((x) => tagsController.addTag(x.slug));
|
||||||
originalPost?.categories.forEach(
|
|
||||||
(x) => categoriesController.addTag(x.slug),
|
|
||||||
);
|
|
||||||
return ComposeState(
|
return ComposeState(
|
||||||
attachments: ValueNotifier<List<UniversalFile>>(
|
attachments: ValueNotifier<List<UniversalFile>>(
|
||||||
originalPost?.attachments
|
originalPost?.attachments
|
||||||
@@ -111,9 +109,13 @@ class ComposeLogic {
|
|||||||
attachmentProgress: ValueNotifier<Map<int, double>>({}),
|
attachmentProgress: ValueNotifier<Map<int, double>>({}),
|
||||||
currentPublisher: ValueNotifier<SnPublisher?>(originalPost?.publisher),
|
currentPublisher: ValueNotifier<SnPublisher?>(originalPost?.publisher),
|
||||||
tagsController: tagsController,
|
tagsController: tagsController,
|
||||||
categoriesController: categoriesController,
|
categories: ValueNotifier<List<SnPostCategory>>(
|
||||||
|
originalPost?.categories ?? [],
|
||||||
|
),
|
||||||
draftId: id,
|
draftId: id,
|
||||||
postType: postType,
|
postType: postType,
|
||||||
|
// initialize without poll by default
|
||||||
|
pollId: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,9 +140,10 @@ class ComposeLogic {
|
|||||||
attachmentProgress: ValueNotifier<Map<int, double>>({}),
|
attachmentProgress: ValueNotifier<Map<int, double>>({}),
|
||||||
currentPublisher: ValueNotifier<SnPublisher?>(null),
|
currentPublisher: ValueNotifier<SnPublisher?>(null),
|
||||||
tagsController: tagsController,
|
tagsController: tagsController,
|
||||||
categoriesController: categoriesController,
|
categories: ValueNotifier<List<SnPostCategory>>([]),
|
||||||
draftId: draft.id,
|
draftId: draft.id,
|
||||||
postType: postType,
|
postType: postType,
|
||||||
|
pollId: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,93 +402,64 @@ class ComposeLogic {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> recordAudioMedia(
|
||||||
|
WidgetRef ref,
|
||||||
|
ComposeState state,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
final audioPath = await showModalBottomSheet<String?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => ComposeRecorder(),
|
||||||
|
);
|
||||||
|
if (audioPath == null) return;
|
||||||
|
|
||||||
|
state.attachments.value = [
|
||||||
|
...state.attachments.value,
|
||||||
|
UniversalFile(
|
||||||
|
data: XFile(audioPath, mimeType: 'audio/m4a'),
|
||||||
|
type: UniversalFileType.audio,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> linkAttachment(
|
static Future<void> linkAttachment(
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
ComposeState state,
|
ComposeState state,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) async {
|
) async {
|
||||||
final TextEditingController idController = TextEditingController();
|
final cloudFile = await showModalBottomSheet<SnCloudFile?>(
|
||||||
String? errorMessage;
|
|
||||||
|
|
||||||
await showModalBottomSheet(
|
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext dialogContext) {
|
useRootNavigator: true,
|
||||||
return StatefulBuilder(
|
isScrollControlled: true,
|
||||||
builder: (context, setState) {
|
builder: (context) => ComposeLinkAttachment(),
|
||||||
return SheetScaffold(
|
|
||||||
titleText: 'linkAttachment'.tr(),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
controller: idController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'fileId'.tr(),
|
|
||||||
helperText: 'fileIdHint'.tr(),
|
|
||||||
helperMaxLines: 3,
|
|
||||||
errorText: errorMessage,
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Gap(16),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: TextButton.icon(
|
|
||||||
icon: const Icon(Symbols.add),
|
|
||||||
label: Text('add'.tr()),
|
|
||||||
onPressed: () async {
|
|
||||||
final fileId = idController.text.trim();
|
|
||||||
if (fileId.isEmpty) {
|
|
||||||
setState(() {
|
|
||||||
errorMessage = 'fileIdCannotBeEmpty'.tr();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final client = ref.read(apiClientProvider);
|
|
||||||
final response = await client.get(
|
|
||||||
'/drive/files/$fileId/info',
|
|
||||||
);
|
|
||||||
final SnCloudFile cloudFile = SnCloudFile.fromJson(
|
|
||||||
response.data,
|
|
||||||
);
|
|
||||||
|
|
||||||
state.attachments.value = [
|
|
||||||
...state.attachments.value,
|
|
||||||
UniversalFile(
|
|
||||||
data: cloudFile,
|
|
||||||
type: switch (cloudFile.mimeType
|
|
||||||
?.split('/')
|
|
||||||
.firstOrNull) {
|
|
||||||
'image' => UniversalFileType.image,
|
|
||||||
'video' => UniversalFileType.video,
|
|
||||||
'audio' => UniversalFileType.audio,
|
|
||||||
_ => UniversalFileType.file,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
];
|
|
||||||
if (context.mounted) {
|
|
||||||
Navigator.of(dialogContext).pop();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
errorMessage = 'failedToFetchFile'.tr(
|
|
||||||
args: [e.toString()],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).padding(horizontal: 24, vertical: 24),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
if (cloudFile == null) return;
|
||||||
|
|
||||||
|
state.attachments.value = [
|
||||||
|
...state.attachments.value,
|
||||||
|
UniversalFile(
|
||||||
|
data: cloudFile,
|
||||||
|
type: switch (cloudFile.mimeType?.split('/').firstOrNull) {
|
||||||
|
'image' => UniversalFileType.image,
|
||||||
|
'video' => UniversalFileType.video,
|
||||||
|
'audio' => UniversalFileType.audio,
|
||||||
|
_ => UniversalFileType.file,
|
||||||
|
},
|
||||||
|
isLink: true,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void updateAttachment(
|
||||||
|
ComposeState state,
|
||||||
|
UniversalFile value,
|
||||||
|
int index,
|
||||||
|
) {
|
||||||
|
state.attachments.value =
|
||||||
|
state.attachments.value.mapIndexed((idx, ele) {
|
||||||
|
if (idx == index) return value;
|
||||||
|
return ele;
|
||||||
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> uploadAttachment(
|
static Future<void> uploadAttachment(
|
||||||
@@ -561,7 +535,7 @@ class ComposeLogic {
|
|||||||
int index,
|
int index,
|
||||||
) async {
|
) async {
|
||||||
final attachment = state.attachments.value[index];
|
final attachment = state.attachments.value[index];
|
||||||
if (attachment.isOnCloud) {
|
if (attachment.isOnCloud && !attachment.isLink) {
|
||||||
final client = ref.watch(apiClientProvider);
|
final client = ref.watch(apiClientProvider);
|
||||||
await client.delete('/drive/files/${attachment.data.id}');
|
await client.delete('/drive/files/${attachment.data.id}');
|
||||||
}
|
}
|
||||||
@@ -587,6 +561,27 @@ class ComposeLogic {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> pickPoll(
|
||||||
|
WidgetRef ref,
|
||||||
|
ComposeState state,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
if (state.pollId.value != null) {
|
||||||
|
state.pollId.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final poll = await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
useRootNavigator: true,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (context) => const ComposePollSheet(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (poll == null) return;
|
||||||
|
state.pollId.value = poll.id;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> performAction(
|
static Future<void> performAction(
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
ComposeState state,
|
ComposeState state,
|
||||||
@@ -644,17 +639,16 @@ class ComposeLogic {
|
|||||||
if (repliedPost != null) 'replied_post_id': repliedPost.id,
|
if (repliedPost != null) 'replied_post_id': repliedPost.id,
|
||||||
if (forwardedPost != null) 'forwarded_post_id': forwardedPost.id,
|
if (forwardedPost != null) 'forwarded_post_id': forwardedPost.id,
|
||||||
'tags': state.tagsController.getTags,
|
'tags': state.tagsController.getTags,
|
||||||
'categories': state.categoriesController.getTags,
|
'categories': state.categories.value.map((e) => e.slug).toList(),
|
||||||
|
if (state.pollId.value != null) 'poll_id': state.pollId.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
await client.request(
|
await client.request(
|
||||||
endpoint,
|
endpoint,
|
||||||
|
queryParameters: {'pub': state.currentPublisher.value?.name},
|
||||||
data: payload,
|
data: payload,
|
||||||
options: Options(
|
options: Options(method: isNewPost ? 'POST' : 'PATCH'),
|
||||||
headers: {'X-Pub': state.currentPublisher.value?.name},
|
|
||||||
method: isNewPost ? 'POST' : 'PATCH',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete draft after successful submission
|
// Delete draft after successful submission
|
||||||
@@ -694,7 +688,7 @@ class ComposeLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handleKeyPress(
|
static void handleKeyPress(
|
||||||
RawKeyEvent event,
|
KeyEvent event,
|
||||||
ComposeState state,
|
ComposeState state,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
@@ -702,11 +696,13 @@ class ComposeLogic {
|
|||||||
SnPost? repliedPost,
|
SnPost? repliedPost,
|
||||||
SnPost? forwardedPost,
|
SnPost? forwardedPost,
|
||||||
}) {
|
}) {
|
||||||
if (event is! RawKeyDownEvent) return;
|
if (event is! KeyDownEvent) return;
|
||||||
|
|
||||||
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
||||||
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
||||||
final isModifierPressed = event.isMetaPressed || event.isControlPressed;
|
final isModifierPressed =
|
||||||
|
HardwareKeyboard.instance.isMetaPressed ||
|
||||||
|
HardwareKeyboard.instance.isControlPressed;
|
||||||
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
||||||
|
|
||||||
if (isPaste && isModifierPressed) {
|
if (isPaste && isModifierPressed) {
|
||||||
@@ -736,6 +732,7 @@ class ComposeLogic {
|
|||||||
state.attachmentProgress.dispose();
|
state.attachmentProgress.dispose();
|
||||||
state.currentPublisher.dispose();
|
state.currentPublisher.dispose();
|
||||||
state.tagsController.dispose();
|
state.tagsController.dispose();
|
||||||
state.categoriesController.dispose();
|
state.categories.dispose();
|
||||||
|
state.pollId.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user