Skip to content

Commit

Permalink
fix ios deeplink
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Oct 18, 2024
1 parent 04b21c0 commit 0878b7e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 53 deletions.
25 changes: 11 additions & 14 deletions iosApp/iosApp/UI/Component/User/CommonProfileHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SwiftUI
import MarkdownUI
import NetworkImage
import shared
import Awesome

enum CommonProfileHeaderConstants {
static let headerHeight: CGFloat = 200
Expand Down Expand Up @@ -53,15 +54,12 @@ struct CommonProfileHeader: View {
.foregroundColor(.gray)
ForEach(0..<user.mark.count, id: \.self) { index in
let mark = user.mark[index]
let icon = switch mark {
case .cat: "cat.circle"
case .verified: "checkmark.circle.fill"
case .locked: "lock.circle"
case .bot: "figure.wave.circle"
switch mark {
case .cat: Awesome.Classic.Solid.cat.image.opacity(0.6)
case .verified: Awesome.Classic.Solid.circleCheck.image.opacity(0.6)
case .locked: Awesome.Classic.Solid.lock.image.opacity(0.6)
case .bot: Awesome.Classic.Solid.robot.image.opacity(0.6)
}
Image(systemName: icon)
.font(.caption)
.opacity(0.6)
}
}
}
Expand Down Expand Up @@ -111,19 +109,18 @@ struct CommonProfileHeader: View {
ForEach(0..<list.count, id: \.self) { index in
let key = list[index]
let value = data.items[key]
let icon = switch key {
case .location: "location.circle"
case .url: "network"
case .verify: "checkmark.circle.fill"
}
Label(
title: {
Markdown(value?.markdown ?? "")
.font(.body)
.markdownInlineImageProvider(.emoji)
},
icon: {
Image(systemName: icon)
switch key {
case .location: Awesome.Classic.Solid.locationDot.image
case .url: Awesome.Classic.Solid.globe.image
case .verify: Awesome.Classic.Solid.circleCheck.image
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ object AppDeepLinkHelper {
val data = Url(url)
return when (data.host) {
"Callback" ->
when (data.pathSegments.getOrNull(1)) {
when (data.segments.getOrNull(0)) {
"SignIn" ->
when (data.pathSegments.getOrNull(2)) {
when (data.segments.getOrNull(1)) {
"Mastodon" -> AppleRoute.Callback.Mastodon
"Misskey" -> AppleRoute.Callback.Misskey
else -> null
Expand All @@ -21,125 +21,125 @@ object AppDeepLinkHelper {

"Search" -> {
val accountKey = data.parameters["accountKey"]?.let { MicroBlogKey.valueOf(it) }
val keyword = data.pathSegments.getOrNull(2) ?: return null
val keyword = data.segments.getOrNull(0) ?: return null
val accountType = accountKey?.let { AccountType.Specific(it) } ?: AccountType.Guest
AppleRoute.Search(accountType, keyword)
}

"Profile" -> {
val accountKey = data.parameters["accountKey"]?.let { MicroBlogKey.valueOf(it) }
val userKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val userKey = MicroBlogKey.valueOf(data.segments.getOrNull(0) ?: return null)
val accountType = accountKey?.let { AccountType.Specific(it) } ?: AccountType.Guest
AppleRoute.Profile(accountType, userKey)
}

"ProfileWithNameAndHost" -> {
val accountKey = data.parameters["accountKey"]?.let { MicroBlogKey.valueOf(it) }
val userName = data.pathSegments.getOrNull(2) ?: return null
val host = data.pathSegments.getOrNull(3) ?: return null
val userName = data.segments.getOrNull(0) ?: return null
val host = data.segments.getOrNull(1) ?: return null
val accountType = accountKey?.let { AccountType.Specific(it) } ?: AccountType.Guest
AppleRoute.ProfileWithNameAndHost(accountType, userName, host)
}

"StatusDetail" -> {
val accountKey = data.parameters["accountKey"]?.let { MicroBlogKey.valueOf(it) }
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(0) ?: return null)
val accountType = accountKey?.let { AccountType.Specific(it) } ?: AccountType.Guest
AppleRoute.StatusDetail(accountType, statusKey)
}

"Compose" ->
when (data.pathSegments.getOrNull(1)) {
when (data.segments.getOrNull(0)) {
"Reply" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
AppleRoute.Compose.Reply(AccountType.Specific(accountKey), statusKey)
}
"Quote" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
AppleRoute.Compose.Quote(AccountType.Specific(accountKey), statusKey)
}
"New" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
AppleRoute.Compose.New(AccountType.Specific(accountKey))
}
else -> null
}

"RawImage" -> {
val rawImage = data.pathSegments.getOrNull(1) ?: return null
val rawImage = data.segments.getOrNull(0) ?: return null
AppleRoute.RawImage(rawImage)
}

"VVO" ->
when (data.pathSegments.getOrNull(1)) {
when (data.segments.getOrNull(0)) {
"StatusDetail" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
AppleRoute.VVO.StatusDetail(AccountType.Specific(accountKey), statusKey)
}
"CommentDetail" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
AppleRoute.VVO.CommentDetail(AccountType.Specific(accountKey), statusKey)
}
"ReplyToComment" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val replyTo = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val rootId = data.pathSegments.getOrNull(4) ?: return null
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val replyTo = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
val rootId = data.segments.getOrNull(3) ?: return null
AppleRoute.VVO.ReplyToComment(AccountType.Specific(accountKey), replyTo, rootId)
}
else -> null
}

"DeleteStatus" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(0) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
AppleRoute.DeleteStatus(AccountType.Specific(accountKey), statusKey)
}

"Bluesky" ->
when (data.pathSegments.getOrNull(1)) {
when (data.segments.getOrNull(0)) {
"ReportStatus" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
AppleRoute.Bluesky.ReportStatus(AccountType.Specific(accountKey), statusKey)
}
else -> null
}

"Mastodon" ->
when (data.pathSegments.getOrNull(1)) {
when (data.segments.getOrNull(0)) {
"ReportStatus" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val userKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(4) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
val userKey = MicroBlogKey.valueOf(data.segments.getOrNull(3) ?: return null)
AppleRoute.Mastodon.ReportStatus(AccountType.Specific(accountKey), statusKey, userKey)
}
else -> null
}

"Misskey" ->
when (data.pathSegments.getOrNull(1)) {
when (data.segments.getOrNull(0)) {
"ReportStatus" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val userKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(4) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
val userKey = MicroBlogKey.valueOf(data.segments.getOrNull(3) ?: return null)
AppleRoute.Misskey.ReportStatus(AccountType.Specific(accountKey), statusKey, userKey)
}
"AddReaction" -> {
val accountKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(3) ?: return null)
val accountKey = MicroBlogKey.valueOf(data.segments.getOrNull(1) ?: return null)
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(2) ?: return null)
AppleRoute.Misskey.AddReaction(AccountType.Specific(accountKey), statusKey)
}
else -> null
}

"StatusMedia" -> {
val accountKey = data.parameters["accountKey"]?.let { MicroBlogKey.valueOf(it) }
val statusKey = MicroBlogKey.valueOf(data.pathSegments.getOrNull(2) ?: return null)
val index = data.pathSegments.getOrNull(3)?.toIntOrNull() ?: return null
val statusKey = MicroBlogKey.valueOf(data.segments.getOrNull(0) ?: return null)
val index = data.segments.getOrNull(1)?.toIntOrNull() ?: return null
val accountType = accountKey?.let { AccountType.Specific(it) } ?: AccountType.Guest
AppleRoute.StatusMedia(accountType, statusKey, index)
}
Expand Down

0 comments on commit 0878b7e

Please sign in to comment.