Skip to content

Commit

Permalink
Merge pull request #22 from payan-app/textfield
Browse files Browse the repository at this point in the history
feat: add text field view
  • Loading branch information
juandahurt authored Jul 3, 2022
2 parents dcda933 + 50869fe commit 6a74308
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PuraceDemo/PuraceDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -50,6 +51,7 @@
2FA986782837351B000DB409 /* GridExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridExample.swift; sourceTree = "<group>"; };
2FA9867A28373DD3000DB409 /* SnackbarExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnackbarExample.swift; sourceTree = "<group>"; };
2FC004082831AC250037EF10 /* StoryExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryExample.swift; sourceTree = "<group>"; };
2FD5447928720B810098468D /* TextFieldExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldExample.swift; sourceTree = "<group>"; };
2FEB27C32839C6B20092B7D3 /* Purace */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Purace; path = ..; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -83,6 +85,7 @@
2F77A233283C4AC700F143FB /* ImageExample.swift */,
2F6267AD2857B6960063A630 /* AccordionExample.swift */,
2F569938285FB93500F2D4D3 /* ModalExample.swift */,
2FD5447928720B810098468D /* TextFieldExample.swift */,
);
path = Basic;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
20 changes: 20 additions & 0 deletions PuraceDemo/PuraceDemo/Examples/Basic/TextFieldExample.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
3 changes: 3 additions & 0 deletions PuraceDemo/PuraceDemo/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct MenuView: View {
NavigationLink("Modal") {
ModalExample()
}
NavigationLink("Text Field") {
TextFieldExample()
}
}
Section(header: Text("Complex")) {
NavigationLink("Collection card") {
Expand Down
34 changes: 34 additions & 0 deletions Sources/Purace/Views/Basic/TextField/PuraceTextField.swift
Original file line number Diff line number Diff line change
@@ -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<String>) {
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)
}
}

0 comments on commit 6a74308

Please sign in to comment.