Skip to content

Commit bd3be86

Browse files
committed
CAIS:improve:键盘界面卡片布局调整
1 parent c92e599 commit bd3be86

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

CAIS/components/AppRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function AddFavoriteView() {
152152
</Section>
153153
<Section
154154
header={<Text>内容</Text>}
155-
footer={<Text>{"可使用 {{text}}、{{date}}、{{time}}、{{datetime}}。"}</Text>}
155+
footer={<Text>{"可使用 {{text}}、{{date}}、{{time}}、{{datetime}}、{{timestamp}}。"}</Text>}
156156
>
157157
<TextField
158158
title=""

CAIS/components/KeyboardView.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import { readPipControlState, requestPipStart, requestPipStop } from "../service
4747

4848
const TAB_FAVORITE = 0
4949
const TAB_CLIPS = 1
50+
const KEYBOARD_ROOT_SIDE_PADDING = 6
51+
const CLIP_SCROLL_SIDE_PADDING = 8
52+
const CLIP_GRID_SPACING = 10
5053
const CONFIGURABLE_BUILTIN_ACTIONS: KeyboardMenuBuiltinAction[] = [
5154
"base64Encode",
5255
"base64Decode",
@@ -232,6 +235,11 @@ function getOrderedKeyboardBuiltins(settings: CaisSettings): KeyboardMenuBuiltin
232235
return [...order, ...missing]
233236
}
234237

238+
function clipTileWidth(): number {
239+
const availableWidth = Device.screen.width - KEYBOARD_ROOT_SIDE_PADDING * 2 - CLIP_SCROLL_SIDE_PADDING * 2
240+
return Math.max(132, Math.floor((availableWidth - CLIP_GRID_SPACING) / 2))
241+
}
242+
235243
function ClipTile(props: {
236244
item: ClipItem
237245
settings: CaisSettings
@@ -244,7 +252,7 @@ function ClipTile(props: {
244252
return (
245253
<Button
246254
buttonStyle="plain"
247-
frame={{ width: 206, maxHeight: "infinity" as any }}
255+
frame={{ width: clipTileWidth(), maxHeight: "infinity" as any }}
248256
action={() => {
249257
playClick()
250258
void props.onInsert(item)
@@ -734,7 +742,7 @@ export function KeyboardView() {
734742
<VStack
735743
spacing={7}
736744
frame={{ maxWidth: "infinity", maxHeight: "infinity" }}
737-
padding={{ top: 6, bottom: 6, leading: 6, trailing: 6 }}
745+
padding={{ top: 6, bottom: 6, leading: KEYBOARD_ROOT_SIDE_PADDING, trailing: KEYBOARD_ROOT_SIDE_PADDING }}
738746
pip={{
739747
isPresented: pipPresented,
740748
maximumUpdatesPerSecond: 2,
@@ -791,12 +799,12 @@ export function KeyboardView() {
791799
axes="horizontal"
792800
scrollIndicator="hidden"
793801
frame={{ maxWidth: "infinity", maxHeight: "infinity" }}
794-
padding={{ leading: 8, trailing: 8 }}
802+
padding={{ leading: CLIP_SCROLL_SIDE_PADDING, trailing: CLIP_SCROLL_SIDE_PADDING }}
795803
>
796804
{visibleItems.length ? (
797805
<LazyHGrid
798806
rows={clipGridRows}
799-
spacing={10}
807+
spacing={CLIP_GRID_SPACING}
800808
frame={{ maxHeight: "infinity" }}
801809
>
802810
<ForEach

CAIS/components/SettingsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function CustomActionEditorView(props: {
118118
{mode === "template" ? (
119119
<Section
120120
header={<Text>模板</Text>}
121-
footer={<Text>{"可使用 {{text}}、{{date}}、{{time}}、{{datetime}}。"}</Text>}
121+
footer={<Text>{"可使用 {{text}}、{{date}}、{{time}}、{{datetime}}、{{timestamp}}。"}</Text>}
122122
>
123123
<TextField
124124
title=""

CAIS/utils/template.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function runtimeTemplateVariables() {
1010
date,
1111
time,
1212
datetime: `${date} ${time}`,
13+
timestamp: String(now.getTime()),
1314
}
1415
}
1516

@@ -20,5 +21,5 @@ export function renderRuntimeTemplate(template: string, text = ""): string {
2021
.replace(/\{\{date\}\}/g, values.date)
2122
.replace(/\{\{time\}\}/g, values.time)
2223
.replace(/\{\{datetime\}\}/g, values.datetime)
24+
.replace(/\{\{timestamp\}\}/g, values.timestamp)
2325
}
24-

0 commit comments

Comments
 (0)