Skip to content

Commit b662adc

Browse files
authored
Merge pull request #4081 from anyproto/ios-5312-delete-toggles-5
IOS-5312 Toggles | Delete homeObjectTypeWidgets
2 parents f9553ae + 4eb568c commit b662adc

File tree

46 files changed

+67988
-70091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+67988
-70091
lines changed

Anytype/Sources/Models/AnytypeWigetId+Extensions.swift

Lines changed: 0 additions & 8 deletions
This file was deleted.

Anytype/Sources/PresentationLayer/Flows/CreateWidgetFlow/CreateWidgetCoordinatorModel.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.

Anytype/Sources/PresentationLayer/Flows/CreateWidgetFlow/CreateWidgetCoordinatorView.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

Anytype/Sources/PresentationLayer/Flows/CreateWidgetFlow/CreateWidgetCoordinatorViewModel.swift

Lines changed: 0 additions & 35 deletions
This file was deleted.

Anytype/Sources/PresentationLayer/Flows/HomeWidgetsCoordinator/HomeWidgetsCoordinatorView.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ private struct HomeWidgetsCoordinatorInternalView: View {
3333
.sheet(item: $model.showChangeTypeData) {
3434
WidgetTypeChangeView(data: $0)
3535
}
36-
.sheet(item: $model.showCreateWidgetData) {
37-
CreateWidgetCoordinatorView(data: $0) {
38-
model.onFinishCreateSource(screenData: $0)
39-
}
40-
}
4136
.anytypeSheet(item: $model.createTypeData) {
4237
CreateObjectTypeView(data: $0)
4338
}

Anytype/Sources/PresentationLayer/Flows/HomeWidgetsCoordinator/HomeWidgetsCoordinatorViewModel.swift

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ final class HomeWidgetsCoordinatorViewModel: HomeWidgetsModuleOutput, SetObjectC
1313
var pageNavigation: PageNavigation?
1414

1515
var showChangeTypeData: WidgetTypeChangeData?
16-
var showCreateWidgetData: CreateWidgetCoordinatorModel?
1716
var createTypeData: CreateObjectTypeData?
1817
var deleteSystemWidgetConfirmationData: DeleteSystemWidgetConfirmationData?
1918

@@ -24,27 +23,12 @@ final class HomeWidgetsCoordinatorViewModel: HomeWidgetsModuleOutput, SetObjectC
2423
self.spaceInfo = info
2524
}
2625

27-
func onFinishCreateSource(screenData: ScreenData?) {
28-
if let screenData {
29-
pageNavigation?.open(screenData)
30-
}
31-
}
32-
3326
// MARK: - HomeWidgetsModuleOutput
3427

3528
func onSpaceSelected() {
3629
pageNavigation?.open(.spaceInfo(.settings(spaceId: spaceInfo.accountSpaceId)))
3730
}
3831

39-
func onCreateWidgetSelected(context: AnalyticsWidgetContext) {
40-
showCreateWidgetData = CreateWidgetCoordinatorModel(
41-
spaceId: spaceInfo.accountSpaceId,
42-
widgetObjectId: spaceInfo.widgetsId,
43-
position: .end,
44-
context: context
45-
)
46-
}
47-
4832
func onCreateObjectType() {
4933
createTypeData = CreateObjectTypeData(spaceId: spaceInfo.accountSpaceId, name: "")
5034
}
@@ -65,15 +49,6 @@ final class HomeWidgetsCoordinatorViewModel: HomeWidgetsModuleOutput, SetObjectC
6549
)
6650
}
6751

68-
func onAddBelowWidget(widgetId: String, context: AnalyticsWidgetContext) {
69-
showCreateWidgetData = CreateWidgetCoordinatorModel(
70-
spaceId: spaceInfo.accountSpaceId,
71-
widgetObjectId: spaceInfo.widgetsId,
72-
position: .below(widgetId: widgetId),
73-
context: context
74-
)
75-
}
76-
7752
func onCreateObjectInSetDocument(setDocument: some SetDocumentProtocol) {
7853
setObjectCreationCoordinator.startCreateObject(
7954
setDocument: setDocument,

Anytype/Sources/PresentationLayer/Modules/HomeWidgets/Container/HomeWidgetsModuleOutput.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ import Foundation
33
@MainActor
44
protocol HomeWidgetsModuleOutput: AnyObject, CommonWidgetModuleOutput {
55
func onSpaceSelected()
6-
func onCreateWidgetSelected(context: AnalyticsWidgetContext)
76
func onCreateObjectType()
87
}

Anytype/Sources/PresentationLayer/Modules/HomeWidgets/Container/HomeWidgetsView.swift

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ private struct HomeWidgetsInternalView: View {
1717
@State private var model: HomeWidgetsViewModel
1818
@State var widgetsDndState = DragState()
1919
@State var typesDndState = DragState()
20-
@State var homeObjectTypeWidgets = FeatureFlags.homeObjectTypeWidgets
2120

2221
init(info: AccountInfo, output: (any HomeWidgetsModuleOutput)?) {
2322
self._model = State(wrappedValue: HomeWidgetsViewModel(info: info, output: output))
@@ -29,10 +28,6 @@ private struct HomeWidgetsInternalView: View {
2928

3029
content
3130
.animation(.default, value: model.widgetBlocks.count)
32-
33-
HomeBottomPanelView(homeState: $model.homeState) {
34-
model.onCreateWidgetFromEditMode()
35-
}
3631
}
3732
.task {
3833
await model.startSubscriptions()
@@ -47,7 +42,6 @@ private struct HomeWidgetsInternalView: View {
4742
}
4843
.navigationBarHidden(true)
4944
.ignoresSafeArea(.keyboard, edges: .bottom)
50-
.homeBottomPanelHidden(model.homeState.isEditWidgets)
5145
}
5246

5347
private var content: some View {
@@ -61,13 +55,9 @@ private struct HomeWidgetsInternalView: View {
6155
private var widgets: some View {
6256
ScrollView {
6357
VStack(spacing: 0) {
64-
if homeObjectTypeWidgets {
65-
topWidgets
66-
blockWidgets
67-
objectTypeWidgets
68-
} else {
69-
oldBlockWidgets
70-
}
58+
topWidgets
59+
blockWidgets
60+
objectTypeWidgets
7161
AnytypeNavigationSpacer()
7262
}
7363
.padding(.horizontal, 20)
@@ -82,28 +72,6 @@ private struct HomeWidgetsInternalView: View {
8272
}
8373
}
8474

85-
@ViewBuilder
86-
private var oldBlockWidgets: some View {
87-
VStack(spacing: 12) {
88-
WidgetSwipeTipView()
89-
ForEach(model.widgetBlocks) { widgetInfo in
90-
HomeWidgetSubmoduleView(
91-
widgetInfo: widgetInfo,
92-
widgetObject: model.widgetObject,
93-
workspaceInfo: model.info,
94-
homeState: $model.homeState,
95-
output: model.output
96-
)
97-
}
98-
editButtons
99-
}
100-
.anytypeVerticalDrop(data: model.widgetBlocks, state: $widgetsDndState) { from, to in
101-
model.widgetsDropUpdate(from: from, to: to)
102-
} dropFinish: { from, to in
103-
model.widgetsDropFinish(from: from, to: to)
104-
}
105-
}
106-
10775
@ViewBuilder
10876
private var blockWidgets: some View {
10977
if model.widgetBlocks.isNotEmpty {
@@ -153,15 +121,4 @@ private struct HomeWidgetsInternalView: View {
153121
}
154122
}
155123
}
156-
157-
private var editButtons: some View {
158-
EqualFitWidthHStack(spacing: 12) {
159-
HomeEditButton(text: Loc.Widgets.Actions.addWidget, homeState: model.homeState) {
160-
model.onCreateWidgetFromMainMode()
161-
}
162-
HomeEditButton(text: Loc.Widgets.Actions.editWidgets, homeState: model.homeState) {
163-
model.onEditButtonTap()
164-
}
165-
}
166-
}
167124
}

Anytype/Sources/PresentationLayer/Modules/HomeWidgets/Container/HomeWidgetsViewModel.swift

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ final class HomeWidgetsViewModel {
7979
AnytypeAnalytics.instance().logScreenWidget()
8080
}
8181

82-
func onEditButtonTap() {
83-
AnytypeAnalytics.instance().logEditWidget()
84-
homeState = .editWidgets
85-
}
86-
8782
func widgetsDropUpdate(from: DropDataElement<BlockWidgetInfo>, to: DropDataElement<BlockWidgetInfo>) {
8883
widgetBlocks.move(fromOffsets: IndexSet(integer: from.index), toOffset: to.index)
8984
}
@@ -118,16 +113,6 @@ final class HomeWidgetsViewModel {
118113
output?.onSpaceSelected()
119114
}
120115

121-
func onCreateWidgetFromEditMode() {
122-
AnytypeAnalytics.instance().logClickAddWidget(context: .editor)
123-
output?.onCreateWidgetSelected(context: .editor)
124-
}
125-
126-
func onCreateWidgetFromMainMode() {
127-
AnytypeAnalytics.instance().logClickAddWidget(context: .main)
128-
output?.onCreateWidgetSelected(context: .main)
129-
}
130-
131116
func onCreateObjectType() {
132117
output?.onCreateObjectType()
133118
}
@@ -158,20 +143,11 @@ final class HomeWidgetsViewModel {
158143
var newWidgetBlocks = blocks
159144
.compactMap { widgetObject.widgetInfo(block: $0) }
160145

161-
newWidgetBlocks.removeAll { $0.source == .library(.chat) }
162-
163-
if FeatureFlags.homeObjectTypeWidgets {
164-
newWidgetBlocks.removeAll { $0.source == .library(.allObjects) || $0.source == .library(.bin) }
165-
}
146+
newWidgetBlocks.removeAll { $0.source == .library(.chat) || $0.source == .library(.allObjects) || $0.source == .library(.bin) }
166147

167148
guard widgetBlocks != newWidgetBlocks else { continue }
168149

169150
widgetBlocks = newWidgetBlocks
170-
171-
// Reset panel for empty state
172-
if newWidgetBlocks.isEmpty && homeState == .editWidgets {
173-
homeState = .readwrite
174-
}
175151
}
176152
}
177153

@@ -183,7 +159,6 @@ final class HomeWidgetsViewModel {
183159
}
184160

185161
private func startObjectTypesTask() async {
186-
guard FeatureFlags.homeObjectTypeWidgets else { return }
187162
let spaceId = spaceId
188163

189164
let stream = objectTypeProvider.objectTypesPublisher(spaceId: spaceId)

Anytype/Sources/PresentationLayer/Modules/HomeWidgets/Container/Models/HomeWidgetState.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ import Foundation
33
enum HomeWidgetsState {
44
case readwrite
55
case readonly
6-
case editWidgets
76
}
87

98
extension HomeWidgetsState {
10-
var isEditWidgets: Bool {
11-
self == .editWidgets
12-
}
13-
149
var isReadWrite: Bool {
1510
self == .readwrite
1611
}
@@ -22,6 +17,6 @@ extension HomeWidgetsState {
2217

2318
extension HomeWidgetsState {
2419
var analyticsWidgetContext: AnalyticsWidgetContext {
25-
isEditWidgets ? .editor : .home
20+
.home
2621
}
2722
}

0 commit comments

Comments
 (0)