Skip to content

Commit

Permalink
Merge pull request #2670 from anyproto/ios-4012-support-bookmarks-widget
Browse files Browse the repository at this point in the history
iOS-4012 Widgets | support bookmarks widget
  • Loading branch information
mgolovko authored Jan 22, 2025
2 parents 5f67785 + 1bf11f1 commit 19ca9ae
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ struct EditorCoordinatorView: View {
WidgetObjectListListsView(spaceId: spaceId, output: model)
case let .media(spaceId):
WidgetObjectListMediaView(spaceId: spaceId, output: model)
case let .bookmarks(spaceId):
WidgetObjectListBookmarksView(spaceId: spaceId, output: model)
case let .page(data):
EditorPageCoordinatorView(data: data, showHeader: true, setupEditorInput: { _, _ in })
case let .list(data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ struct HomeWidgetSubmoduleView: View {
} else {
EmptyView()
}
case (.bookmarks, .compactList):
if FeatureFlags.allContentWidgets {
BookmarksCompactListWidgetSubmoduleView(data: widgetData)
} else {
EmptyView()
}
case (.bookmarks, .list):
if FeatureFlags.allContentWidgets {
BookmarksListWidgetSubmoduleView(data: widgetData)
} else {
EmptyView()
}
case _:
EmptyView()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation
import SwiftUI

struct BookmarksCompactListWidgetSubmoduleView: View {

let data: WidgetSubmoduleData

var body: some View {
AllObjectCommonListWidgetSubmoduleView(data: data, style: .compactList, type: .bookmarks)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation
import SwiftUI

struct BookmarksListWidgetSubmoduleView: View {

let data: WidgetSubmoduleData

var body: some View {
AllObjectCommonListWidgetSubmoduleView(data: data, style: .list, type: .bookmarks)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ enum AllObjectWidgetType: String {
case pages
case lists
case media
case bookmarks
}

extension AllObjectWidgetType {
Expand All @@ -15,6 +16,8 @@ extension AllObjectWidgetType {
Loc.lists
case .media:
Loc.media
case .bookmarks:
Loc.bookmarks
}
}

Expand All @@ -26,6 +29,8 @@ extension AllObjectWidgetType {
.lists(spaceId: spaceId)
case .media:
.media(spaceId: spaceId)
case .bookmarks:
.bookmarks(spaceId: spaceId)
}
}

Expand All @@ -37,6 +42,8 @@ extension AllObjectWidgetType {
.lists
case .media:
.media
case .bookmarks:
.bookmarks
}
}

Expand All @@ -48,6 +55,8 @@ extension AllObjectWidgetType {
.lists
case .media:
.media
case .bookmarks:
.bookmarks
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation
import SwiftUI

struct WidgetObjectListBookmarksView: View {

@StateObject private var model: WidgetObjectListViewModel

init(spaceId: String, output: (any WidgetObjectListCommonModuleOutput)?) {
self._model = StateObject(wrappedValue: WidgetObjectListViewModel(
spaceId: spaceId,
internalModel: WidgetObjectListAllContentViewModel(spaceId: spaceId, type: .bookmarks),
menuBuilder: WidgetObjectListMenuBuilder(),
output: output
))
}

var body: some View {
WidgetObjectListView(model: model)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension EditorScreenData {

var objectId: String? {
switch self {
case .favorites, .recentEdit, .recentOpen, .sets, .collections, .bin, .allContent, .date, .pages, .lists, .media:
case .favorites, .recentEdit, .recentOpen, .sets, .collections, .bin, .allContent, .date, .pages, .lists, .media, .bookmarks:
return nil
case .page(let object):
return object.objectId
Expand Down Expand Up @@ -77,6 +77,8 @@ extension EditorScreenData {
return spaceId
case .media(let spaceId):
return spaceId
case .bookmarks(let spaceId):
return spaceId
case .allContent(let spaceId):
return spaceId
case .page(let object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum EditorScreenData: Hashable, Codable, Equatable, Identifiable {
case pages(spaceId: String)
case lists(spaceId: String)
case media(spaceId: String)
case bookmarks(spaceId: String)
// Object
case page(EditorPageObject)
case list(EditorListObject)
Expand Down

0 comments on commit 19ca9ae

Please sign in to comment.