Add recent documents to home on iOS

This commit is contained in:
Arkadiusz Fal
2022-11-18 23:39:52 +01:00
parent 8ec06b0d59
commit bc1571a746
8 changed files with 148 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ struct BrowsingSettings: View {
#endif
@Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts
#if os(iOS)
@Default(.homeRecentDocumentsItems) private var homeRecentDocumentsItems
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
#endif
@Default(.thumbnailsQuality) private var thumbnailsQuality
@@ -24,6 +25,9 @@ struct BrowsingSettings: View {
@EnvironmentObject<AccountsModel> private var accounts
@State private var homeHistoryItemsText = ""
#if os(iOS)
@State private var homeRecentDocumentsItemsText = ""
#endif
#if os(macOS)
@State private var presentingEditFavoritesSheet = false
#endif
@@ -87,6 +91,22 @@ struct BrowsingSettings: View {
}
.multilineTextAlignment(.trailing)
HStack {
Text("Recent documents")
TextField("Recent documents", text: $homeRecentDocumentsItemsText)
.labelsHidden()
#if !os(macOS)
.keyboardType(.numberPad)
#endif
.onAppear {
homeRecentDocumentsItemsText = String(homeRecentDocumentsItems)
}
.onChange(of: homeRecentDocumentsItemsText) { newValue in
homeRecentDocumentsItems = Int(newValue) ?? 3
}
}
.multilineTextAlignment(.trailing)
if !accounts.isEmpty {
Toggle("Show Favorites", isOn: $showFavoritesInHome)