2021-12-13 12:50:04 -08:00
|
|
|
//
|
|
|
|
// SuccessView.swift
|
|
|
|
// secant-testnet
|
|
|
|
//
|
|
|
|
// Created by Adam Stener on 12/8/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import ComposableArchitecture
|
|
|
|
|
|
|
|
struct ValidationSucceededView: View {
|
|
|
|
var store: RecoveryPhraseValidationStore
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
WithViewStore(store) { viewStore in
|
|
|
|
GeometryReader { proxy in
|
|
|
|
VStack {
|
|
|
|
VStack(spacing: 20) {
|
2022-02-25 04:27:50 -08:00
|
|
|
Text("validationSuccess.title")
|
2022-03-03 05:15:06 -08:00
|
|
|
.titleText()
|
|
|
|
.multilineTextAlignment(.center)
|
2021-12-13 12:50:04 -08:00
|
|
|
|
2022-02-25 04:27:50 -08:00
|
|
|
Text("validationSuccess.description")
|
2022-03-03 05:15:06 -08:00
|
|
|
.paragraphText()
|
2021-12-13 12:50:04 -08:00
|
|
|
.multilineTextAlignment(.center)
|
2022-03-03 05:15:06 -08:00
|
|
|
.padding(.horizontal, 45)
|
2021-12-13 12:50:04 -08:00
|
|
|
}
|
2022-03-03 05:15:06 -08:00
|
|
|
.padding(.vertical, 40)
|
2021-12-13 12:50:04 -08:00
|
|
|
|
|
|
|
VStack {
|
|
|
|
CircularFrame()
|
|
|
|
.backgroundImage(
|
2022-03-03 05:15:06 -08:00
|
|
|
Asset.Assets.Backgrounds.calloutBackupSucceeded.image
|
2021-12-13 12:50:04 -08:00
|
|
|
)
|
|
|
|
.frame(
|
2022-03-03 05:15:06 -08:00
|
|
|
width: circularFrameUniformSize(width: proxy.size.width, height: proxy.size.height),
|
|
|
|
height: circularFrameUniformSize(width: proxy.size.width, height: proxy.size.height)
|
2021-12-13 12:50:04 -08:00
|
|
|
)
|
|
|
|
.badgeIcon(.shield)
|
|
|
|
}
|
2022-03-03 05:15:06 -08:00
|
|
|
.padding(.bottom, 40)
|
2021-12-13 12:50:04 -08:00
|
|
|
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
VStack(spacing: 15) {
|
|
|
|
Button(
|
|
|
|
action: {
|
|
|
|
viewStore.send(.proceedToHome, animation: .easeIn(duration: 1))
|
|
|
|
},
|
|
|
|
label: {
|
2022-02-25 04:27:50 -08:00
|
|
|
Text("validationSuccess.button.goToWallet")
|
2021-12-13 12:50:04 -08:00
|
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.activeButtonStyle
|
2022-03-03 05:15:06 -08:00
|
|
|
.validationSucceededViewLayout()
|
|
|
|
|
2021-12-13 12:50:04 -08:00
|
|
|
Button(
|
|
|
|
action: {
|
|
|
|
viewStore.send(
|
|
|
|
.displayBackedUpPhrase,
|
|
|
|
animation: .easeIn(duration: 1)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
label: {
|
2022-02-25 04:27:50 -08:00
|
|
|
Text("validationSuccess.button.phraseAgain")
|
2021-12-13 12:50:04 -08:00
|
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.secondaryButtonStyle
|
2022-03-03 05:15:06 -08:00
|
|
|
.validationSucceededViewLayout()
|
2021-12-13 12:50:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(.horizontal)
|
|
|
|
.scrollableWhenScaledUp()
|
|
|
|
}
|
|
|
|
}
|
2022-03-03 05:15:06 -08:00
|
|
|
.navigationBarHidden(true)
|
|
|
|
.applySucceededScreenBackground()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Following computations are necessary to handle properly sizing and positioning of elements
|
|
|
|
/// on different devices (apects). iPhone SE and iPhone 8 are similar aspect family devices
|
|
|
|
/// while iPhone X, 11, etc are different family devices, capable to use more of the space.
|
|
|
|
extension ValidationSucceededView {
|
|
|
|
func circularFrameUniformSize(width: CGFloat, height: CGFloat) -> CGFloat {
|
|
|
|
var deviceMultiplier = 1.0
|
|
|
|
|
|
|
|
if width > 0.0 {
|
|
|
|
let aspect = height / width
|
|
|
|
deviceMultiplier = 1.0 + (((aspect / 1.51) - 1.0) * 2.0)
|
|
|
|
}
|
|
|
|
|
|
|
|
return width * 0.48 * deviceMultiplier
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// swiftlint:disable:next private_over_fileprivate strict_fileprivate
|
|
|
|
fileprivate struct ValidationSucceededViewLayout: ViewModifier {
|
|
|
|
func body(content: Content) -> some View {
|
|
|
|
content
|
|
|
|
.frame(
|
|
|
|
minWidth: 0,
|
|
|
|
maxWidth: .infinity,
|
|
|
|
minHeight: 64,
|
|
|
|
maxHeight: .infinity,
|
|
|
|
alignment: .center
|
|
|
|
)
|
|
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
|
|
.padding(.horizontal, 28)
|
|
|
|
.transition(.opacity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension View {
|
|
|
|
func validationSucceededViewLayout() -> some View {
|
|
|
|
modifier(ValidationSucceededViewLayout())
|
2021-12-13 12:50:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ValidationSuccededView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
Group {
|
2022-03-03 05:15:06 -08:00
|
|
|
NavigationView {
|
|
|
|
ValidationSucceededView(store: .demo)
|
|
|
|
}
|
|
|
|
|
|
|
|
ValidationSucceededView(store: .demo)
|
|
|
|
.preferredColorScheme(.dark)
|
|
|
|
|
2021-12-13 12:50:04 -08:00
|
|
|
ValidationSucceededView(store: .demo)
|
2022-03-03 05:15:06 -08:00
|
|
|
.previewDevice(PreviewDevice(rawValue: "iPhone SE (2nd generation)"))
|
|
|
|
|
|
|
|
ValidationSucceededView(store: .demo)
|
|
|
|
.environment(\.sizeCategory, .accessibilityLarge)
|
|
|
|
|
2021-12-13 12:50:04 -08:00
|
|
|
ValidationSucceededView(store: .demo)
|
2022-03-03 05:15:06 -08:00
|
|
|
.environment(\.sizeCategory, .accessibilityLarge)
|
|
|
|
.previewDevice(PreviewDevice(rawValue: "iPhone SE (2nd generation)"))
|
2021-12-13 12:50:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|