Skip to content

Commit

Permalink
Merge pull request #23 from oversizedev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
aromanov91 authored Apr 11, 2023
2 parents 6f19d2e + 58298d2 commit a18b679
Show file tree
Hide file tree
Showing 1,420 changed files with 13,519 additions and 272 deletions.
66 changes: 42 additions & 24 deletions .github/workflows/build-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,58 @@ on:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
PROJECT_DIR: Example
PROJECT_NAME: Example.xcodeproj
iOSSCHEME: Example (iOS)
OSXSCHEME: Example
TVSCHEME: Example
WATCHSCHEME: Example

jobs:

build:
runs-on: macos-12
name: Swift Build (SPM)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: swift build -v
iOStest:
name: Test iOS
run: swift build

example:
name: Run examples
runs-on: macOS-latest
strategy:
matrix:
destination: ['platform=iOS Simulator,OS=15.0,name=iPhone 8','platform=iOS Simulator,OS=15.5,name=iPhone X','platform=iOS Simulator,OS=15.5,name=iPhone 13','platform=iOS Simulator,OS=16.0,name=iPhone 14']
iosDestination: ['platform=iOS Simulator,OS=15.0,name=iPhone 8','platform=iOS Simulator,OS=15.5,name=iPhone X','platform=iOS Simulator,OS=16.0,name=iPhone 14']
macOSDestination: ["platform=macOS,arch=x86_64"]
tvOSDestination: ["platform=tvOS Simulator,name=Apple TV 4K"]
watchOSdestination: ['platform=watchOS Simulator,name=Apple Watch Series 5 - 44mm']

steps:
- name: Checkout
uses: actions/checkout@main
- name: Build and test iOS
uses: actions/checkout@v2

- name: Build iOS
run: |
xcodebuild clean build test -project "Example/Example.xcodeproj" -scheme "Example (iOS)" -sdk $TEST_SDK ONLY_ACTIVE_ARCH=NO | xcpretty
env:
destination: ${{ matrix.destination }}
macOStest:
name: Test MacOS
runs-on: macOS-latest
strategy:
matrix:
destination: ['platform=macOS,arch=x86_64']
steps:
- name: Checkout
uses: actions/checkout@main
- name: Build and test MacOS
xcodebuild clean build -project "${{ env.PROJECT_DIR }}/${{ env.PROJECT_NAME }}" -scheme "${{ env.iOSSCHEME }}" | xcpretty
env:
destination: ${{ matrix.iosDestination }}

- name: Build macOS
run: |
xcodebuild clean build -project "${{ env.PROJECT_DIR }}/${{ env.PROJECT_NAME }}" -scheme "${{ env.OSXSCHEME }}" | xcpretty
env:
destination: ${{ matrix.macOSDestination }}

- name: Build tvOS
run: |
xcodebuild clean build -project "${{ env.PROJECT_DIR }}/${{ env.PROJECT_NAME }}" -scheme "${{ env.TVSCHEME }}" | xcpretty
env:
destination: ${{ matrix.tvOSDestination }}

- name: Build watchOS
run: |
xcodebuild clean build test -project "Example/Example.xcodeproj" -scheme Example -sdk $TEST_SDK ONLY_ACTIVE_ARCH=NO | xcpretty
env:
destination: ${{ matrix.destination }}
xcodebuild clean build -project "${{ env.PROJECT_DIR }}/${{ env.PROJECT_NAME }}" -scheme "${{ env.WATCHSCHEME }}" | xcpretty
env:
destination: ${{ matrix.watchOSdestination }}
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OversizeUI

[![Build Example](https://github.com/oversizedev/OversizeUI/actions/workflows/buildExample.yml/badge.svg)](https://github.com/oversizedev/OversizeUI/actions/workflows/buildExample.yml)
[![Build Example](https://github.com/oversizedev/OversizeUI/actions/workflows/build-example.yml/badge.svg)](https://github.com/oversizedev/OversizeUI/actions/workflows/build-example.yml)[![Deploy DocC](https://github.com/oversizedev/OversizeUI/actions/workflows/publish-docc.yml/badge.svg)](https://github.com/oversizedev/OversizeUI/actions/workflows/publish-docc.yml)

Yet another component library on SwiftUI

Expand Down Expand Up @@ -36,13 +36,13 @@ Colors, Typography, Spacing and other styles in [core folder](Sources/OversizeUI

#### Requirements
- iOS 15+ or macOS 12.0+
- Xcode 14.0+
- Swift 5.7+
- Xcode 14.3+
- Swift 5.8+

#### Swift Package Manager
- File > Swift Packages > Add Package Dependency
- Add `https://github.com/oversizedev/OversizeUI.git`
- Select "Up to Next Major" with "2.2.0"
- Select "Up to Next Major" with "3.0.1"

### Import and use OversizeUI
After the framework has been added you can import the module to use it:
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 a18b679

Please sign in to comment.