Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-4194 Space profile | Supported dynamic space info opening #2855

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class HomeWidgetsCoordinatorViewModel: ObservableObject, HomeWidgetsModule

func onSpaceSelected() {
if FeatureFlags.newSettings {
pageNavigation?.open(.settings(.mainScreen(info: spaceInfo)))
pageNavigation?.open(.spaceInfo(.mainScreen(info: spaceInfo)))
} else {
showSpaceSettingsData = spaceInfo
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ struct SpaceHubCoordinatorView: View {
.anytypeSheet(item: $model.profileData) {
ProfileView(info: $0)
}
.anytypeSheet(item: $model.spaceProfileData) { _ in
ZStack {
RoundedRectangle(cornerRadius: 8).frame(height: 300).foregroundStyle(Color.System.amber25)
AnytypeText("TBD; space profile", style: .title)
}
}
.safariBookmarkObject($model.bookmarkScreenData) {
model.onOpenBookmarkAsObject($0)
}
Expand All @@ -89,7 +95,7 @@ struct SpaceHubCoordinatorView: View {
builder.appendBuilder(for: ChatCoordinatorData.self) {
ChatCoordinatorView(data: $0)
}
builder.appendBuilder(for: SettingsScreenData.self) { data in
builder.appendBuilder(for: SpaceInfoScreenData.self) { data in
switch data {
case .mainScreen(let info):
NewSpaceSettingsCoordinatorView(workspaceInfo: info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class SpaceHubCoordinatorViewModel: ObservableObject {
@Published var showSpaceManager = false
@Published var showObjectIsNotAvailableAlert = false
@Published var profileData: ObjectInfo?
@Published var spaceProfileData: AccountInfo?
@Published var userWarningAlert: UserWarningAlert?
@Published var typeSearchForObjectCreationSpaceId: StringIdentifiable?
@Published var sharingSpaceId: StringIdentifiable?
Expand Down Expand Up @@ -261,8 +262,18 @@ final class SpaceHubCoordinatorViewModel: ObservableObject {
case .bookmark(let data):
await dismissAllPresented?()
bookmarkScreenData = data
case .settings(let data):
navigationPath.push(data)
case .spaceInfo(let data):
guard let spaceView = participantSpacesStorage.participantSpaceView(spaceId: data.spaceId) else {
return
}

if spaceView.isOwner {
navigationPath.push(data)
} else {
await dismissAllPresented?()
spaceProfileData = spaceInfo
}

case nil:
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enum ScreenData: Hashable, Identifiable {
case alert(AlertScreenData)
case preview(MediaFileScreenData)
case bookmark(BookmarkScreenData)
case settings(SettingsScreenData)
case spaceInfo(SpaceInfoScreenData)

var id: Int { hashValue }
}
Expand All @@ -30,7 +30,7 @@ extension ScreenData {
return alertScreenData.objectId
case .bookmark(let data):
return data.editorScreenData.objectId
case .preview, .settings:
case .preview, .spaceInfo:
return nil
}
}
Expand All @@ -45,7 +45,7 @@ extension ScreenData {
mediaFileScreenData.spaceId
case .bookmark(let data):
data.editorScreenData.spaceId
case .settings(let data):
case .spaceInfo(let data):
data.spaceId
}
}
Expand All @@ -54,7 +54,7 @@ extension ScreenData {
switch self {
case .editor(let editorScreenData):
return editorScreenData
case .alert, .preview, .bookmark, .settings:
case .alert, .preview, .bookmark, .spaceInfo:
return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Services

enum SettingsScreenData: Hashable, Codable, Equatable, Identifiable {
enum SpaceInfoScreenData: Hashable, Codable, Equatable, Identifiable {
// Anytype widget screens
case mainScreen(info: AccountInfo)

Expand All @@ -11,7 +11,14 @@ enum SettingsScreenData: Hashable, Codable, Equatable, Identifiable {
var spaceId: String {
switch self {
case .mainScreen(let info):
return info.accountSpaceId
info.accountSpaceId
}
}

var accountInfo: AccountInfo {
switch self {
case .mainScreen(let info):
info
}
}
}