feat(app): card types on one row, scrolling sideways
On a phone the four chips wrapped onto a second row; they now stay on one and scroll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
7c00abcc05
commit
ebe62e82d7
2 changed files with 39 additions and 27 deletions
|
|
@ -263,29 +263,31 @@ class _CardDraftEditorState() extends State<CardDraftEditor> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Chips rather than segments: on a phone they flow onto a second
|
// Chips rather than segments, which would break their names on a
|
||||||
// row, where segments would break their names.
|
// phone; one row, scrolling sideways where it doesn't fit.
|
||||||
Wrap(
|
SingleChildScrollView(
|
||||||
spacing: 8,
|
scrollDirection: Axis.horizontal,
|
||||||
runSpacing: 8,
|
child: Row(
|
||||||
children: [
|
spacing: 8,
|
||||||
for (final (choice, name) in [
|
children: [
|
||||||
(CardKind.flashcard, l10n.composerKindFlashcard),
|
for (final (choice, name) in [
|
||||||
(CardKind.vocabulary, l10n.composerKindVocabulary),
|
(CardKind.flashcard, l10n.composerKindFlashcard),
|
||||||
(CardKind.matching, l10n.composerKindMatching),
|
(CardKind.vocabulary, l10n.composerKindVocabulary),
|
||||||
(CardKind.map, l10n.composerKindMap),
|
(CardKind.matching, l10n.composerKindMatching),
|
||||||
])
|
(CardKind.map, l10n.composerKindMap),
|
||||||
ChoiceChip(
|
])
|
||||||
label: Text(name),
|
ChoiceChip(
|
||||||
selected: choice == kind,
|
label: Text(name),
|
||||||
showCheckmark: false,
|
selected: choice == kind,
|
||||||
onSelected: (_) {
|
showCheckmark: false,
|
||||||
if (choice != kind) {
|
onSelected: (_) {
|
||||||
_change(choice.apply(content));
|
if (choice != kind) {
|
||||||
}
|
_change(choice.apply(content));
|
||||||
},
|
}
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
|
||||||
|
|
@ -393,21 +393,31 @@ void main() {
|
||||||
expect(blocks, contains(containsPair('type', mathBlockType)));
|
expect(blocks, contains(containsPair('type', mathBlockType)));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('the card types fit a phone, none of their names broken', (
|
testWidgets('the card types stay on one row on a phone, scrolling '
|
||||||
tester,
|
'sideways, none of their names broken', (tester) async {
|
||||||
) async {
|
|
||||||
await cards.create('japanese', card('猫', 'cat'));
|
await cards.create('japanese', card('猫', 'cat'));
|
||||||
await showStudyset(tester, size: const Size(412, 915));
|
await showStudyset(tester, size: const Size(412, 915));
|
||||||
await open(tester, '猫');
|
await open(tester, '猫');
|
||||||
|
|
||||||
for (final type in ['Flashcard', 'Vocabulary', 'Matching', 'Map']) {
|
const types = ['Flashcard', 'Vocabulary', 'Matching', 'Map'];
|
||||||
|
for (final type in types) {
|
||||||
final name = tester.renderObject<RenderParagraph>(find.text(type));
|
final name = tester.renderObject<RenderParagraph>(find.text(type));
|
||||||
expect(
|
expect(
|
||||||
name.size.width,
|
name.size.width,
|
||||||
moreOrLessEquals(name.getMaxIntrinsicWidth(double.infinity)),
|
moreOrLessEquals(name.getMaxIntrinsicWidth(double.infinity)),
|
||||||
reason: type,
|
reason: type,
|
||||||
);
|
);
|
||||||
|
expect(
|
||||||
|
tester.getCenter(find.text(type)).dy,
|
||||||
|
tester.getCenter(find.text(types.first)).dy,
|
||||||
|
reason: type,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
await tester.ensureVisible(find.text('Map'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Map').hitTestable(), findsOneWidget);
|
||||||
|
await tester.ensureVisible(find.text('Vocabulary'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Vocabulary'));
|
await tester.tap(find.text('Vocabulary'));
|
||||||
await settle(tester);
|
await settle(tester);
|
||||||
expect(find.text('Reading'), findsOneWidget);
|
expect(find.text('Reading'), findsOneWidget);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue