Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Remove native Swift app (#3235)

Sure Admin (bot)390ed5061668
diff --git a/Project.json b/Project.json
deleted file mode 100644
index 2d3f128aaf..0000000000
--- a/Project.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "name": "Sure",
- "options": {
- "deploymentTarget": {
- "iOS": "18.0"
- }
- },
- "settings": {
- "base": {
- "SWIFT_VERSION": "6.0"
- }
- },
- "targets": {
- "Sure": {
- "type": "application",
- "platform": "iOS",
- "sources": [
- "bitrig/App"
- ],
- "settings": {
- "base": {
- "PRODUCT_BUNDLE_IDENTIFIER": "app.bitrig.new.81790e0e362141ce8bc1315a7a361749",
- "TARGETED_DEVICE_FAMILY": "1,2",
- "ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
- "ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME": "AccentColor"
- }
- },
- "info": {
- "path": "bitrig/App/Info.plist",
- "properties": {
- "CFBundleDisplayName": "Sure",
- "UILaunchScreen": {},
- "UIBackgroundModes": [
- "remote-notification"
- ]
- }
- },
- "entitlements": {
- "path": "bitrig/App/Sure.entitlements",
- "properties": {
- "aps-environment": "development"
- }
- }
- }
- }
-}
diff --git a/appStoreConnect/.gitignore b/appStoreConnect/.gitignore
deleted file mode 100644
index ee889666ef..0000000000
--- a/appStoreConnect/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-assets/
diff --git a/appStoreConnect/app.json b/appStoreConnect/app.json
deleted file mode 100644
index 5167c1091f..0000000000
--- a/appStoreConnect/app.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "bundleId": "am.sure.insights",
- "primaryLocale": "en-US"
-}
diff --git a/appStoreConnect/appInfo/ageRating.json b/appStoreConnect/appInfo/ageRating.json
deleted file mode 100644
index a12dddc0a9..0000000000
--- a/appStoreConnect/appInfo/ageRating.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "ageRatingOverrideV2": "NONE",
- "koreaAgeRatingOverride": "NONE"
-}
diff --git a/appStoreConnect/appInfo/localizations/en-US.json b/appStoreConnect/appInfo/localizations/en-US.json
deleted file mode 100644
index 0509a5a16b..0000000000
--- a/appStoreConnect/appInfo/localizations/en-US.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "Sure Insights"
-}
diff --git a/appStoreConnect/appStoreVersion/iOS/localizations/en-US/localization.json b/appStoreConnect/appStoreVersion/iOS/localizations/en-US/localization.json
deleted file mode 100644
index 0db3279e44..0000000000
--- a/appStoreConnect/appStoreVersion/iOS/localizations/en-US/localization.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-
-}
diff --git a/appStoreConnect/appStoreVersion/iOS/version.json b/appStoreConnect/appStoreVersion/iOS/version.json
deleted file mode 100644
index 728fe12683..0000000000
--- a/appStoreConnect/appStoreVersion/iOS/version.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "releaseType": "AFTER_APPROVAL",
- "versionString": "1.0"
-}
diff --git a/appStoreConnect/lock.json b/appStoreConnect/lock.json
deleted file mode 100644
index 2cc0169cf0..0000000000
--- a/appStoreConnect/lock.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "appId": "6804843427",
- "derived": {
- "appStoreVersionScreenshotSets": {
-
- },
- "pricing": {
- "automaticPrices": [
-
- ]
- }
- },
- "formatVersion": 1,
- "gitignore": "created",
- "resources": {
- "ageRatingDeclaration": {
- "fields": {
- "ageRatingOverrideV2": "NONE",
- "koreaAgeRatingOverride": "NONE"
- },
- "id": "dfacd01a-5017-45ae-a573-78a0664c9e08",
- "type": "ageRatingDeclarations"
- },
- "app": {
- "fields": {
- "primaryLocale": "en-US"
- },
- "id": "6804843427",
- "type": "apps"
- },
- "appInfo": {
- "fields": {
-
- },
- "id": "dfacd01a-5017-45ae-a573-78a0664c9e08",
- "type": "appInfos"
- },
- "appInfoLocalization:en-US": {
- "fields": {
- "name": "Sure Insights"
- },
- "id": "4b775417-5fc0-4aa4-8a4b-a426529092bb",
- "type": "appInfoLocalizations"
- },
- "appStoreVersion:IOS:1.0": {
- "fields": {
- "releaseType": "AFTER_APPROVAL",
- "versionString": "1.0"
- },
- "id": "75f1c2c3-9fc3-4aff-bc21-74da4323c777",
- "type": "appStoreVersions"
- },
- "appStoreVersionLocalization:IOS:1.0:en-US": {
- "fields": {
-
- },
- "id": "855fd9e3-2474-42b6-b9da-4df74ad2c2be",
- "type": "appStoreVersionLocalizations"
- },
- "pricing": {
- "fields": {
- "baseTerritory": "USA",
- "manualPrices": [
-
- ]
- },
- "id": "6804843427",
- "type": "appPriceSchedules"
- }
- }
-}
diff --git a/appStoreConnect/pricing.json b/appStoreConnect/pricing.json
deleted file mode 100644
index 6e41f630b8..0000000000
--- a/appStoreConnect/pricing.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "baseTerritory": "USA",
- "manualPrices": [
-
- ]
-}
diff --git a/bitrig/App/APIClient.swift b/bitrig/App/APIClient.swift
deleted file mode 100644
index c9da6b7548..0000000000
--- a/bitrig/App/APIClient.swift
+++ /dev/null
@@ -1,109 +0,0 @@
-import Foundation
-
-actor SureAPIClient {
- private var baseURL: URL
- private var apiKey: String
- private var session: URLSession
- private var decoder: JSONDecoder
-
- init(baseURL: URL, apiKey: String) {
- self.baseURL = baseURL
- self.apiKey = apiKey
- let configuration = URLSessionConfiguration.default
- configuration.timeoutIntervalForRequest = 30
- configuration.waitsForConnectivity = true
- session = URLSession(configuration: configuration)
- decoder = JSONDecoder()
- }
-
- func update(baseURL: URL, apiKey: String) {
- self.baseURL = baseURL
- self.apiKey = apiKey
- }
-
- func get<T: Decodable & Sendable>(_ path: String, as type: T.Type = T.self) async throws -> T {
- try await request(path: path, method: "GET", body: Optional<String>.none, as: type)
- }
-
- func post<Body: Encodable & Sendable, Response: Decodable & Sendable>(
- _ path: String,
- body: Body,
- as type: Response.Type = Response.self
- ) async throws -> Response {
- try await request(path: path, method: "POST", body: body, as: type)
- }
-
- func postWithoutResponse<Body: Encodable & Sendable>(_ path: String, body: Body) async throws {
- let _: EmptyResponse = try await request(path: path, method: "POST", body: body, as: EmptyResponse.self)
- }
-
- func delete(_ path: String) async throws {
- let _: EmptyResponse = try await request(
- path: path,
- method: "DELETE",
- body: Optional<String>.none,
- as: EmptyResponse.self
- )
- }
-
- private func request<Body: Encodable & Sendable, Response: Decodable & Sendable>(
- path: String,
- method: String,
- body: Body?,
- as type: Response.Type
- ) async throws -> Response {
- let cleanedPath = path.hasPrefix("/") ? String(path.dropFirst()) : path
- guard let url = URL(string: cleanedPath, relativeTo: baseURL)?.absoluteURL else {
- throw SureAPIError.invalidURL
- }
- var request = URLRequest(url: url)
- request.httpMethod = method
- request.setValue("application/json", forHTTPHeaderField: "Accept")
- request.setValue("application/json", forHTTPHeaderField: "Content-Type")
- request.setValue(apiKey, forHTTPHeaderField: "X-Api-Key")
- if let body {
- request.httpBody = try JSONEncoder().encode(body)
- }
-
- let (data, response) = try await session.data(for: request)
- guard let httpResponse = response as? HTTPURLResponse else {
- throw SureAPIError.invalidResponse
- }
- guard 200..<300 ~= httpResponse.statusCode else {
- let serverError = try? decoder.decode(ServerError.self, from: data)
- throw SureAPIError.server(status: httpResponse.statusCode, message: serverError?.message ?? serverError?.error)
- }
- if Response.self == EmptyResponse.self, data.isEmpty {
- return EmptyResponse() as! Response
- }
- do {
- return try decoder.decode(Response.self, from: data)
- } catch {
- throw SureAPIError.decoding(error.localizedDescription)
- }
- }
-}
-
-struct EmptyResponse: Codable, Sendable {}
-
-struct ServerError: Codable, Sendable {
- var error: String?
- var message: String?
-}
-
-enum SureAPIError: LocalizedError, Equatable {
- case invalidURL
- case invalidResponse
- case server(status: Int, message: String?)
- case decoding(String)
-
- var errorDescription: String? {
- switch self {
- case .invalidURL: "The server address is invalid."
- case .invalidResponse: "The server returned an invalid response."
- case let .server(status, message):
- message ?? "The server returned an error (\(status))."
- case let .decoding(message): "Sure returned data this app could not read: \(message)"
- }
- }
-}
diff --git a/bitrig/App/Assets.xcassets/AccentColor.colorset/Contents.json b/bitrig/App/Assets.xcassets/AccentColor.colorset/Contents.json
deleted file mode 100644
index 1059c7c1fa..0000000000
--- a/bitrig/App/Assets.xcassets/AccentColor.colorset/Contents.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "colors" : [
- {
- "color" : {
- "color-space" : "srgb",
- "components" : {
- "alpha" : "1.000",
- "blue" : "0.850",
- "green" : "0.250",
- "red" : "0.290"
- }
- },
- "idiom" : "universal"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/bitrig/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/bitrig/App/Assets.xcassets/AppIcon.appiconset/Contents.json
deleted file mode 100644
index b3f44eb295..0000000000
--- a/bitrig/App/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "images" : [
- {
- "filename" : "Icon.png",
- "idiom" : "universal",
- "platform" : "ios",
- "size" : "1024x1024"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/bitrig/App/Assets.xcassets/AppIcon.appiconset/Icon.png b/bitrig/App/Assets.xcassets/AppIcon.appiconset/Icon.png
deleted file mode 100644
index 6c64ce526e..0000000000
Binary files a/bitrig/App/Assets.xcassets/AppIcon.appiconset/Icon.png and /dev/null differ
diff --git a/bitrig/App/Assets.xcassets/Contents.json b/bitrig/App/Assets.xcassets/Contents.json
deleted file mode 100644
index 73c00596a7..0000000000
--- a/bitrig/App/Assets.xcassets/Contents.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/bitrig/App/Assets.xcassets/SureLogomark.imageset/Contents.json b/bitrig/App/Assets.xcassets/SureLogomark.imageset/Contents.json
deleted file mode 100644
index dd53fcde6c..0000000000
--- a/bitrig/App/Assets.xcassets/SureLogomark.imageset/Contents.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "images" : [
- {
- "filename" : "SureLogomark.svg",
- "idiom" : "universal"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- },
- "properties" : {
- "preserves-vector-representation" : true
- }
-}
diff --git a/bitrig/App/Assets.xcassets/SureLogomark.imageset/SureLogomark.svg b/bitrig/App/Assets.xcassets/SureLogomark.imageset/SureLogomark.svg
deleted file mode 100644
index 9265b6c057..0000000000
--- a/bitrig/App/Assets.xcassets/SureLogomark.imageset/SureLogomark.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 160 145" fill="none">
-<path d="M116.51 119.37C120.062 119.37 122.809 118.751 124.752 117.513C126.696 116.274 127.701 114.58 127.768 112.429L158.828 122.303C157.621 126.409 155.042 130.156 151.088 133.545C147.201 136.869 142.276 139.509 136.312 141.464C130.348 143.419 123.68 144.397 116.309 144.397C110.01 144.397 104.113 143.712 98.6179 142.344C93.19 140.975 88.3986 138.922 84.2439 136.185C80.1562 133.382 76.9397 129.896 74.5943 125.725C72.2489 121.553 71.0762 116.698 71.0762 111.158C71.0762 105.618 72.2489 100.763 74.5943 96.5919C76.9397 92.4208 80.1562 88.9666 84.2439 86.2293C88.3986 83.4268 93.2234 81.3412 98.7184 79.9726C104.213 78.6039 110.077 77.9196 116.309 77.9196C122.675 77.9196 128.505 78.6039 133.799 79.9726C139.16 81.3412 143.75 83.4594 147.57 86.327C151.456 89.1295 154.438 92.714 156.516 97.0807C158.66 101.382 159.732 106.498 159.732 112.429H104.95C104.95 112.429 104.917 112.429 104.85 112.429C104.85 112.429 104.85 112.462 104.85 112.527C104.85 113.504 105.118 114.417 105.654 115.264C106.19 116.111 106.927 116.861 107.865 117.513C108.871 118.099 110.077 118.555 111.484 118.881C112.958 119.207 114.634 119.37 116.51 119.37ZM116.309 102.653C113.025 102.653 110.311 103.24 108.167 104.413C106.023 105.521 104.95 107.117 104.95 109.203C104.95 109.268 104.95 109.333 104.95 109.399C105.017 109.399 105.051 109.399 105.051 109.399H127.466C127.533 109.399 127.567 109.399 127.567 109.399C127.567 109.333 127.567 109.268 127.567 109.203C127.567 108.16 127.265 107.248 126.662 106.466C126.126 105.618 125.355 104.934 124.35 104.413C123.345 103.826 122.139 103.403 120.732 103.142C119.391 102.816 117.917 102.653 116.309 102.653Z" fill="#62a446"/>
-<path d="M37.5666 81.9011C37.5666 85.8115 37.5666 89.7546 37.5666 93.7301C37.5666 97.6406 37.5666 101.584 37.5666 105.559C37.5666 109.47 37.5666 113.413 37.5666 117.388C37.5666 121.559 37.5666 125.73 37.5666 129.902C37.5666 134.073 37.5666 138.276 37.5666 142.513H2.74774C2.74774 136.06 2.74774 129.608 2.74774 123.156C2.74774 116.704 2.74774 110.252 2.74774 103.799C2.74774 100.15 2.74774 96.5 2.74774 92.8503C2.74774 89.2006 2.74774 85.5508 2.74774 81.9011H37.5666ZM37.466 119.246L42.9001 92.9481C43.5039 90.1456 44.678 87.8319 46.4222 86.0071C48.2336 84.117 50.3469 82.6832 52.7621 81.7056C55.1773 80.728 57.6596 80.1414 60.2089 79.9459C62.7583 79.6852 65.1063 79.783 67.2532 80.2392C69.4 80.6302 71.1108 81.3146 72.3854 82.2922L64.7374 118.659C62.7918 117.095 60.4102 116.02 57.5925 115.433C54.8418 114.846 52.0577 114.651 49.24 114.846C46.4223 114.977 43.94 115.433 41.7932 116.215C39.6463 116.997 38.2039 118.007 37.466 119.246Z" fill="#61a446"/>
-<path d="M155.301 0.291725C155.301 4.65836 155.301 20.0576 155.301 24.4894C155.301 28.9212 155.301 33.353 155.301 37.7848C155.301 41.5649 155.301 45.3776 155.301 49.2228C155.301 53.0029 155.301 56.783 155.301 60.563C155.301 64.3431 155.301 68.1232 155.301 71.9033H121.476C121.476 69.166 121.476 66.3961 121.476 63.5936C121.476 60.7912 121.476 57.9887 121.476 55.1862C121.476 52.3186 121.476 49.5487 121.476 46.8766C121.476 40.8154 121.476 34.8846 121.476 29.0841C121.476 23.2185 121.476 6.28771 121.476 0.291725H155.301ZM111.113 5.29173C111.113 8.74593 111.113 18.2327 111.113 21.7521C111.113 25.2063 111.113 28.6605 111.113 32.1147C111.113 35.5689 111.113 39.0557 111.113 42.5751C111.113 44.0089 111.341 45.182 111.798 46.0945C112.319 46.9417 112.971 47.5609 113.753 47.9519C114.6 48.2778 115.48 48.4407 116.392 48.4407C117.305 48.4407 118.217 48.2778 119.13 47.9519C120.107 47.6261 120.889 47.235 121.476 46.7788L113.655 70.9257C111.83 71.8381 109.582 72.5876 106.909 73.1742C104.303 73.7607 101.565 74.054 98.6976 74.054C96.0906 74.054 93.5163 73.7281 90.9745 73.0764C88.4327 72.4898 86.1191 71.4796 84.0335 70.0458C82.0131 68.612 80.3838 66.722 79.1455 64.3757C77.9072 62.0295 77.288 59.0966 77.288 55.5773C77.288 50.8848 77.288 46.1922 77.288 41.4997C77.288 36.8072 77.288 32.1147 77.288 27.4222C77.288 24.7501 77.288 22.078 77.288 19.4058C77.288 16.6686 77.288 7.96384 77.288 5.29173H111.113Z" fill="grey"/>
-<path d="M0.698853 30.6484C0.698853 26.9335 1.74163 23.7074 3.82719 20.9701C5.97792 18.2328 8.87815 15.9517 12.5279 14.1269C16.1776 12.2368 20.3161 10.8356 24.9435 9.92315C29.5708 9.01072 34.3937 8.5545 39.412 8.5545C45.6035 8.5545 51.3388 9.10848 56.6179 10.2164C61.9621 11.3244 66.785 12.7908 71.0864 14.6157V37.2961C69.2616 35.9275 66.8502 34.7543 63.8522 33.7767C60.9194 32.7991 57.791 32.0496 54.4672 31.5282C51.2085 31.0068 48.1127 30.7461 45.1799 30.7461C43.2247 30.7461 41.4324 30.8765 39.8031 31.1372C38.2389 31.3327 36.968 31.6586 35.9904 32.1148C35.078 32.571 34.6218 33.1576 34.6218 33.8745C34.6218 34.2655 34.7521 34.5588 35.0128 34.7543C35.3387 34.9499 35.7949 35.0802 36.3815 35.1454C36.968 35.2105 37.7175 35.2431 38.63 35.2431C40.1289 35.2431 41.465 35.2431 42.6381 35.2431C43.8113 35.2431 45.1147 35.2431 46.5486 35.2431C49.8072 35.2431 53.0659 35.4712 56.3246 35.9275C59.6485 36.3185 62.6465 37.1332 65.3186 38.3715C68.0559 39.6098 70.2392 41.402 71.8685 43.7483C73.4979 46.0294 74.3125 49.06 74.3125 52.84C74.3125 56.8156 73.2046 60.2047 70.9887 63.0071C68.838 65.7444 65.8726 67.9929 62.0925 69.7526C58.3776 71.4471 54.1739 72.6854 49.4814 73.4675C44.854 74.2496 40.0312 74.6406 35.0128 74.6406C29.082 74.6406 23.2164 74.0867 17.4159 72.9787C11.6806 71.8708 6.76001 70.2414 2.65406 68.0907V44.2371C4.28341 45.9968 6.59707 47.4632 9.59506 48.6363C12.6582 49.7443 15.9495 50.5915 19.4689 51.1781C23.0534 51.6995 26.4099 51.9602 29.5382 51.9602C31.5586 51.9602 33.3835 51.8624 35.0128 51.6669C36.6421 51.4062 37.913 51.0478 38.8255 50.5915C39.8031 50.0701 40.2919 49.4184 40.2919 48.6363C40.2919 48.3105 40.1941 48.0823 39.9986 47.952C39.8031 47.8217 39.4772 47.7239 39.021 47.6587C38.63 47.5936 38.076 47.561 37.3591 47.561C36.3815 47.561 35.3713 47.561 34.3285 47.561C33.2857 47.561 32.3407 47.561 31.4934 47.561C29.2123 47.561 26.6706 47.4958 23.8681 47.3654C21.1308 47.1699 18.3935 46.8115 15.6562 46.2901C12.9189 45.7035 10.4097 44.8237 8.12865 43.6505C5.91275 42.4122 4.12047 40.7503 2.75182 38.6648C1.38318 36.514 0.698853 33.8419 0.698853 30.6484Z" fill="grey"/>
-</svg>
diff --git a/bitrig/App/Info.plist b/bitrig/App/Info.plist
deleted file mode 100644
index 0c67376eba..0000000000
--- a/bitrig/App/Info.plist
+++ /dev/null
@@ -1,5 +0,0 @@
-<?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/>
-</plist>
diff --git a/bitrig/App/KeychainStore.swift b/bitrig/App/KeychainStore.swift
deleted file mode 100644
index d3cdab2234..0000000000
--- a/bitrig/App/KeychainStore.swift
+++ /dev/null
@@ -1,49 +0,0 @@
-import Foundation
-import Security
-
-enum KeychainStore {
- private static var service: String { "am.sure.native" }
-
- static func saveAPIKey(_ value: String) throws {
- guard let data = value.data(using: .utf8) else { return }
- let query: [String: Any] = [
- kSecClass as String: kSecClassGenericPassword,
- kSecAttrService as String: service,
- kSecAttrAccount as String: "api-key"
- ]
- SecItemDelete(query as CFDictionary)
- var attributes = query
- attributes[kSecValueData as String] = data
- attributes[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
- let status = SecItemAdd(attributes as CFDictionary, nil)
- guard status == errSecSuccess else { throw KeychainError(status: status) }
- }
-
- static func readAPIKey() -> String? {
- let query: [String: Any] = [
- kSecClass as String: kSecClassGenericPassword,
- kSecAttrService as String: service,
- kSecAttrAccount as String: "api-key",
- kSecReturnData as String: true,
- kSecMatchLimit as String: kSecMatchLimitOne
- ]
- var result: AnyObject?
- guard SecItemCopyMatching(query as CFDictionary, &result) == errSecSuccess,
- let data = result as? Data else { return nil }
- return String(data: data, encoding: .utf8)
- }
-
- static func deleteAPIKey() {
- let query: [String: Any] = [
- kSecClass as String: kSecClassGenericPassword,
- kSecAttrService as String: service,
- kSecAttrAccount as String: "api-key"
- ]
- SecItemDelete(query as CFDictionary)
- }
-}
-
-struct KeychainError: LocalizedError {
- var status: OSStatus
- var errorDescription: String? { "Could not securely save the API key (\(status))." }
-}
diff --git a/bitrig/App/Models.swift b/bitrig/App/Models.swift
deleted file mode 100644
index 010c7675f8..0000000000
--- a/bitrig/App/Models.swift
+++ /dev/null
@@ -1,184 +0,0 @@
-import Foundation
-
-struct MoneyValue: Codable, Sendable {
- var amount: String
- var currency: String
-
- var decimalAmount: Decimal {
- Decimal(string: amount) ?? 0
- }
-
- var formatted: String {
- decimalAmount.formatted(.currency(code: currency).precision(.fractionLength(0...2)))
- }
-}
-
-struct BalanceSheet: Codable, Sendable {
- var currency: String
- var netWorth: MoneyValue
- var assets: MoneyValue
- var liabilities: MoneyValue
-
- enum CodingKeys: String, CodingKey {
- case currency
- case netWorth = "net_worth"
- case assets
- case liabilities
- }
-}
-
-struct SureAccount: Codable, Identifiable, Sendable {
- var id: String
- var name: String
- var balance: String
- var balanceCents: Int
- var cashBalance: String
- var cashBalanceCents: Int
- var currency: String
- var classification: String
- var accountType: String?
- var subtype: String?
- var status: String
- var institutionName: String?
-
- enum CodingKeys: String, CodingKey {
- case id, name, balance, currency, classification, subtype, status
- case balanceCents = "balance_cents"
- case cashBalance = "cash_balance"
- case cashBalanceCents = "cash_balance_cents"
- case accountType = "account_type"
- case institutionName = "institution_name"
- }
-
- var isAsset: Bool { classification == "asset" }
-}
-
-struct AccountCollection: Codable, Sendable {
- var accounts: [SureAccount]
- var pagination: SurePagination?
-}
-
-struct SureBudget: Codable, Identifiable, Sendable {
- var id: String
- var name: String
- var currency: String
- var current: Bool
- var budgetedSpending: String?
- var allocatedSpending: String
- var startDate: String
- var endDate: String
-
- enum CodingKeys: String, CodingKey {
- case id, name, currency, current
- case budgetedSpending = "budgeted_spending"
- case allocatedSpending = "allocated_spending"
- case startDate = "start_date"
- case endDate = "end_date"
- }
-}
-
-struct BudgetCollection: Codable, Sendable {
- var budgets: [SureBudget]
- var pagination: SurePagination?
-}
-
-struct SureInsight: Codable, Identifiable, Sendable, Equatable {
- var id: String
- var type: String
- var title: String
- var body: String
- var priority: String
- var status: String
- var generatedAt: String?
-
- enum CodingKeys: String, CodingKey {
- case id, type, title, body, priority, status
- case generatedAt = "generated_at"
- }
-
- var symbol: String {
- switch type {
- case "cash_flow_warning", "budget_at_risk": "exclamationmark.triangle.fill"
- case "net_worth_milestone", "budget_on_track": "sparkles"
- case "subscription_audit": "repeat"
- case "idle_cash": "banknote.fill"
- default: "chart.line.uptrend.xyaxis"
- }
- }
-}
-
-struct InsightCollection: Codable, Sendable {
- var insights: [SureInsight]
-}
-
-struct SureChat: Codable, Identifiable, Sendable, Hashable {
- var id: String
- var title: String
- var error: String?
- var createdAt: String
- var updatedAt: String
- var lastMessageAt: String?
- var messageCount: Int?
-
- enum CodingKeys: String, CodingKey {
- case id, title, error
- case createdAt = "created_at"
- case updatedAt = "updated_at"
- case lastMessageAt = "last_message_at"
- case messageCount = "message_count"
- }
-}
-
-struct ChatCollection: Codable, Sendable {
- var chats: [SureChat]
- var pagination: SurePagination?
-}
-
-struct SurePagination: Codable, Sendable {
- var page: Int
- var perPage: Int
- var totalCount: Int
- var totalPages: Int
-
- enum CodingKeys: String, CodingKey {
- case page
- case perPage = "per_page"
- case totalCount = "total_count"
- case totalPages = "total_pages"
- }
-}
-
-struct SureMessage: Codable, Identifiable, Sendable, Equatable {
- var id: String
- var type: String
- var role: String
- var content: String
- var createdAt: String
-
- enum CodingKeys: String, CodingKey {
- case id, type, role, content
- case createdAt = "created_at"
- }
-
- var isUser: Bool { role == "user" || type == "user_message" }
-}
-
-struct ChatDetail: Codable, Sendable {
- var id: String
- var title: String
- var error: String?
- var createdAt: String
- var updatedAt: String
- var messages: [SureMessage]
- var pagination: SurePagination?
-
- enum CodingKeys: String, CodingKey {
- case id, title, error, messages, pagination
- case createdAt = "created_at"
- case updatedAt = "updated_at"
- }
-
- var chat: SureChat {
- SureChat(id: id, title: title, error: error, createdAt: createdAt, updatedAt: updatedAt)
- }
-}
diff --git a/bitrig/App/Sure.entitlements b/bitrig/App/Sure.entitlements
deleted file mode 100644
index 0c67376eba..0000000000
--- a/bitrig/App/Sure.entitlements
+++ /dev/null
@@ -1,5 +0,0 @@
-<?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/>
-</plist>
diff --git a/bitrig/App/SureAccountsView.swift b/bitrig/App/SureAccountsView.swift
deleted file mode 100644
index fc04f24cca..0000000000
--- a/bitrig/App/SureAccountsView.swift
+++ /dev/null
@@ -1,74 +0,0 @@
-import SwiftUI
-
-struct SureAccountsView: View {
- @Environment(SureStore.self) private var store
-
- var body: some View {
- NavigationStack {
- ScrollView {
- LazyVStack(spacing: 12) {
- ForEach(store.accounts) { account in
- SureAccountRow(account: account)
- .padding(.horizontal)
- }
- if store.accounts.isEmpty && !store.isLoading {
- ContentUnavailableView(
- "No accounts",
- systemImage: "building.columns",
- description: Text("Add or link an account in Sure, then pull to refresh.")
- )
- }
- }
- .frame(maxWidth: .infinity)
- .padding(.vertical)
- }
- .refreshable { await store.refreshAll() }
- .navigationTitle("Accounts")
- }
- }
-}
-
-struct SureAccountRow: View {
- var account: SureAccount
-
- var body: some View {
- HStack(spacing: 14) {
- Image(systemName: symbol)
- .font(.title3)
- .foregroundStyle(.tint)
- .frame(width: 42, height: 42)
- .background(Color.sureIndigo.opacity(0.1), in: .circle)
- .accessibilityHidden(true)
- VStack(alignment: .leading, spacing: 3) {
- Text(account.name)
- .font(.headline)
- Text(account.institutionName ?? accountTypeLabel)
- .font(.caption)
- .foregroundStyle(.secondary)
- }
- Spacer()
- Text(account.balance)
- .font(.headline.monospacedDigit())
- }
- .padding(14)
- .background(.background.secondary, in: .rect(cornerRadius: 16))
- .accessibilityElement(children: .combine)
- }
-
- private var symbol: String {
- switch account.accountType {
- case "investment": "chart.line.uptrend.xyaxis"
- case "credit_card": "creditcard.fill"
- case "property": "house.fill"
- case "vehicle": "car.fill"
- case "loan": "doc.text.fill"
- default: account.isAsset ? "banknote.fill" : "arrow.down.right"
- }
- }
-
- private var accountTypeLabel: String {
- (account.subtype ?? account.accountType ?? account.classification)
- .replacingOccurrences(of: "_", with: " ")
- .capitalized
- }
-}
diff --git a/bitrig/App/SureApp.swift b/bitrig/App/SureApp.swift
deleted file mode 100644
index 06cc5e2664..0000000000
--- a/bitrig/App/SureApp.swift
+++ /dev/null
@@ -1,75 +0,0 @@
-import SwiftUI
-import UserNotifications
-
-@main
-struct SureApp: App {
- @UIApplicationDelegateAdaptor(SureAppDelegate.self) private var appDelegate
- @State private var store = SureStore()
-
- var body: some Scene {
- WindowGroup {
- SureRootView()
- .environment(store)
- .tint(Color.sureIndigo)
- .task {
- await store.restoreSession()
- }
- .onReceive(NotificationCenter.default.publisher(for: .sureDeviceTokenChanged)) { notification in
- guard let token = notification.object as? String else { return }
- Task { await store.registerPushToken(token) }
- }
- }
- }
-}
-
-final class SureAppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
- func application(
- _ application: UIApplication,
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
- ) -> Bool {
- UNUserNotificationCenter.current().delegate = self
- Task {
- let settings = await UNUserNotificationCenter.current().notificationSettings()
- if settings.authorizationStatus == .authorized || settings.authorizationStatus == .provisional {
- await MainActor.run { application.registerForRemoteNotifications() }
- }
- }
- return true
- }
-
- func application(
- _ application: UIApplication,
- didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
- ) {
- let token = deviceToken.map { String(format: "%02x", $0) }.joined()
- UserDefaults.standard.set(token, forKey: "sure.apnsDeviceToken")
- NotificationCenter.default.post(name: .sureDeviceTokenChanged, object: token)
- }
-
- nonisolated func userNotificationCenter(
- _ center: UNUserNotificationCenter,
- willPresent notification: UNNotification,
- withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
- ) {
- completionHandler([.banner, .sound, .badge])
- }
-
- nonisolated func userNotificationCenter(
- _ center: UNUserNotificationCenter,
- didReceive response: UNNotificationResponse,
- withCompletionHandler completionHandler: @escaping () -> Void
- ) {
- NotificationCenter.default.post(name: .sureOpenInsights, object: nil)
- completionHandler()
- }
-}
-
-extension Notification.Name {
- static var sureDeviceTokenChanged: Notification.Name { Notification.Name("sureDeviceTokenChanged") }
- static var sureOpenInsights: Notification.Name { Notification.Name("sureOpenInsights") }
-}
-
-extension Color {
- static var sureIndigo: Color { Color(red: 0.29, green: 0.25, blue: 0.85) }
- static var sureMint: Color { Color(red: 0.22, green: 0.73, blue: 0.58) }
-}
diff --git a/bitrig/App/SureAssistantView.swift b/bitrig/App/SureAssistantView.swift
deleted file mode 100644
index 64ba48e713..0000000000
--- a/bitrig/App/SureAssistantView.swift
+++ /dev/null
@@ -1,170 +0,0 @@
-import SwiftUI
-
-struct SureAssistantView: View {
- @Environment(SureStore.self) private var store
- @State private var draft = ""
- @FocusState private var composerFocused: Bool
-
- var body: some View {
- NavigationStack {
- ScrollViewReader { proxy in
- ScrollView {
- LazyVStack(spacing: 14) {
- if store.messages.isEmpty {
- VStack(spacing: 16) {
- Image(systemName: "sparkles")
- .font(.system(size: 46))
- .foregroundStyle(.tint)
- Text("Ask about your money")
- .font(.title2.bold())
- Text("Sure’s Assistant can analyze your live accounts, spending, budgets, investments, and insights.")
- .multilineTextAlignment(.center)
- .foregroundStyle(.secondary)
- VStack(spacing: 10) {
- suggestion("What should I pay attention to this month?")
- suggestion("How diversified are my investments?")
- suggestion("Find easy ways I could cut costs")
- }
- }
- .frame(maxWidth: 560)
- .padding(.horizontal, 24)
- .padding(.top, 52)
- } else {
- ForEach(store.messages) { message in
- SureMessageBubble(message: message)
- .id(message.id)
- }
- if store.isAssistantThinking {
- HStack(spacing: 8) {
- ProgressView()
- Text("Thinking…")
- .foregroundStyle(.secondary)
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding(.horizontal)
- .id("thinking")
- }
- }
- }
- .frame(maxWidth: .infinity)
- .padding(.vertical)
- }
- .onChange(of: store.messages.count) {
- if let id = store.messages.last?.id {
- withAnimation(.smooth) { proxy.scrollTo(id, anchor: .bottom) }
- }
- }
- .onChange(of: store.isAssistantThinking) {
- if store.isAssistantThinking {
- withAnimation(.smooth) { proxy.scrollTo("thinking", anchor: .bottom) }
- }
- }
- }
- .safeAreaInset(edge: .bottom) {
- composer
- }
- .navigationTitle(store.selectedChat?.title ?? "Assistant")
- .navigationBarTitleDisplayMode(.inline)
- .toolbar {
- ToolbarItemGroup(placement: .topBarTrailing) {
- Picker("Conversation", selection: chatSelection) {
- Text("New conversation").tag(Optional<String>.none)
- ForEach(store.chats) { chat in
- Text(chat.title).tag(Optional(chat.id))
- }
- }
- .pickerStyle(.menu)
- .labelsHidden()
-
- Button("New conversation", systemImage: "square.and.pencil") {
- store.newChat()
- }
- .labelStyle(.iconOnly)
- }
- }
- }
- }
-
- private var composer: some View {
- HStack(alignment: .bottom, spacing: 10) {
- TextField("Message Sure Assistant", text: $draft, axis: .vertical)
- .lineLimit(1...5)
- .padding(.horizontal, 14)
- .padding(.vertical, 11)
- .background(.background.secondary, in: .rect(cornerRadius: 18))
- .focused($composerFocused)
- .submitLabel(.send)
- .onSubmit(send)
- Button(action: send) {
- Image(systemName: "arrow.up")
- .font(.headline)
- .foregroundStyle(.white)
- .frame(width: 44, height: 44)
- .background(Color.sureIndigo, in: .circle)
- }
- .accessibilityLabel("Send message")
- .disabled(draft.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || store.isAssistantThinking)
- }
- .padding(.horizontal)
- .padding(.vertical, 10)
- .background(.bar)
- }
-
- private var chatSelection: Binding<String?> {
- Binding {
- store.selectedChat?.id
- } set: { id in
- guard let id, let chat = store.chats.first(where: { $0.id == id }) else {
- store.newChat()
- return
- }
- Task { await store.loadChat(chat) }
- }
- }
-
- private func suggestion(_ text: String) -> some View {
- Button {
- draft = text
- send()
- } label: {
- HStack {
- Text(text)
- .multilineTextAlignment(.leading)
- Spacer()
- Image(systemName: "arrow.up.right")
- }
- .padding(14)
- .background(Color.sureIndigo.opacity(0.08), in: .rect(cornerRadius: 14))
- }
- .buttonStyle(.plain)
- }
-
- private func send() {
- let message = draft
- guard !message.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return }
- draft = ""
- Task { await store.sendMessage(message) }
- }
-}
-
-struct SureMessageBubble: View {
- var message: SureMessage
-
- var body: some View {
- HStack {
- if message.isUser { Spacer(minLength: 44) }
- Text(LocalizedStringKey(message.content))
- .textSelection(.enabled)
- .padding(14)
- .foregroundStyle(message.isUser ? Color.white : Color.primary)
- .background(
- message.isUser ? AnyShapeStyle(Color.sureIndigo) : AnyShapeStyle(.background.secondary),
- in: .rect(cornerRadius: 18)
- )
- if !message.isUser { Spacer(minLength: 44) }
- }
- .padding(.horizontal)
- .accessibilityElement(children: .combine)
- .accessibilityLabel(message.isUser ? "You: \(message.content)" : "Sure Assistant: \(message.content)")
- }
-}
diff --git a/bitrig/App/SureBudgetsView.swift b/bitrig/App/SureBudgetsView.swift
deleted file mode 100644
index 53aad34ca2..0000000000
--- a/bitrig/App/SureBudgetsView.swift
+++ /dev/null
@@ -1,52 +0,0 @@
-import SwiftUI
-
-struct SureBudgetsView: View {
- @Environment(SureStore.self) private var store
-
- var body: some View {
- NavigationStack {
- ScrollView {
- LazyVStack(spacing: 14) {
- ForEach(store.budgets) { budget in
- VStack(alignment: .leading, spacing: 12) {
- HStack {
- VStack(alignment: .leading, spacing: 3) {
- Text(budget.name)
- .font(.headline)
- Text("\(budget.startDate) – \(budget.endDate)")
- .font(.caption)
- .foregroundStyle(.secondary)
- }
- Spacer()
- if budget.current {
- Text("CURRENT")
- .font(.caption2.bold())
- .foregroundStyle(Color.sureMint)
- }
- }
- Divider()
- LabeledContent("Allocated", value: budget.allocatedSpending)
- if let planned = budget.budgetedSpending {
- LabeledContent("Planned", value: planned)
- }
- }
- .padding(18)
- .background(.background.secondary, in: .rect(cornerRadius: 18))
- .accessibilityElement(children: .combine)
- }
- if store.budgets.isEmpty && !store.isLoading {
- ContentUnavailableView(
- "No budgets yet",
- systemImage: "chart.pie",
- description: Text("Create a budget in Sure to track it here.")
- )
- }
- }
- .frame(maxWidth: .infinity)
- .padding()
- }
- .refreshable { await store.refreshAll() }
- .navigationTitle("Budgets")
- }
- }
-}
diff --git a/bitrig/App/SureMainTabView.swift b/bitrig/App/SureMainTabView.swift
deleted file mode 100644
index 8b550bbfd1..0000000000
--- a/bitrig/App/SureMainTabView.swift
+++ /dev/null
@@ -1,29 +0,0 @@
-import SwiftUI
-
-struct SureMainTabView: View {
- @Environment(SureStore.self) private var store
-
- var body: some View {
- @Bindable var store = store
- TabView(selection: $store.selectedTab) {
- SureOverviewView()
- .tabItem { Label("Overview", systemImage: "square.grid.2x2.fill") }
- .tag(SureTab.overview)
-
- SureAccountsView()
- .tabItem { Label("Accounts", systemImage: "building.columns.fill") }
- .tag(SureTab.accounts)
-
- SureBudgetsView()
- .tabItem { Label("Budgets", systemImage: "chart.pie.fill") }
- .tag(SureTab.budgets)
-
- SureAssistantView()
- .tabItem { Label("Assistant", systemImage: "sparkles") }
- .tag(SureTab.assistant)
- }
- .onReceive(NotificationCenter.default.publisher(for: .sureOpenInsights)) { _ in
- store.selectedTab = .overview
- }
- }
-}
diff --git a/bitrig/App/SureOverviewView.swift b/bitrig/App/SureOverviewView.swift
deleted file mode 100644
index ad7796e942..0000000000
--- a/bitrig/App/SureOverviewView.swift
+++ /dev/null
@@ -1,137 +0,0 @@
-import SwiftUI
-
-struct SureOverviewView: View {
- @Environment(SureStore.self) private var store
- @State private var showingSettings = false
-
- var body: some View {
- NavigationStack {
- ScrollView {
- LazyVStack(alignment: .leading, spacing: 22) {
- if !store.insights.isEmpty {
- VStack(alignment: .leading, spacing: 12) {
- HStack {
- Label("AI insights", systemImage: "sparkles")
- .font(.title2.bold())
- Spacer()
- Text("LIVE")
- .font(.caption2.bold())
- .foregroundStyle(Color.sureMint)
- .padding(.horizontal, 8)
- .padding(.vertical, 4)
- .background(Color.sureMint.opacity(0.12), in: .capsule)
- }
- Text("Proactive signals from your latest Sure data")
- .font(.subheadline)
- .foregroundStyle(.secondary)
-
- ForEach(store.insights) { insight in
- SureInsightCard(insight: insight)
- }
- }
- }
-
- if let balance = store.balanceSheet {
- VStack(alignment: .leading, spacing: 18) {
- Text("Net worth")
- .font(.headline)
- .foregroundStyle(.secondary)
- Text(balance.netWorth.formatted)
- .font(.system(.largeTitle, design: .rounded, weight: .bold))
- .contentTransition(.numericText())
-
- HStack(spacing: 12) {
- SureMetricCard(title: "Assets", value: balance.assets.formatted, color: Color.sureMint)
- SureMetricCard(title: "Liabilities", value: balance.liabilities.formatted, color: .orange)
- }
- }
- .padding(20)
- .background(.background.secondary, in: .rect(cornerRadius: 22))
- }
-
- VStack(alignment: .leading, spacing: 12) {
- HStack {
- Text("Accounts")
- .font(.title2.bold())
- Spacer()
- Button("See all") { store.selectedTab = .accounts }
- }
- ForEach(store.accounts.prefix(4)) { account in
- SureAccountRow(account: account)
- }
- }
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding()
- }
- .refreshable { await store.refreshAll() }
- .navigationTitle("Overview")
- .toolbar {
- ToolbarItem(placement: .topBarTrailing) {
- Button("Settings", systemImage: "gearshape") { showingSettings = true }
- .labelStyle(.iconOnly)
- }
- }
- .sheet(isPresented: $showingSettings) {
- SureSettingsView()
- }
- .overlay {
- if store.isLoading && store.balanceSheet == nil {
- ProgressView("Loading your finances…")
- }
- }
- }
- }
-}
-
-struct SureInsightCard: View {
- var insight: SureInsight
-
- var body: some View {
- HStack(alignment: .top, spacing: 14) {
- Image(systemName: insight.symbol)
- .font(.title3)
- .foregroundStyle(insight.priority == "high" ? Color.orange : Color.sureIndigo)
- .frame(width: 36, height: 36)
- .background(
- (insight.priority == "high" ? Color.orange : Color.sureIndigo).opacity(0.12),
- in: .circle
- )
- .accessibilityHidden(true)
- VStack(alignment: .leading, spacing: 5) {
- Text(insight.title)
- .font(.headline)
- Text(insight.body)
- .font(.subheadline)
- .foregroundStyle(.secondary)
- .fixedSize(horizontal: false, vertical: true)
- }
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding(16)
- .background(Color.sureIndigo.opacity(0.055), in: .rect(cornerRadius: 18))
- .accessibilityElement(children: .combine)
- }
-}
-
-struct SureMetricCard: View {
- var title: String
- var value: String
- var color: Color
-
- var body: some View {
- VStack(alignment: .leading, spacing: 6) {
- Text(title)
- .font(.caption)
- .foregroundStyle(.secondary)
- Text(value)
- .font(.headline)
- .lineLimit(1)
- .minimumScaleFactor(0.7)
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding(14)
- .background(color.opacity(0.1), in: .rect(cornerRadius: 14))
- .accessibilityElement(children: .combine)
- }
-}
diff --git a/bitrig/App/SureRootView.swift b/bitrig/App/SureRootView.swift
deleted file mode 100644
index 697154a1d7..0000000000
--- a/bitrig/App/SureRootView.swift
+++ /dev/null
@@ -1,16 +0,0 @@
-import SwiftUI
-
-struct SureRootView: View {
- @Environment(SureStore.self) private var store
-
- var body: some View {
- Group {
- if store.isConfigured {
- SureMainTabView()
- } else {
- SureSetupView()
- }
- }
- .animation(.smooth, value: store.isConfigured)
- }
-}
diff --git a/bitrig/App/SureSettingsView.swift b/bitrig/App/SureSettingsView.swift
deleted file mode 100644
index 48c6272450..0000000000
--- a/bitrig/App/SureSettingsView.swift
+++ /dev/null
@@ -1,96 +0,0 @@
-import SwiftUI
-import UserNotifications
-
-struct SureSettingsView: View {
- @Environment(SureStore.self) private var store
- @Environment(\.dismiss) private var dismiss
- @AppStorage("sure.insightNotifications") private var insightNotifications = false
- @State private var notificationStatus = ""
-
- var body: some View {
- NavigationStack {
- ScrollView {
- VStack(alignment: .leading, spacing: 20) {
- VStack(alignment: .leading, spacing: 8) {
- Text("Connection")
- .font(.headline)
- Label(store.baseURLString, systemImage: "lock.fill")
- .font(.subheadline)
- .foregroundStyle(.secondary)
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding(18)
- .background(.background.secondary, in: .rect(cornerRadius: 18))
-
- VStack(alignment: .leading, spacing: 12) {
- Toggle("AI insight notifications", systemImage: "bell.badge.fill", isOn: $insightNotifications)
- .onChange(of: insightNotifications) {
- Task { await updateNotificationPreference() }
- }
- Text("Get notified when Sure finds a new proactive financial insight. You stay in control in iOS Settings.")
- .font(.subheadline)
- .foregroundStyle(.secondary)
- if !notificationStatus.isEmpty {
- Text(notificationStatus)
- .font(.caption)
- .foregroundStyle(.secondary)
- }
- }
- .padding(18)
- .background(.background.secondary, in: .rect(cornerRadius: 18))
-
- Button(role: .destructive) {
- Task {
- await store.disconnect()
- dismiss()
- }
- } label: {
- Label("Disconnect this device", systemImage: "rectangle.portrait.and.arrow.right")
- .frame(maxWidth: .infinity)
- .padding(14)
- .background(Color.red.opacity(0.09), in: .rect(cornerRadius: 14))
- }
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding()
- }
- .navigationTitle("Settings")
- .navigationBarTitleDisplayMode(.inline)
- .toolbar {
- ToolbarItem(placement: .confirmationAction) {
- Button("Done") { dismiss() }
- }
- }
- .task { await readNotificationStatus() }
- }
- }
-
- private func updateNotificationPreference() async {
- if insightNotifications {
- do {
- let granted = try await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge])
- insightNotifications = granted
- if granted {
- await MainActor.run { UIApplication.shared.registerForRemoteNotifications() }
- notificationStatus = "Notifications are enabled."
- } else {
- notificationStatus = "Notifications are off in iOS Settings."
- }
- } catch {
- insightNotifications = false
- notificationStatus = error.localizedDescription
- }
- } else {
- await store.unregisterPushToken()
- notificationStatus = "Notifications are disabled for this device."
- }
- }
-
- private func readNotificationStatus() async {
- let settings = await UNUserNotificationCenter.current().notificationSettings()
- if settings.authorizationStatus == .denied {
- insightNotifications = false
- notificationStatus = "Notifications are off in iOS Settings."
- }
- }
-}
diff --git a/bitrig/App/SureSetupView.swift b/bitrig/App/SureSetupView.swift
deleted file mode 100644
index 87dc3fbe83..0000000000
--- a/bitrig/App/SureSetupView.swift
+++ /dev/null
@@ -1,91 +0,0 @@
-import SwiftUI
-
-struct SureSetupView: View {
- @Environment(SureStore.self) private var store
- @State private var server = "https://demo.sure.am"
- @State private var apiKey = ""
- @FocusState private var focusedField: SetupField?
-
- var body: some View {
- NavigationStack {
- ScrollView {
- VStack(alignment: .leading, spacing: 24) {
- VStack(alignment: .leading, spacing: 10) {
- Image(systemName: "circle.hexagongrid.fill")
- .font(.system(size: 52))
- .foregroundStyle(.tint)
- .accessibilityHidden(true)
- Text("Your finances, made clear")
- .font(.largeTitle.bold())
- Text("Connect securely to Sure with an API key. Your key stays in this device’s Keychain.")
- .font(.title3)
- .foregroundStyle(.secondary)
- }
-
- VStack(spacing: 16) {
- TextField("Sure server", text: $server)
- .textContentType(.URL)
- .keyboardType(.URL)
- .textInputAutocapitalization(.never)
- .autocorrectionDisabled()
- .focused($focusedField, equals: .server)
- .accessibilityLabel("Sure server address")
- SecureField("Read/write API key", text: $apiKey)
- .textContentType(.password)
- .focused($focusedField, equals: .apiKey)
- .accessibilityLabel("Sure read/write API key")
- }
- .padding(18)
- .background(.background.secondary, in: .rect(cornerRadius: 20))
-
- VStack(alignment: .leading, spacing: 10) {
- Label("Connect to the demo", systemImage: "person.badge.key.fill")
- .font(.headline)
- Text("Sign in through the Sure demo, then create a read/write key in Settings → API keys. Paste that key above.")
- .font(.subheadline)
- .foregroundStyle(.secondary)
- Link("Open Sure demo", destination: URL(string: "https://demo.sure.am")!)
- .font(.subheadline.weight(.semibold))
- }
- .padding(16)
- .background(Color.sureIndigo.opacity(0.09), in: .rect(cornerRadius: 16))
-
- if let errorMessage = store.errorMessage {
- Label(errorMessage, systemImage: "exclamationmark.triangle.fill")
- .font(.subheadline)
- .foregroundStyle(.red)
- .accessibilityAddTraits(.isStaticText)
- }
-
- Button {
- focusedField = nil
- Task { await store.connect(baseURL: server, apiKey: apiKey) }
- } label: {
- HStack {
- if store.isLoading {
- ProgressView()
- .tint(.white)
- }
- Text(store.isLoading ? "Connecting…" : "Connect to Sure")
- .fontWeight(.semibold)
- Spacer()
- Image(systemName: "arrow.right")
- }
- .foregroundStyle(.white)
- .padding()
- .background(Color.sureIndigo, in: .rect(cornerRadius: 16))
- }
- .disabled(apiKey.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || store.isLoading)
- }
- .frame(maxWidth: 620, alignment: .leading)
- .padding(24)
- }
- .navigationTitle("Sure")
- }
- }
-}
-
-private enum SetupField {
- case server
- case apiKey
-}
diff --git a/bitrig/App/SureStore.swift b/bitrig/App/SureStore.swift
deleted file mode 100644
index accf67c68b..0000000000
--- a/bitrig/App/SureStore.swift
+++ /dev/null
@@ -1,475 +0,0 @@
-import Foundation
-import Observation
-import UserNotifications
-import UIKit
-
-@MainActor
-@Observable
-final class SureStore {
- var isConfigured = false
- var isLoading = false
- var errorMessage: String?
- var balanceSheet: BalanceSheet?
- var accounts: [SureAccount] = []
- var budgets: [SureBudget] = []
- var insights: [SureInsight] = []
- var chats: [SureChat] = []
- var selectedChat: SureChat?
- var messages: [SureMessage] = []
- var isAssistantThinking = false
- var selectedTab = SureTab.overview
-
- private(set) var baseURLString = "https://demo.sure.am"
- private var client = SureAPIClient(baseURL: URL(string: "https://demo.sure.am")!, apiKey: "")
- private var sessionGeneration = 0
- private var chatGeneration = 0
-
- func restoreSession() async {
- let generation = sessionGeneration
- baseURLString = UserDefaults.standard.string(forKey: "sure.baseURL") ?? "https://demo.sure.am"
- guard let key = KeychainStore.readAPIKey(), !key.isEmpty,
- let url = normalizedURL(baseURLString) else { return }
- await client.update(baseURL: url, apiKey: key)
- guard sessionGeneration == generation else { return }
- do {
- let balance: BalanceSheet = try await client.get("api/v1/balance_sheet")
- guard sessionGeneration == generation else { return }
- balanceSheet = balance
- isConfigured = true
- await refreshAll()
- } catch {
- guard sessionGeneration == generation else { return }
- errorMessage = "Your saved connection needs attention. \(error.localizedDescription)"
- }
- }
-
- func connect(baseURL: String, apiKey: String) async -> Bool {
- guard let url = normalizedURL(baseURL) else {
- errorMessage = "Enter a valid HTTPS server address."
- return false
- }
- sessionGeneration &+= 1
- chatGeneration &+= 1
- let generation = sessionGeneration
- isLoading = true
- errorMessage = nil
- await client.update(baseURL: url, apiKey: apiKey.trimmingCharacters(in: .whitespacesAndNewlines))
- guard sessionGeneration == generation else { return false }
- do {
- let balance: BalanceSheet = try await client.get("api/v1/balance_sheet")
- guard sessionGeneration == generation else { return false }
- balanceSheet = balance
- try KeychainStore.saveAPIKey(apiKey.trimmingCharacters(in: .whitespacesAndNewlines))
- baseURLString = url.absoluteString.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
- UserDefaults.standard.set(baseURLString, forKey: "sure.baseURL")
- isConfigured = true
- isLoading = false
- await refreshAll()
- return sessionGeneration == generation
- } catch {
- guard sessionGeneration == generation else { return false }
- errorMessage = error.localizedDescription
- isLoading = false
- return false
- }
- }
-
- func disconnect() async {
- sessionGeneration &+= 1
- chatGeneration &+= 1
- await unregisterPushToken()
- KeychainStore.deleteAPIKey()
- UserDefaults.standard.removeObject(forKey: "sure.pushSubscriptionID")
- UserDefaults.standard.set(false, forKey: "sure.insightNotifications")
- isConfigured = false
- isLoading = false
- isAssistantThinking = false
- errorMessage = nil
- balanceSheet = nil
- accounts = []
- budgets = []
- insights = []
- chats = []
- selectedChat = nil
- messages = []
- }
-
- func refreshAll() async {
- let generation = sessionGeneration
- isLoading = true
- errorMessage = nil
- async let balanceRequest: BalanceSheet = client.get("api/v1/balance_sheet")
- async let accountsRequest = loadAllPages(
- path: "api/v1/accounts",
- collection: AccountCollection.self,
- items: \.accounts
- )
- async let budgetsRequest = loadAllPages(
- path: "api/v1/budgets",
- collection: BudgetCollection.self,
- items: \.budgets
- )
- do {
- let (balance, loadedAccounts, loadedBudgets) = try await (
- balanceRequest,
- accountsRequest,
- budgetsRequest
- )
- guard sessionGeneration == generation else { return }
- balanceSheet = balance
- accounts = loadedAccounts
- budgets = loadedBudgets
- } catch {
- guard sessionGeneration == generation else { return }
- errorMessage = error.localizedDescription
- isLoading = false
- return
- }
-
- do {
- let loadedChats = try await loadAllPages(
- path: "api/v1/chats",
- collection: ChatCollection.self,
- items: \.chats
- )
- guard sessionGeneration == generation else { return }
- chats = loadedChats
- } catch let error as SureAPIError {
- guard sessionGeneration == generation else { return }
- if case .server(status: 403, message: _) = error {
- chats = []
- } else {
- errorMessage = error.localizedDescription
- }
- } catch {
- guard sessionGeneration == generation else { return }
- errorMessage = error.localizedDescription
- }
-
- await loadInsights()
- guard sessionGeneration == generation else { return }
- if UserDefaults.standard.bool(forKey: "sure.insightNotifications") {
- if let token = UserDefaults.standard.string(forKey: "sure.apnsDeviceToken") {
- await registerPushToken(token)
- }
- } else {
- await unregisterPushToken()
- }
- guard sessionGeneration == generation else { return }
- isLoading = false
- }
-
- func loadInsights() async {
- let generation = sessionGeneration
- do {
- let collection: InsightCollection = try await client.get("api/v1/insights")
- guard sessionGeneration == generation else { return }
- insights = collection.insights
- } catch let error as SureAPIError {
- guard sessionGeneration == generation else { return }
- if case .server(status: 404, message: _) = error {
- insights = makeLocalInsights()
- } else if case .server(status: 403, message: _) = error {
- insights = []
- } else {
- errorMessage = error.localizedDescription
- }
- } catch {
- guard sessionGeneration == generation else { return }
- errorMessage = error.localizedDescription
- }
- }
-
- func loadChat(_ chat: SureChat) async {
- chatGeneration &+= 1
- let generation = sessionGeneration
- let conversationGeneration = chatGeneration
- selectedChat = chat
- isAssistantThinking = false
- do {
- let detail = try await loadLatestChatDetail(chatID: chat.id)
- guard sessionGeneration == generation,
- chatGeneration == conversationGeneration,
- selectedChat?.id == chat.id else { return }
- messages = detail.messages.sorted { $0.createdAt < $1.createdAt }
- } catch {
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- errorMessage = error.localizedDescription
- }
- }
-
- func newChat() {
- chatGeneration &+= 1
- selectedChat = nil
- messages = []
- isAssistantThinking = false
- }
-
- func sendMessage(_ content: String) async {
- let text = content.trimmingCharacters(in: .whitespacesAndNewlines)
- guard !text.isEmpty, !isAssistantThinking else { return }
- let generation = sessionGeneration
- let conversationGeneration = chatGeneration
- isAssistantThinking = true
- errorMessage = nil
- do {
- if let selectedChat {
- let request = MessageRequest(content: text)
- let _: MessageReceipt = try await client.post(
- "api/v1/chats/\(selectedChat.id)/messages",
- body: request
- )
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- messages.append(SureMessage(
- id: UUID().uuidString,
- type: "user_message",
- role: "user",
- content: text,
- createdAt: ISO8601DateFormatter().string(from: Date())
- ))
- } else {
- let request = NewChatRequest(title: makeTitle(from: text), message: text)
- let detail: ChatDetail = try await client.post("api/v1/chats", body: request)
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- selectedChat = detail.chat
- messages = detail.messages.sorted { $0.createdAt < $1.createdAt }
- }
- try await pollForAssistantResponse(
- sessionGeneration: generation,
- chatGeneration: conversationGeneration
- )
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- let loadedChats = try await loadAllPages(
- path: "api/v1/chats",
- collection: ChatCollection.self,
- items: \.chats
- )
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- chats = loadedChats
- } catch {
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- errorMessage = error.localizedDescription
- }
- guard sessionGeneration == generation, chatGeneration == conversationGeneration else { return }
- isAssistantThinking = false
- }
-
- func registerPushToken(_ token: String) async {
- guard isConfigured, UserDefaults.standard.bool(forKey: "sure.insightNotifications") else { return }
- let generation = sessionGeneration
- let environment = APNsEnvironment.current
- let request = PushSubscriptionRequest(
- token: token,
- environment: environment.rawValue,
- platform: "ios"
- )
- do {
- let receipt: PushSubscriptionReceipt = try await client.post(
- "api/v1/push_subscriptions",
- body: request
- )
- guard sessionGeneration == generation else {
- try? await client.delete("api/v1/push_subscriptions/\(receipt.id)")
- return
- }
- UserDefaults.standard.set(receipt.id, forKey: "sure.pushSubscriptionID")
- } catch let error as SureAPIError {
- guard sessionGeneration == generation else { return }
- if case .server(status: 404, message: _) = error { return }
- errorMessage = error.localizedDescription
- } catch {
- guard sessionGeneration == generation else { return }
- errorMessage = error.localizedDescription
- }
- }
-
- func unregisterPushToken() async {
- guard isConfigured,
- let id = UserDefaults.standard.string(forKey: "sure.pushSubscriptionID") else { return }
- let generation = sessionGeneration
- do {
- try await client.delete("api/v1/push_subscriptions/\(id)")
- guard sessionGeneration == generation else { return }
- UserDefaults.standard.removeObject(forKey: "sure.pushSubscriptionID")
- } catch let error as SureAPIError {
- guard sessionGeneration == generation else { return }
- if case .server(status: 404, message: _) = error {
- UserDefaults.standard.removeObject(forKey: "sure.pushSubscriptionID")
- return
- }
- errorMessage = error.localizedDescription
- } catch {
- guard sessionGeneration == generation else { return }
- errorMessage = error.localizedDescription
- }
- }
-
- private func pollForAssistantResponse(sessionGeneration: Int, chatGeneration: Int) async throws {
- guard let chat = selectedChat else { return }
- let previousAssistantIDs = Set(messages.filter { !$0.isUser }.map(\.id))
- let retryDelays = [3, 5, 8, 13, 21, 34]
- for delay in retryDelays {
- try await Task.sleep(for: .seconds(delay))
- guard self.sessionGeneration == sessionGeneration,
- self.chatGeneration == chatGeneration,
- !Task.isCancelled else { return }
- let detail: ChatDetail
- do {
- detail = try await loadLatestChatDetail(chatID: chat.id)
- } catch let error as SureAPIError {
- if case .server(status: 429, message: _) = error {
- throw error
- }
- continue
- } catch {
- continue
- }
- guard self.sessionGeneration == sessionGeneration,
- self.chatGeneration == chatGeneration else { return }
- messages = detail.messages.sorted { $0.createdAt < $1.createdAt }
- if messages.contains(where: { !$0.isUser && !previousAssistantIDs.contains($0.id) && !$0.content.isEmpty }) {
- return
- }
- }
- guard self.sessionGeneration == sessionGeneration, self.chatGeneration == chatGeneration else { return }
- errorMessage = "The assistant is still working. Pull to refresh this conversation in a moment."
- }
-
- private func loadAllPages<Collection: Decodable & Sendable, Item: Sendable>(
- path: String,
- collection: Collection.Type,
- items: KeyPath<Collection, [Item]>
- ) async throws -> [Item] where Collection: PaginatedCollection {
- let firstPage = try await client.get("\(path)?page=1&per_page=100", as: collection)
- var allItems = firstPage[keyPath: items]
- let totalPages = firstPage.pagination?.totalPages ?? 1
- guard totalPages > 1 else { return allItems }
-
- for page in 2...totalPages {
- let nextPage = try await client.get("\(path)?page=\(page)&per_page=100", as: collection)
- allItems.append(contentsOf: nextPage[keyPath: items])
- }
- return allItems
- }
-
- private func loadLatestChatDetail(chatID: String) async throws -> ChatDetail {
- let firstPage: ChatDetail = try await client.get("api/v1/chats/\(chatID)")
- guard let pagination = firstPage.pagination,
- pagination.totalPages > pagination.page else { return firstPage }
-
- return try await client.get("api/v1/chats/\(chatID)?page=\(pagination.totalPages)")
- }
-
- private func makeLocalInsights() -> [SureInsight] {
- var generated: [SureInsight] = []
- if let balanceSheet {
- let liabilities = balanceSheet.liabilities.decimalAmount.magnitude
- let assets = balanceSheet.assets.decimalAmount.magnitude
- if liabilities > 0, assets > 0 {
- let ratio = NSDecimalNumber(decimal: liabilities / assets).doubleValue
- generated.append(SureInsight(
- id: "live-debt-ratio",
- type: ratio > 0.5 ? "cash_flow_warning" : "budget_on_track",
- title: ratio > 0.5 ? "Liabilities need attention" : "Your balance sheet looks resilient",
- body: "Liabilities are \((ratio * 100).formatted(.number.precision(.fractionLength(0))))% of assets, based on your live Sure balances.",
- priority: ratio > 0.5 ? "high" : "low",
- status: "active"
- ))
- }
- }
- if let largest = accounts.filter(\.isAsset).max(by: { abs($0.balanceCents) < abs($1.balanceCents) }) {
- generated.append(SureInsight(
- id: "live-largest-account",
- type: "idle_cash",
- title: "Review your largest account",
- body: "\(largest.name) holds \(largest.balance). Ask the Assistant whether that concentration fits your goals.",
- priority: "medium",
- status: "active"
- ))
- }
- if let currentBudget = budgets.first(where: \.current) {
- generated.append(SureInsight(
- id: "live-current-budget",
- type: "budget_on_track",
- title: "Your current plan is ready to review",
- body: "\(currentBudget.name) has \(currentBudget.allocatedSpending) allocated. Check it before the period ends.",
- priority: "low",
- status: "active"
- ))
- }
- return Array(generated.prefix(3))
- }
-
- private func makeTitle(from content: String) -> String {
- String(content.prefix(48))
- }
-
- private func normalizedURL(_ input: String) -> URL? {
- guard var components = URLComponents(string: input.trimmingCharacters(in: .whitespacesAndNewlines)),
- components.scheme == "https", components.host != nil else { return nil }
- components.path = components.path.trimmingCharacters(in: CharacterSet(charactersIn: "/")) + "/"
- return components.url
- }
-}
-
-enum SureTab: Hashable {
- case overview
- case accounts
- case budgets
- case assistant
-}
-
-protocol PaginatedCollection {
- var pagination: SurePagination? { get }
-}
-
-extension AccountCollection: PaginatedCollection {}
-extension BudgetCollection: PaginatedCollection {}
-extension ChatCollection: PaginatedCollection {}
-
-struct NewChatRequest: Codable, Sendable {
- var title: String
- var message: String
-}
-
-struct MessageRequest: Codable, Sendable {
- var content: String
-}
-
-struct MessageReceipt: Codable, Sendable {
- var id: String
- var chatId: String
-
- enum CodingKeys: String, CodingKey {
- case id
- case chatId = "chat_id"
- }
-}
-
-struct PushSubscriptionRequest: Codable, Sendable {
- var token: String
- var environment: String
- var platform: String
-}
-
-struct PushSubscriptionReceipt: Codable, Sendable {
- var id: String
-}
-
-enum APNsEnvironment: String {
- case sandbox
- case production
-
- static var current: APNsEnvironment {
- #if targetEnvironment(simulator)
- return .sandbox
- #else
- guard let profileURL = Bundle.main.url(forResource: "embedded", withExtension: "mobileprovision"),
- let profileData = try? Data(contentsOf: profileURL),
- let profileText = String(data: profileData, encoding: .isoLatin1) else {
- return .production
- }
- return profileText.contains("<string>development</string>") ? .sandbox : .production
- #endif
- }
-}
diff --git a/bitrig/README.md b/bitrig/README.md
deleted file mode 100644
index b0c6979c08..0000000000
--- a/bitrig/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Sure for iOS and iPadOS
-
-This SwiftUI client connects directly to a Sure instance with `X-Api-Key` authentication.
-
-## Demo connection
-
-- Server: `https://demo.sure.am`
-- Sign in through the demo website using the credentials presented there.
-- Create a **read/write** key under Settings → API keys, then paste it into the native app. The key is stored only in the device Keychain.
-
-Do not commit an API key. The shared demo account is refreshed regularly, so a generated key may need to be recreated.
-
-## AI insight notifications
-
-The app target includes the APNs entitlement and registers device tokens only after the user enables AI insight notifications. Tokens are sent to `POST /api/v1/push_subscriptions` with their sandbox or production environment. The project source intentionally keeps `aps-environment` set to `development`; Apple distribution signing replaces it with `production` for TestFlight and App Store builds.
-
-Server delivery additionally requires a paid Apple Developer Program membership and these backend secrets: `APNS_KEY_ID`, `APNS_TEAM_ID`, `APNS_BUNDLE_ID`, and `APNS_PRIVATE_KEY_BASE64` (the base64-encoded `.p8` contents). Never add their values to this app or repository. Newly created or resurfaced insights enqueue one APNs delivery per recently registered device; development installs use APNs sandbox, while TestFlight and App Store builds use production APNs.