GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(mobile): start tasks and open t3 code from ios control center · pingdotgg/t3code@041cb5c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile
    • app.config.ts
    • fingerprint.config.js
    • plugins
      • ios
        • T3ControlIntents.swift
        • T3OpenAppControl.swift
        • T3StartTaskControl.swift
      • lib
        • createControlSymbol.cjs
      • withIosControls.cjs
      • withIosControls.test.mjs
      • withWidgetLogoAsset.cjs
  • docs/user
    • usage.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/app.config.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/app.config.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ const config: ExpoConfig = {
444444
// Compile out the unused pedometer to avoid an iOS motion purpose string.
445445
["expo-sensors", { motionPermission: false }],
446446
// Mods run in reverse order; expo-widgets must create and wipe the target before assets are added.
447-
...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
447+
...(!isIosPersonalTeamBuild
448+
? ["./plugins/withWidgetLogoAsset.cjs", "./plugins/withIosControls.cjs", widgetsPlugin]
449+
: []),
448450
"./plugins/withAndroidNetworkSecurityConfig.cjs",
449451
"./plugins/withAndroidGradleHeap.cjs",
450452
"./plugins/withAndroidInputBackground.cjs",
Collapse file

‎apps/mobile/fingerprint.config.js‎

Copy file name to clipboardExpand all lines: apps/mobile/fingerprint.config.js
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,14 @@ if (!majorVersion) {
1414

1515
module.exports = {
1616
nativeModuleSourceType: "files",
17-
extraSources: [{ type: "contents", id: "appMajorVersion", contents: majorVersion }],
17+
extraSources: [
18+
{ type: "contents", id: "appMajorVersion", contents: majorVersion },
19+
// The controls plugin copies these native inputs outside Expo's module tracking.
20+
...[
21+
"plugins/ios/T3ControlIntents.swift",
22+
"plugins/ios/T3StartTaskControl.swift",
23+
"plugins/ios/T3OpenAppControl.swift",
24+
"assets/widget/T3Mark.svg",
25+
].map((filePath) => ({ type: "file", filePath })),
26+
],
1827
};
Collapse file

‎apps/mobile/plugins/ios/T3ControlIntents.swift‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import AppIntents
2+
import Foundation
3+
4+
#if !T3_WIDGET_EXTENSION
5+
import UIKit
6+
#endif
7+
8+
@available(iOS 18.0, *)
9+
struct T3StartTaskIntent: AppIntent {
10+
static var title: LocalizedStringResource = "Start a task"
11+
static var openAppWhenRun: Bool = true
12+
13+
@MainActor
14+
func perform() async throws -> some IntentResult {
15+
// Control intents must also belong to the app so iOS runs this action in its process.
16+
#if !T3_WIDGET_EXTENSION
17+
if let url = URL(string: "__T3_SCHEME__://new") {
18+
await UIApplication.shared.open(url)
19+
}
20+
#endif
21+
return .result()
22+
}
23+
}
24+
25+
@available(iOS 18.0, *)
26+
struct T3OpenAppIntent: AppIntent {
27+
static var title: LocalizedStringResource = "Open T3 Code"
28+
static var openAppWhenRun: Bool = true
29+
30+
func perform() async throws -> some IntentResult {
31+
return .result()
32+
}
33+
}
Collapse file

‎apps/mobile/plugins/ios/T3OpenAppControl.swift‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import AppIntents
2+
import SwiftUI
3+
import WidgetKit
4+
5+
@available(iOS 18.0, *)
6+
struct T3OpenAppControl: ControlWidget {
7+
var body: some ControlWidgetConfiguration {
8+
StaticControlConfiguration(kind: "T3OpenAppControl") {
9+
ControlWidgetButton(action: T3OpenAppIntent()) {
10+
Label("Open T3 Code", image: "T3ControlMark")
11+
}
12+
}
13+
.displayName("Open T3 Code")
14+
.description("Open T3 Code.")
15+
}
16+
}
Collapse file

‎apps/mobile/plugins/ios/T3StartTaskControl.swift‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import AppIntents
2+
import SwiftUI
3+
import WidgetKit
4+
5+
@available(iOS 18.0, *)
6+
struct T3StartTaskControl: ControlWidget {
7+
var body: some ControlWidgetConfiguration {
8+
StaticControlConfiguration(kind: "T3StartTaskControl") {
9+
ControlWidgetButton(action: T3StartTaskIntent()) {
10+
Label("Start a task", systemImage: "square.and.pencil")
11+
}
12+
}
13+
.displayName("Start a task")
14+
.description("Start a new task in T3 Code.")
15+
}
16+
}
Collapse file

‎apps/mobile/plugins/lib/createControlSymbol.cjs‎

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
3+
function createControlSymbol(svg) {
4+
const paths = [...svg.matchAll(/<path\b[^>]*\bd="([^"]+)"/g)].map((match) => match[1]);
5+
if (paths.length === 0) throw new Error("The T3 widget mark has no symbol paths.");
6+
const sizes = [
7+
["S", 696],
8+
["M", 1326],
9+
["L", 1956],
10+
];
11+
const guides = sizes
12+
.flatMap(([size, baseline]) =>
13+
[
14+
["Baseline", baseline],
15+
["Capline", baseline - 71],
16+
].map(([name, y]) => `<line id="${name}-${size}" x1="0" y1="${y}" x2="3300" y2="${y}"/>`),
17+
)
18+
.join("");
19+
const symbols = sizes
20+
.map(
21+
([size, baseline]) =>
22+
`<g id="Regular-${size}" transform="translate(1393 ${baseline})">${paths
23+
// Align the mark's ink bounds to the symbol cap height and baseline.
24+
.map((d) => `<path d="${d}" transform="matrix(1.25 0 0 1.25 -19.413625 -117.45)"/>`)
25+
.join("")}</g>`,
26+
)
27+
.join("");
28+
return `<svg xmlns="http://www.w3.org/2000/svg" width="3300" height="2200" viewBox="0 0 3300 2200"><g id="Notes"><text id="template-version">2.0</text></g><g id="Guides">${guides}</g><g id="Symbols">${symbols}</g></svg>\n`;
29+
}
30+
31+
module.exports = { createControlSymbol };
Collapse file

‎apps/mobile/plugins/withIosControls.cjs‎

Copy file name to clipboard
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
const { withDangerousMod, withXcodeProject } = require("expo/config-plugins");
6+
7+
const TARGET_NAME = "ExpoWidgetsTarget";
8+
const INTENT_FILE = "T3ControlIntents.swift";
9+
const CONTROLS = ["T3StartTaskControl", "T3OpenAppControl"];
10+
11+
module.exports = function withIosControls(config) {
12+
const scheme = config.scheme;
13+
if (typeof scheme !== "string" || !/^[a-z][a-z0-9+.-]*$/i.test(scheme)) {
14+
throw new Error("Start a task control requires a single app URL scheme.");
15+
}
16+
17+
config = withDangerousMod(config, [
18+
"ios",
19+
(cfg) => {
20+
const root = cfg.modRequest.platformProjectRoot;
21+
const widgetRoot = path.join(root, TARGET_NAME);
22+
const indexPath = path.join(widgetRoot, "index.swift");
23+
const source = fs.readFileSync(indexPath, "utf8");
24+
const body = "var body: some Widget {";
25+
if (!source.includes(body)) {
26+
throw new Error("Cannot find the Expo widget bundle for the Start a task control.");
27+
}
28+
const missing = CONTROLS.filter((control) => !source.includes(`${control}()`));
29+
if (missing.length > 0) {
30+
fs.writeFileSync(
31+
indexPath,
32+
source.replace(
33+
body,
34+
`${body}\n if #available(iOS 18.0, *) {\n ${missing.map((control) => `${control}()`).join("\n ")}\n }`,
35+
),
36+
);
37+
}
38+
const intent = fs
39+
.readFileSync(path.join(__dirname, "ios", INTENT_FILE), "utf8")
40+
.replaceAll("__T3_SCHEME__", scheme);
41+
fs.writeFileSync(path.join(root, INTENT_FILE), intent);
42+
fs.writeFileSync(path.join(widgetRoot, INTENT_FILE), intent);
43+
for (const control of CONTROLS) {
44+
fs.copyFileSync(
45+
path.join(__dirname, "ios", `${control}.swift`),
46+
path.join(widgetRoot, `${control}.swift`),
47+
);
48+
}
49+
return cfg;
50+
},
51+
]);
52+
53+
return withXcodeProject(config, (cfg) => {
54+
const project = cfg.modResults;
55+
const target = Object.entries(project.pbxNativeTargetSection()).find(
56+
([key, value]) => !key.endsWith("_comment") && value.name === TARGET_NAME,
57+
);
58+
if (!target) {
59+
throw new Error("Register withIosControls before expo-widgets.");
60+
}
61+
const group = project.getFirstProject().firstProject.mainGroup;
62+
project.addSourceFile(INTENT_FILE, { target: project.getFirstTarget().uuid }, group);
63+
for (const file of [INTENT_FILE, ...CONTROLS.map((control) => `${control}.swift`)]) {
64+
project.addSourceFile(`${TARGET_NAME}/${file}`, { target: target[0] }, group);
65+
}
66+
const list = project.pbxXCConfigurationList()[target[1].buildConfigurationList];
67+
for (const reference of list.buildConfigurations) {
68+
const settings = project.pbxXCBuildConfigurationSection()[reference.value].buildSettings;
69+
const flags = settings.SWIFT_ACTIVE_COMPILATION_CONDITIONS ?? '"$(inherited)"';
70+
const values = Array.isArray(flags) ? flags : [flags];
71+
if (!values.includes("T3_WIDGET_EXTENSION")) {
72+
settings.SWIFT_ACTIVE_COMPILATION_CONDITIONS = [...values, "T3_WIDGET_EXTENSION"];
73+
}
74+
}
75+
return cfg;
76+
});
77+
};
Collapse file

‎apps/mobile/plugins/withIosControls.test.mjs‎

Copy file name to clipboard
+79Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import * as NodeFS from "node:fs";
2+
import * as NodeModule from "node:module";
3+
import * as NodeOS from "node:os";
4+
import * as NodePath from "node:path";
5+
import { expect, it } from "vite-plus/test";
6+
7+
const require = NodeModule.createRequire(import.meta.url);
8+
const withIosControls = require("./withIosControls.cjs");
9+
const withWidgetLogoAsset = require("./withWidgetLogoAsset.cjs");
10+
const withWidgets = require("expo-widgets/app.plugin.js").default;
11+
12+
it.each(["t3code", "t3code-dev", "t3code-preview"])(
13+
"adds iOS controls and the T3 symbol to the Expo widget bundle using %s",
14+
async (scheme) => {
15+
const root = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-task-control-"));
16+
try {
17+
NodeFS.writeFileSync(NodePath.join(root, "Podfile"), 'target "T3Code" do\nend\n');
18+
NodeFS.mkdirSync(NodePath.join(root, "assets/widget"), { recursive: true });
19+
NodeFS.copyFileSync(
20+
NodePath.join(import.meta.dirname, "../assets/widget/T3Mark.svg"),
21+
NodePath.join(root, "assets/widget/T3Mark.svg"),
22+
);
23+
const config = withWidgets(
24+
withIosControls(
25+
withWidgetLogoAsset({
26+
name: "T3 Code",
27+
slug: "t3-code",
28+
scheme,
29+
_internal: { projectRoot: root },
30+
ios: { bundleIdentifier: "com.t3tools.t3code" },
31+
}),
32+
),
33+
{
34+
widgets: [
35+
{
36+
name: "SubscriptionUsage",
37+
displayName: "Subscription usage",
38+
description: "Usage",
39+
ios: { supportedFamilies: ["systemSmall"] },
40+
},
41+
],
42+
},
43+
);
44+
await config.mods.ios.dangerous({
45+
...config,
46+
modRequest: { projectRoot: root, platformProjectRoot: root, platform: "ios" },
47+
});
48+
const widgetRoot = NodePath.join(root, "ExpoWidgetsTarget");
49+
const index = NodeFS.readFileSync(NodePath.join(widgetRoot, "index.swift"), "utf8");
50+
expect(index).toContain("if #available(iOS 18.0, *)");
51+
expect(index).toContain("T3StartTaskControl()");
52+
expect(index).toContain("T3OpenAppControl()");
53+
expect(index).toContain("SubscriptionUsage()");
54+
expect(index).toContain("WidgetLiveActivity()");
55+
const intent = NodeFS.readFileSync(NodePath.join(root, "T3ControlIntents.swift"), "utf8");
56+
expect(intent).toContain(`"${scheme}://new"`);
57+
expect(NodeFS.readFileSync(NodePath.join(widgetRoot, "T3ControlIntents.swift"), "utf8")).toBe(
58+
intent,
59+
);
60+
expect(
61+
NodeFS.readFileSync(NodePath.join(widgetRoot, "T3StartTaskControl.swift"), "utf8"),
62+
).toContain("ControlWidgetButton(action: T3StartTaskIntent())");
63+
expect(
64+
NodeFS.readFileSync(NodePath.join(widgetRoot, "T3OpenAppControl.swift"), "utf8"),
65+
).toContain("ControlWidgetButton(action: T3OpenAppIntent())");
66+
const symbolSet = NodePath.join(widgetRoot, "Assets.xcassets/T3ControlMark.symbolset");
67+
expect(
68+
JSON.parse(NodeFS.readFileSync(NodePath.join(symbolSet, "Contents.json"), "utf8")),
69+
).toMatchObject({
70+
symbols: [{ filename: "T3ControlMark.svg", idiom: "universal" }],
71+
});
72+
expect(NodeFS.readFileSync(NodePath.join(symbolSet, "T3ControlMark.svg"), "utf8")).toContain(
73+
'id="Regular-S"',
74+
);
75+
} finally {
76+
NodeFS.rmSync(root, { recursive: true, force: true });
77+
}
78+
},
79+
);
Collapse file

‎apps/mobile/plugins/withWidgetLogoAsset.cjs‎

Copy file name to clipboardExpand all lines: apps/mobile/plugins/withWidgetLogoAsset.cjs
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const path = require("path");
66
const fs = require("fs");
77
const { withDangerousMod, withXcodeProject } = require("expo/config-plugins");
88
const { addWidgetAssetCatalog } = require("./lib/addWidgetAssetCatalog.cjs");
9+
const { createControlSymbol } = require("./lib/createControlSymbol.cjs");
910

1011
const TARGET_NAME = "ExpoWidgetsTarget";
1112
const CATALOG_NAME = "Assets.xcassets";
@@ -38,6 +39,19 @@ function withAssetFiles(config) {
3839
fs.writeFileSync(path.join(catalogDir, "Contents.json"), CATALOG_CONTENTS);
3940
fs.writeFileSync(path.join(imageSetDir, "Contents.json"), IMAGE_SET_CONTENTS);
4041
fs.copyFileSync(source, path.join(imageSetDir, SVG_NAME));
42+
const symbolSetDir = path.join(catalogDir, "T3ControlMark.symbolset");
43+
fs.mkdirSync(symbolSetDir, { recursive: true });
44+
fs.writeFileSync(
45+
path.join(symbolSetDir, "Contents.json"),
46+
JSON.stringify({
47+
info: { author: "expo", version: 1 },
48+
symbols: [{ filename: "T3ControlMark.svg", idiom: "universal" }],
49+
}),
50+
);
51+
fs.writeFileSync(
52+
path.join(symbolSetDir, "T3ControlMark.svg"),
53+
createControlSymbol(fs.readFileSync(source, "utf8")),
54+
);
4155
return cfg;
4256
},
4357
]);
Collapse file

‎docs/user/usage.md‎

Copy file name to clipboardExpand all lines: docs/user/usage.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ Claude quotas. Tap it to open **Usage → Limits**; on Android this works while
192192
the background, otherwise open the app from the launcher. On iOS, use **Edit Widget** to choose
193193
Session, Weekly, or both for each provider. Reopen T3 to refresh expired readings.
194194

195+
## Start a task from Control Center
196+
197+
On iOS 18 or later, open Control Center and choose **Add a Control**.
198+
Find T3 Code and add **Start a task**. Tap the control to open the project chooser for a new task.
199+
Add **Open T3 Code** to open the app without starting a task.
200+
195201
## Keyboard shortcuts
196202

197203
On web and desktop, open Usage from the command palette. While on Usage,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.