From 1063e9e12b4cba5467276ed5cc0f857f6bf68c1b Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Thu, 5 May 2022 14:32:30 -0700 Subject: [PATCH] support grid style cards on iphone --- .../App/Views/Home/HomeFeedViewIOS.swift | 69 ++++++++++--------- .../Sources/App/Views/Home/HomeView.swift | 13 ---- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 05c8e64bc..dffa4dd11 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -8,7 +8,7 @@ import Views #if os(iOS) struct HomeFeedContainerView: View { @EnvironmentObject var dataService: DataService - @AppStorage(UserDefaultKey.homeFeedlayoutPreference.rawValue) var prefersListLayout = UIDevice.isIPhone + @AppStorage(UserDefaultKey.homeFeedlayoutPreference.rawValue) var prefersListLayout = false @ObservedObject var viewModel: HomeFeedViewModel func loadItems(isRefresh: Bool) { @@ -49,6 +49,40 @@ import Views .sheet(item: $viewModel.itemUnderLabelEdit) { item in ApplyLabelsView(mode: .item(item), onSave: nil) } + .toolbar { + ToolbarItem(placement: .barTrailing) { + Button("", action: {}) + .disabled(true) + .overlay { + if viewModel.isLoading, !prefersListLayout { + ProgressView() + } + } + } + ToolbarItem(placement: UIDevice.isIPhone ? .barLeading : .barTrailing) { + Button( + action: { prefersListLayout.toggle() }, + label: { + Label("Toggle Feed Layout", systemImage: prefersListLayout ? "square.grid.2x2" : "list.bullet") + } + ) + } + ToolbarItem(placement: .barTrailing) { + if UIDevice.isIPhone { + NavigationLink( + destination: { ProfileView() }, + label: { + Image.profile + .resizable() + .frame(width: 26, height: 26) + .padding(.vertical) + } + ) + } else { + EmptyView() + } + } + } } .navigationTitle("Home") .navigationBarTitleDisplayMode(.inline) @@ -119,27 +153,6 @@ import Views HomeFeedListView(prefersListLayout: $prefersListLayout, viewModel: viewModel) } else { HomeFeedGridView(viewModel: viewModel) - .toolbar { - ToolbarItem { - Button("", action: {}) - .disabled(true) - .overlay { - if viewModel.isLoading { - ProgressView() - } - } - } - ToolbarItem { - if UIDevice.isIPad { - Button( - action: { prefersListLayout.toggle() }, - label: { - Label("Toggle Feed Layout", systemImage: prefersListLayout ? "square.grid.2x2" : "list.bullet") - } - ) - } - } - } } } } @@ -256,18 +269,6 @@ import Views } } .listStyle(PlainListStyle()) - .toolbar { - ToolbarItem { - if UIDevice.isIPad { - Button( - action: { prefersListLayout.toggle() }, - label: { - Label("Toggle Feed Layout", systemImage: prefersListLayout ? "square.grid.2x2" : "list.bullet") - } - ) - } - } - } } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift index 5c016d814..dcd22386a 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift @@ -8,19 +8,6 @@ struct HomeView: View { if UIDevice.isIPhone { NavigationView { HomeFeedContainerView(viewModel: viewModel) - .toolbar { - ToolbarItem { - NavigationLink( - destination: { ProfileView() }, - label: { - Image.profile - .resizable() - .frame(width: 26, height: 26) - .padding() - } - ) - } - } } .accentColor(.appGrayTextContrast) } else {