-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,701 additions
and
15 deletions.
There are no files selected for viewing
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
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
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,60 @@ | ||
// | ||
// WatchSessionService.swift | ||
// WatchOak Extension | ||
// | ||
// Created by Alex Catchpole on 19/05/2021. | ||
// | ||
|
||
import Foundation | ||
import WatchConnectivity | ||
|
||
class WatchSessionService: NSObject, WCSessionDelegate { | ||
static let sharedManager = WatchSessionService() | ||
|
||
private override init() { | ||
super.init() | ||
} | ||
|
||
private let session: WCSession? = WCSession.isSupported() ? WCSession.default : nil | ||
|
||
private var validSession: WCSession? { | ||
|
||
// paired - the user has to have their device paired to the watch | ||
// watchAppInstalled - the user must have your watch app installed | ||
|
||
// Note: if the device is paired, but your watch app is not installed | ||
// consider prompting the user to install it for a better experience | ||
|
||
if let session = session, session.isPaired && session.isWatchAppInstalled { | ||
return session | ||
} | ||
return nil | ||
} | ||
|
||
func startSession() { | ||
session?.delegate = self | ||
session?.activate() | ||
} | ||
|
||
func setApplicationContext(context: [String : Any]) throws { | ||
guard let session = validSession else { | ||
return | ||
} | ||
|
||
try session.updateApplicationContext(context) | ||
} | ||
|
||
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { | ||
print("activation did complete") | ||
print(activationState.rawValue) | ||
print(error) | ||
} | ||
|
||
func sessionDidBecomeInactive(_ session: WCSession) { | ||
print("session did become inactive") | ||
} | ||
|
||
func sessionDidDeactivate(_ session: WCSession) { | ||
print("session did deactivate") | ||
} | ||
} |
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,25 @@ | ||
// | ||
// AccountsView.swift | ||
// WatchOak Extension | ||
// | ||
// Created by Alex Catchpole on 19/05/2021. | ||
// | ||
|
||
import SwiftUI | ||
import Resolver | ||
|
||
struct AccountsView: View { | ||
@StateObject private var viewModel: AccountsViewModel = Resolver.resolve() | ||
|
||
var body: some View { | ||
List(viewModel.accountListItemViewModels, id: \.id) { vm in | ||
AccountListItem(viewModel: vm) | ||
}.navigationTitle("Accounts") | ||
} | ||
} | ||
|
||
struct AccountsView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
AccountsView() | ||
} | ||
} |
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,32 @@ | ||
// | ||
// AccountsViewModel.swift | ||
// WatchOak Extension | ||
// | ||
// Created by Alex Catchpole on 19/05/2021. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import Resolver | ||
|
||
class AccountsViewModel: NSObject, AccountServiceDelegate, ObservableObject { | ||
@Injected private var accountService: AccountService | ||
|
||
@Published var accountListItemViewModels: [AccountListItemViewModel] = [] | ||
|
||
override init() { | ||
super.init() | ||
accountService.delegate = self | ||
} | ||
|
||
func accountsChanged(accounts: [Account]) { | ||
self.accountListItemViewModels = accounts.map { AccountListItemViewModel(account: $0) } | ||
} | ||
} | ||
|
||
extension Resolver { | ||
static func RegisterAccountsViewModel() { | ||
register { AccountsViewModel() } | ||
} | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
...ak Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json
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,28 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
WatchOak Extension/Assets.xcassets/Complication.complicationset/Contents.json
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,53 @@ | ||
{ | ||
"assets" : [ | ||
{ | ||
"filename" : "Circular.imageset", | ||
"idiom" : "watch", | ||
"role" : "circular" | ||
}, | ||
{ | ||
"filename" : "Extra Large.imageset", | ||
"idiom" : "watch", | ||
"role" : "extra-large" | ||
}, | ||
{ | ||
"filename" : "Graphic Bezel.imageset", | ||
"idiom" : "watch", | ||
"role" : "graphic-bezel" | ||
}, | ||
{ | ||
"filename" : "Graphic Circular.imageset", | ||
"idiom" : "watch", | ||
"role" : "graphic-circular" | ||
}, | ||
{ | ||
"filename" : "Graphic Corner.imageset", | ||
"idiom" : "watch", | ||
"role" : "graphic-corner" | ||
}, | ||
{ | ||
"filename" : "Graphic Extra Large.imageset", | ||
"idiom" : "watch", | ||
"role" : "graphic-extra-large" | ||
}, | ||
{ | ||
"filename" : "Graphic Large Rectangular.imageset", | ||
"idiom" : "watch", | ||
"role" : "graphic-large-rectangular" | ||
}, | ||
{ | ||
"filename" : "Modular.imageset", | ||
"idiom" : "watch", | ||
"role" : "modular" | ||
}, | ||
{ | ||
"filename" : "Utilitarian.imageset", | ||
"idiom" : "watch", | ||
"role" : "utilitarian" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json
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,28 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...tension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json
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,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...sion/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json
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,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json
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,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...n/Assets.xcassets/Complication.complicationset/Graphic Extra Large.imageset/Contents.json
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,28 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ts.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json
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,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.