mirror of
https://github.com/home-assistant/iOS.git
synced 2026-04-30 06:39:43 -05:00
Set CarPlay color icon based in car interface style and add confirmation for actions
This commit is contained in:
@@ -513,6 +513,10 @@
|
||||
425573CE2B5574F100145217 /* CarPlayAreasViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 425573CD2B5574F100145217 /* CarPlayAreasViewModel.swift */; };
|
||||
425573D12B5576E600145217 /* CarPlayDomainsListTemplate+Build.swift in Sources */ = {isa = PBXBuildFile; fileRef = 425573D02B5576E600145217 /* CarPlayDomainsListTemplate+Build.swift */; };
|
||||
425573D32B55770D00145217 /* CarPlayDomainsListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 425573D22B55770D00145217 /* CarPlayDomainsListViewModel.swift */; };
|
||||
425573E62B5838B600145217 /* MaterialDesignIcons+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA732B4FF9F8002729BC /* MaterialDesignIcons+CarPlay.swift */; };
|
||||
425573E72B5838BB00145217 /* HATypedRequest+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA572B46FDD8002729BC /* HATypedRequest+CarPlay.swift */; };
|
||||
425573E82B5838E300145217 /* HAAreaResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA6F2B4EE2E8002729BC /* HAAreaResponse.swift */; };
|
||||
425573E92B58396600145217 /* HAEntity+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66629BA003B00B19FBE /* HAEntity+CarPlay.swift */; };
|
||||
426740A92B17391000C1DD73 /* Data+Hexadecimal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 426740A72B17390A00C1DD73 /* Data+Hexadecimal.swift */; };
|
||||
4278DFD22B45C7AE0087C9D7 /* Core.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4278DFAF2B45C6680087C9D7 /* Core.strings */; };
|
||||
4278DFD32B45C7AE0087C9D7 /* Core.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4278DFAF2B45C6680087C9D7 /* Core.strings */; };
|
||||
@@ -528,23 +532,15 @@
|
||||
42CE8FB32B46C46F00C707F9 /* Domain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42CE8FAC2B46C12C00C707F9 /* Domain.swift */; };
|
||||
42CE8FB62B46D14C00C707F9 /* FrontendStrings+Values.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42CE8FB42B46CAFD00C707F9 /* FrontendStrings+Values.swift */; };
|
||||
42CE8FB72B46D14C00C707F9 /* FrontendStrings+Values.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42CE8FB42B46CAFD00C707F9 /* FrontendStrings+Values.swift */; };
|
||||
42CE8FB92B46D67A00C707F9 /* HAEntity+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66629BA003B00B19FBE /* HAEntity+CarPlay.swift */; };
|
||||
42CE8FBA2B46D67A00C707F9 /* HAEntity+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66629BA003B00B19FBE /* HAEntity+CarPlay.swift */; };
|
||||
42CE8FBB2B46DB6200C707F9 /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B65B15042273188300635D5C /* Assets.swift */; };
|
||||
42DD84132B14ACAB00936F16 /* Color+ColorAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42DD84122B14ACAB00936F16 /* Color+ColorAsset.swift */; };
|
||||
42DD84162B14D7AC00936F16 /* WebViewExternalBusMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42DD84142B14D68C00936F16 /* WebViewExternalBusMessage.swift */; };
|
||||
42DD84192B14D83B00936F16 /* WebViewExternalBusMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42DD84182B14D83B00936F16 /* WebViewExternalBusMessageTests.swift */; };
|
||||
42F1DA582B46FDD8002729BC /* HATypedRequest+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA572B46FDD8002729BC /* HATypedRequest+CarPlay.swift */; };
|
||||
42F1DA592B46FDD8002729BC /* HATypedRequest+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA572B46FDD8002729BC /* HATypedRequest+CarPlay.swift */; };
|
||||
42F1DA5F2B4D4B32002729BC /* CarPlayServerListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA5E2B4D4B32002729BC /* CarPlayServerListTemplate.swift */; };
|
||||
42F1DA612B4D4F31002729BC /* CarPlayNoServerAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA602B4D4F31002729BC /* CarPlayNoServerAlert.swift */; };
|
||||
42F1DA632B4D54CB002729BC /* CarPlayTemplateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA622B4D54CB002729BC /* CarPlayTemplateProvider.swift */; };
|
||||
42F1DA6B2B4ED1BF002729BC /* CarPlayAreasZonesTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA6A2B4ED1BF002729BC /* CarPlayAreasZonesTemplate.swift */; };
|
||||
42F1DA6D2B4ED29C002729BC /* CarPlayPaginatedListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA6C2B4ED29C002729BC /* CarPlayPaginatedListTemplate.swift */; };
|
||||
42F1DA712B4EE2FD002729BC /* HAAreaResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA6F2B4EE2E8002729BC /* HAAreaResponse.swift */; };
|
||||
42F1DA722B4EE2FE002729BC /* HAAreaResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA6F2B4EE2E8002729BC /* HAAreaResponse.swift */; };
|
||||
42F1DA752B4FFA21002729BC /* MaterialDesignIcons+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA732B4FF9F8002729BC /* MaterialDesignIcons+CarPlay.swift */; };
|
||||
42F1DA762B4FFA22002729BC /* MaterialDesignIcons+CarPlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F1DA732B4FF9F8002729BC /* MaterialDesignIcons+CarPlay.swift */; };
|
||||
42F5CAB92B10AD9800409816 /* ThreadCredentialsSharingViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F5CAB82B10AD9800409816 /* ThreadCredentialsSharingViewModelTests.swift */; };
|
||||
42F5CABC2B10AE1A00409816 /* ServerFixture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42F5CABB2B10AE1A00409816 /* ServerFixture.swift */; };
|
||||
42F5CAE52B10CDC600409816 /* HACornerRadius.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42CA28AD2B101D4D0093B31A /* HACornerRadius.swift */; };
|
||||
@@ -1610,6 +1606,7 @@
|
||||
425573CD2B5574F100145217 /* CarPlayAreasViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlayAreasViewModel.swift; sourceTree = "<group>"; };
|
||||
425573D02B5576E600145217 /* CarPlayDomainsListTemplate+Build.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CarPlayDomainsListTemplate+Build.swift"; sourceTree = "<group>"; };
|
||||
425573D22B55770D00145217 /* CarPlayDomainsListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlayDomainsListViewModel.swift; sourceTree = "<group>"; };
|
||||
425573E42B58380D00145217 /* CarPlay.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CarPlay.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/iOSSupport/System/Library/Frameworks/CarPlay.framework; sourceTree = DEVELOPER_DIR; };
|
||||
426740A72B17390A00C1DD73 /* Data+Hexadecimal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Hexadecimal.swift"; sourceTree = "<group>"; };
|
||||
4278DFB02B45C6680087C9D7 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Core.strings; sourceTree = "<group>"; };
|
||||
4278DFB12B45C6680087C9D7 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Core.strings"; sourceTree = "<group>"; };
|
||||
@@ -2985,6 +2982,7 @@
|
||||
29278BB24639BA945D3D86B4 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
425573E42B58380D00145217 /* CarPlay.framework */,
|
||||
422894BF2B03B76200C1DAFB /* ThreadNetwork.framework */,
|
||||
11B63B0E297A19DC00D908ED /* MatterSupport.framework */,
|
||||
1112EA92271B78690038BBFC /* UserNotifications.framework */,
|
||||
@@ -3151,16 +3149,6 @@
|
||||
path = Tests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
42F1DA562B46FDC5002729BC /* CarPlay */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
42F1DA6E2B4EE2CE002729BC /* Responses */,
|
||||
42F1DA572B46FDD8002729BC /* HATypedRequest+CarPlay.swift */,
|
||||
42F1DA732B4FF9F8002729BC /* MaterialDesignIcons+CarPlay.swift */,
|
||||
);
|
||||
path = CarPlay;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
42F1DA6E2B4EE2CE002729BC /* Responses */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -3768,7 +3756,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
426740A42B17348700C1DD73 /* Assets */,
|
||||
42F1DA562B46FDC5002729BC /* CarPlay */,
|
||||
42CE8FAB2B46C11E00C707F9 /* Domain */,
|
||||
42CA28AC2B101D320093B31A /* DesignSystem */,
|
||||
11B38EE0275C545C00205C7B /* Intents */,
|
||||
@@ -3839,7 +3826,6 @@
|
||||
D0A6367320DBE91300E5C49B /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FD3BC66629BA003B00B19FBE /* HAEntity+CarPlay.swift */,
|
||||
B6DF8BC0221C890600370A59 /* UIImageView+UIActivityIndicator.swift */,
|
||||
B6B6B14B215B1E86003DE2DD /* CLKComplication+Strings.swift */,
|
||||
114E9B4D24E89B1300B43EED /* INImage+MaterialDesignIcons.swift */,
|
||||
@@ -4021,6 +4007,10 @@
|
||||
42F1DA602B4D4F31002729BC /* CarPlayNoServerAlert.swift */,
|
||||
42F1DA622B4D54CB002729BC /* CarPlayTemplateProvider.swift */,
|
||||
42F1DA6C2B4ED29C002729BC /* CarPlayPaginatedListTemplate.swift */,
|
||||
42F1DA732B4FF9F8002729BC /* MaterialDesignIcons+CarPlay.swift */,
|
||||
42F1DA572B46FDD8002729BC /* HATypedRequest+CarPlay.swift */,
|
||||
FD3BC66629BA003B00B19FBE /* HAEntity+CarPlay.swift */,
|
||||
42F1DA6E2B4EE2CE002729BC /* Responses */,
|
||||
);
|
||||
path = Templates;
|
||||
sourceTree = "<group>";
|
||||
@@ -5578,6 +5568,7 @@
|
||||
1185DFB4271FF53800ED7D9A /* OnboardingAuthStepModels.swift in Sources */,
|
||||
11F3B85C24C4295200642676 /* EurekaLocationRow.swift in Sources */,
|
||||
B6DA3C7322691A5000DE811C /* AKConverter.swift in Sources */,
|
||||
425573E92B58396600145217 /* HAEntity+CarPlay.swift in Sources */,
|
||||
B68EDD05215F12C900DD6B28 /* NotificationActionConfigurator.swift in Sources */,
|
||||
B616B299227ED68E00828165 /* Bonjour.swift in Sources */,
|
||||
11A48D7F24CA7E820021BDD9 /* Action+Observation.swift in Sources */,
|
||||
@@ -5586,6 +5577,7 @@
|
||||
42F5CAEC2B10CED600409816 /* ThreadCredentialsSharingView.swift in Sources */,
|
||||
1112AE9B25F71775007A541A /* LocationHistoryListViewController.swift in Sources */,
|
||||
B68EDD03215F0E2900DD6B28 /* NotificationCategoryConfigurator.swift in Sources */,
|
||||
425573E72B5838BB00145217 /* HATypedRequest+CarPlay.swift in Sources */,
|
||||
D0FF79D220D87D200034574D /* ClientEventTableViewController.swift in Sources */,
|
||||
117D8A0824A9347F00580913 /* UIColor+CSSRGB.swift in Sources */,
|
||||
42F5CAE92B10CED600409816 /* ThreadCredentialsSharingViewModel.swift in Sources */,
|
||||
@@ -5652,6 +5644,7 @@
|
||||
11E7C4B02702E03000667342 /* WidgetOpenPageIntent+Observation.swift in Sources */,
|
||||
1187DE4624D7E1BD00F0A6A6 /* SimulatorNFCManager.swift in Sources */,
|
||||
1185DF96271FBB9800ED7D9A /* OnboardingAuthLogin.swift in Sources */,
|
||||
425573E62B5838B600145217 /* MaterialDesignIcons+CarPlay.swift in Sources */,
|
||||
42F1DA612B4D4F31002729BC /* CarPlayNoServerAlert.swift in Sources */,
|
||||
11C590ED24A832CA0066085D /* YamlSection.swift in Sources */,
|
||||
11EFCDD624F5FA8D00314D85 /* WebViewSceneDelegate.swift in Sources */,
|
||||
@@ -5683,6 +5676,7 @@
|
||||
B605C891226E9DAC00EF46DD /* Permissions.swift in Sources */,
|
||||
425573D32B55770D00145217 /* CarPlayDomainsListViewModel.swift in Sources */,
|
||||
1169B7AD25AA76E30035F2AE /* MaterialDesignIcons+Eureka.swift in Sources */,
|
||||
425573E82B5838E300145217 /* HAAreaResponse.swift in Sources */,
|
||||
11F55ECD25D3A364003977AC /* NotificationRateLimitViewController.swift in Sources */,
|
||||
42F5CAEB2B10CED600409816 /* ThreadCredentialsSharing+build.swift in Sources */,
|
||||
117EBC32261D398B00F5334A /* ZoneManagerAccuracyFuzzer.swift in Sources */,
|
||||
@@ -5820,13 +5814,11 @@
|
||||
110ED59025A6743900489AF7 /* ConnectivityWrapper.swift in Sources */,
|
||||
1110836924AFEFA60027A67A /* Promise+WebhookJson.swift in Sources */,
|
||||
1164D9DF25FB1B9800515E8A /* UIBarButtonItem+Additions.swift in Sources */,
|
||||
42F1DA592B46FDD8002729BC /* HATypedRequest+CarPlay.swift in Sources */,
|
||||
11B38EF6275C54A300205C7B /* PickAServerError.swift in Sources */,
|
||||
B67CE8AF22200F220034C1D0 /* ObjectMapperTransformers.swift in Sources */,
|
||||
11AF4D13249C7E08006C74C0 /* ActivitySensor.swift in Sources */,
|
||||
11E5CF8224BBCE1B009AC30F /* ProcessInfo+BackgroundTask.swift in Sources */,
|
||||
11AF4D1D249C8AA0006C74C0 /* BatterySensor.swift in Sources */,
|
||||
42CE8FBA2B46D67A00C707F9 /* HAEntity+CarPlay.swift in Sources */,
|
||||
B67CE8A922200F220034C1D0 /* SettingsStore.swift in Sources */,
|
||||
11AF4D26249D1931006C74C0 /* LastUpdateSensor.swift in Sources */,
|
||||
11EE9B4A24C5116F00404AF8 /* ModelManager.swift in Sources */,
|
||||
@@ -5834,7 +5826,6 @@
|
||||
B67CE8B622200F220034C1D0 /* UIColor+HA.swift in Sources */,
|
||||
11B63B0B2979A07000D908ED /* AssistIntentHandler.swift in Sources */,
|
||||
1115044E2528485200DCFA94 /* WatchHelpers.swift in Sources */,
|
||||
42F1DA722B4EE2FE002729BC /* HAAreaResponse.swift in Sources */,
|
||||
1133F59D25F1DA5D00AD776F /* CLLocation+Sanitize.swift in Sources */,
|
||||
B67CE8B522200F220034C1D0 /* String+HA.swift in Sources */,
|
||||
11169BC6262BE45F005EF90A /* UNNotificationContent+Additions.swift in Sources */,
|
||||
@@ -5944,7 +5935,6 @@
|
||||
1101568824D7712F009424C9 /* TagManagerProtocol.swift in Sources */,
|
||||
111858D724CB620600B8CDDC /* Intents.intentdefinition in Sources */,
|
||||
B67CE89D22200F220034C1D0 /* Config.swift in Sources */,
|
||||
42F1DA762B4FFA22002729BC /* MaterialDesignIcons+CarPlay.swift in Sources */,
|
||||
11F855D924DF6C7A0018013E /* MaterialDesignIcons.swift in Sources */,
|
||||
11EE9B5524C62EB300404AF8 /* RealmScene.swift in Sources */,
|
||||
11AF4D20249C8AF1006C74C0 /* ConnectivitySensor.swift in Sources */,
|
||||
@@ -5995,7 +5985,6 @@
|
||||
118BDA8825A6DBBA00731016 /* FrontmostAppSensor.swift in Sources */,
|
||||
11EE9B4624C4E01500404AF8 /* SharedPlist.swift in Sources */,
|
||||
1110836824AFEFA60027A67A /* Promise+WebhookJson.swift in Sources */,
|
||||
42F1DA712B4EE2FD002729BC /* HAAreaResponse.swift in Sources */,
|
||||
42CE8FB22B46C46E00C707F9 /* Domain.swift in Sources */,
|
||||
42F5CAE72B10CDC900409816 /* CardView.swift in Sources */,
|
||||
42DD84132B14ACAB00936F16 /* Color+ColorAsset.swift in Sources */,
|
||||
@@ -6015,7 +6004,6 @@
|
||||
42CE8FA92B45D1E900C707F9 /* FrontendStrings.swift in Sources */,
|
||||
D0EEF335214EB77100D1D360 /* CLLocation+Extensions.swift in Sources */,
|
||||
11AF4D1F249C8AF1006C74C0 /* ConnectivitySensor.swift in Sources */,
|
||||
42CE8FB92B46D67A00C707F9 /* HAEntity+CarPlay.swift in Sources */,
|
||||
11B38EED275C54A200205C7B /* RenderTemplateIntentHandler.swift in Sources */,
|
||||
B6723341225DB82E0031D629 /* KeyedDecodingContainer+JSON.swift in Sources */,
|
||||
11C4629124B14E6B00031902 /* XCGLogger+UNNotification.swift in Sources */,
|
||||
@@ -6073,7 +6061,6 @@
|
||||
D03D893B20E0B2E300D4F28D /* Constants.swift in Sources */,
|
||||
119DE933263325C20099F7D8 /* IconDrawable+Settings.swift in Sources */,
|
||||
114CBAE82839E49E00A9BAFF /* CustomServerTrustManager.swift in Sources */,
|
||||
42F1DA752B4FFA21002729BC /* MaterialDesignIcons+CarPlay.swift in Sources */,
|
||||
1128FF3C297F49D900BAAFD9 /* Locale+IntentLanguage.swift in Sources */,
|
||||
D03D893520E0AEF100D4F28D /* Realm+Initialization.swift in Sources */,
|
||||
D0EEF2C9214D89A700D1D360 /* HAAPI+RequestHelpers.swift in Sources */,
|
||||
@@ -6119,7 +6106,6 @@
|
||||
11C4628E24B128EF00031902 /* WebhookResponseUnhandled.swift in Sources */,
|
||||
1121CD4C271295AD0071C2AA /* Style.swift in Sources */,
|
||||
116570772702B0F6003906A7 /* DiskCache.swift in Sources */,
|
||||
42F1DA582B46FDD8002729BC /* HATypedRequest+CarPlay.swift in Sources */,
|
||||
11657050270188E4003906A7 /* URLComponents+WidgetAuthenticity.swift in Sources */,
|
||||
B672334A225DDF410031D629 /* Event.swift in Sources */,
|
||||
B6C091232151F90300A326DC /* LocationHistory.swift in Sources */,
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public extension MaterialDesignIcons {
|
||||
func carPlayIcon(color: UIColor? = .white) -> UIImage {
|
||||
image(ofSize: .init(width: 64, height: 64), color: color)
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public extension MaterialDesignIcons {
|
||||
}
|
||||
}
|
||||
|
||||
internal extension String {
|
||||
public extension String {
|
||||
var normalizingIconString: String {
|
||||
let base = replacingOccurrences(of: "mdi:|hass:", with: "", options: .regularExpression)
|
||||
.replacingOccurrences(of: ":", with: "_")
|
||||
|
||||
@@ -59,7 +59,7 @@ public enum Domain: String, CaseIterable {
|
||||
return states
|
||||
}
|
||||
|
||||
public var icon: UIImage {
|
||||
public var icon: MaterialDesignIcons {
|
||||
var image = MaterialDesignIcons.bookmarkIcon
|
||||
switch self {
|
||||
case .button:
|
||||
@@ -81,7 +81,7 @@ public enum Domain: String, CaseIterable {
|
||||
case .switch:
|
||||
image = MaterialDesignIcons.lightSwitchIcon
|
||||
}
|
||||
return image.carPlayIcon()
|
||||
return image
|
||||
}
|
||||
|
||||
public var localizedDescription: String {
|
||||
|
||||
@@ -16,7 +16,7 @@ final class CarPlayActionsTemplate: CarPlayTemplateProvider {
|
||||
self.viewModel = viewModel
|
||||
self.template = CPListTemplate(title: L10n.CarPlay.Navigation.Tab.actions, sections: [])
|
||||
template.tabTitle = L10n.CarPlay.Navigation.Tab.actions
|
||||
template.tabImage = MaterialDesignIcons.lightningBoltIcon.carPlayIcon(color: nil)
|
||||
template.tabImage = MaterialDesignIcons.lightningBoltIcon.carPlayIcon()
|
||||
template.tabSystemItem = .more
|
||||
|
||||
self.viewModel.templateProvider = self
|
||||
@@ -46,14 +46,23 @@ final class CarPlayActionsTemplate: CarPlayTemplateProvider {
|
||||
private func section(actions: Results<Action>) -> CPListSection {
|
||||
let items: [CPListItem] = actions.map { action in
|
||||
let materialDesignIcon = MaterialDesignIcons(named: action.IconName)
|
||||
.image(ofSize: CPListItem.maximumImageSize, color: UIColor(hex: action.IconColor))
|
||||
.carPlayIcon(carUserInterfaceStyle: interfaceController?.carTraitCollection.userInterfaceStyle)
|
||||
let item = CPListItem(
|
||||
text: action.Name,
|
||||
detailText: action.Text,
|
||||
image: materialDesignIcon
|
||||
)
|
||||
item.handler = { [weak self] _, completion in
|
||||
self?.viewModel.handleAction(action: action, completion: completion)
|
||||
item.handler = { [weak self] _, _ in
|
||||
self?.viewModel.handleAction(action: action) { success in
|
||||
if success {
|
||||
item.setImage(MaterialDesignIcons.checkIcon.carPlayIcon(color: Constants.tintColor))
|
||||
} else {
|
||||
item.setImage(MaterialDesignIcons.closeIcon.carPlayIcon(color: .red))
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||
item.setImage(materialDesignIcon)
|
||||
}
|
||||
}
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
@@ -24,19 +24,19 @@ final class CarPlayActionsViewModel {
|
||||
actionsToken?.invalidate()
|
||||
}
|
||||
|
||||
func handleAction(action: Action, completion: @escaping () -> Void) {
|
||||
func handleAction(action: Action, completion: @escaping (Bool) -> Void) {
|
||||
guard let server = Current.servers.server(for: action) else {
|
||||
completion()
|
||||
completion(false)
|
||||
return
|
||||
}
|
||||
Current.api(for: server).HandleAction(actionID: action.ID, source: .CarPlay).pipe { result in
|
||||
switch result {
|
||||
case .fulfilled:
|
||||
break
|
||||
completion(true)
|
||||
case let .rejected(error):
|
||||
Current.Log.info(error)
|
||||
completion(false)
|
||||
}
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ final class CarPlayAreasZonesTemplate: CarPlayTemplateProvider {
|
||||
init(viewModel: CarPlayAreasViewModel) {
|
||||
self.viewModel = viewModel
|
||||
self.template = CPListTemplate(title: "", sections: [])
|
||||
template.tabImage = MaterialDesignIcons.sofaIcon.carPlayIcon(color: Constants.tintColor)
|
||||
template.tabImage = MaterialDesignIcons.sofaIcon.carPlayIcon()
|
||||
template.tabTitle = L10n.CarPlay.Navigation.Tab.areas
|
||||
|
||||
viewModel.templateProvider = self
|
||||
|
||||
@@ -18,7 +18,7 @@ class CarPlayDomainsListTemplate: CarPlayTemplateProvider {
|
||||
listTemplate.emptyViewSubtitleVariants = [L10n.CarPlay.Labels.emptyDomainList]
|
||||
self.template = listTemplate
|
||||
template.tabTitle = L10n.CarPlay.Navigation.Tab.domains
|
||||
template.tabImage = MaterialDesignIcons.devicesIcon.carPlayIcon(color: nil)
|
||||
template.tabImage = MaterialDesignIcons.devicesIcon.carPlayIcon()
|
||||
|
||||
viewModel.templateProvider = self
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ final class CarPlayDomainsListViewModel {
|
||||
private var entities: HACache<HACachedStates>?
|
||||
private var entitiesSubscriptionToken: HACancellable?
|
||||
private var domainsCurrentlyInList: [Domain] = []
|
||||
private let overrideCoverIcon = MaterialDesignIcons.garageLockIcon.carPlayIcon()
|
||||
private let overrideCoverIcon = MaterialDesignIcons.garageLockIcon
|
||||
|
||||
weak var templateProvider: CarPlayDomainsListTemplate?
|
||||
|
||||
@@ -48,13 +48,15 @@ final class CarPlayDomainsListViewModel {
|
||||
// Prevent unecessary update and UI glitch for non-touch screen CarPlay
|
||||
guard domainsCurrentlyInList != domains else { return }
|
||||
domainsCurrentlyInList = domains
|
||||
|
||||
let userInterfaceStyle = templateProvider?.interfaceController?.carTraitCollection.userInterfaceStyle
|
||||
domains.forEach { domain in
|
||||
let itemTitle = domain.localizedDescription
|
||||
let listItem = CPListItem(
|
||||
text: itemTitle,
|
||||
detailText: nil,
|
||||
image: domain == .cover ? overrideCoverIcon : domain.icon
|
||||
image: domain == .cover ? overrideCoverIcon
|
||||
.carPlayIcon(carUserInterfaceStyle: userInterfaceStyle) : domain.icon
|
||||
.carPlayIcon(carUserInterfaceStyle: userInterfaceStyle)
|
||||
)
|
||||
listItem.accessoryType = CPListItemAccessoryType.disclosureIndicator
|
||||
listItem.handler = { [weak self] _, completion in
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import Foundation
|
||||
import HAKit
|
||||
import PromiseKit
|
||||
import Shared
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
public extension HAEntity {
|
||||
extension HAEntity {
|
||||
enum DeviceClass: String {
|
||||
case garage
|
||||
case gate
|
||||
@@ -1,7 +1,8 @@
|
||||
import Foundation
|
||||
import HAKit
|
||||
import Shared
|
||||
|
||||
public extension HATypedRequest {
|
||||
extension HATypedRequest {
|
||||
static func toggleDomain(
|
||||
domain: Domain,
|
||||
entityId: String
|
||||
17
Sources/Vehicle/Templates/MaterialDesignIcons+CarPlay.swift
Normal file
17
Sources/Vehicle/Templates/MaterialDesignIcons+CarPlay.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
import CarPlay
|
||||
import Foundation
|
||||
import Shared
|
||||
import UIKit
|
||||
|
||||
extension MaterialDesignIcons {
|
||||
func carPlayIcon(color: UIColor? = nil, carUserInterfaceStyle: UIUserInterfaceStyle? = nil) -> UIImage {
|
||||
let color: UIColor = color ?? {
|
||||
if let carUserInterfaceStyle, carUserInterfaceStyle == .light {
|
||||
.black
|
||||
} else {
|
||||
.white
|
||||
}
|
||||
}()
|
||||
return image(ofSize: CPListItem.maximumImageSize, color: color)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
import Foundation
|
||||
import HAKit
|
||||
|
||||
public struct HAAreaResponse: HADataDecodable {
|
||||
public let aliases: [String]
|
||||
public let areaId: String
|
||||
public let name: String
|
||||
public let picture: String?
|
||||
struct HAAreaResponse: HADataDecodable {
|
||||
let aliases: [String]
|
||||
let areaId: String
|
||||
let name: String
|
||||
let picture: String?
|
||||
|
||||
public init(data: HAData) throws {
|
||||
init(data: HAData) throws {
|
||||
self.init(
|
||||
aliases: try data.decode("aliases"),
|
||||
areaId: try data.decode("area_id"),
|
||||
@@ -24,12 +24,12 @@ public struct HAAreaResponse: HADataDecodable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct HAEntityAreaResponse: HADataDecodable {
|
||||
public let areaId: String?
|
||||
public let entityId: String?
|
||||
public let deviceId: String?
|
||||
struct HAEntityAreaResponse: HADataDecodable {
|
||||
let areaId: String?
|
||||
let entityId: String?
|
||||
let deviceId: String?
|
||||
|
||||
public init(data: HAData) throws {
|
||||
init(data: HAData) throws {
|
||||
self.init(
|
||||
areaId: try? data.decode("area_id"),
|
||||
entityId: try? data.decode("entity_id"),
|
||||
@@ -44,11 +44,11 @@ public struct HAEntityAreaResponse: HADataDecodable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct HADeviceAreaResponse: HADataDecodable {
|
||||
public let areaId: String?
|
||||
public let deviceId: String?
|
||||
struct HADeviceAreaResponse: HADataDecodable {
|
||||
let areaId: String?
|
||||
let deviceId: String?
|
||||
|
||||
public init(data: HAData) throws {
|
||||
init(data: HAData) throws {
|
||||
self.init(
|
||||
areaId: try? data.decode("area_id"),
|
||||
deviceId: try? data.decode("id")
|
||||
@@ -20,7 +20,7 @@ final class CarPlayServersListTemplate: CarPlayTemplateProvider {
|
||||
self.viewModel = viewModel
|
||||
self.template = CPListTemplate(title: "", sections: [])
|
||||
template.tabTitle = L10n.CarPlay.Labels.servers
|
||||
template.tabImage = MaterialDesignIcons.cogIcon.carPlayIcon(color: nil)
|
||||
template.tabImage = MaterialDesignIcons.cogIcon.carPlayIcon()
|
||||
|
||||
viewModel.templateProvider = self
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user