Skip to content

Offline gym log for Android. No account, no ads, no internet.

Photos and medals load as you scroll, smoother onboarding

InlitXeb98a56c9b74
diff --git a/lib/screens/awards_screen.dart b/lib/screens/awards_screen.dart
index 399da75..e532898 100644
--- a/lib/screens/awards_screen.dart
+++ b/lib/screens/awards_screen.dart
@@ -50,19 +50,19 @@ class _AwardsScreenState extends State<AwardsScreen> {
size: 17, color: _picking ? gc.onEmber : gc.text),
),
],
- children: [
- Rise(index: 0, child: _summary(gc, won.length, total)),
+ slivers: [
+ SliverToBoxAdapter(child: Rise(index: 0, child: _summary(gc, won.length, total))),
if (won.isNotEmpty) ...[
- const SizedBox(height: 26),
- Rise(index: 1, child: _section(gc, t.awardsEarned, won.length)),
- const SizedBox(height: 10),
- Rise(index: 2, child: _grid(context, won)),
+ const SliverToBoxAdapter(child: SizedBox(height: 26)),
+ SliverToBoxAdapter(child: Rise(index: 1, child: _section(gc, t.awardsEarned, won.length))),
+ const SliverToBoxAdapter(child: SizedBox(height: 10)),
+ _grid(context, won, 2),
],
if (left.isNotEmpty) ...[
- const SizedBox(height: 26),
- Rise(index: 3, child: _section(gc, t.awardsLocked, left.length)),
- const SizedBox(height: 10),
- Rise(index: 4, child: _grid(context, left)),
+ const SliverToBoxAdapter(child: SizedBox(height: 26)),
+ SliverToBoxAdapter(child: Rise(index: 3, child: _section(gc, t.awardsLocked, left.length))),
+ const SliverToBoxAdapter(child: SizedBox(height: 10)),
+ _grid(context, left, 4),
],
],
),
@@ -149,11 +149,8 @@ class _AwardsScreenState extends State<AwardsScreen> {
);
}
- Widget _grid(BuildContext context, List<AwardId> ids) {
- return GridView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- padding: EdgeInsets.zero,
+ Widget _grid(BuildContext context, List<AwardId> ids, int rise) {
+ return SliverGrid.builder(
itemCount: ids.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
@@ -161,7 +158,7 @@ class _AwardsScreenState extends State<AwardsScreen> {
crossAxisSpacing: 10,
childAspectRatio: 1.02,
),
- itemBuilder: (_, i) => _card(context, ids[i]),
+ itemBuilder: (_, i) => Rise(index: rise, child: _card(context, ids[i])),
);
}
diff --git a/lib/screens/moments_screen.dart b/lib/screens/moments_screen.dart
index a486701..406fc1b 100644
--- a/lib/screens/moments_screen.dart
+++ b/lib/screens/moments_screen.dart
@@ -132,12 +132,12 @@ class _MomentsScreenState extends State<MomentsScreen> {
child: Icon(PhosphorIconsRegular.camera, size: 17, color: gc.text),
),
],
- children: shots.isEmpty
- ? [Rise(index: 0, child: _empty(gc))]
+ slivers: shots.isEmpty
+ ? [SliverToBoxAdapter(child: Rise(index: 0, child: _empty(gc)))]
: [
- Rise(index: 0, child: _stats(gc, shots)),
- const SizedBox(height: 22),
- Rise(index: 1, child: _grouped ? _byDate(gc, shots) : _plainGrid(gc, shots)),
+ SliverToBoxAdapter(child: Rise(index: 0, child: _stats(gc, shots))),
+ const SliverToBoxAdapter(child: SizedBox(height: 22)),
+ if (_grouped) ..._byDate(gc, shots) else _plainGrid(gc, shots),
],
),
);
@@ -169,10 +169,7 @@ class _MomentsScreenState extends State<MomentsScreen> {
}
Widget _plainGrid(GymColors gc, List<Moment> shots) {
- return GridView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- padding: EdgeInsets.zero,
+ return SliverGrid.builder(
itemCount: shots.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
@@ -195,35 +192,31 @@ class _MomentsScreenState extends State<MomentsScreen> {
return '${t.monthName(d.month)} ${d.year}';
}
- Widget _byDate(GymColors gc, List<Moment> shots) {
+ List<Widget> _byDate(GymColors gc, List<Moment> shots) {
final groups = <String, List<Moment>>{};
for (final m in shots) {
groups.putIfAbsent(_bucket(m.date), () => []).add(m);
}
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- for (final entry in groups.entries) ...[
- Padding(
+ return [
+ for (final entry in groups.entries) ...[
+ SliverToBoxAdapter(
+ child: Padding(
padding: const EdgeInsets.fromLTRB(2, 6, 0, 12),
child: Text(entry.key, style: AppTheme.f(16, color: gc.text)),
),
- GridView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: entry.value.length,
- padding: EdgeInsets.zero,
- gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 3,
- mainAxisSpacing: 10,
- crossAxisSpacing: 10,
- ),
- itemBuilder: (_, i) => _square(gc, entry.value[i]),
+ ),
+ SliverGrid.builder(
+ itemCount: entry.value.length,
+ gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ mainAxisSpacing: 10,
+ crossAxisSpacing: 10,
),
- const SizedBox(height: 24),
- ],
+ itemBuilder: (_, i) => _square(gc, entry.value[i]),
+ ),
+ const SliverToBoxAdapter(child: SizedBox(height: 24)),
],
- );
+ ];
}
Widget _square(GymColors gc, Moment moment) {
diff --git a/lib/screens/onboarding_screen.dart b/lib/screens/onboarding_screen.dart
index d32793e..c83d41d 100644
--- a/lib/screens/onboarding_screen.dart
+++ b/lib/screens/onboarding_screen.dart
@@ -1,8 +1,11 @@
+import 'dart:math' as math;
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+import '../catalog/body_art.dart';
import '../catalog/exercise_catalog.dart';
import '../l10n/l10n.dart';
import '../state/fit_state.dart';
@@ -10,8 +13,10 @@ import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/app_background.dart';
import '../widgets/body_rulers.dart';
+import '../widgets/body_map.dart';
import '../widgets/entrance.dart';
import '../widgets/photo_source_sheet.dart';
+import '../widgets/rolling_text.dart';
import '../widgets/ui_kit.dart';
class OnboardingScreen extends StatefulWidget {
@@ -24,13 +29,16 @@ class OnboardingScreen extends StatefulWidget {
class _OnboardingScreenState extends State<OnboardingScreen> {
final _page = PageController();
late final TextEditingController _name = TextEditingController();
- int _index = 0;
+ final _at = ValueNotifier<int>(0);
+
+ int get _index => _at.value;
static const _last = 6;
final Map<String, Set<String>> _places = {};
@override
void dispose() {
_page.dispose();
+ _at.dispose();
_name.dispose();
super.dispose();
}
@@ -39,7 +47,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
_page.animateToPage(i, duration: const Duration(milliseconds: 340), curve: Curves.easeOutCubic);
}
- void _onPage(int i) => setState(() => _index = i);
+ void _onPage(int i) => _at.value = i;
void _finish() {
final typed = _name.text.trim();
@@ -68,8 +76,9 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
setState(() => fit.setProfilePhoto(bytes));
}
- Widget _photo(GymColors gc) {
+ Widget _photo(GymColors gc, {double size = 104}) {
final bytes = fit.profile.photo.isEmpty ? null : fit.profilePhoto;
+ final badge = size * 0.3;
return Center(
child: Semantics(
button: true,
@@ -79,12 +88,12 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
scale: 0.95,
child: Column(children: [
SizedBox(
- width: 104,
- height: 104,
+ width: size,
+ height: size,
child: Stack(clipBehavior: Clip.none, children: [
Container(
- width: 104,
- height: 104,
+ width: size,
+ height: size,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(color: gc.bgRaised, shape: BoxShape.circle),
foregroundDecoration: BoxDecoration(
@@ -92,21 +101,21 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
border: Border.all(color: gc.border, width: 1.5),
),
child: bytes == null
- ? Icon(PhosphorIconsRegular.user, size: 42, color: gc.textTertiary)
+ ? Icon(PhosphorIconsRegular.user, size: size * 0.4, color: gc.textTertiary)
: Image.memory(bytes, fit: BoxFit.cover, gaplessPlayback: true),
),
Positioned(
- right: 0,
- bottom: 2,
+ right: size * 0.02,
+ bottom: size * 0.03,
child: Container(
- width: 34,
- height: 34,
+ width: badge,
+ height: badge,
decoration: BoxDecoration(
color: gc.accent,
shape: BoxShape.circle,
border: Border.all(color: gc.bg, width: 3),
),
- child: Icon(PhosphorIconsBold.camera, size: 15, color: gc.onEmber),
+ child: Icon(PhosphorIconsBold.camera, size: badge * 0.44, color: gc.onEmber),
),
),
]),
@@ -128,28 +137,33 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
resizeToAvoidBottomInset: false,
body: Stack(
children: [
- Positioned.fill(child: _Glow(gc)),
- const Positioned.fill(child: AppBackground(pattern: 'dots')),
+ Positioned.fill(child: RepaintBoundary(child: _Glow(gc))),
+ const Positioned.fill(child: RepaintBoundary(child: AppBackground(pattern: 'dots'))),
SafeArea(
child: Column(
children: [
- _topBar(gc),
+ ValueListenableBuilder<int>(valueListenable: _at, builder: (_, _, _) => _topBar(gc)),
Expanded(
- child: PageView(
+ child: RepaintBoundary(
+ child: PageView(
controller: _page,
onPageChanged: _onPage,
children: [
- _welcome(gc),
- _nameStep(gc),
- _photoStep(gc),
- _unitsStep(gc),
- _bodyStep(gc),
- _goalStep(gc),
- _placeStep(gc),
+ for (final page in [
+ _welcome(gc),
+ _nameStep(gc),
+ _photoStep(gc),
+ _unitsStep(gc),
+ _bodyStep(gc),
+ _goalStep(gc),
+ _placeStep(gc),
+ ])
+ RepaintBoundary(child: page),
],
),
+ ),
),
- _bottomBar(gc),
+ ValueListenableBuilder<int>(valueListenable: _at, builder: (_, _, _) => _bottomBar(gc)),
],
),
),
@@ -235,6 +249,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
required String title,
required String why,
required Widget child,
+ Widget Function(double height)? hero,
}) {
return LayoutBuilder(
builder: (context, box) => SingleChildScrollView(
@@ -245,6 +260,13 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
+ if (hero != null) ...[
+ () {
+ final h = (box.maxHeight * 0.3).clamp(120.0, 250.0);
+ return _in(0, SizedBox(height: h, child: Center(child: hero(h))));
+ }(),
+ const SizedBox(height: 22),
+ ],
_in(0, Padding(padding: const EdgeInsets.only(left: 4), child: _label(gc, t.onbStep(step, _last)))),
const SizedBox(height: 10),
_in(
@@ -274,7 +296,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
}
Widget _label(GymColors gc, String text) => Text(text.toUpperCase(),
- style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4));
Widget _group(GymColors gc, List<Widget> rows) {
return Container(
@@ -320,7 +342,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(t.welcomeKicker.toUpperCase(),
- style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.6)),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),
),
),
const SizedBox(height: 8),
@@ -384,6 +406,44 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
step: 1,
title: t.onbNameTitle,
why: t.onbNameWhy,
+ hero: (h) => ValueListenableBuilder<TextEditingValue>(
+ valueListenable: _name,
+ builder: (context, value, _) {
+ final name = value.text.trim();
+ final avatar = h * 0.46;
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ AnimatedContainer(
+ duration: const Duration(milliseconds: 260),
+ curve: Curves.easeOutCubic,
+ width: avatar,
+ height: avatar,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: name.isEmpty ? gc.bgRaised : gc.ember,
+ ),
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 200),
+ transitionBuilder: (child, a) => ScaleTransition(scale: a, child: FadeTransition(opacity: a, child: child)),
+ child: name.isEmpty
+ ? Icon(PhosphorIconsRegular.user, key: const ValueKey(''), size: avatar * 0.42, color: gc.textTertiary)
+ : Text(name.characters.first.toUpperCase(),
+ key: ValueKey(name.characters.first.toUpperCase()),
+ style: AppTheme.f(avatar * 0.44, weight: FontWeight.w800, color: gc.onEmber)),
+ ),
+ ),
+ SizedBox(height: h * 0.08),
+ AnimatedOpacity(
+ duration: const Duration(milliseconds: 200),
+ opacity: name.isEmpty ? 0.35 : 1,
+ child: Text(t.onbHello(name.isEmpty ? '…' : name),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text)),
+ ),
+ ]);
+ },
+ ),
child: _group(gc, [
Padding(
padding: const EdgeInsets.only(left: 16, right: 8),
@@ -419,11 +479,8 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
step: 2,
title: t.onbPhotoTitle,
why: t.onbPhotoWhy,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 28),
- decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(20)),
- child: _photo(gc),
- ),
+ hero: (h) => _photo(gc, size: h * 0.72),
+ child: const SizedBox.shrink(),
);
}
@@ -434,6 +491,32 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
step: 4,
title: t.onbBodyTitle,
why: t.onbBodyWhy,
+ hero: (h) {
+ const view = Rect.fromLTRB(-4, -2, 234, 466);
+ final art = bodyArtFor(p.sex);
+ return AnimatedSwitcher(
+ duration: const Duration(milliseconds: 360),
+ switchInCurve: Curves.easeOutCubic,
+ transitionBuilder: (child, a) => FadeTransition(
+ opacity: a,
+ child: ScaleTransition(scale: Tween(begin: 0.94, end: 1.0).animate(a), child: child),
+ ),
+ child: SizedBox(
+ key: ValueKey(art.id),
+ height: h,
+ width: h * view.width / view.height,
+ child: CustomPaint(
+ painter: BodyPainter(
+ gc: gc,
+ art: art,
+ crop: view,
+ token: 'onb${art.id}',
+ color: (_) => Color.lerp(gc.bgRaised2, gc.accent, 0.78)!,
+ ),
+ ),
+ ),
+ );
+ },
child: _group(gc, [
_bodyRow(
gc,
@@ -499,16 +582,35 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
step: 5,
title: t.onbGoalTitle,
why: t.onbGoalWhy,
+ hero: (h) => SizedBox(
+ width: h,
+ height: h,
+ child: TweenAnimationBuilder<double>(
+ tween: Tween(end: goal.toDouble()),
+ duration: const Duration(milliseconds: 420),
+ curve: Curves.easeOutCubic,
+ builder: (context, lit, _) => CustomPaint(
+ painter: _WeekRing(lit: lit, on: gc.ember, off: gc.bgRaised2),
+ child: Center(
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ MediaQuery.withNoTextScaling(
+ child: RollingText('$goal',
+ style: AppTheme.d(h * 0.3, weight: FontWeight.w800, color: gc.text, height: 1.4)),
+ ),
+ Text(t.perWeek(goal).replaceFirst('$goal', '').trim().toUpperCase(),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.2)),
+ ]),
+ ),
+ ),
+ ),
+ ),
child: Container(
- padding: const EdgeInsets.fromLTRB(18, 20, 18, 20),
- decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(20)),
+ padding: const EdgeInsets.fromLTRB(14, 14, 14, 14),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(100)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- _label(gc, t.weeklyGoal),
- const SizedBox(height: 8),
- Text(t.perWeek(goal), style: AppTheme.f(22, weight: FontWeight.w800, color: gc.text)),
- const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -550,6 +652,29 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
step: 3,
title: t.onbUnitsTitle,
why: t.onbUnitsWhy,
+ hero: (h) {
+ final kg = fit.units == 'kg';
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
+ children: [
+ MediaQuery.withNoTextScaling(
+ child: RollingText(kg ? '100' : '225',
+ style: AppTheme.d(h * 0.42, weight: FontWeight.w800, color: gc.text, height: 1.4)),
+ ),
+ const SizedBox(width: 8),
+ AnimatedSwitcher(
+ duration: const Duration(milliseconds: 240),
+ child: Text(fit.units,
+ key: ValueKey(fit.units),
+ style: AppTheme.f(h * 0.15, weight: FontWeight.w800, color: gc.ember)),
+ ),
+ ],
+ ),
+ ]);
+ },
child: Row(
children: [
for (final u in const ['kg', 'lb']) ...[
@@ -617,6 +742,36 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
step: 6,
title: t.onbPlaceTitle,
why: t.onbPlaceWhy,
+ hero: (h) {
+ final gear = <String>{'Bodyweight', for (final g in _places.values) ...g};
+ final n = _places.isEmpty
+ ? fit.allExercises.length
+ : fit.allExercises.where((e) => gear.contains(e.equipment)).length;
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ for (final preset in kPlacePresets)
+ AnimatedContainer(
+ duration: const Duration(milliseconds: 240),
+ curve: Curves.easeOutCubic,
+ margin: const EdgeInsets.symmetric(horizontal: 5),
+ width: h * 0.22,
+ height: h * 0.22,
+ decoration: BoxDecoration(
+ color: _places.containsKey(preset) ? gc.ember : gc.bgRaised,
+ borderRadius: BorderRadius.circular(h * 0.07),
+ ),
+ child: Icon(_placeIcons[preset],
+ size: h * 0.1, color: _places.containsKey(preset) ? gc.onEmber : gc.textTertiary),
+ ),
+ ]),
+ SizedBox(height: h * 0.06),
+ MediaQuery.withNoTextScaling(
+ child: RollingText('$n', style: AppTheme.d(h * 0.28, weight: FontWeight.w800, color: gc.text, height: 1.4)),
+ ),
+ Text(t.onbPlaceHero.toUpperCase(),
+ style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.2)),
+ ]);
+ },
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -723,6 +878,34 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
}
}
+class _WeekRing extends CustomPainter {
+ _WeekRing({required this.lit, required this.on, required this.off});
+
+ final double lit;
+ final Color on;
+ final Color off;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final stroke = size.width * 0.07;
+ final rect = (Offset.zero & size).deflate(stroke / 2);
+ const gap = 0.16;
+ const sweep = math.pi * 2 / 7;
+ for (var i = 0; i < 7; i++) {
+ final fill = (lit - i).clamp(0.0, 1.0);
+ final paint = Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = stroke
+ ..strokeCap = StrokeCap.round
+ ..color = Color.lerp(off, on, fill)!;
+ canvas.drawArc(rect, -math.pi / 2 + i * sweep + gap / 2, sweep - gap, false, paint);
+ }
+ }
+
+ @override
+ bool shouldRepaint(_WeekRing old) => old.lit != lit || old.on != on || old.off != off;
+}
+
class _Glow extends StatelessWidget {
const _Glow(this.gc);
diff --git a/lib/widgets/medal_shelf.dart b/lib/widgets/medal_shelf.dart
index e189e49..a6bee2e 100644
--- a/lib/widgets/medal_shelf.dart
+++ b/lib/widgets/medal_shelf.dart
@@ -115,10 +115,7 @@ class _MedalSheet extends StatelessWidget {
return Container(
padding: sheetPad(context),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(gc),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
diff --git a/test/moments_test.dart b/test/moments_test.dart
new file mode 100644
index 0000000..a6bc81d
--- /dev/null
+++ b/test/moments_test.dart
@@ -0,0 +1,39 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/app/gymmane_app.dart';
+import 'package:gymmane/l10n/l10n.dart';
+import 'package:gymmane/services/local_store.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:gymmane/widgets/file_thumb.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ await Store.instance.init();
+ fit.resetAllData();
+ fit.onboarded = true;
+ setAppLanguage('en');
+ });
+
+ testWidgets('fotos: con muchas fotos solo se construyen las que se ven', (tester) async {
+ tester.view.physicalSize = const Size(1080, 2400);
+ tester.view.devicePixelRatio = 2.75;
+ addTearDown(tester.view.reset);
+ final now = DateTime.now();
+ for (var i = 0; i < 120; i++) {
+ fit.moments.add(Moment(now.subtract(Duration(days: i)), 'missing-$i.jpg'));
+ }
+ fit.goMoments();
+ await tester.pumpWidget(const GymManeApp());
+ await tester.pumpAndSettle();
+
+ final built = find.byType(FileThumb).evaluate().length;
+ expect(built, greaterThan(0));
+ expect(built, lessThan(60));
+ fit.moments.clear();
+ fit.persistNow();
+ });
+}
diff --git a/test/onboarding_test.dart b/test/onboarding_test.dart
new file mode 100644
index 0000000..e670d22
--- /dev/null
+++ b/test/onboarding_test.dart
@@ -0,0 +1,39 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/app/gymmane_app.dart';
+import 'package:gymmane/l10n/l10n.dart';
+import 'package:gymmane/services/local_store.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ await Store.instance.init();
+ fit.resetAllData();
+ fit.onboarded = false;
+ setAppLanguage('en');
+ });
+
+ testWidgets('onboarding: pasar de paso mueve la barra y vuelve atrás', (tester) async {
+ tester.view.physicalSize = const Size(1080, 2400);
+ tester.view.devicePixelRatio = 2.75;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(const GymManeApp());
+ await tester.pumpAndSettle();
+
+ expect(find.byIcon(PhosphorIconsBold.arrowLeft), findsNothing);
+ await tester.tap(find.text(t.next));
+ await tester.pumpAndSettle();
+ expect(find.byIcon(PhosphorIconsBold.arrowLeft), findsOneWidget);
+
+ await tester.tap(find.byIcon(PhosphorIconsBold.arrowLeft));
+ await tester.pumpAndSettle();
+ expect(find.byIcon(PhosphorIconsBold.arrowLeft), findsNothing);
+ fit.onboarded = true;
+ fit.persistNow();
+ });
+}