Merge pull request #135 from dh-ecc/nav-add-history-link
Add link to history from `Home`
This commit is contained in:
commit
80bbdc8cda
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue