From d668cba41a6cc60d98cda1da89fd0847c3363da1 Mon Sep 17 00:00:00 2001 From: Gianni Carlo Date: Wed, 2 Oct 2024 12:56:07 -0500 Subject: [PATCH 1/2] Add launch button for control center --- BookPlayer.xcodeproj/project.pbxproj | 6 ++ .../bookplayer.icon.symbolset/Contents.json | 12 +++ .../bookplayer.icon.svg | 94 +++++++++++++++++++ BookPlayerWidgets/BookPlayerWidgets.swift | 56 ++++++----- .../Phone/LaunchAppControlWidgetView.swift | 43 +++++++++ 5 files changed, 186 insertions(+), 25 deletions(-) create mode 100644 BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/Contents.json create mode 100644 BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/bookplayer.icon.svg create mode 100644 BookPlayerWidgets/Phone/LaunchAppControlWidgetView.swift diff --git a/BookPlayer.xcodeproj/project.pbxproj b/BookPlayer.xcodeproj/project.pbxproj index 869b4bf4..e858a138 100644 --- a/BookPlayer.xcodeproj/project.pbxproj +++ b/BookPlayer.xcodeproj/project.pbxproj @@ -389,6 +389,8 @@ 639720832CAB0C380045A4DB /* LastPlayedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639720822CAB0C380045A4DB /* LastPlayedView.swift */; }; 639720852CABB0D00045A4DB /* RecentBooksProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639720842CABB0D00045A4DB /* RecentBooksProvider.swift */; }; 6397208A2CAC5C870045A4DB /* LastPlayedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639720892CAC5C870045A4DB /* LastPlayedModel.swift */; }; + 6397208C2CAC95040045A4DB /* LaunchAppControlWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6397208B2CAC95040045A4DB /* LaunchAppControlWidgetView.swift */; }; + 6397208D2CAC95040045A4DB /* LaunchAppControlWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6397208B2CAC95040045A4DB /* LaunchAppControlWidgetView.swift */; }; 6399F94D2AA03C6C00A5C8EA /* BPSKANManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6399F94C2AA03C6C00A5C8EA /* BPSKANManager.swift */; }; 639AC9892AD9F1D50053AFC6 /* BPDownloadURLSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639AC9882AD9F1D50053AFC6 /* BPDownloadURLSession.swift */; }; 639AC98A2AD9F1D50053AFC6 /* BPDownloadURLSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639AC9882AD9F1D50053AFC6 /* BPDownloadURLSession.swift */; }; @@ -1170,6 +1172,7 @@ 639720822CAB0C380045A4DB /* LastPlayedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LastPlayedView.swift; sourceTree = ""; }; 639720842CABB0D00045A4DB /* RecentBooksProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentBooksProvider.swift; sourceTree = ""; }; 639720892CAC5C870045A4DB /* LastPlayedModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LastPlayedModel.swift; sourceTree = ""; }; + 6397208B2CAC95040045A4DB /* LaunchAppControlWidgetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchAppControlWidgetView.swift; sourceTree = ""; }; 6399F94C2AA03C6C00A5C8EA /* BPSKANManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BPSKANManager.swift; sourceTree = ""; }; 639AC9882AD9F1D50053AFC6 /* BPDownloadURLSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BPDownloadURLSession.swift; sourceTree = ""; }; 639E12C52B85AACF00C875F7 /* SyncTasksObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncTasksObject.swift; sourceTree = ""; }; @@ -2302,6 +2305,7 @@ children = ( 634E67432AFB2DF500595BAC /* BookStartPlaybackIntent.swift */, 6309F1252B0CF1C1002B86A4 /* BookPlaybackToggleIntent.swift */, + 6397208B2CAC95040045A4DB /* LaunchAppControlWidgetView.swift */, 4106413E258725F1008EB8D0 /* TimeListened */, 637DAB092AEB3E0D006DC2D1 /* WidgetEntries.swift */, 418445C2258AE11E0072DD13 /* WidgetUtils.swift */, @@ -3465,6 +3469,7 @@ 410641282579AA2F008EB8D0 /* TimeListenedWidgetView.swift in Sources */, 6309F1272B0CF658002B86A4 /* BookPlaybackToggleIntent.swift in Sources */, 630826032AF5225F002ACE0D /* CircularView.swift in Sources */, + 6397208C2CAC95040045A4DB /* LaunchAppControlWidgetView.swift in Sources */, 630826042AF522EA002ACE0D /* SharedWidgetEntry.swift in Sources */, 41064152258726D2008EB8D0 /* TimeListenedMediumView.swift in Sources */, 41C3396A25E04112003ED2B0 /* MappingModel_v2_to_v3.xcmappingmodel in Sources */, @@ -3640,6 +3645,7 @@ 9F5F13682978D9E100F061A0 /* ProfileSyncTasksStatusView.swift in Sources */, 41AD3DA7221C850F00DC41E1 /* IconCellView.swift in Sources */, 9FF710B92A213084006490E0 /* QueuedSyncTaskRowView.swift in Sources */, + 6397208D2CAC95040045A4DB /* LaunchAppControlWidgetView.swift in Sources */, 9FAB93742A53117C005B92B2 /* CompleteAccountView.swift in Sources */, 6304CF6A2B4C2AE800055285 /* SettingsAutoplayView.swift in Sources */, 4158388326EBD76A00F4A12B /* LibraryListCoordinator.swift in Sources */, diff --git a/BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/Contents.json b/BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/Contents.json new file mode 100644 index 00000000..35488c0f --- /dev/null +++ b/BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/Contents.json @@ -0,0 +1,12 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "symbols" : [ + { + "filename" : "bookplayer.icon.svg", + "idiom" : "universal" + } + ] +} diff --git a/BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/bookplayer.icon.svg b/BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/bookplayer.icon.svg new file mode 100644 index 00000000..6ec43527 --- /dev/null +++ b/BookPlayerWidgets/Assets.xcassets/bookplayer.icon.symbolset/bookplayer.icon.svg @@ -0,0 +1,94 @@ + + + + + +Weight/Scale Variations +Ultralight +Thin +Light +Regular +Medium +Semibold +Bold +Heavy +Black + + + + + + + + + + +Design Variations +Symbols are supported in up to nine weights and three scales. +For optimal layout with text and other symbols, vertically align +symbols with the adjacent text. + + + + + +Margins +Leading and trailing margins on the left and right side of each symbol +can be adjusted by modifying the x-location of the margin guidelines. +Modifications are automatically applied proportionally to all +scales and weights. + + + +Exporting +Symbols should be outlined when exporting to ensure the +design is preserved when submitting to Xcode. +Template v.6.0 +Requires Xcode 16 or greater +Generated from square.and.arrow.up.circle +Typeset at 100.0 points +Small +Medium +Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BookPlayerWidgets/BookPlayerWidgets.swift b/BookPlayerWidgets/BookPlayerWidgets.swift index 64dd83d2..9b11fe90 100644 --- a/BookPlayerWidgets/BookPlayerWidgets.swift +++ b/BookPlayerWidgets/BookPlayerWidgets.swift @@ -6,45 +6,51 @@ // Copyright © 2020 Tortuga Power. All rights reserved. // +import SwiftUI +import WidgetKit + #if os(watchOS) -import BookPlayerWatchKit + import BookPlayerWatchKit #else -import BookPlayerKit + import BookPlayerKit #endif -import SwiftUI -import WidgetKit #if os(iOS) -struct BookPlayerWidgetUI_Previews: PreviewProvider { - static var previews: some View { - Group { - LastPlayedWidgetView(entry: .init( - date: Date(), - items: [ - .init(relativePath: "path1", title: "Test Book Title") - ], - currentlyPlaying: nil - )) - .previewContext(WidgetPreviewContext(family: .systemSmall)) + struct BookPlayerWidgetUI_Previews: PreviewProvider { + static var previews: some View { + Group { + LastPlayedWidgetView( + entry: .init( + date: Date(), + items: [ + .init(relativePath: "path1", title: "Test Book Title") + ], + currentlyPlaying: nil + ) + ) + .previewContext(WidgetPreviewContext(family: .systemSmall)) + } } } -} #endif @main struct BookPlayerBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { -#if os(iOS) - LastPlayedWidget() - TimeListenedWidget() - if #available(iOSApplicationExtension 16.1, *) { + #if os(iOS) + LastPlayedWidget() + TimeListenedWidget() + if #available(iOSApplicationExtension 16.1, *) { + SharedWidget() + SharedIconWidget() + } + if #available(iOSApplicationExtension 18.0, *) { + LaunchAppButton() + } + #elseif os(watchOS) SharedWidget() SharedIconWidget() - } -#elseif os(watchOS) - SharedWidget() - SharedIconWidget() -#endif + #endif } } diff --git a/BookPlayerWidgets/Phone/LaunchAppControlWidgetView.swift b/BookPlayerWidgets/Phone/LaunchAppControlWidgetView.swift new file mode 100644 index 00000000..8b1a66e6 --- /dev/null +++ b/BookPlayerWidgets/Phone/LaunchAppControlWidgetView.swift @@ -0,0 +1,43 @@ +// +// LaunchAppControlWidgetView.swift +// BookPlayerWidgetsPhone +// +// Created by Gianni Carlo on 1/10/24. +// Copyright © 2024 Tortuga Power. All rights reserved. +// + +import AppIntents +import Foundation +import SwiftUI +import WidgetKit + +@available(iOSApplicationExtension 18.0, iOS 18.0, *) +struct LaunchAppButton: ControlWidget { + var body: some ControlWidgetConfiguration { + StaticControlConfiguration( + kind: "com.bookplayer.controlcenter.launchapp" + ) { + ControlWidgetButton(action: LaunchAppIntent()) { + Label("BookPlayer", image: "bookplayer.icon") + } + } + .displayName("BookPlayer") + } +} + +@available(iOSApplicationExtension 16, iOS 16.0, *) +struct LaunchAppIntent: OpenIntent { + static var title: LocalizedStringResource = "Launch App" + @Parameter(title: "Target") + var target: LaunchAppEnum +} + +@available(iOSApplicationExtension 16.0, iOS 16.0, *) +enum LaunchAppEnum: String, AppEnum { + case home + + static var typeDisplayRepresentation = TypeDisplayRepresentation("BookPlayer Home") + static var caseDisplayRepresentations = [ + LaunchAppEnum.home: DisplayRepresentation("Home") + ] +} From 805ddd9cbbdba8b032f823870ba5c766600beb80 Mon Sep 17 00:00:00 2001 From: Gianni Carlo Date: Wed, 2 Oct 2024 14:18:53 -0500 Subject: [PATCH 2/2] Update ci.yml --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1fe92ae..6260a592 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,11 @@ on: jobs: build: # https://github.com/actions/runner-images/tree/main/images/macos - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - # We only use Xcode 15.4 + # We only use Xcode 16.0 - name: Remove unused applications run: | df -hI /dev/disk3s1s1 @@ -26,8 +26,8 @@ jobs: - name: Create Debug.xcconfig run: cp ./BuildConfiguration/Debug.template.xcconfig ./BuildConfiguration/Debug.xcconfig - name: Set Xcode version - run: sudo xcode-select -s "/Applications/Xcode_15.4.app/Contents/Developer" + run: sudo xcode-select -s "/Applications/Xcode_16.app/Contents/Developer" - name: Resolve dependencies run: xcodebuild -resolvePackageDependencies - name: Build and Run tests - run: xcodebuild -scheme BookPlayer test -testPlan Unit\ Tests -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5' + run: xcodebuild -scheme BookPlayer test -testPlan Unit\ Tests -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.0'