2021-11-10 12:09:17 -08:00
|
|
|
import SwiftUI
|
|
|
|
import ComposableArchitecture
|
|
|
|
|
|
|
|
struct HomeView: View {
|
|
|
|
let store: Store<HomeState, HomeAction>
|
|
|
|
|
2021-12-13 17:11:01 -08:00
|
|
|
var body: some View {
|
|
|
|
WithViewStore(store) { viewStore in
|
2022-04-20 07:45:24 -07:00
|
|
|
GeometryReader { proxy in
|
|
|
|
ZStack {
|
2022-04-20 09:41:32 -07:00
|
|
|
scanButton(viewStore)
|
|
|
|
|
|
|
|
profileButton(viewStore)
|
|
|
|
|
|
|
|
sendButton(viewStore)
|
|
|
|
|
|
|
|
requestButton(viewStore)
|
|
|
|
.padding(.top, 140)
|
|
|
|
|
2022-04-20 07:45:24 -07:00
|
|
|
VStack {
|
2022-04-20 09:41:32 -07:00
|
|
|
Text("balance: \(viewStore.totalBalance)")
|
2022-04-20 07:45:24 -07:00
|
|
|
.accessDebugMenuWithHiddenGesture {
|
|
|
|
viewStore.send(.debugMenuStartup)
|
|
|
|
}
|
2022-04-20 09:41:32 -07:00
|
|
|
.padding(.top, 180)
|
2022-04-20 07:45:24 -07:00
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawer(overlay: viewStore.bindingForDrawer(), maxHeight: proxy.size.height) {
|
|
|
|
VStack {
|
|
|
|
TransactionHistoryView(store: store.historyStore())
|
|
|
|
.padding(.top, 10)
|
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
.applyScreenBackground()
|
2022-04-13 06:52:31 -07:00
|
|
|
}
|
2022-04-20 07:45:24 -07:00
|
|
|
}
|
|
|
|
.applyScreenBackground()
|
2022-04-20 09:41:32 -07:00
|
|
|
.navigationBarHidden(true)
|
|
|
|
.applyScreenBackground()
|
|
|
|
.onAppear(perform: { viewStore.send(.preparePublishers) })
|
2021-11-10 12:09:17 -08:00
|
|
|
}
|
2022-04-20 09:41:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Buttons
|
|
|
|
|
|
|
|
extension HomeView {
|
|
|
|
func profileButton(_ viewStore: HomeViewStore) -> some View {
|
|
|
|
VStack {
|
|
|
|
HStack {
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
Image(Asset.Assets.Icons.profile.name)
|
|
|
|
.resizable()
|
|
|
|
.frame(width: 60, height: 60)
|
|
|
|
.padding(.trailing, 15)
|
|
|
|
.navigationLink(
|
|
|
|
isActive: viewStore.bindingForRoute(.profile),
|
|
|
|
destination: {
|
|
|
|
ProfileView(store: store.profileStore())
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func requestButton(_ viewStore: HomeViewStore) -> some View {
|
|
|
|
VStack {
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
Text("home.request")
|
|
|
|
.shadow(color: Asset.Colors.Buttons.buttonsTitleShadow.color, radius: 2, x: 0, y: 2)
|
|
|
|
.frame(
|
|
|
|
minWidth: 0,
|
|
|
|
maxWidth: .infinity,
|
|
|
|
minHeight: 0,
|
|
|
|
maxHeight: .infinity
|
|
|
|
)
|
|
|
|
.foregroundColor(Asset.Colors.Text.secondaryButtonText.color)
|
|
|
|
.background(Asset.Colors.Buttons.secondaryButton.color)
|
|
|
|
.cornerRadius(12)
|
|
|
|
.frame(height: 60)
|
|
|
|
.padding(.horizontal, 50)
|
|
|
|
.neumorphicButton()
|
|
|
|
.navigationLink(
|
|
|
|
isActive: viewStore.bindingForRoute(.request),
|
|
|
|
destination: {
|
|
|
|
RequestView(store: store.requestStore())
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func sendButton(_ viewStore: HomeViewStore) -> some View {
|
|
|
|
VStack {
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
Text("Send")
|
|
|
|
.shadow(color: Asset.Colors.Buttons.buttonsTitleShadow.color, radius: 2, x: 0, y: 2)
|
|
|
|
.frame(
|
|
|
|
minWidth: 0,
|
|
|
|
maxWidth: .infinity,
|
|
|
|
minHeight: 0,
|
|
|
|
maxHeight: .infinity
|
|
|
|
)
|
|
|
|
.foregroundColor(Asset.Colors.Text.activeButtonText.color)
|
|
|
|
.background(Asset.Colors.Buttons.activeButton.color)
|
|
|
|
.cornerRadius(12)
|
|
|
|
.frame(height: 60)
|
|
|
|
.padding(.horizontal, 50)
|
|
|
|
.neumorphicButton()
|
|
|
|
.navigationLink(
|
|
|
|
isActive: viewStore.bindingForRoute(.send),
|
|
|
|
destination: {
|
|
|
|
SendView(store: store.sendStore())
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func scanButton(_ viewStore: HomeViewStore) -> some View {
|
|
|
|
VStack {
|
|
|
|
HStack {
|
|
|
|
Image(Asset.Assets.Icons.qrCode.name)
|
|
|
|
.resizable()
|
|
|
|
.frame(width: 40, height: 40)
|
|
|
|
.padding(.top, 7)
|
|
|
|
.padding(.leading, 22)
|
|
|
|
.navigationLink(
|
|
|
|
isActive: viewStore.bindingForRoute(.scan),
|
|
|
|
destination: {
|
|
|
|
ScanView(store: store.scanStore())
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
|
|
|
|
Spacer()
|
2021-11-10 12:09:17 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-13 17:11:01 -08:00
|
|
|
// MARK: - Previews
|
|
|
|
|
2021-11-10 12:09:17 -08:00
|
|
|
extension HomeStore {
|
2021-12-13 17:17:15 -08:00
|
|
|
static var placeholder: HomeStore {
|
2021-11-10 12:09:17 -08:00
|
|
|
HomeStore(
|
2022-04-14 02:25:05 -07:00
|
|
|
initialState: .placeholder,
|
2021-11-10 12:09:17 -08:00
|
|
|
reducer: .default.debug(),
|
2022-04-13 06:52:31 -07:00
|
|
|
environment: HomeEnvironment(
|
|
|
|
combineSynchronizer: LiveCombineSynchronizer()
|
|
|
|
)
|
2021-11-10 12:09:17 -08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2021-10-26 16:14:03 -07:00
|
|
|
|
2021-11-10 12:09:17 -08:00
|
|
|
struct HomeView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
NavigationView {
|
2021-12-13 17:17:15 -08:00
|
|
|
HomeView(store: .placeholder)
|
2021-11-10 12:09:17 -08:00
|
|
|
}
|
2022-04-20 09:41:32 -07:00
|
|
|
|
|
|
|
NavigationView {
|
|
|
|
HomeView(store: .placeholder)
|
|
|
|
.preferredColorScheme(.dark)
|
|
|
|
}
|
2021-11-10 12:09:17 -08:00
|
|
|
}
|
|
|
|
}
|