Skip to content

Commit a9381b3

Browse files
committed
fix(editor): adjust iOS input sizing for better keyboard handling
Refine minHeight, maxHeight, and padding for iOS to improve input usability and avoid keyboard constraint issues.
1 parent e322d7e commit a9381b3

File tree

2 files changed

+52
-44
lines changed

2 files changed

+52
-44
lines changed

mpp-ios/build-ios-app.sh

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,42 @@ elif [ "$ACTION" = "build" ] || [ "$ACTION" = "run" ]; then
341341

342342
if [ "$ACTION" = "run" ]; then
343343
if [ "$TARGET_TYPE" = "device" ]; then
344-
# 真机运行
345-
if command -v ios-deploy &> /dev/null; then
346-
echo -e "${BLUE}🚀 使用 ios-deploy 安装并运行到设备...${NC}"
347-
ios-deploy --debug --bundle "$APP_PATH" --id "$DEVICE_ID"
344+
# 真机运行 - 使用 devicectl 安装和启动
345+
echo -e "${BLUE}🚀 安装应用到真机...${NC}"
346+
347+
# 获取连接的设备 ID (使用 devicectl)
348+
# UUID 格式: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
349+
DEVICE_UUID=$(xcrun devicectl list devices 2>&1 | grep "connected" | grep -oE "[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}" | head -n 1)
350+
351+
if [ -z "$DEVICE_UUID" ]; then
352+
echo -e "${RED}❌ 未找到已连接的设备${NC}"
353+
echo -e "${YELLOW}请确保设备已连接并信任此电脑${NC}"
354+
exit 1
355+
fi
356+
357+
echo -e "${GREEN}✓ 找到设备: ${DEVICE_UUID}${NC}"
358+
359+
# 使用 devicectl 安装应用
360+
echo -e "${YELLOW} 安装应用...${NC}"
361+
xcrun devicectl device install app --device "$DEVICE_UUID" "$APP_PATH"
362+
363+
if [ $? -ne 0 ]; then
364+
echo -e "${RED}❌ 应用安装失败${NC}"
365+
exit 1
366+
fi
367+
368+
echo -e "${GREEN}✅ 应用安装成功!${NC}"
369+
370+
# 使用 devicectl 启动应用
371+
BUNDLE_ID="cc.unitmesh.AutoDevApp"
372+
echo -e "${YELLOW} 启动应用...${NC}"
373+
xcrun devicectl device process launch --device "$DEVICE_UUID" "$BUNDLE_ID"
374+
375+
if [ $? -ne 0 ]; then
376+
echo -e "${YELLOW}⚠️ 应用启动失败,可能需要在设备上信任开发者证书${NC}"
377+
echo -e "${CYAN}请在 iPhone 上: 设置 -> 通用 -> VPN与设备管理 -> 信任开发者${NC}"
348378
else
349-
echo -e "${YELLOW}⚠️ 未找到 ios-deploy 工具,无法自动安装到真机${NC}"
350-
echo -e "请使用以下命令安装: ${CYAN}brew install ios-deploy${NC}"
351-
echo -e "或者打开 Xcode 手动运行: ${CYAN}open AutoDevApp.xcworkspace${NC}"
379+
echo -e "${GREEN}✅ 应用已启动!${NC}"
352380
fi
353381
else
354382
# 运行到模拟器

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/DevInEditorInput.kt

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,36 +151,27 @@ fun DevInEditorInput(
151151
val inputLineHeight = if (isAndroid && isCompactMode) 24.sp else 22.sp
152152
val maxLines = if (isAndroid && isCompactMode) 5 else 8
153153

154-
// iOS: Use flexible sizing (wrapContent + maxHeight) to avoid keyboard constraint conflicts
154+
// iOS: Use smaller, fixed height to avoid keyboard issues
155155
// Android/Desktop: Use minHeight for touch targets + maxHeight for bounds
156-
val minHeight = if (Platform.isIOS) {
157-
null // iOS uses natural content height to avoid keyboard conflicts
158-
} else if (isCompactMode) {
159-
if (isAndroid) 52.dp else 56.dp
160-
} else {
161-
80.dp
156+
val minHeight = when {
157+
Platform.isIOS -> 44.dp // iOS: standard touch target height
158+
isCompactMode && isAndroid -> 52.dp
159+
isCompactMode -> 56.dp
160+
else -> 80.dp
162161
}
163162

164-
val maxHeight = if (isCompactMode) {
165-
when {
166-
Platform.isIOS -> 160.dp // iOS: generous max height, flexible min
167-
isAndroid -> 120.dp
168-
else -> 96.dp
169-
}
170-
} else {
171-
when {
172-
Platform.isIOS -> 200.dp // iOS: more room in non-compact mode
173-
else -> 160.dp
174-
}
163+
val maxHeight = when {
164+
Platform.isIOS && isCompactMode -> 80.dp // iOS compact: smaller max
165+
Platform.isIOS -> 100.dp // iOS: reduced max height
166+
isCompactMode && isAndroid -> 120.dp
167+
isCompactMode -> 96.dp
168+
else -> 160.dp
175169
}
176170

177-
val padding = if (isCompactMode) {
178-
when {
179-
Platform.isIOS -> 14.dp // iOS: slightly more padding for comfort
180-
else -> 12.dp
181-
}
182-
} else {
183-
20.dp
171+
val padding = when {
172+
Platform.isIOS -> 10.dp // iOS: smaller padding
173+
isCompactMode -> 12.dp
174+
else -> 20.dp
184175
}
185176

186177
// Initialize MCP client manager with config
@@ -511,18 +502,7 @@ fun DevInEditorInput(
511502
modifier =
512503
Modifier
513504
.fillMaxWidth()
514-
.then(
515-
// iOS: Use wrapContentHeight + maxHeight only (no minHeight)
516-
// to avoid conflicts with keyboard constraints
517-
if (Platform.isIOS) {
518-
Modifier
519-
.wrapContentHeight()
520-
.heightIn(max = maxHeight)
521-
} else {
522-
// Android/Desktop: Use traditional min/max constraints
523-
Modifier.heightIn(min = minHeight!!, max = maxHeight)
524-
}
525-
)
505+
.heightIn(min = minHeight, max = maxHeight)
526506
.padding(padding)
527507
) {
528508
BasicTextField(

0 commit comments

Comments
 (0)