Skip to content

Commit cba8a23

Browse files
authored
[LOOP-5826] Preset Onboarding References (#921)
1 parent 8e35b8f commit cba8a23

4 files changed

Lines changed: 180 additions & 0 deletions

File tree

Loop.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
7D70765E1FE06EE3004AC8EA /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7D7076601FE06EE3004AC8EA /* Localizable.strings */; };
222222
7D7076631FE06EE4004AC8EA /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7D7076651FE06EE4004AC8EA /* Localizable.strings */; };
223223
7E69CFFC2A16A77E00203CBD /* ResetLoopManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E69CFFB2A16A77E00203CBD /* ResetLoopManager.swift */; };
224+
841306BB2F7F0D9C00AF0320 /* ReferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841306BA2F7F0D9C00AF0320 /* ReferencesView.swift */; };
224225
84213C752D932F0F00642E78 /* InsulinDeliveryLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84213C742D932F0F00642E78 /* InsulinDeliveryLog.swift */; };
225226
84213C892D94941000642E78 /* InsulinDeliveryLogEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84213C882D94941000642E78 /* InsulinDeliveryLogEvent.swift */; };
226227
84213C8B2D94948900642E78 /* InsulinDeliveryOverview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84213C8A2D94948900642E78 /* InsulinDeliveryOverview.swift */; };
@@ -1115,6 +1116,7 @@
11151116
7E69CFFB2A16A77E00203CBD /* ResetLoopManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetLoopManager.swift; sourceTree = "<group>"; };
11161117
80F864E52433BF5D0026EC26 /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/InfoPlist.strings; sourceTree = "<group>"; };
11171118
840A2F0D2C0F978E003D5E90 /* LoopKitUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LoopKitUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1119+
841306BA2F7F0D9C00AF0320 /* ReferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReferencesView.swift; sourceTree = "<group>"; };
11181120
84213C742D932F0F00642E78 /* InsulinDeliveryLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsulinDeliveryLog.swift; sourceTree = "<group>"; };
11191121
84213C882D94941000642E78 /* InsulinDeliveryLogEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsulinDeliveryLogEvent.swift; sourceTree = "<group>"; };
11201122
84213C8A2D94948900642E78 /* InsulinDeliveryOverview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsulinDeliveryOverview.swift; sourceTree = "<group>"; };
@@ -2451,6 +2453,7 @@
24512453
842E409D2F22F7E2000CCCE0 /* TherapySettingsExampleView.swift */,
24522454
842E409F2F22F7E2000CCCE0 /* IntensitySlider.swift */,
24532455
842E40A02F22F7E2000CCCE0 /* TintedContent.swift */,
2456+
841306BA2F7F0D9C00AF0320 /* ReferencesView.swift */,
24542457
);
24552458
path = Components;
24562459
sourceTree = "<group>";
@@ -3699,6 +3702,7 @@
36993702
C174233C259BEB0F00399C9D /* ManualEntryDoseViewModel.swift in Sources */,
37003703
1D05219B2469E9DF000EBBDE /* StoredAlert.swift in Sources */,
37013704
84FA9D332CF7FD0D004162B4 /* PresetsHistoryView.swift in Sources */,
3705+
841306BB2F7F0D9C00AF0320 /* ReferencesView.swift in Sources */,
37023706
C1E3862628247C6100F561A4 /* StoredLoopNotRunningNotification.swift in Sources */,
37033707
A97F250825E056D500F0EE19 /* OnboardingManager.swift in Sources */,
37043708
438D42F91D7C88BC003244B0 /* PredictionInputEffect.swift in Sources */,
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// ReferencesView.swift
3+
// Loop
4+
//
5+
// Created by Cameron Ingham on 4/2/26.
6+
// Copyright © 2026 LoopKit Authors. All rights reserved.
7+
//
8+
9+
import LoopKitUI
10+
import SwiftUI
11+
12+
public struct ReferencesView: View {
13+
14+
@State private var isExpanded: Bool = false
15+
@State private var selectedURL: URL? = nil
16+
17+
private let references: [Text]
18+
19+
init(_ references: [Text]) {
20+
self.references = references
21+
}
22+
23+
public var body: some View {
24+
VStack(alignment: .leading, spacing: 12) {
25+
HStack(spacing: 0) {
26+
Text("References")
27+
.frame(maxWidth: .infinity, alignment: .leading)
28+
29+
Spacer()
30+
31+
Text(Image(systemName: "chevron.up"))
32+
.rotationEffect(.degrees(isExpanded ? 0 : 180))
33+
.foregroundStyle(.secondary)
34+
}
35+
.contentShape(Rectangle())
36+
.onTapGesture {
37+
isExpanded.toggle()
38+
}
39+
40+
if isExpanded {
41+
Grid(horizontalSpacing: 4, verticalSpacing: 12) {
42+
ForEach(references.indices, id: \.self) { referenceId in
43+
GridRow(alignment: .top) {
44+
Text("\(referenceId + 1).")
45+
46+
references[referenceId]
47+
.frame(maxWidth: .infinity, alignment: .leading)
48+
.accentColor(.secondary)
49+
}
50+
}
51+
}
52+
.font(.footnote)
53+
.foregroundStyle(.secondary)
54+
}
55+
}
56+
.animation(.default, value: isExpanded)
57+
.environment(\.openURL, OpenURLAction { url in
58+
self.selectedURL = url
59+
return .handled
60+
})
61+
.sheet(
62+
isPresented: Binding(
63+
get: { selectedURL != nil },
64+
set: { _,_ in selectedURL = nil }
65+
),
66+
content: {
67+
NavigationStack {
68+
WebView(url: selectedURL!)
69+
.toolbar {
70+
ToolbarItem(placement: .topBarTrailing) {
71+
Button {
72+
selectedURL = nil
73+
} label: {
74+
Image(systemName: "xmark.circle.fill")
75+
.font(.system(size: 24))
76+
.foregroundColor(.secondary)
77+
}
78+
}
79+
}
80+
}
81+
}
82+
)
83+
}
84+
}

0 commit comments

Comments
 (0)