Minor UI improvements, state saving

This commit is contained in:
Arkadiusz Fal
2021-06-28 17:02:13 +02:00
parent b840974f08
commit f7d0e2131c
10 changed files with 52 additions and 60 deletions

View File

@@ -2,7 +2,7 @@ import Defaults
import SwiftUI
struct ContentView: View {
@StateObject private var state = AppState()
@Default(.openChannel) var channel
@StateObject private var profile = Profile()
var body: some View {
@@ -16,9 +16,9 @@ struct ContentView: View {
.tabItem { Text("Popular") }
.tag(TabSelection.popular)
if !state.channelID.isEmpty {
ChannelView(id: state.channelID)
.tabItem { Text("\(state.channel) Channel") }
if channel != nil {
ChannelView(id: channel!.id)
.tabItem { Text("\(channel!.name) Channel") }
.tag(TabSelection.channel)
}
@@ -34,9 +34,8 @@ struct ContentView: View {
.tabItem { Image(systemName: "magnifyingglass") }
.tag(TabSelection.search)
}
.environmentObject(profile)
}
.environmentObject(state)
.environmentObject(profile)
}
var tabSelection: Binding<TabSelection> {

View File

@@ -3,4 +3,6 @@ import Defaults
extension Defaults.Keys {
static let layout = Key<ListingLayout>("listingLayout", default: .cells)
static let tabSelection = Key<TabSelection>("tabSelection", default: .subscriptions)
static let searchQuery = Key<String>("searchQuery", default: "")
static let openChannel = Key<Channel?>("openChannel")
}