Skip to content

Commit 84efe24

Browse files
author
Sina Rabiei
authored
Merge pull request #10 from nssina/main
Changed package name to ShortcutUI
2 parents 71e53aa + 28a0b45 commit 84efe24

19 files changed

+37
-65
lines changed

Package.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// swift-tools-version:5.5
1+
// swift-tools-version: 5.6
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
7-
name: "ShortcutSwiftUI",
7+
name: "ShortcutUI",
88
platforms: [
99
.iOS(.v13),
1010
.macOS(.v11),
@@ -13,8 +13,8 @@ let package = Package(
1313
products: [
1414
// Products define the executables and libraries a package produces, and make them visible to other packages.
1515
.library(
16-
name: "ShortcutSwiftUI",
17-
targets: ["ShortcutSwiftUI"]),
16+
name: "ShortcutUI",
17+
targets: ["ShortcutUI"]),
1818
],
1919
dependencies: [
2020
// Dependencies declare other packages that this package depends on.
@@ -24,10 +24,10 @@ let package = Package(
2424
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
2525
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2626
.target(
27-
name: "ShortcutSwiftUI",
27+
name: "ShortcutUI",
2828
dependencies: []),
2929
.testTarget(
30-
name: "ShortcutSwiftUI-Tests",
31-
dependencies: ["ShortcutSwiftUI"]),
30+
name: "ShortcutUITests",
31+
dependencies: ["ShortcutUI"]),
3232
]
3333
)

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Shortcut SwiftUI
1+
# ShortcutUI
22

33
Contains common utility functions and extensions.
44

@@ -45,11 +45,11 @@ let package = Package(
4545
.package(url: "[email protected]:shortcut/shortcut-swiftui-ios.git", from: "0.0.1")
4646
],
4747
targets: [
48-
.target(name: "YourTestProject", dependencies: ["ShortcutSwiftUI"])
48+
.target(name: "YourTestProject", dependencies: ["ShortcutUI"])
4949
]
5050
)
5151
```
52-
And then import wherever needed: ```import ShortcutSwiftUI ```
52+
And then import wherever needed: ```import ShortcutUI ```
5353

5454
#### Adding it to an existent iOS Project via Swift Package Manager
5555

@@ -63,13 +63,13 @@ If you have doubts, please, check the following links:
6363

6464
[Creating Swift Packages](https://developer.apple.com/videos/play/wwdc2019/410/)
6565

66-
After successfully retrieved the package and added it to your project, just import `ShortcutSwiftUI` and you can get the full benefits of it.
66+
After successfully retrieved the package and added it to your project, just import `ShortcutUI` and you can get the full benefits of it.
6767

6868

6969
## Usage example
7070

7171
```swift
72-
import ShortcutSwiftUI
72+
import ShortcutUI
7373

7474
...
7575
```
@@ -82,3 +82,4 @@ import ShortcutSwiftUI
8282
4. Perform your changes, debug, run the unit tests
8383
5. Make sure that all the tests pass and there are no Xcode warnings or lint issues
8484
6. Open a pull request
85+

Sources/ShortcutSwiftUI/Extensions/Color+Extension.swift Sources/ShortcutUI/Extensions/Color+Extension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//
44
// Color+Extension.swift
5-
// ShortcutSwiftUI
5+
// ShortcutUI
66
//
77
// Created by Gabriel Sabadin on 2022-08-16.
88
// Copyright © 2021 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/Extensions/String+Extension.swift Sources/ShortcutUI/Extensions/String+Extension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// String+Extension.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Sheikh Bayazid on 2022-03-16.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/Extensions/UIDevice+Extension.swift Sources/ShortcutUI/Extensions/UIDevice+Extension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// UIDevice+Extension.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Sina Rabiei on 2022-03-30.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/Extensions/View+Extension.swift Sources/ShortcutUI/Extensions/View+Extension.swift

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// View+Extension.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Darya Gurinovich on 2022-01-07.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.
@@ -68,15 +68,11 @@ public extension View {
6868
AnyView(self)
6969
}
7070

71-
#if !os(macOS)
71+
#if !os(macOS)
7272
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
7373
clipShape(RoundedCorner(radius: radius, corners: corners))
7474
}
75-
76-
func hideKeyboard() {
77-
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
78-
}
79-
#endif
75+
#endif
8076
}
8177

8278
#if !os(macOS)

Sources/ShortcutSwiftUI/SwiftUI/AlertPresenter/ActionSheet+Extension.swift Sources/ShortcutUI/SwiftUI/AlertPresenter/ActionSheet+Extension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ActionSheet+Extension.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Sheikh Bayazid on 2022-02-14.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/AlertPresenter/Alert+Extension.swift Sources/ShortcutUI/SwiftUI/AlertPresenter/Alert+Extension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Alert+Extension.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Sheikh Bayazid on 2022-02-14.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/AlertPresenter/AlertPresenter.swift Sources/ShortcutUI/SwiftUI/AlertPresenter/AlertPresenter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// AlertPresenter.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Sheikh Bayazid on 2022-02-11.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/AlertPresenter/AlertViewModel.swift Sources/ShortcutUI/SwiftUI/AlertPresenter/AlertViewModel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// swiftlint:disable nesting
33
//
44
// Alert+Extension.swift
5-
// ShortcutSwiftUI
5+
// ShortcutUI
66
//
77
// Created by Sheikh Bayazid on 2022-02-14.
88
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/BottomSheet/BottomSheet.swift Sources/ShortcutUI/SwiftUI/BottomSheet/BottomSheet.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// BottomSheet.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Darya Gurinovich on 2022-01-07.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/BottomSheet/BottomSheetView.swift Sources/ShortcutUI/SwiftUI/BottomSheet/BottomSheetView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// BottomSheetView.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Darya Gurinovich on 2022-01-07.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/BottomSheet/BottomSheetViewModifier.swift Sources/ShortcutUI/SwiftUI/BottomSheet/BottomSheetViewModifier.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// BottomSheetViewModifier.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Darya Gurinovich on 2022-01-07.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/ModalView/ModalPresenter.swift Sources/ShortcutUI/SwiftUI/ModalView/ModalPresenter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protocol ModalPresenter {
5151
func closeModal()
5252
}
5353

54-
open class ModalViewRouter<PresentationState: ModalPresentationState>: ObservableObject, ModalPresenter {
54+
public class ModalViewRouter<PresentationState: ModalPresentationState>: ObservableObject, ModalPresenter {
5555
@Published var customSheetPresentationState: PresentationState? {
5656
didSet {
5757
handlePresentationStateChange(oldValue: oldValue, newValue: customSheetPresentationState)

Sources/ShortcutSwiftUI/SwiftUI/ModalView/ModalViewPresenterViewModifier.swift Sources/ShortcutUI/SwiftUI/ModalView/ModalViewPresenterViewModifier.swift

+5-29
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ import SwiftUI
1212
struct ModalViewPresenterViewModifier<PresentationState: ModalPresentationState>: ViewModifier {
1313
@EnvironmentObject var modalViewRouter: ModalViewRouter<PresentationState>
1414

15-
@Binding private var options: [BottomSheet.Options]
15+
private let options: [BottomSheet.Options]
1616

1717
init(options: [BottomSheet.Options] = []) {
18-
self._options = .constant(options)
19-
}
20-
21-
init(options: Binding<[BottomSheet.Options]>) {
22-
self._options = options
18+
self.options = options
2319
}
2420

2521
public func body(content: Content) -> some View {
@@ -48,26 +44,8 @@ public extension View {
4844
/// Works with the implementation of the `ModalPresentationState` protocol that represents all modals that can be shown with this presenter.
4945
/// Need to set an environmentObject of `ModalViewRouter<S: ModalPresentationState>` before using this modifier otherwise an error will occur.
5046
///
51-
/// - parameters:
52-
/// - presentationStateType: A type that represent possible states to show
53-
/// - options: Modal view options to customise it
54-
///
55-
func modalViewPresenter<PresentationState: ModalPresentationState>(presentationStateType: PresentationState.Type,
56-
options: [BottomSheet.Options] = []) -> some View {
57-
self.modifier(ModalViewPresenterViewModifier<PresentationState>(options: options))
58-
}
59-
60-
/// A view modifier to present modal views from any view.
61-
///
62-
/// Works with the implementation of the `ModalPresentationState` protocol that represents all modals that can be shown with this presenter.
63-
/// Need to set an environmentObject of `ModalViewRouter<S: ModalPresentationState>` before using this modifier otherwise an error will occur.
64-
///
65-
/// - parameters:
66-
/// - presentationStateType: A type that represent possible states to show
67-
/// - options: A options binding to allow to change the modal options
68-
///
6947
func modalViewPresenter<PresentationState: ModalPresentationState>(presentationStateType: PresentationState.Type,
70-
options: Binding<[BottomSheet.Options]>) -> some View {
48+
options: [BottomSheet.Options]) -> some View {
7149
self.modifier(ModalViewPresenterViewModifier<PresentationState>(options: options))
7250
}
7351
}
@@ -83,7 +61,6 @@ struct ModalViewPresenterViewModifier_Previews: PreviewProvider {
8361
@StateObject private var testModalViewRouter = TestModalViewRouter()
8462

8563
@State var color: Color = .red
86-
@State var options: [BottomSheet.Options] = [.disableSwipeToDismiss, .tapToDismiss]
8764

8865
var body: some View {
8966
ZStack {
@@ -93,13 +70,12 @@ struct ModalViewPresenterViewModifier_Previews: PreviewProvider {
9370
testModalViewRouter.setModal(state: .text("Hello World!"),
9471
type: .customSheet) {
9572
color = [Color.red, .purple, .blue, .yellow, .green].randomElement() ?? .orange
96-
97-
options = [.tapToDismiss]
9873
}
9974
}
10075
}
10176
.modalViewPresenter(presentationStateType: TestModalPresentationState.self,
102-
options: $options)
77+
options: [.tapToDismiss,
78+
.maxHeight(500)])
10379
.environmentObject(testModalViewRouter)
10480
}
10581
}

Sources/ShortcutSwiftUI/SwiftUI/NavigationLink+Extension.swift Sources/ShortcutUI/SwiftUI/NavigationLink+Extension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// NavigationLink+Extension.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Karl Söderberg on 2022-01-17.
66
// Copyright © 2022 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/View+Fullscreen.swift Sources/ShortcutUI/SwiftUI/View+Fullscreen.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// View+Fullscreen.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Karl Söderberg on 2022-08-25.
66
// Copyright © 2021 Shortcut Scandinavia Apps AB. All rights reserved.

Sources/ShortcutSwiftUI/SwiftUI/WKWebViewRepresentable.swift Sources/ShortcutUI/SwiftUI/WKWebViewRepresentable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// WKWebViewRepresentable.swift
3-
// ShortcutSwiftUI
3+
// ShortcutUI
44
//
55
// Created by Karl Söderberg on 2022-01-04.
66
// Copyright © 2021 Shortcut Scandinavia Apps AB. All rights reserved.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import XCTest
2-
@testable import ShortcutSwiftUI
2+
@testable import ShortcutUI
33

4-
final class ShortcutSwiftUITests: XCTestCase {
4+
final class ShortcutUITests: XCTestCase {
55
func testExample() throws {
66
// This is an example of a functional test case.
77
// Use XCTAssert and related functions to verify your tests produce the correct
88
// results.
9-
109
}
1110
}

0 commit comments

Comments
 (0)