Merge pull request #135 from dh-ecc/nav-add-history-link

Add link to history from `Home`
This commit is contained in:
Francisco Gindre 2021-12-15 11:30:48 -03:00 committed by GitHub
commit 80bbdc8cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 54 deletions

View File

@ -78,17 +78,6 @@ extension HomeStore {
typealias HomeViewStore = ViewStore<HomeState, HomeAction>
extension HomeViewStore {
func historyToggleString() -> String {
let hideShowString = isHistoryActive ? "HIDE" : "SHOW"
let selectedString = selectedTranactionID.map { "selected id: \($0)" } ?? "NONE selected"
let parts = [hideShowString, "History", selectedString]
return parts.joined(separator: " ")
}
func toggleShowingHistory() {
send(.updateRoute(isHistoryActive ? nil : .history))
}
func toggleSelectedTransaction() {
let isAlreadySelected = (self.selectedTranactionID != nil)
let transcation = self.transactionHistoryState.transactions[5]
@ -96,10 +85,6 @@ extension HomeViewStore {
send(.transactionHistory(.setRoute(newRoute)))
}
var isHistoryActive: Bool {
self.route == .history
}
var selectedTranactionID: Int? {
self.transactionHistoryState
.route
@ -115,42 +100,6 @@ extension HomeViewStore {
}
)
}
var showHistoryBinding: Binding<Bool> {
self.binding(
get: { $0.route == .history },
send: { isActive in
return .updateRoute(isActive ? .history : nil)
}
)
}
var showPhraseDisplayBinding: Binding<Bool> {
self.binding(
get: { $0.route == .recoveryPhraseDisplay },
send: { isActive in
return .updateRoute(isActive ? .send : nil)
}
)
}
var showSendBinding: Binding<Bool> {
self.binding(
get: { $0.route == .send },
send: { isActive in
return .updateRoute(isActive ? .send : nil)
}
)
}
var showProfileBinding: Binding<Bool> {
self.binding(
get: { $0.route == .profile },
send: { isActive in
return .updateRoute(isActive ? .profile : nil)
}
)
}
}
// MARK: PlaceHolders

View File

@ -55,6 +55,15 @@ struct HomeView: View {
}
}
Section(header: Text("Modal Routes")) {
ForEach(modalRoutes) { routeValue in
Button(
action: { viewStore.send(.updateRoute(routeValue.route)) },
label: { Text("\(String(describing: routeValue.route))") }
)
}
}
Section(header: Text("Other Actions")) {
Button(
action: { viewStore.toggleSelectedTransaction() },
@ -69,7 +78,7 @@ struct HomeView: View {
}
}
.fullScreenCover(
isPresented: viewStore.showHistoryBinding,
isPresented: viewStore.bindingForRoute(.history),
content: {
NavigationView {
TransactionHistoryView(store: store.historyStore())
@ -107,8 +116,6 @@ extension HomeStore {
}
}
// MARK: - Previews
struct HomeView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {