Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Platform and minor bug fixes #42

Merged
merged 12 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions .github/workflows/ci-pull-request.yml

This file was deleted.

43 changes: 28 additions & 15 deletions .github/workflows/ci-release.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: CI - Release
name: CI
on:
pull_request:
types:
- closed
branches:
- main
push:
branches:
- '**'
workflow_dispatch:

jobs:
Expand All @@ -13,9 +16,14 @@ jobs:
uses: oversizedev/GithubWorkflows/.github/workflows/build-swiftpm.yml@main
strategy:
matrix:
packages: [OversizeUI]
destination:
- platform=iOS Simulator,name=iPhone 16,OS=18.0
- platform=watchOS Simulator,name=Apple Watch SE (40mm) (2nd generation),OS=11.0
- platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=18.0
- platform=macOS,arch=arm64
with:
package: ${{ matrix.packages }}
package: OversizeUI
destination: ${{ matrix.destination }}
secrets: inherit

build-iOS-example:
Expand All @@ -24,7 +32,9 @@ jobs:
uses: oversizedev/GithubWorkflows/.github/workflows/build-app.yml@main
strategy:
matrix:
destination: ['platform=iOS Simulator,name=iPhone 15 Pro,OS=17.2', 'platform=iOS Simulator,name=iPad Pro (12.9-inch) (6th generation),OS=17.2']
destination:
- platform=iOS Simulator,name=iPhone 16 Pro,OS=18.0
- platform=iOS Simulator,name=iPad (10th generation),OS=18.0
with:
path: Example/Example
scheme: Example (iOS)
Expand All @@ -47,7 +57,9 @@ jobs:
uses: oversizedev/GithubWorkflows/.github/workflows/build-app.yml@main
strategy:
matrix:
destination: ['platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=17.2', 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=16.4']
destination:
- platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=18.0
- platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0
with:
path: Example/Example
scheme: Example (tvOS)
Expand All @@ -60,22 +72,23 @@ jobs:
uses: oversizedev/GithubWorkflows/.github/workflows/build-app.yml@main
strategy:
matrix:
destination: ['platform=watchOS Simulator,name=Apple Watch SE (44mm) (2nd generation),OS=10.5']
destination:
- platform=watchOS Simulator,name=Apple Watch SE (40mm) (2nd generation),OS=11.0
with:
path: Example/Example
scheme: Example (watchOS)
destination: ${{ matrix.destination }}
secrets: inherit

bump:
name: Bump version
needs: [build-swiftpm, build-iOS-example, build-macOS-example, build-tvOS-example, build-watchOS-example]
if: github.ref == 'refs/heads/main'
needs:
- build-swiftpm
- build-iOS-example
- build-macOS-example
- build-tvOS-example
- build-watchOS-example

uses: oversizedev/GithubWorkflows/.github/workflows/bump.yml@main
secrets: inherit

publish-docc:
name: Publish docc
needs: bump
uses: ./.github/workflows/publish-docc.yml
secrets: inherit

37 changes: 0 additions & 37 deletions .github/workflows/publish-docc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion 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/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)
[![Build Example](https://github.com/oversizedev/OversizeUI/actions/workflows/build-example.yml/badge.svg)](https://github.com/oversizedev/OversizeUI/actions/workflows/ci-release.yml)

Yet another component library on SwiftUI

Expand Down
2 changes: 0 additions & 2 deletions Sources/OversizeUI/Controls/ContentView/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ extension ContentView {
#if os(macOS)
.controlSize(.large)
#endif

case .back:

Button(action: { dismiss() }) {
Expand Down Expand Up @@ -247,7 +246,6 @@ extension ContentView {
.buttonStyle(.tertiary)
#endif
.disabled(true)

case .none:
EmptyView()
}
Expand Down
36 changes: 26 additions & 10 deletions Sources/OversizeUI/Controls/Divider/Separator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,40 @@ public struct Separator: View {

return Rectangle()
.fill(Color.border)
.frame(width: isHorizontal ? nil : 0.5,
height: isHorizontal ? 0.5 : nil)
.frame(
width: isHorizontal ? nil : lineWidth,
height: isHorizontal ? lineWidth : nil
)
#if !os(macOS)
.padding(insets(isHorizontal))
#endif
}

private func insets(_ isHorizontal: Bool) -> EdgeInsets {
if isHorizontal {
EdgeInsets(top: 0.5,
leading: padding.rawValue,
bottom: 0,
trailing: padding.rawValue)
EdgeInsets(
top: 0.5,
leading: padding.rawValue,
bottom: 0,
trailing: padding.rawValue
)
} else {
EdgeInsets(top: padding.rawValue,
leading: 0.5,
bottom: padding.rawValue,
trailing: 0)
EdgeInsets(
top: padding.rawValue,
leading: 0.5,
bottom: padding.rawValue,
trailing: 0
)
}
}

var lineWidth: CGFloat {
#if os(macOS)
return 1
#else
return 0.5
#endif
}
}

struct Separator_Preview: PreviewProvider {
Expand Down
6 changes: 3 additions & 3 deletions Sources/OversizeUI/Controls/PageControl/PageIndexView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import SwiftUI

public struct PageIndexView: View {
@Binding private var index: Int
private var index: Int
private let maxIndex: Int

public init(_ index: Binding<Int>, maxIndex: Int) {
_index = index
public init(_ index: Int, maxIndex: Int) {
self.index = index
self.maxIndex = maxIndex
}

Expand Down
10 changes: 4 additions & 6 deletions Sources/OversizeUI/Controls/PriceField/PriceField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ public struct PriceField: View {
return formatter
}

private var strValue2: String { value.components(separatedBy: CharacterSet(charactersIn: "0123456789").inverted).joined() } // value.filter { !$0.isWhitespace } }
private var doubleValue2: Double { .init((Double(strValue2) ?? 0) / 100.0) ?? 0 }
private var stringValue2: String { value.components(separatedBy: CharacterSet(charactersIn: "0123456789").inverted).joined() }
private var doubleValue2: Double { .init((Double(stringValue2) ?? 0) / 100.0) ?? 0 }

private var strValue3: String { value.components(separatedBy: CharacterSet(charactersIn: "0123456789").inverted).joined() } // value.filter { !$0.isWhitespace } }
private var doubleValue3: Double { .init((Double(strValue3) ?? 0) * 100) ?? 0 }
private var stringValue3: String { value.components(separatedBy: CharacterSet(charactersIn: "0123456789").inverted).joined() }
private var doubleValue3: Double { .init((Double(stringValue3) ?? 0) * 100) ?? 0 }

private var strValue: String { value.filter { !$0.isWhitespace } }
private var doubleValue: Double { .init(strValue) ?? 0 }
private var formattedValue: String {
let value = doubleValue

return formatter.string(for: value) ?? ""
}

Expand Down Expand Up @@ -80,7 +79,6 @@ public struct PriceField: View {
.padding(.leading, .xSmall)

Text(dispalySymbol)

.onChange(of: currency) { _ in
validate()
}
Expand Down
13 changes: 7 additions & 6 deletions Sources/OversizeUI/Controls/Row/Row.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public struct Row<LeadingLabel, TrailingLabel>: View where LeadingLabel: View, T
(subtitle?.isEmpty) != nil
}

public init(_ title: String,
subtitle: String? = nil,
action: (() -> Void)? = nil,
@ViewBuilder leading: () -> LeadingLabel,
@ViewBuilder trailing: () -> TrailingLabel)
{
public init(
_ title: String,
subtitle: String? = nil,
action: (() -> Void)? = nil,
@ViewBuilder leading: () -> LeadingLabel,
@ViewBuilder trailing: () -> TrailingLabel
) {
self.title = title
self.subtitle = subtitle
self.action = action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import SwiftUI

public struct ScrollViewWithOffsetTracking<Content: View>: View {
public typealias ScrollAction = (_ offset: CGPoint) -> Void

private let axes: Axis.Set
private let showsIndicators: Bool
private let cordinateSpaceName: String
private let onScroll: ScrollAction
private let content: () -> Content

public init(
_ axes: Axis.Set = .vertical,
showsIndicators: Bool = true,
Expand All @@ -20,14 +28,6 @@ public struct ScrollViewWithOffsetTracking<Content: View>: View {
self.content = content
}

public typealias ScrollAction = (_ offset: CGPoint) -> Void

private let axes: Axis.Set
private let showsIndicators: Bool
private let cordinateSpaceName: String
private let onScroll: ScrollAction
private let content: () -> Content

public var body: some View {
ScrollView(axes, showsIndicators: showsIndicators) {
ScrollViewOffsetTracker {
Expand Down
Loading