Skip to content

Commit

Permalink
Merge pull request #22 from oversizedev/new-icons
Browse files Browse the repository at this point in the history
New icons
  • Loading branch information
aromanov91 authored Apr 11, 2023
2 parents 195c2fa + 783bded commit d657270
Show file tree
Hide file tree
Showing 1,415 changed files with 13,440 additions and 232 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<true/>
</dict>
</plist>
54 changes: 36 additions & 18 deletions Example/Shared/DemoPages/TextFieldDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,54 @@ import OversizeUI
import SwiftUI

struct TextFieldDemo: View {
@State var text = ""

var body: some View {
PageView("Text Fields") {
VStack(spacing: .xSmall) {
TextField("Text", text: .constant("Placeholder"))
.textFieldStyle(DefaultPlaceholderTextFieldStyle())

TextField("Text", text: .constant("Placeholder"))
.textFieldStyle(OverPlaceholderTextFieldStyle(placeholder: "Label"))

TextField("Text", text: .constant("Placeholder"))
.textFieldStyle(InsidePlaceholderTextFieldStyle(placeholder: "Label"))

TextField("Text", text: .constant("Placeholder"))
.textFieldStyle(DefaultPlaceholderTextFieldStyle())
.helper(.constant("Help"), style: .constant(.helperText))
fields

TextField("Text", text: .constant("Placeholder"))
.textFieldStyle(OverPlaceholderTextFieldStyle(placeholder: "Label"))
.helper(.constant("Ok"), style: .constant(.sussesText))
fields
.fieldLabelPosition(.adjacent)

TextField("Text", text: .constant("Placeholder"))
.textFieldStyle(InsidePlaceholderTextFieldStyle(placeholder: "Label"))
.helper(.constant("Error"), style: .constant(.errorText))
fields
.fieldLabelPosition(.overInput)

}.padding()
}
.leadingBar {
BarButton(.back)
}
}

var fields: some View {
VStack(spacing: .xSmall) {
TextField("Text", text: $text)
.textFieldStyle(.default)

TextField("Text", text: $text)
.textFieldStyle(.placeholder("Placeholder"))

TextField("Text", text: $text)
.textFieldStyle(.placeholder("Placeholder", text: $text))

TextField("Text", text: $text, prompt: Text("Promt"))
.textFieldStyle(.placeholder("Placeholder", text: $text))

TextField("Text", text: $text)
.textFieldStyle(.placeholder("Placeholder", text: $text))
.fieldHelper(.constant("Help"), style: .constant(.helperText))

TextField("Text", text: $text)
.textFieldStyle(.placeholder("Placeholder", text: $text))
.fieldHelper(.constant("Ok"), style: .constant(.sussesText))

TextField("Text", text: $text)
.textFieldStyle(.placeholder("Placeholder", text: $text))
.fieldHelper(.constant("Error"), style: .constant(.errorText))

}.padding()
}
}

struct TextFielsDemo_Previews: PreviewProvider {
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swiftlint:disable all

Expand Down
1 change: 1 addition & 0 deletions Sources/OversizeUI/Controls/Button/BarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum BarButtonType {
@available(*, deprecated, message: "Use .disabled() modificator")
case disabled(_ text: String)
case image(_ image: Image, action: () -> Void)
@available(*, renamed: "image")
case icon(_ icon: IconsNames, action: () -> Void)
}

Expand Down
38 changes: 35 additions & 3 deletions Sources/OversizeUI/Controls/Button/FieldButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SwiftUI

public struct FieldButtonStyle: ButtonStyle {
@Environment(\.theme) private var theme: ThemeSettings
@Environment(\.fieldPosition) private var fieldPosition: FieldPosition

public init() {}

Expand All @@ -17,17 +18,48 @@ public struct FieldButtonStyle: ButtonStyle {
.hLeading()
}
.padding()
.background(
.background(fieldBackground(isPressed: configuration.isPressed))
}

@ViewBuilder
private func fieldBackground(isPressed: Bool) -> some View {
switch fieldPosition {
case .default:
RoundedRectangle(cornerRadius: Radius.medium, style: .continuous)
.fill(configuration.isPressed ? Color.surfaceTertiary : Color.surfaceSecondary)
.fill(isPressed ? Color.surfaceTertiary : Color.surfaceSecondary)
.overlay(
RoundedRectangle(cornerRadius: Radius.medium,
style: .continuous)
.stroke(theme.borderTextFields
? Color.border
: Color.surfaceSecondary, lineWidth: CGFloat(theme.borderSize))
)
)
case .top, .bottom, .center:
RoundedRectangleCorner(radius: Radius.medium, corners: backgroundShapeCorners)
.fill(isPressed ? Color.surfaceTertiary : Color.surfaceSecondary)
.overlay(
RoundedRectangleCorner(radius: Radius.medium, corners: backgroundShapeCorners)
.stroke(theme.borderTextFields
? Color.border
: Color.surfaceSecondary, lineWidth: CGFloat(theme.borderSize))
)
}
}

@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
private var backgroundShapeCorners: UIRectCorner {
switch fieldPosition {
case .default:
return [.allCorners]
case .top:
return [.topLeft, .topRight]
case .bottom:
return [.bottomLeft, .bottomRight]
case .center:
return []
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions Sources/OversizeUI/Controls/Checkbox/Checkbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public extension Checkbox where Label == EmptyView {
struct Checkbox_LibraryContent: LibraryContentProvider {
var views: [LibraryItem] {
LibraryItem(
Checkbox(isOn: .constant(false)) {
Checkbox(isOn: .constant(false), label: {
Text("Text")
},
}),
title: "Checkbox", category: .control
)
}
Expand All @@ -129,17 +129,17 @@ struct Checkbox_LibraryContent: LibraryContentProvider {
struct Checkbox_preview: PreviewProvider {
static var previews: some View {
VStack(spacing: 24) {
Checkbox(isOn: .constant(true)) {
Checkbox(isOn: .constant(true), label: {
Text("Text")
}
})

Checkbox(isOn: .constant(false), alignment: .leading, label: {
Text("Text")
})

Checkbox(isOn: .constant(true), alignment: .trailing) {
Checkbox(isOn: .constant(true), alignment: .trailing, label: {
Text("Text")
}
})

Checkbox("Text", isOn: .constant(false), alignment: .leading)

Expand Down
Loading

0 comments on commit d657270

Please sign in to comment.