Change trending category button behavior

This commit is contained in:
Arkadiusz Fal
2021-06-25 00:48:28 +02:00
parent 0e02a6e25a
commit 594c77b7d4
6 changed files with 49 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ struct PlayerView: View {
.edgesIgnoringSafeArea(.all)
}
.task {
Task.init {
Task {
provider.load()
}
}

View File

@@ -8,7 +8,7 @@ struct PopularVideosView: View {
var body: some View {
VideosView(tabSelection: $tabSelection, videos: videos)
.task {
Task.init {
Task {
provider.load()
}
}

View File

@@ -9,7 +9,7 @@ struct SubscriptionsView: View {
var body: some View {
VideosView(tabSelection: $tabSelection, videos: videos)
.task {
Task.init {
Task {
provider.load()
}
}

View File

@@ -17,22 +17,9 @@ struct TrendingView: View {
HStack(alignment: .top) {
Spacer()
Button(trendingState.category.name) {
selectingCategory.toggle()
}
.fullScreenCover(isPresented: $selectingCategory) {
TrendingCategorySelectionView(selectedCategory: $trendingState.category)
}
Text(trendingState.country.flag)
.font(.system(size: 60))
Button(trendingState.country.rawValue) {
selectingCountry.toggle()
}
.fullScreenCover(isPresented: $selectingCountry) {
TrendingCountrySelectionView(selectedCountry: $trendingState.country)
}
categoryButton
countryFlag
countryButton
Spacer()
}
@@ -48,4 +35,31 @@ struct TrendingView: View {
return videosProvider.videos
}
var categoryButton: some View {
Button(trendingState.category.name) {
trendingState.category = trendingState.category.next()
}
.contextMenu {
ForEach(TrendingCategory.allCases) { category in
Button(category.name) {
trendingState.category = category
}
}
}
}
var countryFlag: some View {
Text(trendingState.country.flag)
.font(.system(size: 60))
}
var countryButton: some View {
Button(trendingState.country.rawValue) {
selectingCountry.toggle()
}
.fullScreenCover(isPresented: $selectingCountry) {
TrendingCountrySelectionView(selectedCountry: $trendingState.country)
}
}
}