Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): make goal setup primary action full width (#6490)

Kirozeng9b61eb0a5679
diff --git a/apps/mobile/src/__tests__/goalNativeForm.test.tsx b/apps/mobile/src/__tests__/goalNativeForm.test.tsx
index 9b59b3ff7e..7083e416af 100644
--- a/apps/mobile/src/__tests__/goalNativeForm.test.tsx
+++ b/apps/mobile/src/__tests__/goalNativeForm.test.tsx
@@ -14,7 +14,7 @@ vi.mock('@expo/ui/swift-ui', async () => {
if (p.testID) bridge.props.set(p.testID, p);
return React.createElement('div', null, p.children);
};
- return { HStack: control, RNHostView: control, Button: control, DisclosureGroup: control, Picker: control, ProgressView: control, Text: control, TextField: control,
+ return { Section: control, VStack: control, HStack: control, RNHostView: control, Button: control, DisclosureGroup: control, Picker: control, ProgressView: control, Text: control, TextField: control,
useNativeState: (initial: string) => {
const state = React.useRef({ value: initial, get() { return this.value; }, set(value: string) { this.value = value; } });
return state.current;
@@ -22,7 +22,7 @@ vi.mock('@expo/ui/swift-ui', async () => {
};
});
vi.mock('@expo/ui/swift-ui/modifiers', () => Object.fromEntries(
- ['fixedSize', 'buttonBorderShape', 'controlSize', 'accessibilityHint', 'accessibilityLabel', 'buttonStyle', 'contentShape', 'disabled', 'font', 'foregroundStyle', 'frame', 'lineLimit', 'pickerStyle', 'tag', 'tint'].map(key => [key, (value: any) => ({ [key]: value })]).concat([['shapes', { rectangle: () => ({}) }] as any]),
+ ['listRowBackground', 'listRowInsets', 'listRowSeparator', 'fixedSize', 'buttonBorderShape', 'controlSize', 'accessibilityHint', 'accessibilityLabel', 'buttonStyle', 'contentShape', 'disabled', 'font', 'foregroundStyle', 'frame', 'lineLimit', 'pickerStyle', 'tag', 'tint'].map(key => [key, (value: any) => ({ [key]: value })]).concat([['shapes', { rectangle: () => ({}) }] as any]),
));
vi.mock('@/theme', () => ({ navigationChrome: { target: 44 }, useTheme: () => ({ colors: {
cta: bridge.mode === 'dark' ? 'white' : 'black',
@@ -79,8 +79,8 @@ it.each(['light', 'dark'])('pairs the goal label and busy indicator with the CTA
bridge.mode = mode;
const foreground = mode === 'dark' ? 'black' : 'white';
mount({ initial: { objective: '目标' } });
- expect(control('goalStartButton').children.props.modifiers).toContainEqual({ foregroundStyle: foreground });
+ expect(control('goalStartButton').children.props.children.props.modifiers).toContainEqual({ foregroundStyle: foreground });
mount({ busy: true, initial: { objective: '目标' } });
- expect(control('goalStartButton').children.props.modifiers).toContainEqual({ tint: foreground });
+ expect(control('goalStartButton').children.props.children.props.modifiers).toContainEqual({ tint: foreground });
expect(control('goalStartButton').modifiers).toContainEqual({ disabled: true });
});
diff --git a/apps/mobile/src/session/ContextSheetGoalView.ios.tsx b/apps/mobile/src/session/ContextSheetGoalView.ios.tsx
index 68b684c110..39b4a05072 100644
--- a/apps/mobile/src/session/ContextSheetGoalView.ios.tsx
+++ b/apps/mobile/src/session/ContextSheetGoalView.ios.tsx
@@ -2,8 +2,8 @@ import { NativeErrorNotice } from '@/components/NativeErrorNotice.ios';
import { useNativeGlassButtonStyle } from "@/platform/chrome/nativeGlassButtonStyle.ios";
import { useState, type ComponentProps } from 'react';
import { useTranslation } from 'react-i18next';
-import { Button, DisclosureGroup, Picker, ProgressView, Text, TextField, useNativeState } from '@expo/ui/swift-ui';
-import { accessibilityHint, accessibilityLabel, buttonStyle, contentShape, disabled as disable, font, foregroundStyle, frame, lineLimit, pickerStyle, shapes, tag, tint } from '@expo/ui/swift-ui/modifiers';
+import { Button, DisclosureGroup, Picker, ProgressView, Section as NativeSection, Text, TextField, VStack, useNativeState } from '@expo/ui/swift-ui';
+import { accessibilityHint, accessibilityLabel, buttonStyle, contentShape, disabled as disable, font, foregroundStyle, frame, lineLimit, listRowBackground, listRowInsets, listRowSeparator, pickerStyle, shapes, tag, tint } from '@expo/ui/swift-ui/modifiers';
import { useTheme } from '@/theme';
import type { MobileGoalLimitsInput } from '@cindy/maker-shared/device-link-contract';
import type { ContextSheetGoalViewProps, ContextSheetGoalCreateForm as GoalCreateForm } from './ContextSheetGoalView';
@@ -35,7 +35,7 @@ export function ContextSheetGoalCreateForm({ busy, disabled = false, disabledHin
<TextField text={text} onTextChange={setObjective} axis="vertical"
placeholder={t('interaction.contextSheet.goalPlaceholder')}
testID="contextSheet.goalObjectiveInput"
- modifiers={[lineLimit({ min: 3, max: 6 }), disable(busy), accessibilityLabel(t('interaction.contextSheet.goalObjectiveAccessibility'))]} />
+ modifiers={[lineLimit({ min: 3, max: 6 }), tint(colors.inputCaret), disable(busy), accessibilityLabel(t('interaction.contextSheet.goalObjectiveAccessibility'))]} />
</Section>
<Section>
<DisclosureGroup label={t('interaction.contextSheet.advancedSettings')}
@@ -47,15 +47,23 @@ export function ContextSheetGoalCreateForm({ busy, disabled = false, disabledHin
<LimitPicker label={t('interaction.contextSheet.noProgressLimit')} value={limits.noProgressLimit} presets={[2, 3, 5]} busy={busy} onChange={value => patch({ noProgressLimit: value })} testID="contextSheet.goalNoProgressOptions" />
</DisclosureGroup>
</Section>
- {error ? <Section><NativeErrorNotice message={error} /></Section> : disabled && disabledHint ? <Section><Text modifiers={[foregroundStyle(colors.textSecondary)]}>{disabledHint}</Text></Section> : null}
- <Section>
+ <NativeSection modifiers={[
+ listRowBackground('clear'), listRowSeparator('hidden'),
+ listRowInsets({ top: 0, bottom: 0, leading: 0, trailing: 0 }),
+ ]}>
+ {error ? <NativeErrorNotice message={error} /> : disabled && disabledHint ? <Text modifiers={[font({ textStyle: 'footnote' }), foregroundStyle(colors.textSecondary)]}>{disabledHint}</Text> : null}
<Button onPress={submit} testID="contextSheet.goalStartButton" modifiers={[
- ...glassStyle, frame({ maxWidth: Infinity, minHeight: 44 }),
+ ...glassStyle,
disable(busy || disabled || !objective.trim()),
...(disabled && disabledHint ? [accessibilityHint(disabledHint)] : []),
accessibilityLabel(t('interaction.contextSheet.startGoal')),
- ]}>{busy ? <ProgressView modifiers={[tint(colors.ctaText)]} /> : <Text modifiers={[foregroundStyle(colors.ctaText)]}>{t('interaction.contextSheet.startGoal')}</Text>}</Button>
- </Section>
+ ]}>
+ {/* Size the native label so the button's visible face fills the row too. */}
+ <VStack modifiers={[frame({ maxWidth: Infinity, minHeight: 44 }), contentShape(shapes.rectangle())]}>
+ {busy ? <ProgressView modifiers={[tint(colors.ctaText)]} /> : <Text modifiers={[foregroundStyle(colors.ctaText)]}>{t('interaction.contextSheet.startGoal')}</Text>}
+ </VStack>
+ </Button>
+ </NativeSection>
</>;
}
diff --git a/apps/mobile/src/session/ContextSheetGoalView.tsx b/apps/mobile/src/session/ContextSheetGoalView.tsx
index 95173035f9..e3ec2366ec 100644
--- a/apps/mobile/src/session/ContextSheetGoalView.tsx
+++ b/apps/mobile/src/session/ContextSheetGoalView.tsx
@@ -162,6 +162,8 @@ export function ContextSheetGoalCreateForm({
onChangeText={setObjective}
placeholder={t('interaction.contextSheet.goalPlaceholder')}
placeholderTextColor={colors.textPlaceholder}
+ selectionColor={colors.inputCaret}
+ cursorColor={colors.inputCaret}
style={styles.objectiveInput}
testID="contextSheet.goalObjectiveInput"
value={objective}
@@ -221,7 +223,7 @@ export function ContextSheetGoalCreateForm({
accessibilityHint={disabled ? disabledHint : undefined}
accessibilityLabel={t('interaction.contextSheet.startGoal')}
accessibilityRole="button"
- accessibilityState={{ disabled: busy || disabled || !objective.trim() }}
+ accessibilityState={{ busy, disabled: busy || disabled || !objective.trim() }}
disabled={busy || disabled || !objective.trim()}
onPress={submit}
style={({ pressed }) => [
@@ -449,7 +451,7 @@ function makeGoalStyles(colors: ThemeColors) {
lineHeight: lineHeight.body,
marginTop: spacing.sm,
minHeight: 120,
- padding: spacing.md + 2,
+ padding: spacing.lg,
textAlignVertical: 'top' as const,
},
// 「高级设置」折叠行:整行 44pt 可点,标题在左、展开指示在右(对齐 iOS DisclosureGroup)。
@@ -460,6 +462,7 @@ function makeGoalStyles(colors: ThemeColors) {
justifyContent: 'space-between' as const,
marginTop: spacing.md,
minHeight: 44,
+ paddingVertical: spacing.sm,
},
advancedToggleText: {
color: colors.textPrimary,
@@ -518,7 +521,9 @@ function makeGoalStyles(colors: ThemeColors) {
alignItems: 'center' as const,
backgroundColor: colors.cta,
borderRadius: radius.pill,
- height: 50,
+ minHeight: 50,
+ paddingHorizontal: spacing.lg,
+ paddingVertical: spacing.md,
justifyContent: 'center' as const,
marginTop: spacing.xl,
},