Skip to content

Commit

Permalink
Merge pull request #144 from wwt/update-viewinspector
Browse files Browse the repository at this point in the history
Updated Develop Dependencies
  • Loading branch information
morganzellers committed Sep 22, 2021
2 parents 95ed566 + 143e65d commit e256818
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 56 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ on:

jobs:
test:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Run TESTS
Expand All @@ -28,29 +29,32 @@ jobs:
retention-days: 90

build_for_swift_package_manager:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Validate SwiftPM BUILDs
run: bundle exec fastlane build_swiftpm
working-directory: ${{ env.working-directory }}

build_for_cocoapods:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Validate Cocoapods Can Deploy (lib lint)
run: bundle exec fastlane cocoapods_liblint
working-directory: ${{ env.working-directory }}

lint:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Swiftlint
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/PR_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on: [ pull_request ]

jobs:
test:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Run TESTS
Expand All @@ -25,29 +26,32 @@ jobs:
retention-days: 90

build_for_swift_package_manager:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Validate SwiftPM BUILDs
run: bundle exec fastlane build_swiftpm
working-directory: ${{ env.working-directory }}

build_for_cocoapods:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Validate Cocoapods Can Deploy (lib lint)
run: bundle exec fastlane cocoapods_liblint
working-directory: ${{ env.working-directory }}

lint:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Swiftlint
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:

jobs:
release:
runs-on: macos-latest
runs-on: macos-11
env:
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
if: ${{ github.repository == 'wwt/SwiftCurrent' }}
steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ on:

jobs:
version_bump:
runs-on: macos-latest
runs-on: macos-11
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository == 'wwt/SwiftCurrent' }}
env:
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
working-directory: .github
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -56,7 +57,10 @@ jobs:
tag: ${{ steps.bump_version.outputs.version }}
name: Release ${{ steps.bump_version.outputs.version }}
deploy_documentation:
runs-on: macos-latest
runs-on: macos-11
env:
working-directory: .github
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
needs: version_bump
steps:
- uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import SwiftUI
// swiftlint:disable:next file_types_order
extension View {
func testableAlert<Item>(item: Binding<Item?>, content: @escaping (Item) -> Alert) -> some View where Item: Identifiable {
modifier(InspectableAlertWithItem(item: item, alertBuilder: content))
modifier(InspectableAlertWithItem(item: item, popupBuilder: content))
}
}

struct InspectableAlertWithItem<Item: Identifiable>: ViewModifier {
let item: Binding<Item?>
let alertBuilder: (Item) -> Alert
let popupBuilder: (Item) -> Alert
let onDismiss: (() -> Void)? = nil

func body(content: Self.Content) -> some View {
content.alert(item: item, content: alertBuilder)
content.alert(item: item, content: popupBuilder)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,16 @@ extension View {
func testableSheet<Item, Sheet>(item: Binding<Item?>,
onDismiss: (() -> Void)? = nil,
content: @escaping (Item) -> Sheet) -> some View where Item: Identifiable, Sheet: View {
modifier(InspectableSheetWithItem(item: item, onDismiss: onDismiss, content: content))
modifier(InspectableSheetWithItem(item: item, onDismiss: onDismiss, popupBuilder: content))
}
}

struct InspectableSheetWithItem<Item, Sheet>: ViewModifier where Item: Identifiable, Sheet: View {
let item: Binding<Item?>
let onDismiss: (() -> Void)?
let content: (Item) -> Sheet
let sheetBuilder: (Item) -> Any

init(item: Binding<Item?>, onDismiss: (() -> Void)?, content: @escaping (Item) -> Sheet) {
self.item = item
self.onDismiss = onDismiss
self.content = content
self.sheetBuilder = { content($0) as Any }
}
let popupBuilder: (Item) -> Sheet

func body(content: Self.Content) -> some View {
content.sheet(item: item, onDismiss: onDismiss, content: self.content)
content.sheet(item: item, onDismiss: onDismiss, content: popupBuilder)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ extension ViewControllerWrapper: Inspectable { }

extension SwiftUIExample.Inspection: InspectionEmissary where V: View { }
extension SwiftCurrent_SwiftUI.Inspection: InspectionEmissary where V: View { }
extension InspectableSheetWithItem: SheetItemProvider { }
extension InspectableAlertWithItem: AlertItemProvider { }
extension InspectableSheetWithItem: ItemPopupPresenter { }
extension InspectableAlertWithItem: ItemPopupPresenter { }
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: Version("2.0.0-beta.1")),
.package(url: "https://github.com/apple/swift-algorithms", .upToNextMajor(from: "0.0.1")),
.package(url: "https://github.com/sindresorhus/ExceptionCatcher", from: "2.0.0"),
.package(url: "https://github.com/nalexn/ViewInspector.git", from: "0.8.1")
.package(url: "https://github.com/nalexn/ViewInspector.git", from: "0.9.0")
],
targets: [
.target(
Expand Down
14 changes: 3 additions & 11 deletions Sources/SwiftCurrent_SwiftUI/ViewInspector/InspectableSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@ import SwiftUI
extension View {
func testableSheet<Sheet>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping () -> Sheet
) -> some View where Sheet: View {
modifier(InspectableSheet(isPresented: isPresented, onDismiss: onDismiss, content: content))
modifier(InspectableSheet(isPresented: isPresented, onDismiss: onDismiss, popupBuilder: content))
}
}

@available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *)
struct InspectableSheet<Sheet>: ViewModifier where Sheet: View {
let isPresented: Binding<Bool>
let onDismiss: (() -> Void)?
let content: () -> Sheet
let sheetBuilder: () -> Any

init(isPresented: Binding<Bool>, onDismiss: (() -> Void)?, content: @escaping () -> Sheet) {
self.isPresented = isPresented
self.onDismiss = onDismiss
self.content = content
sheetBuilder = { content() as Any }
}
let popupBuilder: () -> Sheet

func body(content: Self.Content) -> some View {
content.sheet(isPresented: isPresented, content: self.content)
content.sheet(isPresented: isPresented, onDismiss: onDismiss, content: popupBuilder)
}
}
12 changes: 6 additions & 6 deletions SwiftCurrent.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "02b7a39a99c4da27abe03cab2053a9034379639f",
"version": "2.0.0"
"revision": "0630439888c94657a235ffcd5977d6047ef3c87b",
"version": "2.0.1"
}
},
{
Expand Down Expand Up @@ -60,8 +60,8 @@
"repositoryURL": "https://github.com/Swinject/Swinject",
"state": {
"branch": null,
"revision": "8a76d2c74bafbb455763487cc6a08e91bad1f78b",
"version": "2.7.1"
"revision": "b1d92a53159fe45e162c307183aec9be15e4e7ae",
"version": "2.8.0"
}
},
{
Expand All @@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/nalexn/ViewInspector.git",
"state": {
"branch": null,
"revision": "a9b0d2af51b8afbbcb6a3e1005aabf8726852a77",
"version": "0.8.1"
"revision": "0d546878902bdde8c4682141f848a9dc44e04ba6",
"version": "0.9.0"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftCurrent
@available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *)
extension InspectableView where View == ViewType.Sheet {
func isPresented() throws -> Bool {
return (Mirror(reflecting: content.view).descendant("builder", "isPresented") as? Binding<Bool>)?.wrappedValue ?? false
return (Mirror(reflecting: content.view).descendant("presenter", "isPresented") as? Binding<Bool>)?.wrappedValue ?? false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ extension ViewControllerWrapper: Inspectable { }
extension Inspection: InspectionEmissary where V: View { }

@available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *)
extension InspectableSheet: SheetProvider { }
extension InspectableSheet: PopupPresenter { }

0 comments on commit e256818

Please sign in to comment.