Skip to content

Commit

Permalink
IOS-3165 Merge branch 'ios-3473-app-empty-space-main' into ios-3165-i…
Browse files Browse the repository at this point in the history
…ntegrate-middleware

# Conflicts:
#	Anytype.xcodeproj/project.pbxproj
#	Libraryfile
#	Modules/AnytypeCore/AnytypeCore/Generated/FeatureFlags+Flags.swift
#	Modules/AnytypeCore/AnytypeCore/Utils/FeatureFlags/FeatureDescription+Flags.swift
  • Loading branch information
mgolovko committed Oct 17, 2024
2 parents 135fca3 + 7622d3d commit b62f6e4
Show file tree
Hide file tree
Showing 35 changed files with 990 additions and 282 deletions.
8 changes: 8 additions & 0 deletions Anytype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
2AB511AE29093CB4005D0A91 /* InlineMarkdownListenerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AB511AD29093CB4005D0A91 /* InlineMarkdownListenerTests.swift */; };
2ADB57862CB6B6FE00BFC386 /* Cache in Frameworks */ = {isa = PBXBuildFile; productRef = 2ADB57852CB6B6FE00BFC386 /* Cache */; };
2ADD66782CB57036009ED95E /* MessageAttachmentsGridLayoutBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ADD66772CB57036009ED95E /* MessageAttachmentsGridLayoutBuilderTests.swift */; };
2E29780E2CB6B8170017204D /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 2AFB542128634FC5004F7458 /* Localizable.stringsdict */; };
2E8165BB2CB6B9830037D0BF /* LocalizableWidget.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2ACE06512B7CD96D009AA7B6 /* LocalizableWidget.strings */; };
2EEE411E2C1080AD000AB88B /* CachedAsyncImage in Frameworks */ = {isa = PBXBuildFile; productRef = 2EEE411D2C1080AD000AB88B /* CachedAsyncImage */; };
3D0D65942C789543001F9781 /* CustomSpaceOrderBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D0D65932C789543001F9781 /* CustomSpaceOrderBuilderTests.swift */; };
3D24B09C2C1A2DAF00795BAA /* ConfettiSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 3D24B09B2C1A2DAF00795BAA /* ConfettiSwiftUI */; };
Expand Down Expand Up @@ -242,6 +244,8 @@
2AF8755E2BCD23CC00FB1532 /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = id.lproj/LocalizableWidget.strings; sourceTree = "<group>"; };
2AF8755F2BCD23CE00FB1532 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/LocalizableWidget.strings; sourceTree = "<group>"; };
2AFB542228634FC5004F7458 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
2E29780F2CB6B8360017204D /* be */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = be; path = be.lproj/LocalizableWidget.strings; sourceTree = "<group>"; };
2E2978102CB6B8390017204D /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/LocalizableWidget.strings; sourceTree = "<group>"; };
2E9421FD2C19DFC600AD05C2 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
2E9421FE2C19DFCB00AD05C2 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2E9421FF2C19DFCF00AD05C2 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = pl; path = pl.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
Expand Down Expand Up @@ -869,6 +873,7 @@
C9D57023278C474E00F6DBB8 /* ComponentColors.xcassets in Resources */,
3D568FB5266A287400DC7881 /* SystemColors.xcassets in Resources */,
0AAC96682340C288006CE58C /* Localizable.strings in Resources */,
2E29780E2CB6B8170017204D /* Localizable.stringsdict in Resources */,
2A9BC1352BD175E8007AFCDF /* LocalizableError.xcstrings in Resources */,
03A46A40231417D6009AC10C /* InfoPlist.strings in Resources */,
0303ED0522D8EDAD005C552B /* Assets.xcassets in Resources */,
Expand All @@ -894,6 +899,7 @@
buildActionMask = 2147483647;
files = (
C960DFB328D88618002898AE /* Assets.xcassets in Resources */,
2E8165BB2CB6B9830037D0BF /* LocalizableWidget.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1098,6 +1104,8 @@
2AF8755F2BCD23CE00FB1532 /* de */,
2E9422002C19DFE300AD05C2 /* pl */,
2E9422052C19E16200AD05C2 /* zh-Hant */,
2E29780F2CB6B8360017204D /* be */,
2E2978102CB6B8390017204D /* tr */,
);
name = LocalizableWidget.strings;
sourceTree = "<group>";
Expand Down
48 changes: 48 additions & 0 deletions Anytype/Generated/Error+Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4807,6 +4807,54 @@ extension Anytype_Rpc.Object.CreateSet.Response.Error: @retroactive LocalizedErr
}
}

extension Anytype_Rpc.Object.CrossSpaceSearchSubscribe.Response.Error: @retroactive LocalizedError {
public var errorDescription: String? {
let localizeError = localizeError()
if localizeError.isNotEmpty {
return localizeError
}
return "Error: \(description_p) (\(code))"
}

private func localizeError() -> String {
switch code {
case .null:
return ""
case .unknownError:
return ""
case .badInput:
return String(localized: "Object.CrossSpaceSearchSubscribe.badInput", defaultValue: "", table: "LocalizableError")
.checkValue(key: "Object.CrossSpaceSearchSubscribe.badInput")
case .UNRECOGNIZED:
return ""
}
}
}

extension Anytype_Rpc.Object.CrossSpaceSearchUnsubscribe.Response.Error: @retroactive LocalizedError {
public var errorDescription: String? {
let localizeError = localizeError()
if localizeError.isNotEmpty {
return localizeError
}
return "Error: \(description_p) (\(code))"
}

private func localizeError() -> String {
switch code {
case .null:
return ""
case .unknownError:
return ""
case .badInput:
return String(localized: "Object.CrossSpaceSearchUnsubscribe.badInput", defaultValue: "", table: "LocalizableError")
.checkValue(key: "Object.CrossSpaceSearchUnsubscribe.badInput")
case .UNRECOGNIZED:
return ""
}
}
}

extension Anytype_Rpc.Object.Duplicate.Response.Error: @retroactive LocalizedError {
public var errorDescription: String? {
let localizeError = localizeError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ final class AppConfigurator {

private let configurators: [any AppConfiguratorProtocol] = [
EnvironmentConfiguration(),
AppVersionTrackerConfigurator(),
NonFatalAlertConfigurator(),
MiddlewareMerticsConfigurator(),
MiddlewareHandlerConfigurator(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

final class AppVersionTrackerConfigurator: AppConfiguratorProtocol {

@Injected(\.appVersionTracker)
private var appVersionTracker: any AppVersionTrackerProtocol

func configure() {
appVersionTracker.trackLaunch()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ final class GlobalServicesConfiguration: AppConfiguratorProtocol {
private var fileErrorEventHandler: any FileErrorEventHandlerProtocol
@Injected(\.deviceSceneStateListener)
private var deviceSceneStateListener: any DeviceSceneStateListenerProtocol
@Injected(\.appVersionTracker)
private var appVersionTracker: any AppVersionTrackerProtocol
@Injected(\.appVersionUpdateService)
private var appVersionUpdateService: any AppVersionUpdateServiceProtocol

Expand All @@ -22,7 +20,6 @@ final class GlobalServicesConfiguration: AppConfiguratorProtocol {
accountEventHandler.startSubscription()
fileErrorEventHandler.startSubscription()
deviceSceneStateListener.start()
appVersionTracker.trackLaunch()
appVersionUpdateService.prepareData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ import TipKit
import AnytypeCore

final class TipsConfiguration: AppConfiguratorProtocol {

@Injected(\.userWarningAlertsHandler)
private var userWarningAlertsHandler: any UserWarningAlertsHandlerProtocol

func configure() {
if #available(iOS 17.0, *) {
do {
if FeatureFlags.userWarningAlerts, userWarningAlertsHandler.getNextUserWarningAlert().isNotNil {
// Do not show tips during launch when displaying warning alert. We don't want to overwhelm users.
return
}

if FeatureFlags.resetTips {
try Tips.resetDatastore()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct AuthBackgroundView<Content>: View where Content: View {
bottomOffset: bottomOffset
)
}
.background(Color.Background.primary)
.overlay {
navigationView
}
.ignoresSafeArea(.all)
}

Expand All @@ -31,10 +35,6 @@ struct AuthBackgroundView<Content>: View where Content: View {
playerView(width: width, height: height)
Spacer.fixedHeight(bottomOffset)
}
.overlay {
navigationView

}
}

private var navigationView: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@ struct KeyPhraseMoreInfoView: View {
VStack(spacing: 20) {
DragIndicator()
ScrollView(.vertical, showsIndicators: false) {
Spacer.fixedHeight(26)

AnytypeText(Loc.Auth.JoinFlow.Key.ReadMore.title, style: .heading)
.foregroundColor(.Auth.inputText)
.multilineTextAlignment(.center)

Spacer.fixedHeight(32)

optionsRows

Spacer.fixedHeight(28)

instruction
content
}
}
.padding(.horizontal, 24)
.background(Color.Background.secondary)
}

private var content: some View {
VStack(spacing: 0) {
Spacer.fixedHeight(26)

AnytypeText(Loc.Auth.JoinFlow.Key.ReadMore.title, style: .heading)
.foregroundColor(.Auth.inputText)
.multilineTextAlignment(.center)

Spacer.fixedHeight(32)

optionsRows

Spacer.fixedHeight(28)

instruction
}
}

private var optionsRows: some View {
VStack(alignment: .leading, spacing: 16) {
optionRow(for: "🎲", description: Loc.Auth.JoinFlow.Key.ReadMore.Option1.title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ struct EditorSetCoordinatorView: View {
@StateObject private var model: EditorSetCoordinatorViewModel
@Environment(\.pageNavigation) private var pageNavigation
@Environment(\.dismiss) private var dismiss


@Environment(\.dismissAllPresented) private var dismissAllPresented

init(data: EditorSetObject, showHeader: Bool) {
self._model = StateObject(wrappedValue: EditorSetCoordinatorViewModel(data: data, showHeader: showHeader))
Expand All @@ -17,6 +16,7 @@ struct EditorSetCoordinatorView: View {
EditorSetView(data: model.data, showHeader: model.showHeader, output: model)
.onAppear {
model.pageNavigation = pageNavigation
model.dismissAllPresented = dismissAllPresented
}
.onChange(of: model.dismiss) { _ in
dismiss()
Expand Down Expand Up @@ -48,6 +48,9 @@ struct EditorSetCoordinatorView: View {
output: model
)
}
.anytypeSheet(item: $model.setObjectCreationData) {
SetObjectCreationSettingsView(data: $0, output: model)
}
.snackbar(toastBarData: $model.toastBarData)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ final class EditorSetCoordinatorViewModel:
EditorSetModuleOutput,
SetObjectCreationCoordinatorOutput,
ObjectSettingsCoordinatorOutput,
RelationValueCoordinatorOutput
RelationValueCoordinatorOutput,
SetObjectCreationSettingsOutput
{
let data: EditorSetObject
let showHeader: Bool
@Injected(\.legacySetObjectCreationCoordinator)
private var setObjectCreationCoordinator: any SetObjectCreationCoordinatorProtocol
@Injected(\.legacySetObjectCreationSettingsCoordinator)
private var setObjectCreationSettingsCoordinator: any SetObjectCreationSettingsCoordinatorProtocol
private var legacySetObjectCreationSettingsCoordinator: any SetObjectCreationSettingsCoordinatorProtocol
@Injected(\.relationValueProcessingService)
private var relationValueProcessingService: any RelationValueProcessingServiceProtocol

Expand All @@ -32,6 +33,7 @@ final class EditorSetCoordinatorViewModel:
private var navigationContext: any NavigationContextProtocol

var pageNavigation: PageNavigation?
var dismissAllPresented: DismissAllPresented?
@Published var dismiss = false

@Published var setViewPickerData: SetViewData?
Expand All @@ -42,6 +44,7 @@ final class EditorSetCoordinatorViewModel:
@Published var toastBarData: ToastBarData = .empty
@Published var objectIconPickerData: ObjectIconPickerData?
@Published var syncStatusSpaceId: StringIdentifiable?
@Published var setObjectCreationData: SetObjectCreationData?
@Published var presentSettings = false

init(data: EditorSetObject, showHeader: Bool) {
Expand Down Expand Up @@ -162,10 +165,14 @@ final class EditorSetCoordinatorViewModel:
viewId: String,
onTemplateSelection: @escaping (ObjectCreationSetting) -> ()
) {
setObjectCreationSettingsCoordinator.showSetObjectCreationSettings(
setObjectCreationData = SetObjectCreationData(
setDocument: document,
viewId: viewId,
onTemplateSelection: onTemplateSelection
onTemplateSelection: { [weak self] setting in
self?.syncDismissAllPresented {
onTemplateSelection(setting)
}
}
)
}

Expand Down Expand Up @@ -204,6 +211,29 @@ final class EditorSetCoordinatorViewModel:
func versionRestored(_ text: String) {
toastBarData = ToastBarData(text: Loc.VersionHistory.Toast.message(text), showSnackBar: true, messageType: .none)
}

// MARK: - SetObjectCreationSettingsOutput

func onObjectTypesSearchAction(setDocument: some SetDocumentProtocol, completion: @escaping (ObjectType) -> Void) {
legacySetObjectCreationSettingsCoordinator.onObjectTypesSearchAction(setDocument: setDocument, completion: completion)
}

func templateEditingHandler(
setting: ObjectCreationSetting,
onSetAsDefaultTempalte: @escaping (String) -> Void,
onTemplateSelection: ((ObjectCreationSetting) -> Void)?
) {
legacySetObjectCreationSettingsCoordinator.templateEditingHandler(setting: setting, onSetAsDefaultTempalte: onSetAsDefaultTempalte, onTemplateSelection: onTemplateSelection)
}

// MARK: - Private

func syncDismissAllPresented(completion: @escaping () -> Void) {
Task { @MainActor in
await dismissAllPresented?()
completion()
}
}
}

extension EditorSetCoordinatorViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ struct SpaceHubCoordinatorView: View {
}
.onChange(of: model.navigationPath) { _ in model.onPathChange() }

.task { await model.startHandleWorkspaceInfo() }
.task { await model.setup() }
.task { await model.startHandleAppActions() }

.handleSpaceShareTip()
.handleSharingTip()
Expand Down
Loading

0 comments on commit b62f6e4

Please sign in to comment.