-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from payan-app/textfield
feat: add text field view
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
PuraceDemo/PuraceDemo/Examples/Basic/TextFieldExample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Sources/Purace/Views/Basic/TextField/PuraceTextField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |