Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 0 additions & 8 deletions Anytype/Sources/Models/AnytypeWigetId+Extensions.swift

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ private struct HomeWidgetsCoordinatorInternalView: View {
.sheet(item: $model.showChangeTypeData) {
WidgetTypeChangeView(data: $0)
}
.sheet(item: $model.showCreateWidgetData) {
CreateWidgetCoordinatorView(data: $0) {
model.onFinishCreateSource(screenData: $0)
}
}
.anytypeSheet(item: $model.createTypeData) {
CreateObjectTypeView(data: $0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ final class HomeWidgetsCoordinatorViewModel: HomeWidgetsModuleOutput, SetObjectC
var pageNavigation: PageNavigation?

var showChangeTypeData: WidgetTypeChangeData?
var showCreateWidgetData: CreateWidgetCoordinatorModel?
var createTypeData: CreateObjectTypeData?
var deleteSystemWidgetConfirmationData: DeleteSystemWidgetConfirmationData?

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

func onFinishCreateSource(screenData: ScreenData?) {
if let screenData {
pageNavigation?.open(screenData)
}
}

// MARK: - HomeWidgetsModuleOutput

func onSpaceSelected() {
pageNavigation?.open(.spaceInfo(.settings(spaceId: spaceInfo.accountSpaceId)))
}

func onCreateWidgetSelected(context: AnalyticsWidgetContext) {
showCreateWidgetData = CreateWidgetCoordinatorModel(
spaceId: spaceInfo.accountSpaceId,
widgetObjectId: spaceInfo.widgetsId,
position: .end,
context: context
)
}

func onCreateObjectType() {
createTypeData = CreateObjectTypeData(spaceId: spaceInfo.accountSpaceId, name: "")
}
Expand All @@ -65,15 +49,6 @@ final class HomeWidgetsCoordinatorViewModel: HomeWidgetsModuleOutput, SetObjectC
)
}

func onAddBelowWidget(widgetId: String, context: AnalyticsWidgetContext) {
showCreateWidgetData = CreateWidgetCoordinatorModel(
spaceId: spaceInfo.accountSpaceId,
widgetObjectId: spaceInfo.widgetsId,
position: .below(widgetId: widgetId),
context: context
)
}

func onCreateObjectInSetDocument(setDocument: some SetDocumentProtocol) {
setObjectCreationCoordinator.startCreateObject(
setDocument: setDocument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ import Foundation
@MainActor
protocol HomeWidgetsModuleOutput: AnyObject, CommonWidgetModuleOutput {
func onSpaceSelected()
func onCreateWidgetSelected(context: AnalyticsWidgetContext)
func onCreateObjectType()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ private struct HomeWidgetsInternalView: View {
@State private var model: HomeWidgetsViewModel
@State var widgetsDndState = DragState()
@State var typesDndState = DragState()
@State var homeObjectTypeWidgets = FeatureFlags.homeObjectTypeWidgets

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

content
.animation(.default, value: model.widgetBlocks.count)

HomeBottomPanelView(homeState: $model.homeState) {
model.onCreateWidgetFromEditMode()
}
}
.task {
await model.startSubscriptions()
Expand All @@ -47,7 +42,6 @@ private struct HomeWidgetsInternalView: View {
}
.navigationBarHidden(true)
.ignoresSafeArea(.keyboard, edges: .bottom)
.homeBottomPanelHidden(model.homeState.isEditWidgets)
}

private var content: some View {
Expand All @@ -61,13 +55,9 @@ private struct HomeWidgetsInternalView: View {
private var widgets: some View {
ScrollView {
VStack(spacing: 0) {
if homeObjectTypeWidgets {
topWidgets
blockWidgets
objectTypeWidgets
} else {
oldBlockWidgets
}
topWidgets
blockWidgets
objectTypeWidgets
AnytypeNavigationSpacer()
}
.padding(.horizontal, 20)
Expand All @@ -82,28 +72,6 @@ private struct HomeWidgetsInternalView: View {
}
}

@ViewBuilder
private var oldBlockWidgets: some View {
VStack(spacing: 12) {
WidgetSwipeTipView()
ForEach(model.widgetBlocks) { widgetInfo in
HomeWidgetSubmoduleView(
widgetInfo: widgetInfo,
widgetObject: model.widgetObject,
workspaceInfo: model.info,
homeState: $model.homeState,
output: model.output
)
}
editButtons
}
.anytypeVerticalDrop(data: model.widgetBlocks, state: $widgetsDndState) { from, to in
model.widgetsDropUpdate(from: from, to: to)
} dropFinish: { from, to in
model.widgetsDropFinish(from: from, to: to)
}
}

@ViewBuilder
private var blockWidgets: some View {
if model.widgetBlocks.isNotEmpty {
Expand Down Expand Up @@ -153,15 +121,4 @@ private struct HomeWidgetsInternalView: View {
}
}
}

private var editButtons: some View {
EqualFitWidthHStack(spacing: 12) {
HomeEditButton(text: Loc.Widgets.Actions.addWidget, homeState: model.homeState) {
model.onCreateWidgetFromMainMode()
}
HomeEditButton(text: Loc.Widgets.Actions.editWidgets, homeState: model.homeState) {
model.onEditButtonTap()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ final class HomeWidgetsViewModel {
AnytypeAnalytics.instance().logScreenWidget()
}

func onEditButtonTap() {
AnytypeAnalytics.instance().logEditWidget()
homeState = .editWidgets
}

func widgetsDropUpdate(from: DropDataElement<BlockWidgetInfo>, to: DropDataElement<BlockWidgetInfo>) {
widgetBlocks.move(fromOffsets: IndexSet(integer: from.index), toOffset: to.index)
}
Expand Down Expand Up @@ -118,16 +113,6 @@ final class HomeWidgetsViewModel {
output?.onSpaceSelected()
}

func onCreateWidgetFromEditMode() {
AnytypeAnalytics.instance().logClickAddWidget(context: .editor)
output?.onCreateWidgetSelected(context: .editor)
}

func onCreateWidgetFromMainMode() {
AnytypeAnalytics.instance().logClickAddWidget(context: .main)
output?.onCreateWidgetSelected(context: .main)
}

func onCreateObjectType() {
output?.onCreateObjectType()
}
Expand Down Expand Up @@ -158,20 +143,11 @@ final class HomeWidgetsViewModel {
var newWidgetBlocks = blocks
.compactMap { widgetObject.widgetInfo(block: $0) }

newWidgetBlocks.removeAll { $0.source == .library(.chat) }

if FeatureFlags.homeObjectTypeWidgets {
newWidgetBlocks.removeAll { $0.source == .library(.allObjects) || $0.source == .library(.bin) }
}
newWidgetBlocks.removeAll { $0.source == .library(.chat) || $0.source == .library(.allObjects) || $0.source == .library(.bin) }

guard widgetBlocks != newWidgetBlocks else { continue }

widgetBlocks = newWidgetBlocks

// Reset panel for empty state
if newWidgetBlocks.isEmpty && homeState == .editWidgets {
homeState = .readwrite
}
}
}

Expand All @@ -183,7 +159,6 @@ final class HomeWidgetsViewModel {
}

private func startObjectTypesTask() async {
guard FeatureFlags.homeObjectTypeWidgets else { return }
let spaceId = spaceId

let stream = objectTypeProvider.objectTypesPublisher(spaceId: spaceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import Foundation
enum HomeWidgetsState {
case readwrite
case readonly
case editWidgets
}

extension HomeWidgetsState {
var isEditWidgets: Bool {
self == .editWidgets
}

var isReadWrite: Bool {
self == .readwrite
}
Expand All @@ -22,6 +17,6 @@ extension HomeWidgetsState {

extension HomeWidgetsState {
var analyticsWidgetContext: AnalyticsWidgetContext {
isEditWidgets ? .editor : .home
.home
}
}

This file was deleted.

Loading
Loading