← 返回 openai 的题目列表Jetpack Compose: Build a UI Similar to Google Translate Home Screen
类型:online_judge
Implement an Android screen using Jetpack Compose whose layout and basic interactions resemble the Google Translate home screen (home page only; no real translation backend required).
Requirements
Top area:
A simple top bar (can include an app name/logo placeholder).
Language selector:
Two language selector buttons (Source / Target) with a “swap languages” button in between.
Tapping a language button opens a simple picker (Dialog/BottomSheet). Selecting an item updates the current language.
Input area:
A multi-line text input.
A “clear input” action (enabled/visible only when there is text).
Output area:
When input is non-empty, show a result card below (fake translation is fine, e.g., prefix the input with Translated:).
State management:
Manage input text, selected languages, and picker visibility using Compose state and/or a ViewModel.
Constraints
Kotlin + Jetpack Compose only.
Material3 components allowed.
No networking or persistence required.
Data/Performance
Provide at least 10 languages in the picker.
Input text can be up to 5,000 characters; UI should remain responsive.
Manual Acceptance Tests
Initial: source=English, target=Spanish, empty input, result not shown.
Enter hello: result card appears with Translated: hello.
Tap swap: source/target are swapped.
Pick Chinese from the language picker: button label updates.
Tap clear: input cleared and result card disappears.
Example
Input
init
Output
source=English,target=Spanish,input=EMPTY,result=HIDDEN