2022-03-01 00:12:50 -08:00
|
|
|
//
|
|
|
|
// ImportSeedEditor.swift
|
|
|
|
// secant-testnet
|
|
|
|
//
|
|
|
|
// Created by Lukáš Korba on 02/25/2022.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import ComposableArchitecture
|
|
|
|
|
|
|
|
struct ImportSeedEditor: View {
|
|
|
|
var store: ImportWalletStore
|
|
|
|
|
|
|
|
/// Clearance of the black color for the TextEditor under the text (.dark colorScheme)
|
|
|
|
init(store: ImportWalletStore) {
|
|
|
|
self.store = store
|
|
|
|
UITextView.appearance().backgroundColor = .clear
|
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
WithViewStore(store) { viewStore in
|
|
|
|
TextEditor(text: viewStore.binding(\.$importedSeedPhrase))
|
2022-05-11 08:26:39 -07:00
|
|
|
.autocapitalization(.none)
|
2022-03-01 00:12:50 -08:00
|
|
|
.importSeedEditorModifier()
|
2022-05-26 05:47:55 -07:00
|
|
|
.padding(.horizontal, 28)
|
|
|
|
.padding(.vertical, 10)
|
2022-03-01 00:12:50 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ImportSeedEditorModifier: ViewModifier {
|
2022-05-11 08:26:39 -07:00
|
|
|
var backgroundColor = Color.white
|
|
|
|
|
2022-03-01 00:12:50 -08:00
|
|
|
func body(content: Content) -> some View {
|
|
|
|
content
|
|
|
|
.foregroundColor(Asset.Colors.Text.importSeedEditor.color)
|
|
|
|
.padding()
|
2022-05-11 08:26:39 -07:00
|
|
|
.background(backgroundColor)
|
2022-03-01 00:12:50 -08:00
|
|
|
.cornerRadius(4)
|
|
|
|
.overlay(
|
|
|
|
RoundedRectangle(cornerRadius: 4)
|
|
|
|
.stroke(Color.black, lineWidth: 2)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension View {
|
2022-05-11 08:26:39 -07:00
|
|
|
func importSeedEditorModifier(_ backgroundColor: Color = .white) -> some View {
|
|
|
|
modifier(ImportSeedEditorModifier(backgroundColor: backgroundColor))
|
2022-03-01 00:12:50 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ImportSeedInputField_Previews: PreviewProvider {
|
|
|
|
static let width: CGFloat = 400
|
|
|
|
static let height: CGFloat = 200
|
|
|
|
|
|
|
|
static var previews: some View {
|
|
|
|
Group {
|
|
|
|
ImportSeedEditor(store: .demo)
|
|
|
|
.frame(width: width, height: height)
|
|
|
|
.applyScreenBackground()
|
|
|
|
.preferredColorScheme(.light)
|
|
|
|
|
|
|
|
ImportSeedEditor(store: .demo)
|
|
|
|
.frame(width: width, height: height)
|
|
|
|
.applyScreenBackground()
|
|
|
|
.preferredColorScheme(.dark)
|
|
|
|
}
|
|
|
|
.previewLayout(.fixed(width: width + 50, height: height + 50))
|
|
|
|
}
|
|
|
|
}
|