Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(ios): animate the thinking orb in the dynamic island

leepokaib62b4be6814a
diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxproj
index 102f3a1b..fb191513 100644
--- a/apps/Codync.xcodeproj/project.pbxproj
+++ b/apps/Codync.xcodeproj/project.pbxproj
@@ -11,6 +11,7 @@
01A1F820EFEE49A8FCCFC3F3 /* BotListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0582B6169BFC36E4BCD51C0D /* BotListView.swift */; };
0631979397E0D6822747E03A /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6E13F8EA6C7B0DA4D899FEE /* RootView.swift */; };
0C920E4962F182ADF75670C5 /* CodyncBot-tablet-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 120FD9DBA315A6DD543463D8 /* CodyncBot-tablet-Ink.ttf */; };
+ 0D6E2869DC5A1BC7D6385444 /* CodyncOrb-Dot.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0C44BCF971511A5E94D073D5 /* CodyncOrb-Dot.ttf */; };
17DD96A91B1EC2AE699F4A2F /* ViewingBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C0E04490F5C56FD070539E6 /* ViewingBadge.swift */; };
1855DC364C2F8E5B62878BD8 /* CodyncBot-teardrop-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 203A43D8DF8D3832F95FA837 /* CodyncBot-teardrop-Ink.ttf */; };
198096547EAA6C5FBB68558F /* CodyncBot-hex-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 89A0D530BEF30AF36F9DBEA8 /* CodyncBot-hex-Ink.ttf */; };
@@ -49,6 +50,7 @@
980C29719BDE2E874C9AD53A /* CodyncBot-wedge-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C3BB9F034194450254CE14EC /* CodyncBot-wedge-Tint.ttf */; };
9BBB2FAEDBD35A83EAB02981 /* AccountSwitcherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB282B31FBC94EE70D07638 /* AccountSwitcherView.swift */; };
AA601649E43A5AF73DCF5B5E /* WebRTC in Frameworks */ = {isa = PBXBuildFile; productRef = 2D9748E611692583AFC5A152 /* WebRTC */; };
+ ABE57DA1C72A08A22262AAB1 /* CodyncOrb-Ghost.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8E783FFF5EC2697C16FA2E1B /* CodyncOrb-Ghost.ttf */; };
B09F6D6EDC6C6B0B9919D6BF /* CodyncBot-blob-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C484135603CEF437C27BE67B /* CodyncBot-blob-Ink.ttf */; };
B1815C13D0D78E99415C2DC2 /* CodyncBot-cloud-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5A21538E748C62E82DF7B139 /* CodyncBot-cloud-Ink.ttf */; };
B3450CFD87D4096B3BCA7885 /* CodyncBot-wedge-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C6B96EE690FC5355C9E3D1B5 /* CodyncBot-wedge-Ink.ttf */; };
@@ -101,6 +103,7 @@
0582B6169BFC36E4BCD51C0D /* BotListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotListView.swift; sourceTree = "<group>"; };
0829A4FCADAC108E8C2DB2F1 /* Widgets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Widgets.entitlements; sourceTree = "<group>"; };
0A87B0091DAF0E4807D62017 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
+ 0C44BCF971511A5E94D073D5 /* CodyncOrb-Dot.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncOrb-Dot.ttf"; sourceTree = "<group>"; };
120FD9DBA315A6DD543463D8 /* CodyncBot-tablet-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-tablet-Ink.ttf"; sourceTree = "<group>"; };
1318104275E5BEC47B7088AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
1E47C60032C326157E0386B8 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
@@ -127,6 +130,7 @@
89A0D530BEF30AF36F9DBEA8 /* CodyncBot-hex-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-hex-Ink.ttf"; sourceTree = "<group>"; };
8BA06CEE98A7CDED62678522 /* Input.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Input.swift; sourceTree = "<group>"; };
8CC3E47D480A5F15CA95C504 /* HostLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostLink.swift; sourceTree = "<group>"; };
+ 8E783FFF5EC2697C16FA2E1B /* CodyncOrb-Ghost.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncOrb-Ghost.ttf"; sourceTree = "<group>"; };
9AD0BD16672E128A4F26272B /* SignInButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInButtons.swift; sourceTree = "<group>"; };
A65FE0504B741D0B44DB2516 /* CodyncApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodyncApp.swift; sourceTree = "<group>"; };
AAD970B8394F4EDFB85A8936 /* CodyncBot-cloud-Tint.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-cloud-Tint.ttf"; sourceTree = "<group>"; };
@@ -218,6 +222,8 @@
C8F46BD8301E7E2C83C35111 /* CodyncBot-teardrop-Tint.ttf */,
C6B96EE690FC5355C9E3D1B5 /* CodyncBot-wedge-Ink.ttf */,
C3BB9F034194450254CE14EC /* CodyncBot-wedge-Tint.ttf */,
+ 0C44BCF971511A5E94D073D5 /* CodyncOrb-Dot.ttf */,
+ 8E783FFF5EC2697C16FA2E1B /* CodyncOrb-Ghost.ttf */,
);
path = Fonts;
sourceTree = "<group>";
@@ -531,6 +537,8 @@
E78E3B5FAFEB79F31AAC104D /* CodyncBot-teardrop-Tint.ttf in Resources */,
B3450CFD87D4096B3BCA7885 /* CodyncBot-wedge-Ink.ttf in Resources */,
980C29719BDE2E874C9AD53A /* CodyncBot-wedge-Tint.ttf in Resources */,
+ 0D6E2869DC5A1BC7D6385444 /* CodyncOrb-Dot.ttf in Resources */,
+ ABE57DA1C72A08A22262AAB1 /* CodyncOrb-Ghost.ttf in Resources */,
674BCFBAC7022359FB673FDB /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift b/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift
index 68f1ac8b..01bb58d5 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift
@@ -201,13 +201,13 @@ public struct ActivityIslandFooter: View {
if state.phase == .needsInput {
ActivityReviewButton(state: state, link: link)
} else if let since = state.elapsedStart(startedAt) {
- // One centered Text: a timer Text claims its widest width, so as a Label it
- // sat left of center.
- Text("\(Image(systemName: "timer")) \(Text(since, style: .timer))")
+ // The timer alone, centered on its own: a timer Text reserves its widest width,
+ // so beside an icon (or interpolated with one) it sat off center.
+ Text(since, style: .timer)
+ .font(.system(size: 13, weight: .medium))
.monospacedDigit()
+ .foregroundStyle(Palette.tertiary)
.multilineTextAlignment(.center)
- .font(.system(size: 12))
- .foregroundStyle(Palette.secondary)
.frame(maxWidth: .infinity)
}
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift b/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift
index 2d3c415c..b67cd2e3 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift
@@ -137,7 +137,7 @@ struct DottedBody: View {
}
/// The working loop the Dynamic Island plays one frame per second (a timer Text in a font
- /// whose digits are these frames; see tools/bot-frame-fonts.py): the light circles the ball
+ /// whose digits are these frames; see tools/timer-fonts.py): the light circles the ball
/// once, the eyes look right, back, left, and blink on the last frame.
static func workingLoop(shape: String, size: CGFloat) -> [[Ink]] {
let cells = DotGrid(size: size)
diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift b/apps/ios/Kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift
index 290b1eb3..5243c159 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift
@@ -45,6 +45,12 @@ enum ThinkingOrbGeometry {
return frame
}
+ /// The working orb the Dynamic Island plays one frame per second (tools/timer-fonts.py):
+ /// ten frames 0.6 engine units apart, so each dot moves a short, readable step.
+ static func workingLoop(size: Double) -> [Frame] {
+ (0..<10).map { frame(state: .working, size: size, time: 0.6 + Double($0) * 0.6) }
+ }
+
private static func projector(_ yaw: Double, _ tilt: Double, _ size: Double, _ scale: Double) -> (Point) -> Point {
let sy = sin(yaw), cy = cos(yaw), st = sin(tilt), ct = cos(tilt)
return { p in
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/SurfaceRenderTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/SurfaceRenderTests.swift
index 99648a26..5a0308fc 100644
--- a/apps/ios/Kit/Tests/CodyncKitTests/SurfaceRenderTests.swift
+++ b/apps/ios/Kit/Tests/CodyncKitTests/SurfaceRenderTests.swift
@@ -70,21 +70,28 @@ import Testing
try data.write(to: URL(fileURLWithPath: path))
}
-/// Writes the Dynamic Island's working loop (every shape, 10 frames, in points of a 20 pt face)
-/// for tools/bot-frame-fonts.py: `TEST_RUNNER_CODYNC_FRAMES_FILE=<file.json> xcodebuild test …
-/// -only-testing:'CodyncKitTests/exportBotFrames()'`.
+/// Writes the Dynamic Island's working loops (the bot in every shape and the thinking orb,
+/// 10 frames each, in points of a 20 pt face) for tools/timer-fonts.py:
+/// `TEST_RUNNER_CODYNC_FRAMES_FILE=<file.json> xcodebuild test … -only-testing:'CodyncKitTests/exportBotFrames()'`.
+/// Each font is one layer: `Ink` every dot of the bot, `Tint` its lit dots (in its color),
+/// `Ghost` the orb's faint orbit trails, `Dot` its moving dots.
@MainActor @Test func exportBotFrames() throws {
guard let file = ProcessInfo.processInfo.environment["CODYNC_FRAMES_FILE"] else { return }
- let shapes = ["blob", "pebble", "squircle", "tablet", "wedge", "hex", "cloud", "teardrop"]
- var out: [String: [[[String: Double]]]] = [:]
- for shape in shapes {
- out[shape] = DottedBody.workingLoop(shape: shape, size: 20).map { frame in
- frame.filter { !$0.eye }.map {
- ["x": $0.dot.center.x, "y": $0.dot.center.y, "r": $0.radius, "ink": $0.ink, "tint": $0.tint]
- }
+ func dots(_ list: [(x: Double, y: Double, r: Double)]) -> [[String: Double]] {
+ list.map { ["x": $0.x, "y": $0.y, "r": $0.r] }
+ }
+ var fonts: [String: [[[String: Double]]]] = [:]
+ for shape in ["blob", "pebble", "squircle", "tablet", "wedge", "hex", "cloud", "teardrop"] {
+ let loop = DottedBody.workingLoop(shape: shape, size: 20)
+ fonts["CodyncBot-\(shape)-Ink"] = loop.map { f in dots(f.filter { !$0.eye }.map { ($0.dot.center.x, $0.dot.center.y, $0.radius) }) }
+ fonts["CodyncBot-\(shape)-Tint"] = loop.map { f in
+ dots(f.filter { !$0.eye && $0.tint > 0.35 }.map { ($0.dot.center.x, $0.dot.center.y, $0.radius) })
}
}
- let data = try JSONSerialization.data(withJSONObject: ["size": 20, "shapes": out], options: [.sortedKeys])
+ let orb = ThinkingOrbGeometry.workingLoop(size: 20)
+ fonts["CodyncOrb-Ghost"] = orb.map { f in dots(f.dots.filter { $0.alpha < 1 }.map { ($0.x, $0.y, $0.radius) }) }
+ fonts["CodyncOrb-Dot"] = orb.map { f in dots(f.dots.filter { $0.alpha >= 1 }.map { ($0.x, $0.y, $0.radius) }) }
+ let data = try JSONSerialization.data(withJSONObject: ["size": 20, "fonts": fonts], options: [.sortedKeys])
try data.write(to: URL(fileURLWithPath: file))
}
diff --git a/apps/ios/Widgets/CodyncWidgets.swift b/apps/ios/Widgets/CodyncWidgets.swift
index 90ffa900..76b06cbb 100644
--- a/apps/ios/Widgets/CodyncWidgets.swift
+++ b/apps/ios/Widgets/CodyncWidgets.swift
@@ -22,7 +22,7 @@ struct CodyncWidgets: WidgetBundle {
struct BotsEntry: TimelineEntry {
let date: Date
- let bots: [Bot]
+ var bots: [Bot]
let paired: Bool
var links: [String: URL] = [:]
@@ -40,6 +40,14 @@ struct BotsEntry: TimelineEntry {
}
return BotsEntry(date: .now, bots: bots, paired: !storage.computers.isEmpty, links: links)
}
+
+ /// Only one computer's bots; nil keeps every computer.
+ func on(_ computerId: ComputerID?) -> BotsEntry {
+ guard let computerId else { return self }
+ var entry = self
+ entry.bots = bots.filter { $0.id.hasPrefix("\(computerId)/") }
+ return entry
+ }
}
struct BotsTimeline: TimelineProvider {
@@ -121,11 +129,34 @@ struct BotsTeamWidget: Widget {
.containerBackground(Palette.surface, for: .widget)
}
.configurationDisplayName("Team")
- .description("Four bots at a glance. Edit the widget to choose who sits in each spot.")
+ .description("Four bots at a glance. Edit the widget to choose the computer and who sits in each spot.")
.supportedFamilies([.systemSmall])
}
}
+/// A computer of the selected account; the Team widget shows only its bots.
+struct ComputerEntity: AppEntity {
+ static let typeDisplayRepresentation: TypeDisplayRepresentation = "Computer"
+ static let defaultQuery = ComputerEntityQuery()
+
+ let id: ComputerID
+ let name: String
+ var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(name)") }
+}
+
+struct ComputerEntityQuery: EntityQuery {
+ private var all: [ComputerEntity] {
+ SharedStore.activeContext.computers.map { ComputerEntity(id: $0.id, name: $0.name) }
+ }
+
+ func entities(for identifiers: [ComputerID]) async throws -> [ComputerEntity] {
+ let all = all
+ return identifiers.compactMap { id in all.first { $0.id == id } }
+ }
+
+ func suggestedEntities() async throws -> [ComputerEntity] { all }
+}
+
/// A bot of the selected account, keyed `<computerId>/<botId>` like the widget snapshot.
struct BotEntity: AppEntity {
static let typeDisplayRepresentation: TypeDisplayRepresentation = "Bot"
@@ -137,8 +168,11 @@ struct BotEntity: AppEntity {
}
struct BotEntityQuery: EntityQuery {
+ /// The widget's computer: the spot pickers list only its bots.
+ @IntentParameterDependency<TeamIntent>(\.$computer) var team
+
private var all: [BotEntity] {
- BotsEntry.current.bots.filter { !$0.hidden }.map { BotEntity(id: $0.id, name: $0.name) }
+ BotsEntry.current.on(team?.computer.id).bots.filter { !$0.hidden }.map { BotEntity(id: $0.id, name: $0.name) }
.sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }
}
@@ -152,8 +186,9 @@ struct BotEntityQuery: EntityQuery {
struct TeamIntent: WidgetConfigurationIntent {
static let title: LocalizedStringResource = "Team"
- static let description = IntentDescription("Choose a bot for each spot; empty spots show the bots that need you.")
+ static let description = IntentDescription("Choose a computer and a bot for each spot; empty spots show the bots that need you.")
+ @Parameter(title: "Computer") var computer: ComputerEntity?
@Parameter(title: "Top left") var first: BotEntity?
@Parameter(title: "Top right") var second: BotEntity?
@Parameter(title: "Bottom left") var third: BotEntity?
@@ -174,12 +209,12 @@ struct TeamTimeline: AppIntentTimelineProvider {
}
func snapshot(for configuration: TeamIntent, in context: Context) async -> TeamEntry {
- context.isPreview ? placeholder(in: context) : TeamEntry(date: .now, bots: .current, picks: configuration.picks)
+ context.isPreview ? placeholder(in: context) : TeamEntry(date: .now, bots: BotsEntry.current.on(configuration.computer?.id), picks: configuration.picks)
}
/// The app writes the roster and reloads this widget when a bot's state changes.
func timeline(for configuration: TeamIntent, in context: Context) async -> Timeline<TeamEntry> {
- Timeline(entries: [TeamEntry(date: .now, bots: .current, picks: configuration.picks)], policy: .never)
+ Timeline(entries: [TeamEntry(date: .now, bots: BotsEntry.current.on(configuration.computer?.id), picks: configuration.picks)], policy: .never)
}
}
@@ -559,14 +594,14 @@ struct BotLiveActivity: Widget {
avatar(context, state: state, size: 26).frame(maxHeight: .infinity)
}
DynamicIslandExpandedRegion(.trailing) {
- BotActivityIndicator(state: state, size: 28).frame(maxHeight: .infinity)
+ indicator(context, state: state, size: 28).frame(maxHeight: .infinity)
}
// Centered under the camera, between the avatar and the orb, so nothing reaches
// the island's 44 pt corners (HIG: concentric margins, wrap around the camera).
DynamicIslandExpandedRegion(.center) {
- VStack(spacing: 2) {
- Text(context.attributes.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.text)
- Text(state.caption).font(.system(size: 12)).foregroundStyle(state.captionTint)
+ VStack(spacing: 3) {
+ Text(context.attributes.name).font(.system(size: 15, weight: .semibold)).foregroundStyle(Palette.text)
+ Text(state.caption).font(.system(size: 13)).foregroundStyle(state.captionTint)
.contentTransition(.interpolate)
}
.lineLimit(1)
@@ -581,7 +616,7 @@ struct BotLiveActivity: Widget {
} compactLeading: {
avatar(context, state: state, size: 20)
} compactTrailing: {
- BotActivityIndicator(state: state)
+ indicator(context, state: state, size: 20)
} minimal: {
BotActivityIndicator(state: state)
.accessibilityLabel("\(context.attributes.name), \(state.title)")
@@ -595,6 +630,22 @@ struct BotLiveActivity: Widget {
.init(status: context.state.status, activity: context.state.activity, isStale: context.isStale)
}
+ /// While the bot works, the orb keeps orbiting (in step with the face); otherwise it holds
+ /// its state's mark.
+ @ViewBuilder
+ private func indicator(_ context: ActivityViewContext<BotActivityAttributes>, state: BotActivityPresentation, size: CGFloat) -> some View {
+ ZStack {
+ if state.phase == .working {
+ WorkingOrb(since: context.state.startedAt ?? .now, color: state.tint, size: size)
+ .transition(.opacity)
+ } else {
+ BotActivityIndicator(state: state, size: size).transition(.opacity)
+ }
+ }
+ .animation(Motion.activityPhase, value: state.phase)
+ .accessibilityLabel(state.title)
+ }
+
/// While the bot works, the island's face plays its loop; otherwise it holds its mood.
@ViewBuilder
private func avatar(_ context: ActivityViewContext<BotActivityAttributes>, state: BotActivityPresentation, size: CGFloat) -> some View {
@@ -614,7 +665,7 @@ struct BotLiveActivity: Widget {
/// The working bot, alive in the Dynamic Island. A Live Activity draws one frame and only a
/// timer keeps changing, so this is a timer drawn in fonts whose digits are the ten frames of
-/// the bot's loop (tools/bot-frame-fonts.py); only the seconds digit draws, one frame a second.
+/// the bot's loop (tools/timer-fonts.py); only the seconds digit draws, one frame a second.
/// Two layers, like the app's avatar: every dot in grey ink, the lit ones in the bot's color.
struct WorkingBotFace: View {
let shape: String
@@ -627,22 +678,43 @@ struct WorkingBotFace: View {
var body: some View {
let shape = Self.shapes.contains(shape) ? shape : "blob"
ZStack {
- layer("CodyncBot-\(shape)-Ink").foregroundStyle(Palette.text.opacity(0.6))
- layer("CodyncBot-\(shape)-Tint").foregroundStyle(AvatarPalette.color(color))
+ TimerFrames(font: "CodyncBot-\(shape)-Ink", since: since, size: size).foregroundStyle(Palette.text.opacity(0.6))
+ TimerFrames(font: "CodyncBot-\(shape)-Tint", since: since, size: size).foregroundStyle(AvatarPalette.color(color))
}
- .frame(width: size, height: size)
- .clipped()
.accessibilityHidden(true)
}
+}
+
+/// The thinking orb, orbiting in the Dynamic Island the same way: its faint orbit trails and
+/// its moving dots, one frame a second, in step with the working bot's face.
+struct WorkingOrb: View {
+ let since: Date
+ let color: Color
+ let size: CGFloat
+
+ var body: some View {
+ ZStack {
+ TimerFrames(font: "CodyncOrb-Ghost", since: since, size: size).foregroundStyle(color.opacity(0.25))
+ TimerFrames(font: "CodyncOrb-Dot", since: since, size: size).foregroundStyle(color)
+ }
+ }
+}
- /// The font draws only the timer's last digit (every other character shapes to nothing),
- /// so the text is one face wide however the system lays out timer text.
- private func layer(_ font: String) -> some View {
+/// A timer drawn in one of the loop fonts: the font draws only the timer's last digit (every
+/// other character shapes to nothing), so the text is one face wide however the system lays out
+/// timer text.
+private struct TimerFrames: View {
+ let font: String
+ let since: Date
+ let size: CGFloat
+
+ var body: some View {
Text(since, style: .timer)
.font(.custom(font, fixedSize: size))
// Western digits whatever the region: the font only has those.
.environment(\.locale, Locale(identifier: "en_US_POSIX"))
.lineLimit(1)
.frame(width: size, height: size)
+ .clipped()
}
}
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Ink.ttf
index 33a481b1..9ca5f99f 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Tint.ttf
index ac61f992..f8d87690 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-blob-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Ink.ttf
index 42bd0730..05ac4a1e 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Tint.ttf
index 1ebec305..e5494e60 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-cloud-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Ink.ttf
index c00fffd0..a80bb4d6 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Tint.ttf
index b18486dc..4ab5b73d 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-hex-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Ink.ttf
index 9b3b625a..4b52c35a 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Tint.ttf
index 7524538c..7cb33d3e 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-pebble-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Ink.ttf
index fb892071..a475aacf 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Tint.ttf
index f5c6bc45..ac3fc368 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-squircle-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Ink.ttf
index c4037b37..f2fae7eb 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Tint.ttf
index d15966a3..1f7ee57e 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-tablet-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Ink.ttf
index d4df146f..c4a4b613 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Tint.ttf
index da19a0f3..1dabb37b 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-teardrop-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Ink.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Ink.ttf
index 6a72d8d6..acdc71ae 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Ink.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Ink.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Tint.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Tint.ttf
index 0db2c778..a987368e 100644
Binary files a/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Tint.ttf and b/apps/ios/Widgets/Resources/Fonts/CodyncBot-wedge-Tint.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncOrb-Dot.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncOrb-Dot.ttf
new file mode 100644
index 00000000..e2fd5f24
Binary files /dev/null and b/apps/ios/Widgets/Resources/Fonts/CodyncOrb-Dot.ttf differ
diff --git a/apps/ios/Widgets/Resources/Fonts/CodyncOrb-Ghost.ttf b/apps/ios/Widgets/Resources/Fonts/CodyncOrb-Ghost.ttf
new file mode 100644
index 00000000..f2b66820
Binary files /dev/null and b/apps/ios/Widgets/Resources/Fonts/CodyncOrb-Ghost.ttf differ
diff --git a/apps/ios/Widgets/Resources/Info.plist b/apps/ios/Widgets/Resources/Info.plist
index f2303c4b..e62a3901 100644
--- a/apps/ios/Widgets/Resources/Info.plist
+++ b/apps/ios/Widgets/Resources/Info.plist
@@ -4,7 +4,7 @@
<dict>
<key>CodyncKeychainGroup</key>
<string>$(AppIdentifierPrefix)com.pokai.Codync</string>
- <!-- The Dynamic Island's animated bot faces (tools/bot-frame-fonts.py). -->
+ <!-- The Dynamic Island's animated bot faces and thinking orb (tools/timer-fonts.py). -->
<key>UIAppFonts</key>
<array>
<string>CodyncBot-blob-Ink.ttf</string>
@@ -23,6 +23,8 @@
<string>CodyncBot-teardrop-Tint.ttf</string>
<string>CodyncBot-wedge-Ink.ttf</string>
<string>CodyncBot-wedge-Tint.ttf</string>
+ <string>CodyncOrb-Dot.ttf</string>
+ <string>CodyncOrb-Ghost.ttf</string>
</array>
<key>NSExtension</key>
<dict>
diff --git a/docs/design/mobile-widgets.md b/docs/design/mobile-widgets.md
index 55ea7629..cb18de12 100644
--- a/docs/design/mobile-widgets.md
+++ b/docs/design/mobile-widgets.md
@@ -61,7 +61,7 @@ State 分頁的 Live Activity 頁顯示鎖定畫面形式,Dynamic Island 頁
狀態色:待回應琥珀(`Palette.attention`)、失敗紅、完成綠;工作中的說明維持灰色,只有需要注意的狀態跳出來。經過時間用 `Text(startedAt, style: .timer)` 由系統自己往上數,不需要推播(`startedAt` 已在 remote content state 裡)。狀態切換時動的是 bot 本身:每個 mood 有固定的一幀姿勢(idle 光從左上、working 光掃到右側且眼睛往右看、needs you 正面光加漣漪),`still: true` 時每顆點是獨立的 view,系統會逐點插值大小與顏色,所以 halftone 的亮處會滑到新位置、眼睛移過去(`Motion.activityPhase`)。右側的 orb/勾號/警告只做淡入淡出。文字用 `.contentTransition(.interpolate)`,Review/時間列由下往上進場。全部在 iOS 給 activity 更新的 2 s 內,而且只用內建 transition,因為 Live Activity 不執行自訂 transition。展開島底部的時間是單一置中 Text(圖示內嵌),避免 timer Text 佔滿寬度後偏左。Review 只開啟對話,核准仍在 App 的 permission card。
-**動態島上工作中的 bot 會動**:Live Activity 只畫一幀,唯一會自己更新的是計時器文字,所以 Compact 與 Expanded 的頭像在 working 時是一個從 `startedAt` 起算的 timer `Text`,用自訂字型畫:字型裡 `0`–`9` 是 bot 工作迴圈的十格(光繞球一圈、眼睛右看→回正→左看、最後一格眨眼),只露出秒數最後一位,所以每秒換一格、十秒一輪。每種外型兩套字型疊起來(`Ink` 灰點、`Tint` 亮點上 bot 顏色),共 16 個 TTF 在 `apps/ios/Widgets/Resources/Fonts/`,由 widget 的 `UIAppFonts` 載入。格子來自 App 自己的繪圖(`DottedBody.workingLoop`),改了頭像畫法要重產:先跑 `exportBotFrames()` 測試輸出 JSON,再跑 `tools/bot-frame-fonts.py`(步驟寫在檔頭)。這只用公開 API(自訂字型 + timer Text),不是 Apple 文件化的動畫方式,未來 iOS 改了 timer 的繪製可能失效;其他狀態與 Lock Screen 仍是靜態姿勢。
+**動態島上工作中的 bot 會動**:Live Activity 只畫一幀,唯一會自己更新的是計時器文字,所以 Compact 與 Expanded 的頭像在 working 時是一個從 `startedAt` 起算的 timer `Text`,用自訂字型畫:字型裡 `0`–`9` 是 bot 工作迴圈的十格(光繞球一圈、眼睛右看→回正→左看、最後一格眨眼),只露出秒數最後一位,所以每秒換一格、十秒一輪。每種外型兩套字型疊起來(`Ink` 灰點、`Tint` 亮點上 bot 顏色),右側的 thinking orb 也用同一招(`CodyncOrb-Ghost` 淡軌跡、`CodyncOrb-Dot` 移動的點,來自 `ThinkingOrbGeometry.workingLoop`),和頭像同一個計時器所以同步換格;字型只畫計時器的最後一位(其他字元透過 contextual alternates 變成空白),整段文字剛好一格寬,不靠對齊或裁切。共 18 個 TTF 在 `apps/ios/Widgets/Resources/Fonts/`,由 widget 的 `UIAppFonts` 載入。格子來自 App 自己的繪圖(`DottedBody.workingLoop`),改了頭像畫法要重產:先跑 `exportBotFrames()` 測試輸出 JSON,再跑 `tools/timer-fonts.py`(步驟寫在檔頭)。展開島的計時器自成一行、置中(timer Text 會預留最寬寬度,跟圖示放一起就會偏)。這只用公開 API(自訂字型 + timer Text),不是 Apple 文件化的動畫方式,未來 iOS 改了 timer 的繪製可能失效;其他狀態與 Lock Screen 仍是靜態姿勢。
模擬器截圖看不到 Live Activity,所以 Live Activity、動態島(各狀態 × Lock Screen/Compact/Minimal/Expanded,淺色與深色)和 widget 卡片改用 render 測試輸出 PNG 檢查:
diff --git a/tools/bot-frame-fonts.py b/tools/timer-fonts.py
similarity index 75%
rename from tools/bot-frame-fonts.py
rename to tools/timer-fonts.py
index 482ba719..f036836d 100755
--- a/tools/bot-frame-fonts.py
+++ b/tools/timer-fonts.py
@@ -1,17 +1,19 @@
#!/usr/bin/env python3
-"""Builds the Dynamic Island's animated bot faces as fonts.
+"""Builds the Dynamic Island's animations as fonts.
-Live Activities draw one frame and only a timer Text keeps updating, so the working bot is a
-timer whose seconds digit is drawn in a font where `0`–`9` are the ten frames of its loop.
-Two fonts per character shape, stacked in the widget: `Ink` (every dot, tinted grey) and
-`Tint` (the lit dots, tinted in the bot's color).
+Live Activities draw one frame and only a timer Text keeps updating, so each animation is a
+timer whose last digit is drawn in a font where `0`–`9` are the ten frames of a loop (every
+other character the timer prints shapes to nothing). One font per layer, stacked and tinted in
+the widget: the working bot (`CodyncBot-<shape>-Ink` / `-Tint`) and the thinking orb
+(`CodyncOrb-Ghost` / `-Dot`).
-The frames come from the app's own drawing code (CharacterAvatar.swift, `workingLoop`):
+The frames come from the app's own drawing code (`DottedBody.workingLoop`,
+`ThinkingOrbGeometry.workingLoop`):
cd apps/ios/Kit && TEST_RUNNER_CODYNC_FRAMES_FILE=/tmp/frames.json xcodebuild test \
-scheme CodyncKit-Package -derivedDataPath ../../../build/dd \
-destination 'platform=iOS Simulator,id=<sim>' '-only-testing:CodyncKitTests/exportBotFrames()'
- tools/bot-frame-fonts.py /tmp/frames.json apps/ios/Widgets/Resources/Fonts
+ tools/timer-fonts.py /tmp/frames.json apps/ios/Widgets/Resources/Fonts
"""
import json
@@ -24,8 +26,6 @@ from fontTools.pens.ttGlyphPen import TTGlyphPen
EM = 1000
DIGITS = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
-# A lit dot joins the color layer above this much of the bot's color.
-TINT_THRESHOLD = 0.35
def circle(pen, cx, cy, r):
@@ -88,14 +88,11 @@ def build(name, frames, size, out):
def main():
frames_file, out_dir = Path(sys.argv[1]), Path(sys.argv[2])
data = json.loads(frames_file.read_text())
- size = data["size"]
out_dir.mkdir(parents=True, exist_ok=True)
- for shape, frames in sorted(data["shapes"].items()):
- assert len(frames) == 10, f"{shape}: a timer digit needs 10 frames"
- build(f"CodyncBot-{shape}-Ink", frames, size, out_dir)
- lit = [[d for d in f if d["tint"] > TINT_THRESHOLD] for f in frames]
- build(f"CodyncBot-{shape}-Tint", lit, size, out_dir)
- print(f"wrote {2 * len(data['shapes'])} fonts to {out_dir}")
+ for name, frames in sorted(data["fonts"].items()):
+ assert len(frames) == 10, f"{name}: a timer digit needs 10 frames"
+ build(name, frames, data["size"], out_dir)
+ print(f"wrote {len(data['fonts'])} fonts to {out_dir}")
if __name__ == "__main__":