Skip to content

Commit

Permalink
Add PageIndexView and update readme for Xcode 14
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Sep 9, 2022
1 parent 2843629 commit 46fd9e6
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Example/ExampleUITests/ExampleUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ExampleUITests: XCTestCase {

func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
let app: XCUIApplication = .init()
app.launch()

// Use recording to get started writing UI tests.
Expand Down
2 changes: 1 addition & 1 deletion Example/Shared/ComponentsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import OversizeUI
import SwiftUI

struct Page: Identifiable {
let id = UUID()
let id: UUID = .init()
let name: String
let page: AnyView
}
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
],
dependencies: [],
targets: [
.target(name: "OversizeUI", dependencies: [] ),
.target(name: "OversizeUI", dependencies: []),
.testTarget(name: "OversizeUITests", dependencies: ["OversizeUI"]),
]
)
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

Yet another component library on SwiftUI

## Design System
Controls and styles in [Figma](https://www.figma.com/community/file/1144847542164788208)

## Controls

Some of the controls available include:
Expand Down Expand Up @@ -34,13 +37,13 @@ Colors, Typography, Spacing and other styles in [core folder](Sources/OversizeUI

#### Requirements
- iOS 15+ or macOS 12.0+
- Xcode 13.4+
- Swift 5.6+
- Xcode 14.0+
- Swift 5.7+

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

### Import and use OversizeUI
After the framework has been added you can import the module to use it:
Expand Down
6 changes: 3 additions & 3 deletions Sources/OversizeUI/Controls/BlurView/BlurView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import SwiftUI
public let style: UIBlurEffect.Style

public func makeUIView(context _: UIViewRepresentableContext<BlurView>) -> UIView {
let view = UIView(frame: .zero)
let view: UIView = .init(frame: .zero)
view.backgroundColor = .clear
let blurEffect = UIBlurEffect(style: style)
let blurView = UIVisualEffectView(effect: blurEffect)
let blurEffect: UIBlurEffect = .init(style: style)
let blurView: UIVisualEffectView = .init(effect: blurEffect)
blurView.translatesAutoresizingMaskIntoConstraints = false
view.insertSubview(blurView, at: 0)
NSLayoutConstraint.activate([
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeUI/Controls/GridSelect/GridSelectStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public extension View {
func gridSelectStyle(_ style: GridSelectStyleType) -> some View {
switch style {
case let .default(selected: selected, icon: icon):
let style = IslandGridSelectStyle()
let style: IslandGridSelectStyle = .init()

return environment(\.gridSelectStyle, AnyGridSelectStyle(seletionStyle: selected,
unseletionStyle: style.unseletionStyle,
icon: icon,
style: style))
case let .onlySelection(selected: selected, icon: icon):
let style = SelectionOnlyGridSelectStyle()
let style: SelectionOnlyGridSelectStyle = .init()

return environment(\.gridSelectStyle, AnyGridSelectStyle(seletionStyle: selected,
unseletionStyle: style.unseletionStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import SwiftUI
longitude: coordinate.longitude
)

let geocoder = CLGeocoder()
let geocoder: CLGeocoder = .init()

geocoder.reverseGeocodeLocation(loc) { placemarks, error in
if error != nil { return }
Expand Down
12 changes: 6 additions & 6 deletions Sources/OversizeUI/Controls/LocationPicker/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import SwiftUI
public struct MapView: UIViewRepresentable {
@Binding var centerCoordinate: CLLocationCoordinate2D

let mapView = MKMapView()
let mapView: MKMapView = .init()

public func makeUIView(context: Context) -> MKMapView {
mapView.delegate = context.coordinator

// mapView.centerCoordinate = centerCoordinate
let center = CLLocationCoordinate2D(latitude: centerCoordinate.latitude, longitude: centerCoordinate.longitude)
let center: CLLocationCoordinate2D = .init(latitude: centerCoordinate.latitude, longitude: centerCoordinate.longitude)

let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region = MKCoordinateRegion(center: center, span: span)
let span: MKCoordinateSpan = .init(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region: MKCoordinateRegion = .init(center: center, span: span)
mapView.setRegion(region, animated: true)

return mapView
Expand Down Expand Up @@ -52,10 +52,10 @@ import SwiftUI
let coordinate = parent.mapView.convert(location, toCoordinateFrom: parent.mapView)

withAnimation {
let clObject = CLLocationCoordinate2D(latitude: coordinate.latitude, longitude: coordinate.longitude)
let clObject: CLLocationCoordinate2D = .init(latitude: coordinate.latitude, longitude: coordinate.longitude)
parent.centerCoordinate = clObject

let annotation = MKPointAnnotation()
let annotation: MKPointAnnotation = .init()
annotation.coordinate = clObject

withAnimation {
Expand Down
29 changes: 29 additions & 0 deletions Sources/OversizeUI/Controls/PageControl/PageIndexView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright © 2022 Alexander Romanov
// PageIndexView.swift
//

import SwiftUI

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

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

public var body: some View {
HStack(spacing: 8) {
ForEach(0 ..< maxIndex, id: \.self) { index in
Capsule()
.fill(index == self.index ? Color.accent : Color.surfaceTertiary)
.frame(width: index == self.index ? 28 : 8, height: 8)
.animation(.default, value: index)
}
}
.padding(12)
.animation(.default, value: index)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public extension View {
func segmentedControlStyle(_ style: SegmentedControlStyleType) -> some View {
switch style {
case .default:
let style = RectangleSegmentedControlStyle()
let style: RectangleSegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: style.isEquallySpacing,
Expand All @@ -42,7 +42,7 @@ public extension View {
unseletionStyle: style.unseletionStyle,
style: style))
case let .island(selected: selected):
let style = IslandSegmentedControlStyle()
let style: IslandSegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: true,
Expand All @@ -51,7 +51,7 @@ public extension View {
unseletionStyle: .surface,
style: style))
case let .islandScroll(selected: selected):
let style = ScrollSegmentedControlStyle()
let style: ScrollSegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: false,
Expand All @@ -60,7 +60,7 @@ public extension View {
unseletionStyle: .surface,
style: style))
case let .onlySelection(selected: selected):
let style = SelectionOnlySegmentedControlStyle()
let style: SelectionOnlySegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: true,
Expand All @@ -69,7 +69,7 @@ public extension View {
unseletionStyle: .clean,
style: style))
case let .onlySelectionLeading(selected: selected):
let style = SelectionOnlySegmentedControlStyle()
let style: SelectionOnlySegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: false,
Expand All @@ -78,7 +78,7 @@ public extension View {
unseletionStyle: .clean,
style: style))
case let .onlySelectionScroll(selected: selected):
let style = ScrollSegmentedControlStyle()
let style: ScrollSegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: false,
Expand All @@ -87,7 +87,7 @@ public extension View {
unseletionStyle: .clean,
style: style))
case let .islandLeading(selected: selected):
let style = IslandSegmentedControlStyle()
let style: IslandSegmentedControlStyle = .init()

return environment(\.segmentedControlStyle,
AnySegmentedControlStyle(isEquallySpacing: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct ScreenSize {
}

private struct ScreenSizeKey: EnvironmentKey {
static let defaultValue = ScreenSize(width: 375, height: 667)
static let defaultValue: ScreenSize = .init(width: 375, height: 667)
}

public extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import SwiftUI

extension Date: RawRepresentable {
private static let formatter = ISO8601DateFormatter()
private static let formatter: ISO8601DateFormatter = .init()

public var rawValue: String {
Date.formatter.string(from: self)
Expand All @@ -29,7 +29,7 @@ extension Array: RawRepresentable where Element: Codable {

public var rawValue: String {
guard let data = try? JSONEncoder().encode(self),
let result = String(data: data, encoding: .utf8)
let result: String = .init(data: data, encoding: .utf8)
else {
return "[]"
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeUI/Extensions/Color/Color+Hex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public extension Color {
#if canImport(AppKit)
let color = NSColor(self).usingColorSpace(.displayP3)!
#elseif canImport(UIKit)
let color = UIColor(self)
let color: UIColor = .init(self)
#endif

var t = (CGFloat(), CGFloat(), CGFloat(), CGFloat())
Expand Down Expand Up @@ -117,7 +117,7 @@ private func hexIntFromColorComponents(rgba components: ColorComponentsRGBA) ->

struct Hex_Preview: PreviewProvider {
static var previews: some View {
let green = Color(hex: "#00FF00")
let green: Color = .init(hex: "#00FF00")

return Circle()
.frame(width: 100, height: 100)
Expand Down
2 changes: 1 addition & 1 deletion Sources/OversizeUI/Extensions/HalfSheet/HalfSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SwiftUI
return .medium()
}
}

@available(iOS 16, *)
func convertToSUI() -> PresentationDetent {
if self == .medium {
Expand Down

0 comments on commit 46fd9e6

Please sign in to comment.