Skip to content
Closed
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
@@ -1,6 +1,6 @@
import SwiftUI

struct IncreaseTapButton<Label: View>: View {
struct ExpandedTapAreaButton<Label: View>: View {

let action: @MainActor () -> Void
let insets: EdgeInsets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct NavigationHeader<TitleView: View, RightView: View>: View {

var body: some View {
NavigationHeaderContainer(spacing: 20) {
IncreaseTapButton {
ExpandedTapAreaButton {
dismiss()
} label: {
Image(asset: .X24.back)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct PageNavigationBackButton: View {
@Environment(\.pageNavigationHiddenBackButton) private var pageNavigationHiddenBackButton

var body: some View {
IncreaseTapButton {
ExpandedTapAreaButton {
pageNavigation.pop()
} label: {
Image(asset: .X24.back)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ struct ChatCoordinatorView: View {
.anytypeSheet(isPresented: $model.showDisabledPushNotificationsAlert){
DisabledPushNotificationsAlertView()
}
.anytypeSheet(item: $model.inviteLinkData) { data in
InviteLinkCoordinatorView(data: data)
}
.sheet(item: $model.spaceShareData) { data in
SpaceShareCoordinatorView(data: data)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Foundation
import PhotosUI
import SwiftUI
import Services
import AnytypeCore

struct ChatCoordinatorData: Hashable, Codable {
let chatId: String
Expand Down Expand Up @@ -30,7 +29,6 @@ final class ChatCoordinatorViewModel: ObservableObject, ChatModuleOutput {
@Published var cameraData: SimpleCameraData?
@Published var showSpaceSettingsData: AccountInfo?
@Published var newLinkedObject: EditorScreenData?
@Published var inviteLinkData: SpaceShareData?
@Published var spaceShareData: SpaceShareData?
@Published var qrCodeInviteLink: URL?

Expand Down Expand Up @@ -100,12 +98,7 @@ final class ChatCoordinatorViewModel: ObservableObject, ChatModuleOutput {
}

func onInviteLinkSelected() {
let data = SpaceShareData(spaceId: spaceId, route: .chat)
if FeatureFlags.newSpaceMembersFlow {
spaceShareData = data
} else {
inviteLinkData = data
}
spaceShareData = SpaceShareData(spaceId: spaceId, route: .chat)
}

func onShowQrCodeSelected(url: URL) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import SwiftUI
import Services
import AnytypeCore

struct SpaceShareCoordinatorView: View {

Expand All @@ -12,23 +11,15 @@ struct SpaceShareCoordinatorView: View {
}

var body: some View {
Group {
if FeatureFlags.newSpaceMembersFlow {
NewSpaceShareView(data: model.data, output: model)
} else {
SpaceShareView(data: model.data) {
model.onMoreInfoSelected()
}
SpaceShareView(data: model.data, output: model)
.sheet(isPresented: $model.showMoreInfo) {
SpaceMoreInfoView()
}
.sheet(item: $model.shareInviteLink) { link in
ActivityView(activityItems: [link])
}
.anytypeSheet(item: $model.qrCodeInviteLink) {
QrCodeView(title: Loc.joinSpace, data: $0.absoluteString, analyticsType: .inviteSpace, route: .inviteLink)
}
}
.sheet(isPresented: $model.showMoreInfo) {
SpaceMoreInfoView()
}
.sheet(item: $model.shareInviteLink) { link in
ActivityView(activityItems: [link])
}
.anytypeSheet(item: $model.qrCodeInviteLink) {
QrCodeView(title: Loc.joinSpace, data: $0.absoluteString, analyticsType: .inviteSpace, route: .inviteLink)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI
import Services

@MainActor
final class SpaceShareCoordinatorViewModel: ObservableObject, NewInviteLinkModuleOutput {
final class SpaceShareCoordinatorViewModel: ObservableObject, InviteLinkModuleOutput {

@Published var showMoreInfo = false
@Published var shareInviteLink: URL? = nil
Expand All @@ -15,7 +15,7 @@ final class SpaceShareCoordinatorViewModel: ObservableObject, NewInviteLinkModul
self.data = data
}

// MARK: - NewInviteLinkModuleOutput
// MARK: - InviteLinkModuleOutput

func onMoreInfoSelected() {
showMoreInfo = true
Expand Down
13 changes: 10 additions & 3 deletions Anytype/Sources/PresentationLayer/Modules/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ struct ChatView: View {
.ignoresSafeArea()
}
.overlay(alignment: .top) {
ChatHeaderView(spaceId: model.spaceId, chatId: model.chatId) {
model.onTapWidgets()
}
ChatHeaderView(
spaceId: model.spaceId,
chatId: model.chatId,
onTapOpenWidgets: {
model.onTapWidgets()
},
onTapAddMembers: {
model.onTapInviteLink()
}
)
}
.onAppear {
model.keyboardDismiss = keyboardDismiss
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import Foundation
import SwiftUI
import Services

struct ChatHeaderView: View {

@StateObject private var model: ChatHeaderViewModel

init(spaceId: String, chatId: String, onTapOpenWidgets: @escaping () -> Void) {
self._model = StateObject(wrappedValue: ChatHeaderViewModel(spaceId: spaceId, chatId: chatId, onTapOpenWidgets: onTapOpenWidgets))

init(
spaceId: String,
chatId: String,
onTapOpenWidgets: @escaping () -> Void,
onTapAddMembers: @escaping (() -> Void)
) {
self._model = StateObject(wrappedValue: ChatHeaderViewModel(
spaceId: spaceId,
chatId: chatId,
onTapOpenWidgets: onTapOpenWidgets,
onTapAddMembers: onTapAddMembers
))
}

var body: some View {
PageNavigationHeader {
IncreaseTapButton {
ExpandedTapAreaButton {
model.tapOpenWidgets()
} label: {
HStack(spacing: 6) {
Expand All @@ -33,12 +44,23 @@ struct ChatHeaderView: View {
}
}
} rightView: {
if model.showWidgetsButton {
IncreaseTapButton {
model.tapOpenWidgets()
} label: {
IconView(icon: model.icon)
.frame(width: 28, height: 28)
HStack(spacing: 16) {
if model.showAddMembersButton {
ExpandedTapAreaButton {
model.tapAddMembers()
} label: {
Image(systemName: "person.fill.badge.plus")
.foregroundColor(.Control.transparentSecondary)
.frame(width: 28, height: 28)
}
}
if model.showWidgetsButton {
ExpandedTapAreaButton {
model.tapOpenWidgets()
} label: {
IconView(icon: model.icon)
.frame(width: 28, height: 28)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,41 @@ import AnytypeCore

@MainActor
final class ChatHeaderViewModel: ObservableObject {

@Injected(\.workspaceStorage)
private var workspaceStorage: any WorkspacesStorageProtocol
@Injected(\.syncStatusStorage)
private var syncStatusStorage: any SyncStatusStorageProtocol
@Injected(\.participantSpacesStorage)
private var participantSpacesStorage: any ParticipantSpacesStorageProtocol
private let openDocumentProvider: any OpenedDocumentsProviderProtocol = Container.shared.openedDocumentProvider()

@Published var title: String?
@Published var icon: Icon?
@Published var showWidgetsButton: Bool = false
@Published var chatLoading = false
@Published var spaceLoading = false
@Published var muted = false

var showLoading: Bool {
chatLoading || spaceLoading
}

@Published var showAddMembersButton: Bool = false

var showLoading: Bool { chatLoading || spaceLoading }

private let spaceId: String
private let chatId: String
private let onTapOpenWidgets: () -> Void
private let onTapAddMembers: (() -> Void)
private let chatObject: any BaseDocumentProtocol

init(spaceId: String, chatId: String, onTapOpenWidgets: @escaping () -> Void) {

init(
spaceId: String,
chatId: String,
onTapOpenWidgets: @escaping () -> Void,
onTapAddMembers: @escaping (() -> Void)
) {
self.spaceId = spaceId
self.chatId = chatId
self.onTapOpenWidgets = onTapOpenWidgets
self.onTapAddMembers = onTapAddMembers
self.chatObject = openDocumentProvider.document(objectId: chatId, spaceId: spaceId)
}

Expand All @@ -44,18 +52,20 @@ final class ChatHeaderViewModel: ObservableObject {
_ = await (spaceViewSub, chatSub, spaceStatusSub)
}

func tapOpenWidgets() {
onTapOpenWidgets()
}
func tapOpenWidgets() { onTapOpenWidgets() }

func tapAddMembers() { onTapAddMembers() }

// MARK: - Private

private func subscribeOnSpaceView() async {
for await spaceView in workspaceStorage.spaceViewPublisher(spaceId: spaceId).values {
for await participantSpaceView in participantSpacesStorage.participantSpaceViewPublisher(spaceId: spaceId).values {
let spaceView = participantSpaceView.spaceView
title = spaceView.title
icon = spaceView.objectIconImage
showWidgetsButton = spaceView.chatId == chatId && spaceView.initialScreenIsChat
muted = FeatureFlags.muteSpacePossibility && !spaceView.pushNotificationMode.isUnmutedAll
showAddMembersButton = participantSpaceView.participant?.permission == .owner
}
}

Expand Down

This file was deleted.

This file was deleted.

Loading