mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Remember last used trending category and country
This commit is contained in:
parent
c4674c06a4
commit
994f1f9215
@ -1,6 +1,7 @@
|
|||||||
// swiftlint:disable switch_case_on_newline
|
// swiftlint:disable switch_case_on_newline
|
||||||
|
import Defaults
|
||||||
|
|
||||||
enum Country: String, CaseIterable, Identifiable, Hashable {
|
enum Country: String, CaseIterable, Identifiable, Hashable, Defaults.Serializable {
|
||||||
var id: String {
|
var id: String {
|
||||||
rawValue
|
rawValue
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
enum TrendingCategory: String, CaseIterable, Identifiable {
|
import Defaults
|
||||||
|
|
||||||
|
enum TrendingCategory: String, CaseIterable, Identifiable, Defaults.Serializable {
|
||||||
case `default`, music, gaming, movies
|
case `default`, music, gaming, movies
|
||||||
|
|
||||||
var id: TrendingCategory.RawValue {
|
var id: TrendingCategory.RawValue {
|
||||||
|
@ -9,6 +9,9 @@ extension Defaults.Keys {
|
|||||||
static let accounts = Key<[Instance.Account]>("accounts", default: [])
|
static let accounts = Key<[Instance.Account]>("accounts", default: [])
|
||||||
static let defaultAccountID = Key<String?>("defaultAccountID")
|
static let defaultAccountID = Key<String?>("defaultAccountID")
|
||||||
|
|
||||||
|
static let trendingCategory = Key<TrendingCategory>("trendingCategory", default: .default)
|
||||||
|
static let trendingCountry = Key<Country>("trendingCountry", default: .us)
|
||||||
|
|
||||||
static let selectedPlaylistID = Key<String?>("selectedPlaylistID")
|
static let selectedPlaylistID = Key<String?>("selectedPlaylistID")
|
||||||
static let showingAddToPlaylist = Key<Bool>("showingAddToPlaylist", default: false)
|
static let showingAddToPlaylist = Key<Bool>("showingAddToPlaylist", default: false)
|
||||||
static let videoIDToAddToPlaylist = Key<String?>("videoIDToAddToPlaylist")
|
static let videoIDToAddToPlaylist = Key<String?>("videoIDToAddToPlaylist")
|
||||||
|
@ -2,7 +2,7 @@ import SwiftUI
|
|||||||
|
|
||||||
struct TrendingCountry: View {
|
struct TrendingCountry: View {
|
||||||
static let prompt = "Country Name or Code"
|
static let prompt = "Country Name or Code"
|
||||||
@Binding var selectedCountry: Country?
|
@Binding var selectedCountry: Country
|
||||||
|
|
||||||
@StateObject private var store = Store(Country.allCases)
|
@StateObject private var store = Store(Country.allCases)
|
||||||
|
|
||||||
@ -87,9 +87,7 @@ struct TrendingCountry: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func selectCountryAndDismiss(_ country: Country? = nil) {
|
func selectCountryAndDismiss(_ country: Country? = nil) {
|
||||||
let selected = country ?? selection
|
if let selected = country ?? selection {
|
||||||
|
|
||||||
if selected != nil {
|
|
||||||
selectedCountry = selected
|
selectedCountry = selected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
|
import Defaults
|
||||||
import Siesta
|
import Siesta
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct TrendingView: View {
|
struct TrendingView: View {
|
||||||
@StateObject private var store = Store<[Video]>()
|
@StateObject private var store = Store<[Video]>()
|
||||||
|
|
||||||
@State private var category: TrendingCategory = .default
|
@Default(.trendingCategory) private var category
|
||||||
@State private var country: Country! = .pl
|
@Default(.trendingCountry) private var country
|
||||||
|
|
||||||
@State private var presentingCountrySelection = false
|
@State private var presentingCountrySelection = false
|
||||||
|
|
||||||
@EnvironmentObject<InvidiousAPI> private var api
|
@EnvironmentObject<InvidiousAPI> private var api
|
||||||
|
Loading…
Reference in New Issue
Block a user