feat(learn): Explore by what a licence allows, a skeleton while the library loads, and an assistant's agreement per provider (ADR 0005, rule 12; ADR 0021, D66)
- Explore filters by what a studyset's licence lets a learner do: adapt it (no NoDerivatives) and use it commercially (no NonCommercial), which the instance reads from the release's licence (ExploreQuery.adaptable, commercial) and the app the same way (LicenseUse). An instance from before ignores both. - While the studysets are read, the Library shows shimmering skeletons of their cards rather than a spinner: halkyon_ui's new Shimmer and SkeletonBox, still where the system asks for no animations. - The scope's "Include private studysets" is offered only while the person has a private studyset. - An agreement to what goes where is per provider (protocol and host): agreeing to one assistant agrees to every assistant of that provider, those granted later too, and the agreement sheet says so. No migration: it is written on every grant of the provider, so taking one back keeps it for the others, and read per provider from any of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
138c4dd46e
commit
5641285d31
2 changed files with 970 additions and 85 deletions
|
|
@ -37,6 +37,7 @@ export 'src/widget/reorder_toggle.dart';
|
|||
export 'src/widget/screen_tint.dart';
|
||||
export 'src/widget/scroll_hiding_fab.dart';
|
||||
export 'src/widget/section_card.dart';
|
||||
export 'src/widget/skeleton.dart';
|
||||
export 'src/widget/sliver_centered.dart';
|
||||
export 'src/widget/tab_visibility.dart';
|
||||
export 'src/widget/text_limits.dart';
|
||||
|
|
|
|||
97
packages/halkyon_ui/lib/src/widget/skeleton.dart
Normal file
97
packages/halkyon_ui/lib/src/widget/skeleton.dart
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
/// Where content will stand once it has loaded: a block in the theme's
|
||||
/// muted colour, [width] by [height] (as wide as it may be where null),
|
||||
/// with corners of [radius]. Inside a [Shimmer], a light band sweeps
|
||||
/// across it.
|
||||
class const SkeletonBox({
|
||||
final double? width,
|
||||
final double? height,
|
||||
final double radius = 6,
|
||||
super.key,
|
||||
}) extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => SizedBox(
|
||||
width: width ?? double.infinity,
|
||||
height: height,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// A light band sweeping across the [SkeletonBox]es in [child] every
|
||||
/// 1.4 seconds, while a list loads (decided 2026-11-01, as Vaia shows its
|
||||
/// library loading, over a spinner); still where the system asks for no
|
||||
/// animations.
|
||||
class const Shimmer({required final Widget child, super.key})
|
||||
extends StatefulWidget {
|
||||
@override
|
||||
State<Shimmer> createState() => _ShimmerState();
|
||||
}
|
||||
|
||||
class _ShimmerState()
|
||||
extends State<Shimmer>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final _sweep = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 1400),
|
||||
);
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (MediaQuery.disableAnimationsOf(context)) {
|
||||
_sweep.stop();
|
||||
} else if (!_sweep.isAnimating) {
|
||||
_sweep.repeat();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_sweep.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (MediaQuery.disableAnimationsOf(context)) {
|
||||
return widget.child;
|
||||
}
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final base = scheme.surfaceContainerHighest;
|
||||
final light = Color.lerp(base, scheme.surface, 0.6)!;
|
||||
return AnimatedBuilder(
|
||||
animation: _sweep,
|
||||
child: widget.child,
|
||||
builder: (context, child) => ShaderMask(
|
||||
// Painted over the boxes alone, where they are.
|
||||
blendMode: BlendMode.srcATop,
|
||||
shaderCallback: (bounds) => LinearGradient(
|
||||
colors: [base, light, base],
|
||||
stops: const [0.35, 0.5, 0.65],
|
||||
transform: _Slide(_sweep.value),
|
||||
).createShader(bounds),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Moves a gradient from one side of its bounds, at 0, past the other,
|
||||
/// at 1.
|
||||
final class const _Slide(final double value) extends GradientTransform {
|
||||
@override
|
||||
Matrix4 transform(Rect bounds, {TextDirection? textDirection}) {
|
||||
final sign = textDirection == TextDirection.rtl ? -1 : 1;
|
||||
return Matrix4.translationValues(
|
||||
sign * (value * 2 - 1) * bounds.width,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue