Skip to content

Commit

Permalink
Show bottom sheet to add new feeds on iOS - #91
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Jan 7, 2024
1 parent bc0db68 commit 3e0b3c5
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 169 deletions.
2 changes: 2 additions & 0 deletions i18n/src/commonMain/resources/MR/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@
<string name="add_feed_categories_title">Categories</string>
<string name="action_save">Save</string>
<string name="import_export_description">FeedFlow supports the import and export of your subscriptions with an OPML file, for better interoperability with the other feed readers</string>
<string name="no_feed_modal_title">Add a new feed</string>
<string name="no_feed_modal_message">It looks like you are not subscribed to any feeds yet. You can manually add a feed, or you can import your subscriptions from another RSS reader</string>
</resources>
26 changes: 9 additions & 17 deletions iosApp/FeedFlow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
2152FB042600AC8F00CF470E /* FeedFlowApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* FeedFlowApp.swift */; };
7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
CC14A1462B4851BD0093FF3A /* SettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC14A1452B4851BD0093FF3A /* SettingsScreen.swift */; };
CC14A1482B4856B40093FF3A /* NavigationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC14A1472B4856B40093FF3A /* NavigationExtensions.swift */; };
CC14A14A2B4ADAAB0093FF3A /* NoFeedsBottomSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC14A1492B4ADAAB0093FF3A /* NoFeedsBottomSheet.swift */; };
CC14A14C2B4B09710093FF3A /* CompatViewRoute.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC14A14B2B4B09710093FF3A /* CompatViewRoute.swift */; };
CC23293029D63038005D0E06 /* commonMain in Resources */ = {isa = PBXBuildFile; fileRef = CC23292E29D63038005D0E06 /* commonMain */; };
CC23293129D63038005D0E06 /* iosMain in Resources */ = {isa = PBXBuildFile; fileRef = CC23292F29D63038005D0E06 /* iosMain */; };
CC23293529D8300C005D0E06 /* View+.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC23293429D8300C005D0E06 /* View+.swift */; };
Expand All @@ -40,7 +41,6 @@
CC323E1229D2239300138233 /* KMPNativeCoroutinesCore in Frameworks */ = {isa = PBXBuildFile; productRef = CC323E1129D2239300138233 /* KMPNativeCoroutinesCore */; };
CC323E1629D229AC00138233 /* ObservableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC323E1529D229AC00138233 /* ObservableViewModel.swift */; };
CC323E1829D22C4200138233 /* HomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC323E1729D22C4200138233 /* HomeScreen.swift */; };
CC323E1B29D22E1500138233 /* Route.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC323E1A29D22E1500138233 /* Route.swift */; };
CC4B803B29D98BB20004A0AB /* Nuke in Frameworks */ = {isa = PBXBuildFile; productRef = CC4B803A29D98BB20004A0AB /* Nuke */; };
CC4B803D29D98BB20004A0AB /* NukeUI in Frameworks */ = {isa = PBXBuildFile; productRef = CC4B803C29D98BB20004A0AB /* NukeUI */; };
CC4B804029D9A31E0004A0AB /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = CC4B803F29D9A31E0004A0AB /* Collections */; };
Expand Down Expand Up @@ -105,7 +105,8 @@
7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
CC14A1452B4851BD0093FF3A /* SettingsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreen.swift; sourceTree = "<group>"; };
CC14A1472B4856B40093FF3A /* NavigationExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationExtensions.swift; sourceTree = "<group>"; };
CC14A1492B4ADAAB0093FF3A /* NoFeedsBottomSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoFeedsBottomSheet.swift; sourceTree = "<group>"; };
CC14A14B2B4B09710093FF3A /* CompatViewRoute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompatViewRoute.swift; sourceTree = "<group>"; };
CC23292E29D63038005D0E06 /* commonMain */ = {isa = PBXFileReference; lastKnownFileType = folder; name = commonMain; path = ../../shared/src/commonMain; sourceTree = "<group>"; };
CC23292F29D63038005D0E06 /* iosMain */ = {isa = PBXFileReference; lastKnownFileType = folder; name = iosMain; path = ../../shared/src/iosMain; sourceTree = "<group>"; };
CC23293429D8300C005D0E06 /* View+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+.swift"; sourceTree = "<group>"; };
Expand All @@ -116,7 +117,6 @@
CC2939DB2AE47B67008AF888 /* RegularView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegularView.swift; sourceTree = "<group>"; };
CC323E1529D229AC00138233 /* ObservableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObservableViewModel.swift; sourceTree = "<group>"; };
CC323E1729D22C4200138233 /* HomeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreen.swift; sourceTree = "<group>"; };
CC323E1A29D22E1500138233 /* Route.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Route.swift; sourceTree = "<group>"; };
CC4B804329DA03460004A0AB /* HomeListIndexHolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeListIndexHolder.swift; sourceTree = "<group>"; };
CC6E681E2A5B1429009F4A3C /* ShareSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareSheet.swift; sourceTree = "<group>"; };
CC6E68202A5F446A009F4A3C /* BrowserSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserSelector.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -243,7 +243,6 @@
CCA704C929D4B76F00560FA3 /* DI */,
CCA704C229D4B66100560FA3 /* App */,
CCA704BE29D4B61C00560FA3 /* UI */,
CCDF168B29D2347300222A0A /* Navigation */,
CC323E1929D22C5100138233 /* Home */,
CCA704DD29D6225B00560FA3 /* Settings */,
CC323E1529D229AC00138233 /* ObservableViewModel.swift */,
Expand All @@ -254,9 +253,11 @@
CC323E1929D22C5100138233 /* Home */ = {
isa = PBXGroup;
children = (
CCA704E329D6251D00560FA3 /* Model */,
CCA704D229D60CDF00560FA3 /* Components */,
CC323E1729D22C4200138233 /* HomeScreen.swift */,
CC4B804329DA03460004A0AB /* HomeListIndexHolder.swift */,
CC14A1492B4ADAAB0093FF3A /* NoFeedsBottomSheet.swift */,
);
path = Home;
sourceTree = "<group>";
Expand Down Expand Up @@ -333,6 +334,7 @@
isa = PBXGroup;
children = (
CCA704C629D4B69B00560FA3 /* SnackbarData.swift */,
CC14A14B2B4B09710093FF3A /* CompatViewRoute.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -382,7 +384,6 @@
CC6E68352A6C1D37009F4A3C /* About */,
CC7B9D2929D8C4F40026985C /* Feeds */,
CC7B9D2829D8C4EC0026985C /* AddFeed */,
CCA704E329D6251D00560FA3 /* Model */,
CCA704E629D626D400560FA3 /* FilePickerController.swift */,
CC6E681E2A5B1429009F4A3C /* ShareSheet.swift */,
CC6E68202A5F446A009F4A3C /* BrowserSelector.swift */,
Expand All @@ -399,15 +400,6 @@
path = Model;
sourceTree = "<group>";
};
CCDF168B29D2347300222A0A /* Navigation */ = {
isa = PBXGroup;
children = (
CC323E1A29D22E1500138233 /* Route.swift */,
CC14A1472B4856B40093FF3A /* NavigationExtensions.swift */,
);
path = Navigation;
sourceTree = "<group>";
};
D9A201890E050A39547A1B1E /* xcschemes */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -650,6 +642,7 @@
CC4B804429DA03460004A0AB /* HomeListIndexHolder.swift in Sources */,
CCA704CC29D4B88E00560FA3 /* Spacing.swift in Sources */,
CC9C5A492AA254F800323B94 /* ImportExportScreen.swift in Sources */,
CC14A14C2B4B09710093FF3A /* CompatViewRoute.swift in Sources */,
CC2939D82AE47A6A008AF888 /* SidebarDrawer.swift in Sources */,
CCA704DC29D6143400560FA3 /* FeedListView.swift in Sources */,
2152FB042600AC8F00CF470E /* FeedFlowApp.swift in Sources */,
Expand All @@ -666,10 +659,9 @@
CC14A1462B4851BD0093FF3A /* SettingsScreen.swift in Sources */,
CCA704E729D626D400560FA3 /* FilePickerController.swift in Sources */,
CCA704D829D60F4300560FA3 /* NoFeedsSourceView.swift in Sources */,
CC14A14A2B4ADAAB0093FF3A /* NoFeedsBottomSheet.swift in Sources */,
CCA704C729D4B69B00560FA3 /* SnackbarData.swift in Sources */,
CC2939DA2AE47B31008AF888 /* CompactView.swift in Sources */,
CC14A1482B4856B40093FF3A /* NavigationExtensions.swift in Sources */,
CC323E1B29D22E1500138233 /* Route.swift in Sources */,
CCA704C129D4B63300560FA3 /* Snackbar.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
11 changes: 11 additions & 0 deletions iosApp/Source/App/Model/CompatViewRoute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// CompatViewRoute.swift
// FeedFlow
//
// Created by Marco Gomiero on 07/01/24.
// Copyright © 2024. All rights reserved.
//

enum CompactViewRoute: Hashable {
case feed
}
9 changes: 0 additions & 9 deletions iosApp/Source/App/RegularView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ struct RegularView: View {
homeViewModel: homeViewModel
)
.environmentObject(indexHolder)
.navigationDestination(for: CommonRoute.self) { route in
switch route {
case .aboutScreen:
AboutScreen()

case .importExportScreen:
ImportExportScreen()
}
}
}
.navigationBarTitleDisplayMode(.inline)
}
Expand Down
6 changes: 5 additions & 1 deletion iosApp/Source/Home/Components/EmptyFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ struct EmptyFeedView: View {
.font(.body)

Button(
localizer.refresh_feeds.localized,
action: {
onReloadClick()
},
label: {
Text(localizer.refresh_feeds.localized)
.frame(maxWidth: .infinity)
}
)
.buttonStyle(.bordered)
.padding(.top, Spacing.regular)
.padding(.horizontal, Spacing.medium)
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion iosApp/Source/Home/Components/NoFeedsSourceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ struct NoFeedsSourceView: View {
.font(.body)

Button(
localizer.add_feed.localized,
action: {
onAddFeedClick()
},
label: {
Text(localizer.add_feed.localized)
.frame(maxWidth: .infinity)
}
)
.buttonStyle(.bordered)
.padding(.top, Spacing.regular)
.padding(.horizontal, Spacing.medium)
}
}
}
Expand Down
25 changes: 21 additions & 4 deletions iosApp/Source/Home/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ struct HomeContent: View {
onRefresh()
},
onAddFeedClick: {
self.sheetToShow = .settings
self.sheetToShow = .noFeedSource
},
requestNewPage: requestNewPage,
onItemClick: onItemClick
Expand Down Expand Up @@ -335,10 +335,27 @@ struct HomeContent: View {
}
.sheet(item: $sheetToShow) { item in
switch item {
case .feedList:
FeedSourceListScreen()
case .settings:
SettingsScreen()

case .noFeedSource:
NoFeedsBottomSheet(
onAddFeedClick: {
self.sheetToShow = .addFeed
},
onImportExportClick: {
self.sheetToShow = .importExport
}
)
case .addFeed:
AddFeedScreen(
showCloseButton: true
)

case .importExport:
ImportExportScreen(
showCloseButton: true
)
}
}
}
Expand Down Expand Up @@ -425,7 +442,7 @@ struct HomeContentSettings_Previews: PreviewProvider {
feedState: .constant(PreviewItemsKt.feedItemsForPreview),
showLoading: .constant(false),
unreadCount: .constant(42),
sheetToShow: .constant(HomeSheetToShow.feedList),
sheetToShow: .constant(HomeSheetToShow.noFeedSource),
toggleListScroll: .constant(false),
currentFeedFilter: .constant(FeedFilter.Timeline()),
onRefresh: { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import Foundation

enum HomeSheetToShow: Identifiable {
case feedList
case settings
case noFeedSource
case addFeed
case importExport

var id: Int {
hashValue
Expand Down
72 changes: 72 additions & 0 deletions iosApp/Source/Home/NoFeedsBottomSheet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// NoFeedsBottomSheet.swift
// FeedFlow
//
// Created by Marco Gomiero on 07/01/24.
// Copyright © 2024. All rights reserved.
//

import SwiftUI

struct NoFeedsBottomSheet: View {

@Environment(\.presentationMode)
private var presentationMode

let onAddFeedClick: () -> Void
let onImportExportClick: () -> Void

var preferredHeight: CGFloat = 400

var body: some View {
NavigationStack {
List {

Section {
Text(localizer.no_feed_modal_message.localized)
.font(.body)
.multilineTextAlignment(.leading)
}

Section {
Button {
onAddFeedClick()
} label: {
Label(
localizer.add_feed.localized,
systemImage: "plus.app"
)
}

Button {
onImportExportClick()
} label: {
Label(
localizer.import_export_opml.localized,
systemImage: "arrow.up.arrow.down"
)
}
}
}
.listStyle(.insetGrouped)
.scrollContentBackground(.hidden)
.background(Color.secondaryBackgroundColor)
.navigationTitle(localizer.no_feed_modal_title.localized)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
self.presentationMode.wrappedValue.dismiss()
} label: {
Text(localizer.action_done.localized).bold()
}
}
}
}
.presentationDetents([.height(preferredHeight), .large])
}
}

#Preview {
NoFeedsBottomSheet(onAddFeedClick: {}, onImportExportClick: {})
}
22 changes: 0 additions & 22 deletions iosApp/Source/Navigation/NavigationExtensions.swift

This file was deleted.

46 changes: 0 additions & 46 deletions iosApp/Source/Navigation/Route.swift

This file was deleted.

Loading

0 comments on commit 3e0b3c5

Please sign in to comment.