diff --git a/PuraceDemo/PuraceDemo.xcodeproj/project.pbxproj b/PuraceDemo/PuraceDemo.xcodeproj/project.pbxproj index ae361f4..810a8e9 100644 --- a/PuraceDemo/PuraceDemo.xcodeproj/project.pbxproj +++ b/PuraceDemo/PuraceDemo.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ 2FA986792837351B000DB409 /* GridExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA986782837351B000DB409 /* GridExample.swift */; }; 2FA9867B28373DD3000DB409 /* SnackbarExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA9867A28373DD3000DB409 /* SnackbarExample.swift */; }; 2FC004092831AC250037EF10 /* StoryExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FC004082831AC250037EF10 /* StoryExample.swift */; }; + 2FD5447A28720B810098468D /* TextFieldExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FD5447928720B810098468D /* TextFieldExample.swift */; }; 2FEB27C42839C6B20092B7D3 /* Purace in Resources */ = {isa = PBXBuildFile; fileRef = 2FEB27C32839C6B20092B7D3 /* Purace */; }; 2FEB27C62839C6BB0092B7D3 /* Purace in Frameworks */ = {isa = PBXBuildFile; productRef = 2FEB27C52839C6BB0092B7D3 /* Purace */; }; /* End PBXBuildFile section */ @@ -50,6 +51,7 @@ 2FA986782837351B000DB409 /* GridExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridExample.swift; sourceTree = ""; }; 2FA9867A28373DD3000DB409 /* SnackbarExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnackbarExample.swift; sourceTree = ""; }; 2FC004082831AC250037EF10 /* StoryExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryExample.swift; sourceTree = ""; }; + 2FD5447928720B810098468D /* TextFieldExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldExample.swift; sourceTree = ""; }; 2FEB27C32839C6B20092B7D3 /* Purace */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Purace; path = ..; sourceTree = ""; }; /* End PBXFileReference section */ @@ -83,6 +85,7 @@ 2F77A233283C4AC700F143FB /* ImageExample.swift */, 2F6267AD2857B6960063A630 /* AccordionExample.swift */, 2F569938285FB93500F2D4D3 /* ModalExample.swift */, + 2FD5447928720B810098468D /* TextFieldExample.swift */, ); path = Basic; sourceTree = ""; @@ -229,6 +232,7 @@ 2FA9867B28373DD3000DB409 /* SnackbarExample.swift in Sources */, 2F1F7D7528318EEE00AA30DB /* ButtonExample.swift in Sources */, 2FA986792837351B000DB409 /* GridExample.swift in Sources */, + 2FD5447A28720B810098468D /* TextFieldExample.swift in Sources */, 2F9321B5282EE49E003DA929 /* SceneDelegate.swift in Sources */, 2F27BC9D284814B600B5AC8D /* TabExample.swift in Sources */, 2F072907283C00080098C5AF /* LoaderExample.swift in Sources */, diff --git a/PuraceDemo/PuraceDemo/Examples/Basic/TextFieldExample.swift b/PuraceDemo/PuraceDemo/Examples/Basic/TextFieldExample.swift new file mode 100644 index 0000000..ec797ff --- /dev/null +++ b/PuraceDemo/PuraceDemo/Examples/Basic/TextFieldExample.swift @@ -0,0 +1,20 @@ +// +// TextFieldExample.swift +// PuraceDemo +// +// Created by Juan Hurtado on 3/07/22. +// + +import Foundation +import SwiftUI +import Purace + +struct TextFieldExample: View { + @State var text: String = "" + + var body: some View { + PuraceTextField("Hola", text: $text) + .padding() + Spacer() + } +} diff --git a/PuraceDemo/PuraceDemo/MenuView.swift b/PuraceDemo/PuraceDemo/MenuView.swift index f2bde57..21e004a 100644 --- a/PuraceDemo/PuraceDemo/MenuView.swift +++ b/PuraceDemo/PuraceDemo/MenuView.swift @@ -35,6 +35,9 @@ struct MenuView: View { NavigationLink("Modal") { ModalExample() } + NavigationLink("Text Field") { + TextFieldExample() + } } Section(header: Text("Complex")) { NavigationLink("Collection card") { diff --git a/Sources/Purace/Views/Basic/TextField/PuraceTextField.swift b/Sources/Purace/Views/Basic/TextField/PuraceTextField.swift new file mode 100644 index 0000000..7b6fe36 --- /dev/null +++ b/Sources/Purace/Views/Basic/TextField/PuraceTextField.swift @@ -0,0 +1,34 @@ +// +// PuraceTextField.swift +// +// +// Created by Juan Hurtado on 3/07/22. +// + +import Foundation +import SwiftUI + +public struct PuraceTextField: View { + var placeholder: String + @Binding var text: String + + public init(_ placeholder: String, text: Binding) { + self.placeholder = placeholder + _text = text + } + + public var body: some View { + TextField(placeholder, text: $text, onCommit: { + print("asdf?") + }) + .textFieldStyle(.plain) + .padding(.horizontal, 12) + .frame(height: 40) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(Color.black.opacity(0.05)) + ) + .font(PuraceStyle.Font.get(size: 12)) + .foregroundColor(PuraceStyle.Color.N1) + } +}