Skip to content

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

Add the profile tab with a cover, a badge, levels and your own photos

InlitX70f808e74a87
diff --git a/assets/img/banner_default.jpg b/assets/img/banner_default.jpg
new file mode 100644
index 0000000..b383d93
Binary files /dev/null and b/assets/img/banner_default.jpg differ
diff --git a/lib/models/profile.dart b/lib/models/profile.dart
index d023fc3..9226a8b 100644
--- a/lib/models/profile.dart
+++ b/lib/models/profile.dart
@@ -1,6 +1,9 @@
+const String kDefaultName = 'InlitX';
+const String kDefaultHandle = 'inlitx';
+
class Profile {
Profile({
- this.name = 'InlitX',
+ this.name = kDefaultName,
this.sex = 'male',
this.age = 28,
this.heightCm = 175,
@@ -8,6 +11,10 @@ class Profile {
this.activity = 1.55,
this.weeklyGoal = 4,
this.photo = '',
+ this.handle = '',
+ this.badge = 'blue',
+ this.banner = '',
+ this.since,
});
String name;
@@ -18,6 +25,10 @@ class Profile {
double activity;
int weeklyGoal;
String photo;
+ String handle;
+ String badge;
+ String banner;
+ DateTime? since;
Map<String, dynamic> toJson() => {
'name': name,
@@ -28,9 +39,13 @@ class Profile {
'act': activity,
'goal': weeklyGoal,
if (photo.isNotEmpty) 'photo': photo,
+ if (handle.isNotEmpty) 'handle': handle,
+ 'badge': badge,
+ if (banner.isNotEmpty) 'banner': banner,
+ if (since != null) 'since': since!.toIso8601String(),
};
factory Profile.fromJson(Map<String, dynamic> j) => Profile(
- name: (j['name'] as String?) ?? 'InlitX',
+ name: (j['name'] as String?) ?? kDefaultName,
sex: (j['sex'] as String?) ?? 'male',
age: (j['age'] as num?)?.toInt() ?? 28,
heightCm: (j['h'] as num?)?.toDouble() ?? 175,
@@ -38,5 +53,9 @@ class Profile {
activity: (j['act'] as num?)?.toDouble() ?? 1.55,
weeklyGoal: (j['goal'] as num?)?.toInt() ?? 4,
photo: (j['photo'] as String?) ?? '',
+ handle: (j['handle'] as String?) ?? '',
+ badge: (j['badge'] as String?) ?? 'blue',
+ banner: (j['banner'] as String?) ?? '',
+ since: DateTime.tryParse((j['since'] as String?) ?? ''),
);
}
diff --git a/lib/screens/moments_screen.dart b/lib/screens/moments_screen.dart
new file mode 100644
index 0000000..df1e9ef
--- /dev/null
+++ b/lib/screens/moments_screen.dart
@@ -0,0 +1,312 @@
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+import '../l10n/l10n.dart';
+import '../services/media_store.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import '../widgets/dialogs.dart';
+import '../widgets/photo_source_sheet.dart';
+import '../widgets/ui_kit.dart';
+
+class MomentsScreen extends StatefulWidget {
+ const MomentsScreen({super.key});
+
+ @override
+ State<MomentsScreen> createState() => _MomentsScreenState();
+}
+
+class _MomentsScreenState extends State<MomentsScreen> {
+ bool _busy = false;
+ bool _grouped = false;
+
+ Future<void> _add() async {
+ if (_busy) return;
+ final source = await pickPhotoSource(context);
+ if (source == null) return;
+ setState(() => _busy = true);
+ try {
+ if (source == ImageSource.gallery) {
+ final shots = await ImagePicker()
+ .pickMultiImage(maxWidth: 1440, maxHeight: 1920, imageQuality: 88);
+ for (final shot in shots) {
+ await fit.addMoment(shot.path);
+ }
+ return;
+ }
+ final shot = await ImagePicker()
+ .pickImage(source: source, maxWidth: 1440, maxHeight: 1920, imageQuality: 88);
+ if (shot == null) return;
+ await fit.addMoment(shot.path);
+ } catch (_) {
+ } finally {
+ if (mounted) setState(() => _busy = false);
+ }
+ }
+
+ void _open(Moment moment) {
+ final path = MediaStore.pathFor(moment.file) ?? '';
+ if (path.isEmpty) return;
+ Navigator.of(context).push(PageRouteBuilder<void>(
+ opaque: false,
+ barrierColor: Colors.transparent,
+ transitionDuration: const Duration(milliseconds: 280),
+ reverseTransitionDuration: const Duration(milliseconds: 220),
+ pageBuilder: (_, animation, _) =>
+ _PhotoView(moment: moment, path: path, animation: animation),
+ ));
+ }
+
+ Future<void> _remove(Moment moment) async {
+ final ok = await askConfirm(
+ context,
+ title: t.deletePhotoTitle,
+ body: t.deletePhotoBody,
+ confirmLabel: t.delete,
+ danger: true,
+ );
+ if (ok) fit.deleteMoment(moment);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final shots = fit.momentsNewest;
+
+ return SafeArea(
+ bottom: false,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ ScreenHeader(
+ title: t.photosCard,
+ onBack: fit.backFromMoments,
+ subtitle: shots.isEmpty ? null : t.momentCount(shots.length),
+ actions: [
+ RoundAction(
+ onTap: () => setState(() => _grouped = !_grouped),
+ label: t.photosCard,
+ child: Icon(
+ _grouped
+ ? PhosphorIconsRegular.squaresFour
+ : PhosphorIconsRegular.rows,
+ size: 17,
+ color: context.gc.text),
+ ),
+ const SizedBox(width: 8),
+ RoundAction(
+ onTap: _add,
+ label: t.snapNow,
+ child: Icon(PhosphorIconsRegular.camera, size: 17, color: context.gc.text),
+ ),
+ ],
+ ),
+ const SizedBox(height: 18),
+ Expanded(
+ child: shots.isEmpty
+ ? _empty(gc)
+ : (_grouped ? _byDate(gc, shots) : _plainGrid(gc, shots)),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _plainGrid(GymColors gc, List<Moment> shots) {
+ return GridView.builder(
+ padding: const EdgeInsets.only(bottom: 110),
+ itemCount: shots.length,
+ gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ mainAxisSpacing: 8,
+ crossAxisSpacing: 8,
+ childAspectRatio: 0.74,
+ ),
+ itemBuilder: (_, i) => _tile(gc, shots[i]),
+ );
+ }
+
+ String _bucket(DateTime d) {
+ final now = DateTime.now();
+ final day = DateTime(d.year, d.month, d.day);
+ final today = DateTime(now.year, now.month, now.day);
+ final days = today.difference(day).inDays;
+ if (days <= 0) return titleCase(t.today);
+ if (days < 7) return titleCase(t.thisWeek);
+ if (d.year == now.year) return t.monthName(d.month);
+ return '${t.monthName(d.month)} ${d.year}';
+ }
+
+ 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 ListView(
+ padding: const EdgeInsets.only(bottom: 110),
+ children: [
+ for (final entry in groups.entries) ...[
+ 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,
+ gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ mainAxisSpacing: 10,
+ crossAxisSpacing: 10,
+ ),
+ itemBuilder: (_, i) => _square(gc, entry.value[i]),
+ ),
+ const SizedBox(height: 24),
+ ],
+ ],
+ );
+ }
+
+ Widget _square(GymColors gc, Moment moment) {
+ final path = MediaStore.pathFor(moment.file) ?? '';
+ return GestureDetector(
+ onTap: () => _open(moment),
+ onLongPress: () => _remove(moment),
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(20),
+ child: Hero(
+ tag: moment.file,
+ child: Image.file(File(path),
+ fit: BoxFit.cover,
+ errorBuilder: (_, _, _) => ColoredBox(color: gc.bgRaised2)),
+ ),
+ ),
+ );
+ }
+
+ Widget _empty(GymColors gc) {
+ return Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(PhosphorIconsRegular.camera, size: 34, color: gc.textTertiary),
+ const SizedBox(height: 14),
+ Text(t.momentsEmptyTitle, style: AppTheme.f(16, color: gc.text)),
+ const SizedBox(height: 6),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 40),
+ child: Text(t.momentsEmptyHint,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(12.5,
+ weight: FontWeight.w500, color: gc.textTertiary, height: 1.45)),
+ ),
+ const SizedBox(height: 18),
+ GhostButton(label: t.snapNow, icon: PhosphorIconsRegular.camera, onTap: _add),
+ ],
+ ),
+ );
+ }
+
+ Widget _tile(GymColors gc, Moment moment) {
+ final path = MediaStore.pathFor(moment.file) ?? '';
+ return GestureDetector(
+ onTap: () => _open(moment),
+ onLongPress: () => _remove(moment),
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(14),
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ Hero(
+ tag: moment.file,
+ child: Image.file(File(path),
+ fit: BoxFit.cover,
+ errorBuilder: (_, _, _) => ColoredBox(color: gc.bgRaised2)),
+ ),
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 0,
+ child: Container(
+ padding: const EdgeInsets.symmetric(vertical: 5),
+ color: Colors.black.withValues(alpha: 0.45),
+ child: Text(t.shortDate(moment.date),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(10.5, weight: FontWeight.w600, color: Colors.white)),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class _PhotoView extends StatelessWidget {
+ const _PhotoView({required this.moment, required this.path, required this.animation});
+
+ final Moment moment;
+ final String path;
+ final Animation<double> animation;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return AnimatedBuilder(
+ animation: animation,
+ builder: (context, _) {
+ final v = Curves.easeOutCubic.transform(animation.value);
+ return Material(
+ type: MaterialType.transparency,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => Navigator.of(context).pop(),
+ child: Stack(
+ children: [
+ Positioned.fill(
+ child: BackdropFilter(
+ filter: ui.ImageFilter.blur(sigmaX: 20 * v, sigmaY: 20 * v),
+ child: ColoredBox(color: gc.pageBg.withValues(alpha: 0.62 * v)),
+ ),
+ ),
+ Center(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(24, 86, 24, 36),
+ child: Hero(
+ tag: moment.file,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(22),
+ child: Image.file(File(path), fit: BoxFit.contain),
+ ),
+ ),
+ ),
+ ),
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 54,
+ child: Opacity(
+ opacity: v,
+ child: Text(
+ t.fullDate(moment.date),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ },
+ );
+ }
+}
diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart
new file mode 100644
index 0000000..c81771a
--- /dev/null
+++ b/lib/screens/profile_screen.dart
@@ -0,0 +1,631 @@
+import 'dart:io';
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+import '../l10n/l10n.dart';
+import '../models/profile.dart';
+import '../services/media_store.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import '../widgets/medal_shelf.dart';
+import '../widgets/photo_source_sheet.dart';
+import '../widgets/profile_avatar.dart';
+import 'settings_screen.dart';
+import 'share_sheet.dart';
+
+const List<String> kProfileBadges = ['gold', 'blue', 'green'];
+
+Color badgeColor(String id) => switch (id) {
+ 'blue' => const Color(0xFF4A9EEB),
+ 'green' => const Color(0xFF54B979),
+ _ => const Color(0xFFE8B84B),
+ };
+
+class ProfileScreen extends StatefulWidget {
+ const ProfileScreen({super.key});
+
+ @override
+ State<ProfileScreen> createState() => _ProfileScreenState();
+}
+
+class _ProfileScreenState extends State<ProfileScreen> {
+ bool _busy = false;
+
+ Future<void> _pickBanner() async {
+ if (_busy) return;
+ final source = await pickPhotoSource(context);
+ if (source == null) return;
+ setState(() => _busy = true);
+ try {
+ final shot = await ImagePicker()
+ .pickImage(source: source, maxWidth: 1600, maxHeight: 900, imageQuality: 82);
+ if (shot == null) return;
+ fit.setProfileBanner(await File(shot.path).readAsBytes());
+ } catch (_) {
+ } finally {
+ if (mounted) setState(() => _busy = false);
+ }
+ }
+
+ Future<void> _snapshot() async {
+ if (_busy) return;
+ final source = await pickPhotoSource(context);
+ if (source == null) return;
+ setState(() => _busy = true);
+ try {
+ if (source == ImageSource.gallery) {
+ final shots = await ImagePicker()
+ .pickMultiImage(maxWidth: 1440, maxHeight: 1920, imageQuality: 88);
+ for (final shot in shots) {
+ await fit.addMoment(shot.path);
+ }
+ return;
+ }
+ final shot = await ImagePicker()
+ .pickImage(source: source, maxWidth: 1440, maxHeight: 1920, imageQuality: 88);
+ if (shot == null) return;
+ await fit.addMoment(shot.path);
+ } catch (_) {
+ } finally {
+ if (mounted) setState(() => _busy = false);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return CustomScrollView(
+ slivers: [
+ SliverPersistentHeader(
+ pinned: true,
+ delegate: _ProfileHeader(
+ gc: gc,
+ top: MediaQuery.paddingOf(context).top,
+ onBanner: _pickBanner,
+ onEdit: () => showProfileSheet(context),
+ onShare: () => showShareSheet(context),
+ ),
+ ),
+ SliverToBoxAdapter(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(20, 20, 0, 0),
+ child: _stats(gc),
+ ),
+ ),
+ SliverToBoxAdapter(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(20, 32, 20, 110),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _heading(gc, t.awardsTitle, count: '${fit.awardCount}', onMore: fit.goAwards),
+ const SizedBox(height: 16),
+ const MedalShelf(size: 66),
+ const SizedBox(height: 34),
+ _heading(gc, t.snapshots, onMore: fit.goMoments),
+ const SizedBox(height: 16),
+ _photoCards(gc),
+ const SizedBox(height: 34),
+ _heading(gc, t.yearTitle),
+ const SizedBox(height: 16),
+ _year(gc),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _year(GymColors gc) {
+ final months = fit.sessionsByMonth;
+ final peak = months.fold(1, math.max);
+ final thisMonth = DateTime.now().month;
+ final best = fit.bestMonthThisYear;
+ final lifted = fit.liftedSpanOf(fit.volumeThisYearKg);
+
+ return Container(
+ padding: const EdgeInsets.fromLTRB(18, 18, 18, 16),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(child: _yearStat(gc, '${fit.sessionsThisYear}', '', t.statWorkouts)),
+ Expanded(child: _yearStat(gc, lifted.$1, lifted.$2, t.statLifted)),
+ Expanded(
+ child: _yearStat(gc, '${fit.monthsTrainedThisYear}', '/12', t.yearMonths),
+ ),
+ ],
+ ),
+ const SizedBox(height: 20),
+ SizedBox(
+ height: 58,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ for (var m = 1; m <= 12; m++) ...[
+ if (m > 1) const SizedBox(width: 5),
+ Expanded(
+ child: Container(
+ height: 6 + 52 * (months[m - 1] / peak),
+ decoration: BoxDecoration(
+ color: m == thisMonth
+ ? gc.ember
+ : (months[m - 1] > 0 ? gc.textTertiary : gc.bgRaised2),
+ borderRadius: BorderRadius.circular(5),
+ ),
+ ),
+ ),
+ ],
+ ],
+ ),
+ ),
+ const SizedBox(height: 9),
+ Row(
+ children: [
+ for (var m = 1; m <= 12; m++) ...[
+ if (m > 1) const SizedBox(width: 5),
+ Expanded(
+ child: Text(
+ t.monthInitial(m),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(9.5,
+ weight: FontWeight.w600,
+ color: m == thisMonth ? gc.text : gc.textTertiary),
+ ),
+ ),
+ ],
+ ],
+ ),
+ if (best > 0) ...[
+ const SizedBox(height: 16),
+ Row(
+ children: [
+ Text('${t.yearBestMonth} · ',
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),
+ Text(t.monthName(best),
+ style: AppTheme.f(12, weight: FontWeight.w700, color: gc.textSecondary)),
+ ],
+ ),
+ ],
+ ],
+ ),
+ );
+ }
+
+ Widget _yearStat(GymColors gc, String value, String unit, String label) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
+ children: [
+ Text(value, style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text)),
+ if (unit.isNotEmpty)
+ Text(unit,
+ style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.textSecondary)),
+ ],
+ ),
+ const SizedBox(height: 5),
+ Text(label.toUpperCase(),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(9.5,
+ weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ ],
+ );
+ }
+
+ Widget _heading(GymColors gc, String title, {String? count, VoidCallback? onMore}) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onMore,
+ child: Row(
+ children: [
+ Text(title, style: AppTheme.f(21, color: gc.text)),
+ if (count != null) ...[
+ const SizedBox(width: 9),
+ Text(count, style: AppTheme.f(17, weight: FontWeight.w600, color: gc.textTertiary)),
+ ],
+ const Spacer(),
+ if (onMore != null) Icon(PhosphorIconsBold.caretRight, size: 16, color: gc.textTertiary),
+ ],
+ ),
+ );
+ }
+
+ Widget _stats(GymColors gc) {
+ final items = <(String, String, String)>[
+ (t.statWorkouts, '${fit.totalSessions}', ''),
+ (t.statTrained, fit.trainedSpan.$1, fit.trainedSpan.$2),
+ (t.statSets, '${fit.totalSets}', ''),
+ (t.statLifted, fit.liftedSpan.$1, fit.liftedSpan.$2),
+ (t.statStreak, '${fit.currentStreak}', t.statDays),
+ ];
+ return SizedBox(
+ height: 52,
+ child: ListView.separated(
+ scrollDirection: Axis.horizontal,
+ padding: const EdgeInsets.only(right: 20),
+ itemCount: items.length,
+ separatorBuilder: (_, _) => const SizedBox(width: 28),
+ itemBuilder: (_, i) {
+ final (label, value, unit) = items[i];
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Text(label.toUpperCase(),
+ style: AppTheme.f(10.5,
+ weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ const SizedBox(height: 7),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
+ children: [
+ Text(value, style: AppTheme.f(23, weight: FontWeight.w800, color: gc.text)),
+ if (unit.isNotEmpty) ...[
+ const SizedBox(width: 4),
+ Text(unit,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),
+ ],
+ ],
+ ),
+ ],
+ );
+ },
+ ),
+ );
+ }
+
+ Widget _photoCards(GymColors gc) {
+ final shots = fit.momentsNewest.take(3).map((m) => m.file).toList();
+ return IntrinsicHeight(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(
+ child: _card(
+ gc,
+ label: t.photosCard,
+ trailing: shots.isEmpty ? null : '${fit.momentCount}',
+ onTap: fit.goMoments,
+ child: shots.isEmpty
+ ? Icon(PhosphorIconsRegular.imagesSquare, size: 28, color: gc.textTertiary)
+ : _fan(gc, shots),
+ ),
+ ),
+ const SizedBox(width: 14),
+ Expanded(
+ child: _card(
+ gc,
+ label: t.snapNow,
+ onTap: _snapshot,
+ child: Container(
+ width: 56,
+ height: 56,
+ decoration: BoxDecoration(color: gc.bgRaised2, shape: BoxShape.circle),
+ child: Icon(PhosphorIconsRegular.camera, size: 24, color: gc.textSecondary),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _card(
+ GymColors gc, {
+ required String label,
+ required Widget child,
+ required VoidCallback onTap,
+ String? trailing,
+ }) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Container(
+ height: 168,
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
+ child: Column(
+ children: [
+ Expanded(child: Center(child: child)),
+ Padding(
+ padding: const EdgeInsets.only(bottom: 18),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Text(label, style: AppTheme.f(14.5, color: gc.text)),
+ if (trailing != null) ...[
+ const SizedBox(width: 7),
+ Text(trailing,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textTertiary)),
+ ],
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _fan(GymColors gc, List<String> files) {
+ const spread = [-0.22, 0.0, 0.22];
+ const shift = [-30.0, 0.0, 30.0];
+ final order = [
+ for (var i = 0; i < files.length; i++)
+ if (i != 1) i,
+ if (files.length > 1) 1,
+ ];
+ return SizedBox(
+ height: 94,
+ width: double.infinity,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ for (final i in order)
+ Transform.translate(
+ offset: Offset(files.length == 1 ? 0 : shift[i], 0),
+ child: Transform.rotate(
+ angle: files.length == 1 ? 0 : spread[i],
+ child: _thumb(gc, files[i], raised: i == 1 || files.length == 1),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _thumb(GymColors gc, String file, {bool raised = false}) {
+ final path = MediaStore.pathFor(file) ?? '';
+ return Container(
+ width: 62,
+ height: 86,
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(12),
+ border: raised ? null : Border.all(color: gc.bgRaised, width: 2.5),
+ boxShadow: raised
+ ? [BoxShadow(color: Colors.black.withValues(alpha: 0.45), blurRadius: 14)]
+ : null,
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: Image.file(File(path),
+ fit: BoxFit.cover, errorBuilder: (_, _, _) => const SizedBox.shrink()),
+ );
+ }
+}
+
+class _ProfileHeader extends SliverPersistentHeaderDelegate {
+ _ProfileHeader({
+ required this.gc,
+ required this.top,
+ required this.onBanner,
+ required this.onEdit,
+ required this.onShare,
+ });
+
+ final GymColors gc;
+ final double top;
+ final VoidCallback onBanner;
+ final VoidCallback onEdit;
+ final VoidCallback onShare;
+
+ static const _banner = 176.0;
+ static const _identity = 128.0;
+ static const _bar = 60.0;
+ static const _identityBlock = 136.0;
+
+ @override
+ double get maxExtent => _banner + _identity;
+
+ @override
+ double get minExtent => top + _bar;
+
+ @override
+ bool shouldRebuild(_ProfileHeader old) => true;
+
+ @override
+ Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
+ final range = maxExtent - minExtent;
+ final shrunk = range <= 0 ? 1.0 : (shrinkOffset / range).clamp(0.0, 1.0);
+ final bytes = fit.profileBanner;
+ final p = fit.profile;
+
+ final height = math.max(maxExtent - shrinkOffset, minExtent);
+ final bannerHeight = (height - 18 - _identityBlock + 38).clamp(minExtent, height);
+
+ return SizedBox(
+ height: height,
+ child: Stack(
+ children: [
+ Positioned(
+ left: 0,
+ right: 0,
+ top: 0,
+ height: bannerHeight,
+ child: GestureDetector(
+ onTap: onBanner,
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ Container(
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ image: DecorationImage(
+ image: bytes == null ? kDefaultBanner : MemoryImage(bytes),
+ fit: BoxFit.cover,
+ ),
+ ),
+ ),
+ IgnorePointer(
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ gc.bg.withValues(alpha: 0.18 + 0.6 * shrunk),
+ gc.bg.withValues(alpha: 0.10 + 0.6 * shrunk),
+ gc.bg.withValues(alpha: 0.55),
+ gc.bg,
+ ],
+ stops: const [0, 0.38, 0.78, 1],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ Positioned(
+ top: top + 9,
+ right: 16,
+ child: Row(children: [
+ _round(PhosphorIconsRegular.shareNetwork, onShare),
+ const SizedBox(width: 10),
+ _round(PhosphorIconsRegular.gearSix, fit.goPreferences),
+ ]),
+ ),
+ Positioned(
+ left: 20,
+ right: 20,
+ bottom: 18,
+ child: Opacity(
+ opacity: (1 - shrunk * 2).clamp(0.0, 1.0),
+ child: _full(p),
+ ),
+ ),
+ Positioned(
+ left: 20,
+ top: top + 6,
+ height: 44,
+ child: Opacity(
+ opacity: ((shrunk - 0.62) / 0.38).clamp(0.0, 1.0),
+ child: _compact(p),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _round(IconData icon, VoidCallback onTap) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Container(
+ width: 38,
+ height: 38,
+ decoration:
+ BoxDecoration(color: Colors.black.withValues(alpha: 0.5), shape: BoxShape.circle),
+ child: Icon(icon, size: 18, color: Colors.white),
+ ),
+ );
+ }
+
+ Widget _compact(Profile p) {
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ ProfileAvatar(size: 34),
+ const SizedBox(width: 11),
+ Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(children: [
+ Text(fit.displayName, style: AppTheme.f(15.5, color: gc.text)),
+ if (p.badge.isNotEmpty) ...[
+ const SizedBox(width: 5),
+ Icon(PhosphorIconsFill.sealCheck, size: 14, color: badgeColor(p.badge)),
+ ],
+ ]),
+ Text('@${fit.profileHandle}',
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textSecondary)),
+ ],
+ ),
+ ],
+ );
+ }
+
+ Widget _full(Profile p) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ ProfileAvatar(size: 76),
+ const Spacer(),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onEdit,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10),
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(100),
+ ),
+ child: Text(t.editProfile,
+ style: AppTheme.f(13.5, weight: FontWeight.w600, color: gc.text)),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 13),
+ Row(children: [
+ Flexible(
+ child: Text(p.name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(24, weight: FontWeight.w800, color: gc.text)),
+ ),
+ if (p.badge.isNotEmpty) ...[
+ const SizedBox(width: 7),
+ Icon(PhosphorIconsFill.sealCheck, size: 19, color: badgeColor(p.badge)),
+ ],
+ ]),
+ const SizedBox(height: 4),
+ Text(
+ '@${fit.profileHandle} · ${fit.weightLabel(p.weightKg)}',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary),
+ ),
+ const SizedBox(height: 8),
+ Row(children: [
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(100),
+ ),
+ child: Text(t.levelShort(fit.athleteLevel),
+ style: AppTheme.f(12, weight: FontWeight.w700, color: gc.text)),
+ ),
+ const SizedBox(width: 8),
+ Flexible(
+ child: Text(
+ t.levelToNext(fit.sessionsToNextLevel, fit.athleteLevel + 1),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary),
+ ),
+ ),
+ ]),
+ ],
+ );
+ }
+}
diff --git a/lib/state/moments_state.dart b/lib/state/moments_state.dart
new file mode 100644
index 0000000..5f2eee0
--- /dev/null
+++ b/lib/state/moments_state.dart
@@ -0,0 +1,49 @@
+part of 'fit_state.dart';
+
+class Moment {
+ const Moment(this.date, this.file, {this.note = ''});
+
+ final DateTime date;
+ final String file;
+ final String note;
+
+ Map<String, dynamic> toJson() =>
+ {'d': date.toIso8601String(), 'f': file, if (note.isNotEmpty) 'n': note};
+
+ factory Moment.fromJson(Map<String, dynamic> j) => Moment(
+ DateTime.tryParse((j['d'] as String?) ?? '') ?? DateTime.now(),
+ (j['f'] as String?) ?? '',
+ note: (j['n'] as String?) ?? '',
+ );
+}
+
+mixin MomentsState on FitCore {
+ final List<Moment> moments = [];
+
+ List<Moment> get momentsNewest {
+ final out = [...moments]..sort((a, b) => b.date.compareTo(a.date));
+ return out;
+ }
+
+ int get momentCount => moments.length;
+
+ Future<bool> addMoment(String srcPath, {String note = ''}) async {
+ final saved = await MediaStore.importFor('moment', srcPath);
+ if (saved == null) return false;
+ moments.add(Moment(DateTime.now(), saved, note: note));
+ _persist();
+ notifyListeners();
+ return true;
+ }
+
+ void deleteMoment(Moment moment) {
+ moments.removeWhere((m) => m.file == moment.file);
+ MediaStore.delete(moment.file);
+ _persist();
+ notifyListeners();
+ }
+
+ void goMoments() => pushRoute('moments');
+
+ void backFromMoments() => popRoute(fallback: 'settings');
+}
diff --git a/lib/widgets/photo_source_sheet.dart b/lib/widgets/photo_source_sheet.dart
index b4eaaaa..55df606 100644
--- a/lib/widgets/photo_source_sheet.dart
+++ b/lib/widgets/photo_source_sheet.dart
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../theme/app_colors.dart';
@@ -50,7 +50,7 @@ class PhotoSourceSheet extends StatelessWidget {
child: Row(children: [
Icon(icon, size: 20, color: gc.textSecondary),
const SizedBox(width: 14),
- Expanded(child: Text(label, style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text))),
+ Expanded(child: Text(label, style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text))),
]),
),
);
diff --git a/lib/widgets/profile_avatar.dart b/lib/widgets/profile_avatar.dart
index ac3f966..7c107c1 100644
--- a/lib/widgets/profile_avatar.dart
+++ b/lib/widgets/profile_avatar.dart
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
+const kDefaultBanner = AssetImage('assets/img/banner_default.jpg');
+
class ProfileAvatar extends StatelessWidget {
const ProfileAvatar({super.key, this.size = 52});