Mercurial > public > simoleon
diff Simoleon/UI/ConversionTextfield.swift @ 160:0c589138a6f3
Implement Conversion Box
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 29 Aug 2021 19:04:34 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/UI/ConversionTextfield.swift Sun Aug 29 19:04:34 2021 +0100 @@ -0,0 +1,39 @@ +// +// ConversionTextfield.swift +// Simoleon +// +// Created by Dennis Concepción Martín on 29/8/21. +// + +import SwiftUI + +struct ConversionTextfield: View { + @Binding var amount: String + @Binding var isEditing: Bool + + var body: some View { + ZStack { + TextField("Enter amount", text: $amount) { startedEditing in + if startedEditing { + withAnimation { + isEditing = true + } + } + } + onCommit: { + withAnimation { + isEditing = false + } + } + .keyboardType(.decimalPad) + .font(Font.title.weight(.semibold)) + .lineLimit(1) + } + } +} + +struct ConversionTextfield_Previews: PreviewProvider { + static var previews: some View { + ConversionTextfield(amount: .constant("1000"), isEditing: .constant(false)) + } +}