Skip to content

Commit

Permalink
Version 2.0.0 (#5)
Browse files Browse the repository at this point in the history
New Pi Monitor Widget
iPad OS support
  • Loading branch information
Bunn authored Oct 2, 2020
1 parent 69222ba commit bbb8457
Show file tree
Hide file tree
Showing 30 changed files with 1,030 additions and 109 deletions.
42 changes: 42 additions & 0 deletions PiStatsMobile/IntentHandler/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>IntentHandler</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IntentsRestrictedWhileLocked</key>
<array/>
<key>IntentsRestrictedWhileProtectedDataUnavailable</key>
<array/>
<key>IntentsSupported</key>
<array>
<string>SelectPiholeIntent</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.intents-service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).IntentHandler</string>
</dict>
</dict>
</plist>
10 changes: 10 additions & 0 deletions PiStatsMobile/IntentHandler/IntentHandler.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.dev.bunn.PiStatsMobile</string>
</array>
</dict>
</plist>
40 changes: 40 additions & 0 deletions PiStatsMobile/IntentHandler/IntentHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// IntentHandler.swift
// IntentHandler
//
// Created by Fernando Bunn on 30/09/2020.
//

import Intents

class IntentHandler: INExtension, SelectPiholeIntentHandling {

func providePiholeOptionsCollection(for intent: SelectPiholeIntent, with completion: @escaping (INObjectCollection<PiholeIntent>?, Error?) -> Void) {
let piholes = validPiholes().map {
PiholeIntent(
identifier: $0.id.uuidString,
display: $0.title
)
}
let collection = INObjectCollection(items: piholes)
completion(collection, nil)
}

func defaultPihole(for intent: SelectPiholeIntent) -> PiholeIntent? {
if let pihole = validPiholes().first {
return PiholeIntent(
identifier: pihole.id.uuidString,
display: pihole.title
)
}
return nil
}

override func handler(for intent: INIntent) -> Any {
return self
}

private func validPiholes() -> [Pihole] {
Pihole.restoreAll().filter{ $0.hasPiMonitor }
}
}
248 changes: 238 additions & 10 deletions PiStatsMobile/PiStatsMobile.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/Bunn/PiMonitor",
"state": {
"branch": null,
"revision": "a89879d3fb601871361dfc1f6b9d6cd7c4c42a11",
"version": "0.0.4"
"revision": "c0dbc72b466e437de94041948c576dc318e9af8a",
"version": "0.0.5"
}
},
{
Expand Down
167 changes: 167 additions & 0 deletions PiStatsMobile/PiStatsMobile/Base.lproj/PiholeIntents.intentdefinition
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>INEnums</key>
<array/>
<key>INIntentDefinitionModelVersion</key>
<string>1.2</string>
<key>INIntentDefinitionNamespace</key>
<string>pwIO52</string>
<key>INIntentDefinitionSystemVersion</key>
<string>19H2</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>12A7300</string>
<key>INIntentDefinitionToolsVersion</key>
<string>12.0.1</string>
<key>INIntents</key>
<array>
<dict>
<key>INIntentCategory</key>
<string>information</string>
<key>INIntentDescription</key>
<string>Select Pihole to display stats</string>
<key>INIntentDescriptionID</key>
<string>9VVPSk</string>
<key>INIntentEligibleForWidgets</key>
<true/>
<key>INIntentIneligibleForSuggestions</key>
<true/>
<key>INIntentLastParameterTag</key>
<integer>2</integer>
<key>INIntentName</key>
<string>SelectPihole</string>
<key>INIntentParameters</key>
<array>
<dict>
<key>INIntentParameterConfigurable</key>
<true/>
<key>INIntentParameterDisplayName</key>
<string>Pihole</string>
<key>INIntentParameterDisplayNameID</key>
<string>PiJeMO</string>
<key>INIntentParameterDisplayPriority</key>
<integer>1</integer>
<key>INIntentParameterName</key>
<string>pihole</string>
<key>INIntentParameterObjectType</key>
<string>PiholeIntent</string>
<key>INIntentParameterObjectTypeNamespace</key>
<string>pwIO52</string>
<key>INIntentParameterPromptDialogs</key>
<array>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Configuration</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Primary</string>
</dict>
</array>
<key>INIntentParameterSupportsDynamicEnumeration</key>
<true/>
<key>INIntentParameterTag</key>
<integer>2</integer>
<key>INIntentParameterType</key>
<string>Object</string>
</dict>
</array>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeName</key>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
</dict>
<key>INIntentTitle</key>
<string>Select Pihole</string>
<key>INIntentTitleID</key>
<string>XxlkUM</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>View</string>
</dict>
</array>
<key>INTypes</key>
<array>
<dict>
<key>INTypeDisplayName</key>
<string>Pihole Intent</string>
<key>INTypeDisplayNameID</key>
<string>YlcCql</string>
<key>INTypeLastPropertyTag</key>
<integer>100</integer>
<key>INTypeName</key>
<string>PiholeIntent</string>
<key>INTypeProperties</key>
<array>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>1</integer>
<key>INTypePropertyName</key>
<string>identifier</string>
<key>INTypePropertyTag</key>
<integer>1</integer>
<key>INTypePropertyType</key>
<string>String</string>
</dict>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>2</integer>
<key>INTypePropertyName</key>
<string>displayString</string>
<key>INTypePropertyTag</key>
<integer>2</integer>
<key>INTypePropertyType</key>
<string>String</string>
</dict>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>3</integer>
<key>INTypePropertyName</key>
<string>pronunciationHint</string>
<key>INTypePropertyTag</key>
<integer>3</integer>
<key>INTypePropertyType</key>
<string>String</string>
</dict>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>4</integer>
<key>INTypePropertyName</key>
<string>alternativeSpeakableMatches</string>
<key>INTypePropertySupportsMultipleValues</key>
<true/>
<key>INTypePropertyTag</key>
<integer>4</integer>
<key>INTypePropertyType</key>
<string>SpeakableString</string>
</dict>
</array>
</dict>
</array>
</dict>
</plist>
11 changes: 0 additions & 11 deletions PiStatsMobile/PiStatsMobile/PiStatsMobileApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ final class DataModel: ObservableObject {
let piholeProviderListManager = PiholeDataProviderListManager()
let userPreferences = UserPreferences.shared
private var offlineBadgeCancellable: AnyCancellable?

init() {
setupCancellables()
}

private func setupCancellables() {
offlineBadgeCancellable = userPreferences.$displayIconBadgeForOfflinePiholes.receive(on: DispatchQueue.main).sink { [weak self] value in
self?.piholeProviderListManager.shouldUpdateIconBadgeWithOfflinePiholes = value
}
}
}

@main
Expand All @@ -35,6 +25,5 @@ struct PiStatsMobileApp: App {
.environmentObject(dataModel.piholeProviderListManager)
.environmentObject(dataModel.userPreferences)
}

}
}
4 changes: 4 additions & 0 deletions PiStatsMobile/PiStatsMobile/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>Camera permission is necessary to read the API Token QRCode</string>
<key>NSUserActivityTypes</key>
<array>
<string>SelectPiholeIntent</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
12 changes: 12 additions & 0 deletions PiStatsMobile/PiStatsMobile/Utils/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Constants.swift
// PiStatsMobile
//
// Created by Fernando Bunn on 02/10/2020.
//

import Foundation

struct Constants {
static let appGroup = "group.dev.bunn.PiStatsMobile"
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DisableDurationManager: ObservableObject {
}

func addNewItem() {
items.append(DisableTimeItem(timeInterval: 30))
items.append(DisableTimeItem(timeInterval: 0))
setupCancellables()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
extension UserDefaults {

static func shared() -> UserDefaults {
let appGroup = "group.dev.bunn.PiStatsMobile"
return UserDefaults(suiteName: appGroup)!
return UserDefaults(suiteName: Constants.appGroup)!
}
}
24 changes: 24 additions & 0 deletions PiStatsMobile/PiStatsMobile/Utils/ViewUtils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ViewUtils.swift
// PiStatsMobile
//
// Created by Fernando Bunn on 01/10/2020.
//

import SwiftUI

struct ViewUtils {

static func shieldStatusImageForDataProvider(_ dataProvider: PiholeDataProvider) -> some View {
if dataProvider.hasErrorMessages || dataProvider.status == .enabledAndDisabled {
return Image(systemName: UIConstants.SystemImages.piholeStatusWarning)
.foregroundColor(UIConstants.Colors.statusWarning)
} else if dataProvider.status == .allEnabled {
return Image(systemName: UIConstants.SystemImages.piholeStatusOnline)
.foregroundColor(UIConstants.Colors.statusOnline)
} else {
return Image(systemName: UIConstants.SystemImages.piholeStatusOffline)
.foregroundColor(UIConstants.Colors.statusOffline)
}
}
}
4 changes: 2 additions & 2 deletions PiStatsMobile/PiStatsMobile/Views/Piholes/MetricsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI
import PiMonitor

struct MetricItem: Identifiable {
fileprivate struct MetricItem: Identifiable {
let value: String
let systemName: String
let helpText: String
Expand All @@ -19,7 +19,7 @@ struct MetricsView: View {
@ObservedObject var dataProvider: PiholeDataProvider
private let imageSize: CGFloat = 15

func getMetricItems() -> [MetricItem] {
private func getMetricItems() -> [MetricItem] {
return [
MetricItem(value: dataProvider.temperature, systemName: UIConstants.SystemImages.metricTemperature, helpText: "Raspberry Pi temperature"),
MetricItem(value: dataProvider.uptime, systemName: UIConstants.SystemImages.metricUptime, helpText: "Raspberry Pi uptime"),
Expand Down
Loading

0 comments on commit bbb8457

Please sign in to comment.