-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Ammaar-Alam/app
building stable version of ios app
- Loading branch information
Showing
34 changed files
with
1,469 additions
and
507 deletions.
There are no files selected for viewing
344 changes: 56 additions & 288 deletions
344
Ammaar's Dorm Controls/Ammaar's Dorm Controls.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
...ls.xcodeproj/project.xcworkspace/xcuserdata/alam.xcuserdatad/IDEFindNavigatorScopes.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?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"> | ||
<array/> | ||
</plist> |
Binary file modified
BIN
+111 KB
(360%)
....xcodeproj/project.xcworkspace/xcuserdata/alam.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
6 changes: 0 additions & 6 deletions
6
... Dorm Controls.xcodeproj/xcuserdata/alam.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
Ammaar's Dorm Controls/Ammaar's Dorm Controls/Ammaar_s_Dorm_ControlsApp.swift
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
Ammaar's Dorm Controls/Ammaar's Dorm Controls/AppDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import UIKit | ||
import SwiftUI | ||
|
||
class AppDelegate: NSObject, UIApplicationDelegate { | ||
// The shortcut handling code for older iOS versions or the original code snippet | ||
// has been removed because we are using SceneDelegate for handling quick actions | ||
// in iOS 13+. | ||
// | ||
// This ensures no placeholders or duplicate code. The scene delegate will handle | ||
// shortcuts, so no changes are needed here. | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
return true | ||
} | ||
} |
146 changes: 146 additions & 0 deletions
146
Ammaar's Dorm Controls/Ammaar's Dorm Controls/AppIntents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import AppIntents | ||
import Foundation | ||
|
||
@available(iOS 17.0, *) | ||
enum DoorAction: String, CaseIterable, AppEnum { | ||
static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Door Action") | ||
|
||
case open = "open" | ||
case close = "close" | ||
case emergencyClose = "emergency-close" | ||
|
||
static var caseDisplayRepresentations: [DoorAction: DisplayRepresentation] = [ | ||
.open: DisplayRepresentation( | ||
title: "Open Door", | ||
subtitle: "Opens the dorm door", | ||
image: .init(systemName: "arrow.up.circle") | ||
), | ||
.close: DisplayRepresentation( | ||
title: "Close Door", | ||
subtitle: "Closes the dorm door", | ||
image: .init(systemName: "lock") | ||
), | ||
.emergencyClose: DisplayRepresentation( | ||
title: "Emergency Close", | ||
subtitle: "Force closes/untangles the door", | ||
image: .init(systemName: "exclamationmark.triangle") | ||
) | ||
] | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
struct DoorActionIntent: AppIntent { | ||
static var title: LocalizedStringResource = "Perform Door Action" | ||
static var description = IntentDescription("Choose an action to perform on the door (open, close, or emergency close).") | ||
|
||
@Parameter(title: "Action", default: .open) | ||
var action: DoorAction | ||
|
||
func perform() async throws -> some IntentResult & ProvidesDialog { | ||
try await performDoorCommand(action.rawValue) | ||
return .result(dialog: "Performed \(action) action on the door.") | ||
} | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
struct OpenDoorIntent: AppIntent { | ||
static var title: LocalizedStringResource = "Open Door" | ||
static var description = IntentDescription("Opens the dorm door immediately.") | ||
|
||
func perform() async throws -> some IntentResult & ProvidesDialog { | ||
try await performDoorCommand("open") | ||
return .result(dialog: "Door opened successfully!") | ||
} | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
struct OpenDoorIn3SecIntent: AppIntent { | ||
static var title: LocalizedStringResource = "Open Door (3 Seconds)" | ||
static var description = IntentDescription("Opens the door immediately, waits 3 seconds, then closes it.") | ||
|
||
func perform() async throws -> some IntentResult & ProvidesDialog { | ||
try await performDoorCommand("open") | ||
try await Task.sleep(nanoseconds: 3_000_000_000) | ||
try await performDoorCommand("close") | ||
return .result(dialog: "Opened, waited 3 seconds, and closed the door.") | ||
} | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
struct CloseDoorIntent: AppIntent { | ||
static var title: LocalizedStringResource = "Close Door" | ||
static var description = IntentDescription("Closes the dorm door.") | ||
|
||
func perform() async throws -> some IntentResult & ProvidesDialog { | ||
try await performDoorCommand("close") | ||
return .result(dialog: "Door closed successfully!") | ||
} | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
struct GetDoorStatusIntent: AppIntent, WidgetConfigurationIntent { | ||
static var title: LocalizedStringResource = "Door Status Configuration" | ||
static var description = IntentDescription("Configures the door status widget.") | ||
// No perform method needed. | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
extension AppIntent { | ||
func performDoorCommand(_ command: String) async throws { | ||
try await withCheckedThrowingContinuation { continuation in | ||
NetworkManager.shared.sendCommand(command: command) { result in | ||
switch result { | ||
case .success: | ||
continuation.resume() | ||
case .failure(let error): | ||
continuation.resume(throwing: error) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func getDoorStatus() async throws -> String { | ||
try await withCheckedThrowingContinuation { continuation in | ||
NetworkManager.shared.fetchDoorStatus { result in | ||
switch result { | ||
case .success(let status): | ||
continuation.resume(returning: status.doorOpen ? "Door is Open" : "Door is Closed") | ||
case .failure(let error): | ||
continuation.resume(throwing: error) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@available(iOS 17.0, *) | ||
struct DoorShortcutsProvider: AppShortcutsProvider { | ||
static var appShortcuts: [AppShortcut] { | ||
return [ | ||
AppShortcut( | ||
intent: OpenDoorIn3SecIntent(), | ||
phrases: ["Open door in three seconds"], | ||
shortTitle: "Open in 3s", | ||
systemImageName: "timer" | ||
), | ||
AppShortcut( | ||
intent: OpenDoorIntent(), | ||
phrases: ["Open door now"], | ||
shortTitle: "Open Now", | ||
systemImageName: "arrow.up.circle" | ||
), | ||
AppShortcut( | ||
intent: CloseDoorIntent(), | ||
phrases: ["Close the door"], | ||
shortTitle: "Close Door", | ||
systemImageName: "lock" | ||
), | ||
AppShortcut( | ||
intent: DoorActionIntent(), | ||
phrases: ["Perform a door action"], | ||
shortTitle: "Perform Door Action", | ||
systemImageName: "gear" | ||
) | ||
] | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
Ammaar's Dorm Controls/Ammaar's Dorm Controls/ContentView.swift
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
Ammaar's Dorm Controls/Ammaar's Dorm Controls/Models/AppError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
|
||
struct AppError: Identifiable { | ||
let id = UUID() | ||
let message: String | ||
} |
5 changes: 5 additions & 0 deletions
5
Ammaar's Dorm Controls/Ammaar's Dorm Controls/Models/AuthStatus.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
struct AuthStatus: Codable { | ||
let authRequired: Bool | ||
} |
2 changes: 2 additions & 0 deletions
2
Ammaar's Dorm Controls/Ammaar's Dorm Controls/Models/Constants.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Foundation | ||
// No global constants needed currently. |
6 changes: 6 additions & 0 deletions
6
Ammaar's Dorm Controls/Ammaar's Dorm Controls/Models/LoginResponse.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
|
||
struct LoginResponse: Codable { | ||
let message: String | ||
let token: String | ||
} |
23 changes: 23 additions & 0 deletions
23
Ammaar's Dorm Controls/Ammaar's Dorm Controls/MyDormDoorApp.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import SwiftUI | ||
|
||
@main | ||
struct MyDormDoorApp: App { | ||
@StateObject var doorViewModel = DoorControlViewModel() | ||
@StateObject var loginViewModel = LoginViewModel() | ||
@State private var pendingShortcutAction: ShortcutActionType? = nil | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
ContentView(pendingShortcutAction: $pendingShortcutAction) | ||
.environmentObject(doorViewModel) | ||
.environmentObject(loginViewModel) | ||
.onAppear { | ||
// If there was a shortcut action requested at launch, capture it now. | ||
if let action = SceneDelegate.requestedShortcutAction { | ||
pendingShortcutAction = action | ||
SceneDelegate.requestedShortcutAction = nil | ||
} | ||
} | ||
} | ||
} | ||
} |
76 changes: 0 additions & 76 deletions
76
Ammaar's Dorm Controls/Ammaar's Dorm Controls/NetworkManager.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.