fix(theme): every spinner is Material 3 Expressive's, pulling down too
The app's spinner is Material 3 Expressive's morphing indicator, but pulling a list down (the library, a studyset's parts, Explore) showed Flutter's older circular one, as did the spinners in buttons and a few dialogs. Pulling down now brings the app's spinner in a small round container that comes down with the pull and stays while it refreshes (AppRefreshIndicator, over Flutter's RefreshIndicator without its own spinner), and buttons show it small in their own colour (ButtonLoadingIndicator). Only determinate progress (a mastery ring) stays a circle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
5455453d20
commit
a57816a869
11 changed files with 194 additions and 25 deletions
|
|
@ -97,7 +97,7 @@ A spaced-repetition learning app: studysets of flashcards, reviewed on an FSRS s
|
||||||
- **Material comes from `package:material_ui`** (Cupertino from `package:cupertino_ui`), never from `package:flutter/material.dart`, which Flutter deprecates from its November 2026 release on. Packages still on the SDK's copy get the app's theme and localizations through `MaterialUiCompatibilityBridge` in `MaterialApp.builder`; remove it once they have moved.
|
- **Material comes from `package:material_ui`** (Cupertino from `package:cupertino_ui`), never from `package:flutter/material.dart`, which Flutter deprecates from its November 2026 release on. Packages still on the SDK's copy get the app's theme and localizations through `MaterialUiCompatibilityBridge` in `MaterialApp.builder`; remove it once they have moved.
|
||||||
- **Navigation is `go_router`**: the routes in `lib/src/app/app_router.dart`, their paths in `core/router/route_paths.dart`. Four tabs (Home, Library, Explore, Profile) are the branches of a `StatefulShellRoute`, each keeping its own stack of screens alive while another tab shows (`tabsContainer`, go_router's indexed stack plus `TabVisibility`, which a screen depends on to stop something once its tab is hidden); `AppShell` shows them as a navigation rail from 600 dp on and as a navigation bar below (Material 3 Expressive's shorter one, 64 dp, set in the theme: Flutter's Material library has none yet), floating above the bottom edge (`FloatingNavigationBar`): the tab screens run on beneath it (the shell's `extendBody`), every list ending with room for it (the body's bottom padding) and floating buttons lifted by `FloatingNavigationBar.coverOf`, with the background of the screen in view around it in between (`ScreenTint`); it steps aside inside a studyset (its screen, notes, paths and dictionary: `RoutePaths.isInsideStudyset`), whose own bar at the bottom takes its place, leaving a strip as high as the system's bar (decided 2026-10-11, as Material 3 puts toolbars below the top level and Vaia does), and choosing the open tab again returns to its first screen. A tab's own screens are routes nested in its branch, reached with `context.go` (a studyset's screen in the library), and **the screens behind a studyset are its path** (decided 2026-10-11; `feature/studyset/widget/studyset_navigation.dart`): a topic, at any depth, opens with the screens of the levels between pushed beneath it (`openStudysetWithin`; the same route, keyed by id and named by its location, so several stack), the path's steps and the levels a long press on back lists go up by popping to that page (`goUpTo`), and a studyset opened from elsewhere gets its levels beneath it (`openStudyset`). So back, Android's predictive back, iOS's swipe from the edge and the path all lead one level up. Below expanded windows the topics open in a sheet from the end of the path's line, never a drawer, whose swipe from the edge is iOS's way back. A studyset's notes and learning paths (working through one, writing it, writing a step) are routes of the Library branch too, so the tabs stay beside them. What needs the whole window (studying, a card, a PDF, settings) is a top-level route over the tabs, reached with `context.push`. Explore lists what is published (see *Explore and copies*).
|
- **Navigation is `go_router`**: the routes in `lib/src/app/app_router.dart`, their paths in `core/router/route_paths.dart`. Four tabs (Home, Library, Explore, Profile) are the branches of a `StatefulShellRoute`, each keeping its own stack of screens alive while another tab shows (`tabsContainer`, go_router's indexed stack plus `TabVisibility`, which a screen depends on to stop something once its tab is hidden); `AppShell` shows them as a navigation rail from 600 dp on and as a navigation bar below (Material 3 Expressive's shorter one, 64 dp, set in the theme: Flutter's Material library has none yet), floating above the bottom edge (`FloatingNavigationBar`): the tab screens run on beneath it (the shell's `extendBody`), every list ending with room for it (the body's bottom padding) and floating buttons lifted by `FloatingNavigationBar.coverOf`, with the background of the screen in view around it in between (`ScreenTint`); it steps aside inside a studyset (its screen, notes, paths and dictionary: `RoutePaths.isInsideStudyset`), whose own bar at the bottom takes its place, leaving a strip as high as the system's bar (decided 2026-10-11, as Material 3 puts toolbars below the top level and Vaia does), and choosing the open tab again returns to its first screen. A tab's own screens are routes nested in its branch, reached with `context.go` (a studyset's screen in the library), and **the screens behind a studyset are its path** (decided 2026-10-11; `feature/studyset/widget/studyset_navigation.dart`): a topic, at any depth, opens with the screens of the levels between pushed beneath it (`openStudysetWithin`; the same route, keyed by id and named by its location, so several stack), the path's steps and the levels a long press on back lists go up by popping to that page (`goUpTo`), and a studyset opened from elsewhere gets its levels beneath it (`openStudyset`). So back, Android's predictive back, iOS's swipe from the edge and the path all lead one level up. Below expanded windows the topics open in a sheet from the end of the path's line, never a drawer, whose swipe from the edge is iOS's way back. A studyset's notes and learning paths (working through one, writing it, writing a step) are routes of the Library branch too, so the tabs stay beside them. What needs the whole window (studying, a card, a PDF, settings) is a top-level route over the tabs, reached with `context.push`. Explore lists what is published (see *Explore and copies*).
|
||||||
- **Routes carry ids, never objects.** A screen finds its item in the repository's live list with `FoundById` (`core/widget/`): a spinner until the list arrives, then the item, or a screen saying it no longer exists (deleted on another device, or an old link). A screen that deletes its item closes, and keeps showing the item while it goes. Why: every location can be built from its path alone, and no screen goes on showing something that has gone.
|
- **Routes carry ids, never objects.** A screen finds its item in the repository's live list with `FoundById` (`core/widget/`): a spinner until the list arrives, then the item, or a screen saying it no longer exists (deleted on another device, or an old link). A screen that deletes its item closes, and keeps showing the item while it goes. Why: every location can be built from its path alone, and no screen goes on showing something that has gone.
|
||||||
- **The look is one theme** (`core/theme/`): `appTheme(brightness)` with hand-written light and dark colour schemes around the brand's cobalt and copper; `Theme.of(context).extras` (`ThemeExtras`) for the colours Material has no role for (states, the four FSRS ratings, a starred star); `PaletteColor` for the 20 colours a person can give content; snack bars floating above the navigation bar as Material 3 places them, in its inverse colours (dark in the light theme), lined up with the floating bar, 560 wide and centred from medium windows on (`FittedSnackBars`, decided 2026-10-12; Flutter's default is Material 2's fixed bar across the foot); `TopGradient` for a colour washing down from the top of every tab's first screen, Settings and Connect Claude (cobalt) and of every screen of a studyset (its colour, own or inherited, which `_inStudyset` in the router hands down as `ScreenColor`): the studyset, studying it, its cards, writing them, its notes, paths and dictionary; behind a clear app bar, in dark mode a deep shade (42 % of the colour over black), in light mode a tint, held to WCAG AA for the theme's text. From medium windows on, a `TintFrame` takes the colour of the screen in view (`ScreenTint`, claimed by the `TopGradient` whose tab shows and whose route is on top), fading out by 60 % of the height: the rail sits on it, transparent, and the screen is a rounded panel inset beside it, its own wash half as strong; screens over the tabs (studying, the card browser and composer, Settings) sit in the same frame without the rail (`FramedScreen`). As Vaia does, decided 2026-10-10. The PDF reader and the reading timeline stay plain. `theme_test.dart` holds text to WCAG AA contrast (4.5:1) on each palette colour and on the dark theme's primary colour and surface. **Fonts are bundled, never fetched** (`core/theme/app_fonts.dart`, `assets/fonts/ATTRIBUTION.md`): Noto Sans is the app's font on every device (Latin, Greek with polytonic, Cyrillic); Noto Sans JP, SC, TC and KR fill in Japanese, Chinese and Korean, Japanese first unless a studyset's language puts its own first (`StudysetLanguageScope`, which every studyset route wraps its screen in through `_inStudyset`; Han characters take the first listed font's shapes); each is one variable font holding every weight, and their OFL licences join the licence list. Scripts none covers (Arabic, Hebrew, Thai, …) fall back to the device's own fonts. A studyset's languages (`frontLanguage`, `backLanguage`, BCP 47) are given together or inherited together from the nearest studyset above (`languagesOf`). Never add `google_fonts` or anything else that downloads fonts. Layouts follow Material 3's window-size classes (`context.windowSize`, `core/layout/`), and running text stays within `readableContentMaxWidth`. Icons are Lucide (`lucide_icons_flutter`), except a starred star and the marks of a choice not yet checked (filled box and circle), which need the fill Lucide lacks; the Material icons left in older screens go when those are restyled. Shared widgets are in `core/widget/` (`SectionCard`, `AppLoadingIndicator`, `confirmDestructiveAction`, `FoundById`, `TitleWithKicker`, `ContentCountsLine`, `showUndoSnackBar`, `ScrollHidingFab`, `PaletteColorPicker`, `CountStepper`, `RequiredFieldLabel` and `FieldInfoButton`, `ReorderToggle`, `ReorderGrip`, `CollapsingRow`, `CountBadge`, `liftWhileDragged`, `LaunchScreen` (what shows while the app opens: the kingfisher, "Halkyon" over "Learn"), `SliverCentered` and `EmptyListMessage` (what an empty list shows: icon, "No … yet", and which menus add some), and the sheets below).
|
- **The look is one theme** (`core/theme/`): `appTheme(brightness)` with hand-written light and dark colour schemes around the brand's cobalt and copper; `Theme.of(context).extras` (`ThemeExtras`) for the colours Material has no role for (states, the four FSRS ratings, a starred star); `PaletteColor` for the 20 colours a person can give content; snack bars floating above the navigation bar as Material 3 places them, in its inverse colours (dark in the light theme), lined up with the floating bar, 560 wide and centred from medium windows on (`FittedSnackBars`, decided 2026-10-12; Flutter's default is Material 2's fixed bar across the foot); `TopGradient` for a colour washing down from the top of every tab's first screen, Settings and Connect Claude (cobalt) and of every screen of a studyset (its colour, own or inherited, which `_inStudyset` in the router hands down as `ScreenColor`): the studyset, studying it, its cards, writing them, its notes, paths and dictionary; behind a clear app bar, in dark mode a deep shade (42 % of the colour over black), in light mode a tint, held to WCAG AA for the theme's text. From medium windows on, a `TintFrame` takes the colour of the screen in view (`ScreenTint`, claimed by the `TopGradient` whose tab shows and whose route is on top), fading out by 60 % of the height: the rail sits on it, transparent, and the screen is a rounded panel inset beside it, its own wash half as strong; screens over the tabs (studying, the card browser and composer, Settings) sit in the same frame without the rail (`FramedScreen`). As Vaia does, decided 2026-10-10. The PDF reader and the reading timeline stay plain. `theme_test.dart` holds text to WCAG AA contrast (4.5:1) on each palette colour and on the dark theme's primary colour and surface. **Fonts are bundled, never fetched** (`core/theme/app_fonts.dart`, `assets/fonts/ATTRIBUTION.md`): Noto Sans is the app's font on every device (Latin, Greek with polytonic, Cyrillic); Noto Sans JP, SC, TC and KR fill in Japanese, Chinese and Korean, Japanese first unless a studyset's language puts its own first (`StudysetLanguageScope`, which every studyset route wraps its screen in through `_inStudyset`; Han characters take the first listed font's shapes); each is one variable font holding every weight, and their OFL licences join the licence list. Scripts none covers (Arabic, Hebrew, Thai, …) fall back to the device's own fonts. A studyset's languages (`frontLanguage`, `backLanguage`, BCP 47) are given together or inherited together from the nearest studyset above (`languagesOf`). Never add `google_fonts` or anything else that downloads fonts. Layouts follow Material 3's window-size classes (`context.windowSize`, `core/layout/`), and running text stays within `readableContentMaxWidth`. Icons are Lucide (`lucide_icons_flutter`), except a starred star and the marks of a choice not yet checked (filled box and circle), which need the fill Lucide lacks; the Material icons left in older screens go when those are restyled. Shared widgets are in `core/widget/` (`SectionCard`, `AppLoadingIndicator` (every spinner is Material 3 Expressive's, in buttons `ButtonLoadingIndicator`, pulling a list down `AppRefreshIndicator`, never Flutter's older circular one), `confirmDestructiveAction`, `FoundById`, `TitleWithKicker`, `ContentCountsLine`, `showUndoSnackBar`, `ScrollHidingFab`, `PaletteColorPicker`, `CountStepper`, `RequiredFieldLabel` and `FieldInfoButton`, `ReorderToggle`, `ReorderGrip`, `CollapsingRow`, `CountBadge`, `liftWhileDragged`, `LaunchScreen` (what shows while the app opens: the kingfisher, "Halkyon" over "Learn"), `SliverCentered` and `EmptyListMessage` (what an empty list shows: icon, "No … yet", and which menus add some), and the sheets below).
|
||||||
- **A studyset's content is in three parts** (`feature/studyset/widget/studyset_parts.dart`, decided 2026-10-12, as Vaia has it): Material (its flashcards, notes and files in tabs, each saying how many it holds, each list whole with its tools at the end of the tabs' row, which fold one by one where room runs short rather than cutting the tabs off (`CollapsingRow`: Browse's words first, then the filter into the ⋮ menu, then Browse; as the studyset's own actions fold into icons); decided 2026-10-12 after a trial of sections one below the other, the first three of each behind Show all, as Vaia stacks them: the lists run to hundreds of cards, and tabs are Material 3's way within a part; the tab is kept as the studyset's part, while the material shows, and opened for the first time it opens on a tab with something in it), Progress (always, nothing yet where nothing was studied, so the switch never changes as reviews are read, decided 2026-10-12: how much is learnt, what is due today, the study time this week from the reviews' durations, each at most `Review.maxStudyTime`, `StudysetActivityCubit`) and Study plan (the paths finished, Next up, the paths). `StudysetPartSwitch` chooses between them in the header: below expanded windows in a line of its own under the title, from there on in the path's line, which the topics leave free there, centred above the material's column (at the line's end where that column is narrower than the switch; the path folds before it); it ticks as the navigation bar does. **A studyset opens on the part it was left on, on this device** (`StudysetTabs`, `studyset_tabs.json` in the person's folder, read as their data opens, decided 2026-10-11; a tab kept before the parts counts as its part); opened there for the first time, on the study plan while a path is unfinished, else on the material, showing that it loads until it knows rather than one part and then another. Material added or imported shows in its part (`ContentTabCubit`).
|
- **A studyset's content is in three parts** (`feature/studyset/widget/studyset_parts.dart`, decided 2026-10-12, as Vaia has it): Material (its flashcards, notes and files in tabs, each saying how many it holds, each list whole with its tools at the end of the tabs' row, which fold one by one where room runs short rather than cutting the tabs off (`CollapsingRow`: Browse's words first, then the filter into the ⋮ menu, then Browse; as the studyset's own actions fold into icons); decided 2026-10-12 after a trial of sections one below the other, the first three of each behind Show all, as Vaia stacks them: the lists run to hundreds of cards, and tabs are Material 3's way within a part; the tab is kept as the studyset's part, while the material shows, and opened for the first time it opens on a tab with something in it), Progress (always, nothing yet where nothing was studied, so the switch never changes as reviews are read, decided 2026-10-12: how much is learnt, what is due today, the study time this week from the reviews' durations, each at most `Review.maxStudyTime`, `StudysetActivityCubit`) and Study plan (the paths finished, Next up, the paths). `StudysetPartSwitch` chooses between them in the header: below expanded windows in a line of its own under the title, from there on in the path's line, which the topics leave free there, centred above the material's column (at the line's end where that column is narrower than the switch; the path folds before it); it ticks as the navigation bar does. **A studyset opens on the part it was left on, on this device** (`StudysetTabs`, `studyset_tabs.json` in the person's folder, read as their data opens, decided 2026-10-11; a tab kept before the parts counts as its part); opened there for the first time, on the study plan while a path is unfinished, else on the material, showing that it loads until it knows rather than one part and then another. Material added or imported shows in its part (`ContentTabCubit`).
|
||||||
- **Statistics** (`feature/statistics/`, decided 2026-10-12, as Vaia has them): the Profile tab's second tab, for anonymous people too. The time studied in all, per day (every day from the first studied to today counted) and the most in one day, and by days, weeks or months (ten, ten, twelve bars) the study time and the ratings, as bars the app draws itself (`BarChart`, no chart package); a tap on a bar says what it holds. Computed on the device from every review (`studyStatistics`, `StatisticsCubit`), every rating counted, crammed ones too, a fresh start not, and **a review counts as at most a minute of study** (`Review.maxStudyTime`, as Anki does by default: a card left on the screen over lunch isn't an hour of study; stored durations stay as they were), here and in a studyset's Progress. What waits in Recently deleted counts nowhere, here or on Home.
|
- **Statistics** (`feature/statistics/`, decided 2026-10-12, as Vaia has them): the Profile tab's second tab, for anonymous people too. The time studied in all, per day (every day from the first studied to today counted) and the most in one day, and by days, weeks or months (ten, ten, twelve bars) the study time and the ratings, as bars the app draws itself (`BarChart`, no chart package); a tap on a bar says what it holds. Computed on the device from every review (`studyStatistics`, `StatisticsCubit`), every rating counted, crammed ones too, a fresh start not, and **a review counts as at most a minute of study** (`Review.maxStudyTime`, as Anki does by default: a card left on the screen over lunch isn't an hour of study; stored durations stay as they were), here and in a studyset's Progress. What waits in Recently deleted counts nowhere, here or on Home.
|
||||||
- **Lists that can grow long are built as they scroll into view**: a studyset's parts are `CustomScrollView`s holding each list's slivers (`SliverList`, `SliverReorderableList`), and what a list says in place of its rows sits in a `SliverCentered`. Never a `shrinkWrap` list inside another scrolling view: that builds every row at once, and 1,000 cards then froze the window for seconds, long enough for the desktop to offer to kill the app. Rows are put in another order in a Reorder mode (`ReorderToggle` beside the list; a `ReorderGrip` in place of each row's options; positions from `core/sync/fractional_position.dart`), never with Flutter's default drag handles, which on the desktop lie over a row's trailing end, its … button. Flashcards have no Reorder (decided 2026-10-08): they keep the order they were created or imported in, which new cards and cramming follow, and sub-studysets put lessons in order; no one drags a card among a thousand. **The card browser** (`feature/card/widget/card_browser_screen.dart`, decided 2026-10-09: the older design, gaps filled) opens from Browse beside the flashcards' tab, over the tabs (`/studysets/:id/flashcards`, `?subtree=1` with everything inside, which a line below the title says; the title has how many cards beside it): grid or detail (one card beside the list, which follows it; on a phone above a strip), as last left per studyset on the device (`DeviceSettings.detailedBrowsers`); search over front, back, reading, meanings, hints, explanation and tag names (katakana as hiragana, romaji finding kana; `card_browser.dart`); sort (own order, newest, oldest, A–Z by reading, due first); a filter sheet (kind, one tag, state: new, learning, due, buried, reported); and choosing cards (a toggle; shift-click or long-press for a range) to move (`showCardMoveSheet`), tag, untag, start afresh or delete with Undo. It reads every card of the studysets, as lists do (schedules from the review repository's cache).
|
- **Lists that can grow long are built as they scroll into view**: a studyset's parts are `CustomScrollView`s holding each list's slivers (`SliverList`, `SliverReorderableList`), and what a list says in place of its rows sits in a `SliverCentered`. Never a `shrinkWrap` list inside another scrolling view: that builds every row at once, and 1,000 cards then froze the window for seconds, long enough for the desktop to offer to kill the app. Rows are put in another order in a Reorder mode (`ReorderToggle` beside the list; a `ReorderGrip` in place of each row's options; positions from `core/sync/fractional_position.dart`), never with Flutter's default drag handles, which on the desktop lie over a row's trailing end, its … button. Flashcards have no Reorder (decided 2026-10-08): they keep the order they were created or imported in, which new cards and cramming follow, and sub-studysets put lessons in order; no one drags a card among a thousand. **The card browser** (`feature/card/widget/card_browser_screen.dart`, decided 2026-10-09: the older design, gaps filled) opens from Browse beside the flashcards' tab, over the tabs (`/studysets/:id/flashcards`, `?subtree=1` with everything inside, which a line below the title says; the title has how many cards beside it): grid or detail (one card beside the list, which follows it; on a phone above a strip), as last left per studyset on the device (`DeviceSettings.detailedBrowsers`); search over front, back, reading, meanings, hints, explanation and tag names (katakana as hiragana, romaji finding kana; `card_browser.dart`); sort (own order, newest, oldest, A–Z by reading, due first); a filter sheet (kind, one tag, state: new, learning, due, buried, reported); and choosing cards (a toggle; shift-click or long-press for a range) to move (`showCardMoveSheet`), tag, untag, start afresh or delete with Undo. It reads every card of the studysets, as lists do (schedules from the review repository's cache).
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import 'package:halkyon_learn_flutter/src/core/dependencies/person_scope.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/editor/atomic_block.dart';
|
import 'package:halkyon_learn_flutter/src/core/editor/atomic_block.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/editor/editor_blocks.dart';
|
import 'package:halkyon_learn_flutter/src/core/editor/editor_blocks.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/router/route_paths.dart';
|
import 'package:halkyon_learn_flutter/src/core/router/route_paths.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/core/widget/app_loading_indicator.dart';
|
||||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||||
import 'package:material_ui/material_ui.dart';
|
import 'package:material_ui/material_ui.dart';
|
||||||
|
|
||||||
|
|
@ -272,10 +273,7 @@ class const _SoundButton() extends StatelessWidget {
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
context.read<SoundBloc>().add(const SoundEventToggled()),
|
context.read<SoundBloc>().add(const SoundEventToggled()),
|
||||||
icon: switch (state) {
|
icon: switch (state) {
|
||||||
SoundState.loading => const SizedBox.square(
|
SoundState.loading => const ButtonLoadingIndicator(),
|
||||||
dimension: 18,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
),
|
|
||||||
SoundState.playing => const Icon(LucideIcons.square),
|
SoundState.playing => const Icon(LucideIcons.square),
|
||||||
SoundState.idle ||
|
SoundState.idle ||
|
||||||
SoundState.missing ||
|
SoundState.missing ||
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,152 @@ import 'package:material_ui/material_ui.dart';
|
||||||
|
|
||||||
/// The app's spinner for anything still loading: Material 3 Expressive's
|
/// The app's spinner for anything still loading: Material 3 Expressive's
|
||||||
/// morphing indicator, which Flutter doesn't ship yet. Every loading state
|
/// morphing indicator, which Flutter doesn't ship yet. Every loading state
|
||||||
/// shows this widget, so swapping in the SDK's own indicator one day changes
|
/// shows this widget, a button's too ([ButtonLoadingIndicator]) and pulling
|
||||||
/// one file. Determinate progress (a mastery ring) and small in-button
|
/// a list down ([AppRefreshIndicator]), so swapping in the SDK's own
|
||||||
/// spinners stay [CircularProgressIndicator]s.
|
/// indicator one day changes one file. Determinate progress (a mastery
|
||||||
|
/// ring) stays a [CircularProgressIndicator].
|
||||||
class const AppLoadingIndicator({
|
class const AppLoadingIndicator({
|
||||||
/// The side of its square; Material's 48 dp when null.
|
/// The side of its square; Material's 48 dp when null.
|
||||||
final double? size,
|
final double? size,
|
||||||
|
|
||||||
|
/// Its colour; the theme's primary colour when null.
|
||||||
|
final Color? color,
|
||||||
super.key,
|
super.key,
|
||||||
}) extends StatelessWidget {
|
}) extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => ExpressiveLoadingIndicator(
|
Widget build(BuildContext context) => ExpressiveLoadingIndicator(
|
||||||
|
color: color,
|
||||||
constraints: switch (size) {
|
constraints: switch (size) {
|
||||||
final size? => BoxConstraints.tightFor(width: size, height: size),
|
final size? => BoxConstraints.tightFor(width: size, height: size),
|
||||||
null => null,
|
null => null,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The app's spinner in a button, in place of its icon or label while what
|
||||||
|
/// it started is under way: small, in the button's own colour.
|
||||||
|
class const ButtonLoadingIndicator({super.key}) extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => AppLoadingIndicator(
|
||||||
|
size: 20,
|
||||||
|
color:
|
||||||
|
IconTheme.of(context).color ?? DefaultTextStyle.of(context).style.color,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pulling [child] down runs [onRefresh], the app's spinner showing
|
||||||
|
/// meanwhile, as Material 3 Expressive's pull to refresh has it: in a small
|
||||||
|
/// round container that comes down with the pull and stays while it
|
||||||
|
/// refreshes. Flutter's own [RefreshIndicator] draws the older spinner, so
|
||||||
|
/// it only does the pulling here (its `noSpinner` kind).
|
||||||
|
class const AppRefreshIndicator({
|
||||||
|
required final RefreshCallback onRefresh,
|
||||||
|
required final Widget child,
|
||||||
|
super.key,
|
||||||
|
}) extends StatefulWidget {
|
||||||
|
/// How far down the container comes at most, and stays while refreshing.
|
||||||
|
static const restingTop = 24.0;
|
||||||
|
|
||||||
|
/// The container's side.
|
||||||
|
static const containerSize = 44.0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AppRefreshIndicator> createState() => _AppRefreshIndicatorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppRefreshIndicatorState() extends State<AppRefreshIndicator> {
|
||||||
|
RefreshIndicatorStatus? _status;
|
||||||
|
|
||||||
|
/// How far the list was pulled past its top, in logical pixels.
|
||||||
|
var _pulled = 0.0;
|
||||||
|
|
||||||
|
bool _tracked(ScrollNotification notification) {
|
||||||
|
if (notification.depth != 0 || notification.metrics.axis != Axis.vertical) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (notification) {
|
||||||
|
case ScrollStartNotification():
|
||||||
|
if (_status != RefreshIndicatorStatus.refresh) {
|
||||||
|
_pulled = 0;
|
||||||
|
}
|
||||||
|
case OverscrollNotification(:final overscroll)
|
||||||
|
when overscroll < 0 && notification.metrics.extentBefore == 0:
|
||||||
|
setState(() => _pulled -= overscroll);
|
||||||
|
case ScrollUpdateNotification(:final scrollDelta?)
|
||||||
|
when _pulled > 0 && scrollDelta > 0:
|
||||||
|
setState(() => _pulled = (_pulled - scrollDelta).clamp(0, _pulled));
|
||||||
|
// A list that bounces (iOS) goes past its top by itself.
|
||||||
|
case ScrollUpdateNotification(:final metrics)
|
||||||
|
when metrics.pixels < metrics.minScrollExtent:
|
||||||
|
setState(() => _pulled = metrics.minScrollExtent - metrics.pixels);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
final status = _status;
|
||||||
|
final refreshing =
|
||||||
|
status == RefreshIndicatorStatus.refresh ||
|
||||||
|
status == RefreshIndicatorStatus.snap;
|
||||||
|
final pulling =
|
||||||
|
status == RefreshIndicatorStatus.drag ||
|
||||||
|
status == RefreshIndicatorStatus.armed;
|
||||||
|
const size = AppRefreshIndicator.containerSize;
|
||||||
|
// Comes down with the pull, half as fast as the finger, to rest.
|
||||||
|
final top = refreshing
|
||||||
|
? AppRefreshIndicator.restingTop
|
||||||
|
: (_pulled / 2 - size).clamp(-size, AppRefreshIndicator.restingTop);
|
||||||
|
final shown = refreshing || (pulling && _pulled > 0);
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: _tracked,
|
||||||
|
child: RefreshIndicator.noSpinner(
|
||||||
|
onRefresh: widget.onRefresh,
|
||||||
|
onStatusChange: (status) => setState(() {
|
||||||
|
_status = status;
|
||||||
|
if (status == RefreshIndicatorStatus.done ||
|
||||||
|
status == RefreshIndicatorStatus.canceled) {
|
||||||
|
_pulled = 0;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
child: widget.child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: top,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
opacity: shown ? 1 : 0,
|
||||||
|
duration: const Duration(milliseconds: 150),
|
||||||
|
child: Center(
|
||||||
|
child: Material(
|
||||||
|
color: colors.primaryContainer,
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
elevation: 3,
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: size,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
child: shown
|
||||||
|
? AppLoadingIndicator(
|
||||||
|
color: colors.onPrimaryContainer,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ class const _Results({required final ExploreState state})
|
||||||
child: Text(l10n.exploreClearFilters),
|
child: Text(l10n.exploreClearFilters),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_ => RefreshIndicator(
|
_ => AppRefreshIndicator(
|
||||||
onRefresh: () async => send(ExploreEventFiltered(state.filter)),
|
onRefresh: () async => send(ExploreEventFiltered(state.filter)),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
// Room at the end for the navigation bar floating over the foot.
|
// Room at the end for the navigation bar floating over the foot.
|
||||||
|
|
@ -570,10 +570,7 @@ class const ExploreAddButton({
|
||||||
style: style,
|
style: style,
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
child: progress == null
|
child: progress == null
|
||||||
? const SizedBox.square(
|
? const ButtonLoadingIndicator()
|
||||||
dimension: 18,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
)
|
|
||||||
: Text(l10n.explorePercent((progress * 100).round())),
|
: Text(l10n.explorePercent((progress * 100).round())),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:halkyon_learn_flutter/l10n/app_localizations.dart';
|
import 'package:halkyon_learn_flutter/l10n/app_localizations.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/instance/instance.dart';
|
import 'package:halkyon_learn_flutter/src/core/instance/instance.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/instance/instance_checker.dart';
|
import 'package:halkyon_learn_flutter/src/core/instance/instance_checker.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/core/widget/app_loading_indicator.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/widget/text_limits.dart';
|
import 'package:halkyon_learn_flutter/src/core/widget/text_limits.dart';
|
||||||
import 'package:material_ui/material_ui.dart';
|
import 'package:material_ui/material_ui.dart';
|
||||||
|
|
||||||
|
|
@ -124,10 +125,7 @@ class _InstanceStepState() extends State<InstanceStep> {
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: _checking ? null : _continue,
|
onPressed: _checking ? null : _continue,
|
||||||
child: _checking
|
child: _checking
|
||||||
? const SizedBox.square(
|
? const ButtonLoadingIndicator()
|
||||||
dimension: 20,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
)
|
|
||||||
: Text(l10n.instanceContinue),
|
: Text(l10n.instanceContinue),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import 'package:halkyon_learn_flutter/src/core/asset/data/asset_repository.dart'
|
||||||
import 'package:halkyon_learn_flutter/src/core/content/content_blocks.dart';
|
import 'package:halkyon_learn_flutter/src/core/content/content_blocks.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/content/rich_content.dart';
|
import 'package:halkyon_learn_flutter/src/core/content/rich_content.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/editor/editor_blocks.dart';
|
import 'package:halkyon_learn_flutter/src/core/editor/editor_blocks.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/core/widget/app_loading_indicator.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/pdf_source/data/pdf_engine.dart';
|
import 'package:halkyon_learn_flutter/src/feature/pdf_source/data/pdf_engine.dart';
|
||||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||||
import 'package:material_ui/material_ui.dart';
|
import 'package:material_ui/material_ui.dart';
|
||||||
|
|
@ -202,7 +203,7 @@ class _PdfCaptureOverlayState() extends State<PdfCaptureOverlay> {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
if (_working)
|
if (_working)
|
||||||
const CircularProgressIndicator()
|
const AppLoadingIndicator()
|
||||||
else
|
else
|
||||||
Text(
|
Text(
|
||||||
l10n.readerCaptureHint,
|
l10n.readerCaptureHint,
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,7 @@ class _PublishSheetState() extends State<_PublishSheet> {
|
||||||
child: FilledButton.icon(
|
child: FilledButton.icon(
|
||||||
onPressed: publishing ? null : _publish,
|
onPressed: publishing ? null : _publish,
|
||||||
icon: publishing
|
icon: publishing
|
||||||
? const SizedBox.square(
|
? const ButtonLoadingIndicator()
|
||||||
dimension: 18,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
)
|
|
||||||
: const Icon(LucideIcons.globe),
|
: const Icon(LucideIcons.globe),
|
||||||
label: Text(
|
label: Text(
|
||||||
l10n.publishButton(
|
l10n.publishButton(
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import 'package:halkyon_learn_flutter/src/core/dependencies/person_scope.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/editor/atomic_block.dart';
|
import 'package:halkyon_learn_flutter/src/core/editor/atomic_block.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/editor/editor_blocks.dart';
|
import 'package:halkyon_learn_flutter/src/core/editor/editor_blocks.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/router/route_paths.dart';
|
import 'package:halkyon_learn_flutter/src/core/router/route_paths.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/core/widget/app_loading_indicator.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/core/widget/text_limits.dart';
|
import 'package:halkyon_learn_flutter/src/core/widget/text_limits.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/study/model/study_focus.dart';
|
import 'package:halkyon_learn_flutter/src/feature/study/model/study_focus.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset.dart';
|
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset.dart';
|
||||||
|
|
@ -277,7 +278,7 @@ class _StudyButtonDialogState() extends State<_StudyButtonDialog> {
|
||||||
content: SizedBox(
|
content: SizedBox(
|
||||||
width: 420,
|
width: 420,
|
||||||
child: studysets == null || tags == null
|
child: studysets == null || tags == null
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: AppLoadingIndicator())
|
||||||
: SingleChildScrollView(
|
: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ class _GridState() extends State<_Grid> {
|
||||||
final archiveOpen = searching || _archiveOpen;
|
final archiveOpen = searching || _archiveOpen;
|
||||||
final deletedOpen = searching || _deletedOpen;
|
final deletedOpen = searching || _deletedOpen;
|
||||||
// Pulled down, the library syncs.
|
// Pulled down, the library syncs.
|
||||||
return RefreshIndicator(
|
return AppRefreshIndicator(
|
||||||
onRefresh: () => Future.wait([
|
onRefresh: () => Future.wait([
|
||||||
syncAndWait(context.read<SyncStatusBloc>()),
|
syncAndWait(context.read<SyncStatusBloc>()),
|
||||||
context.read<PublishedCubit>().refresh(),
|
context.read<PublishedCubit>().refresh(),
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ Widget _pullToSync(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
ScrollController scroll,
|
ScrollController scroll,
|
||||||
List<Widget> slivers,
|
List<Widget> slivers,
|
||||||
) => RefreshIndicator(
|
) => AppRefreshIndicator(
|
||||||
onRefresh: () => syncAndWait(context.read<SyncStatusBloc>()),
|
onRefresh: () => syncAndWait(context.read<SyncStatusBloc>()),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: scroll,
|
controller: scroll,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:expressive_loading_indicator/expressive_loading_indicator.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/core/theme/app_theme.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/core/widget/app_loading_indicator.dart';
|
||||||
|
import 'package:material_ui/material_ui.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets("pulled down, it refreshes with the app's spinner, Material 3 "
|
||||||
|
"Expressive's, not Flutter's older one", (tester) async {
|
||||||
|
final refreshing = Completer<void>();
|
||||||
|
var refreshes = 0;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
theme: appTheme(Brightness.light),
|
||||||
|
home: Scaffold(
|
||||||
|
body: AppRefreshIndicator(
|
||||||
|
onRefresh: () {
|
||||||
|
refreshes++;
|
||||||
|
return refreshing.future;
|
||||||
|
},
|
||||||
|
child: ListView(
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
children: const [Text('Japanese')],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(find.byType(ExpressiveLoadingIndicator), findsNothing);
|
||||||
|
|
||||||
|
await tester.fling(find.text('Japanese'), const Offset(0, 400), 1000);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(milliseconds: 300));
|
||||||
|
expect(refreshes, 1);
|
||||||
|
expect(find.byType(ExpressiveLoadingIndicator), findsOneWidget);
|
||||||
|
expect(find.byType(CircularProgressIndicator), findsNothing);
|
||||||
|
|
||||||
|
refreshing.complete();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(ExpressiveLoadingIndicator), findsNothing);
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue