-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iosApp): support filters in agenda screen.
- Loading branch information
1 parent
f62d030
commit 5ea1dc6
Showing
12 changed files
with
237 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+21.7 KB
(100%)
...codeproj/project.xcworkspace/xcuserdata/GERARD.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// AgendaFiltersNavigation.swift | ||
// iosApp | ||
// | ||
// Created by GERARD on 08/01/2024. | ||
// Copyright © 2024 orgName. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AgendaFiltersNavigation: View { | ||
@EnvironmentObject var viewModelFactory: ViewModelFactory | ||
|
||
var body: some View { | ||
NavigationLink { | ||
AgendaFiltersVM( | ||
viewModel: viewModelFactory.makeAgendaFiltersViewModel() | ||
) | ||
} label: { | ||
Image(systemName: "line.3.horizontal.decrease.circle") | ||
.accessibilityLabel("actionFilteringFavorites") | ||
} | ||
.buttonStyle(.plain) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// AgendaFilters.swift | ||
// iosApp | ||
// | ||
// Created by GERARD on 08/01/2024. | ||
// Copyright © 2024 orgName. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import SharedDi | ||
|
||
struct AgendaFilters: View { | ||
let filtersUi: FiltersUi | ||
var onFavoriteSelected: (Bool) -> () | ||
var onCategorySelected: (CategoryUi, Bool) -> () | ||
var onFormatSelected: (FormatUi, Bool) -> () | ||
|
||
var body: some View { | ||
List { | ||
Section(header: Text("titleFiltersFavorites")) { | ||
Toggle(isOn: Binding.constant(filtersUi.onlyFavorites), label: { | ||
Text("actionFilteringFavorites") | ||
}) | ||
.onTapGesture { | ||
onFavoriteSelected(!filtersUi.onlyFavorites) | ||
} | ||
} | ||
Section(header: Text("titleFiltersCategories")) { | ||
ForEach(Array(filtersUi.categories.keys), id: \.self) { key in | ||
let isOn = filtersUi.categories[key] ?? false | ||
Toggle(isOn: Binding.constant(isOn as! Bool), label: { | ||
Text(key.name) | ||
}) | ||
.onTapGesture { | ||
onCategorySelected(key, !(isOn as! Bool)) | ||
} | ||
} | ||
} | ||
Section(header: Text("titleFiltersFormats")) { | ||
ForEach(Array(filtersUi.formats.keys), id: \.self) { key in | ||
let isOn = filtersUi.formats[key] ?? false | ||
Toggle(isOn: Binding.constant(isOn as! Bool), label: { | ||
Text(key.name) | ||
}) | ||
.onTapGesture { | ||
onFormatSelected(key, !(isOn as! Bool)) | ||
} | ||
} | ||
} | ||
} | ||
.navigationTitle(Text("screenFilters")) | ||
.navigationBarTitleDisplayMode(.inline) | ||
} | ||
} | ||
|
||
#Preview { | ||
AgendaFilters( | ||
filtersUi: FiltersUi.companion.fake, | ||
onFavoriteSelected: { selected in }, | ||
onCategorySelected: { category, selected in }, | ||
onFormatSelected: { format, selected in } | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// AgendaFiltersVM.swift | ||
// iosApp | ||
// | ||
// Created by GERARD on 08/01/2024. | ||
// Copyright © 2024 orgName. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import SharedDi | ||
|
||
struct AgendaFiltersVM: View { | ||
@ObservedObject var viewModel: AgendaFiltersViewModel | ||
|
||
init(viewModel: AgendaFiltersViewModel) { | ||
self.viewModel = viewModel | ||
} | ||
|
||
var body: some View { | ||
let uiState = viewModel.uiState | ||
NavigationView { | ||
Group { | ||
switch uiState { | ||
case .success(let filtersUi): | ||
AgendaFilters( | ||
filtersUi: filtersUi, | ||
onFavoriteSelected: { selected in | ||
Task { | ||
await viewModel.applyFavoriteFilter(selected: selected) | ||
} | ||
}, | ||
onCategorySelected: { category, selected in | ||
Task { | ||
await viewModel.applyCategoryFilter(categoryUi: category, selected: selected) | ||
} | ||
}, | ||
onFormatSelected: { format, selected in | ||
Task { | ||
await viewModel.applyFormatFilter(formatUi: format, selected: selected) | ||
} | ||
} | ||
) | ||
case .failure: | ||
Text("textError") | ||
case .loading: | ||
Text("textLoading") | ||
} | ||
} | ||
} | ||
.onAppear { | ||
viewModel.fetchFilters() | ||
} | ||
.onDisappear { | ||
viewModel.stop() | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.