Add SportPath auth APIs and training content foundation
This commit is contained in:
@@ -29,21 +29,21 @@ class SportPathApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetMaterialApp(
|
||||
title: 'SportPath Tracker',
|
||||
title: 'SportPath',
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: const Locale('ar', 'SA'), // دعم اللغة العربية افتراضياً
|
||||
locale: const Locale('ar', 'JO'), // دعم اللغة العربية افتراضياً
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
fontFamily: 'Inter', // التأكد من وجود الخط في pubspec
|
||||
fontFamily: null,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xFFFF5722), // اللون البرتقالي الأساسي
|
||||
primary: const Color(0xFFFF5722),
|
||||
secondary: const Color(0xFF263238),
|
||||
brightness: Brightness.dark, // وضع ليلي متميز
|
||||
seedColor: const Color(0xFF456C52),
|
||||
primary: const Color(0xFF456C52),
|
||||
secondary: const Color(0xFF26382D),
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
scaffoldBackgroundColor: const Color(0xFF121212),
|
||||
scaffoldBackgroundColor: const Color(0xFFF5F7F2),
|
||||
cardTheme: CardThemeData(
|
||||
color: const Color(0xFF1E1E1E),
|
||||
color: Colors.white,
|
||||
elevation: 0,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
|
||||
+439
-218
@@ -2,8 +2,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../controllers/workout_controller.dart';
|
||||
import '../models/workout.dart';
|
||||
import '../utils/formatters.dart';
|
||||
import '../screens/history_screen.dart';
|
||||
import '../services/sync_service.dart';
|
||||
import '../utils/formatters.dart';
|
||||
|
||||
const _ink = Color(0xFF17251E);
|
||||
const _green = Color(0xFF456C52);
|
||||
const _paper = Color(0xFFF5F7F2);
|
||||
const _muted = Color(0xFF778078);
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({super.key});
|
||||
@@ -14,237 +20,452 @@ class HomeScreen extends StatelessWidget {
|
||||
final syncService = Get.find<SyncService>();
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// 1. شريط العنوان المخصص (Premium Header)
|
||||
SliverAppBar(
|
||||
expandedHeight: 200,
|
||||
floating: false,
|
||||
pinned: true,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: const Text("Tracker Running",
|
||||
style: TextStyle(fontWeight: FontWeight.w800)),
|
||||
background: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Color(0xFFFF5722), Color(0xFFE64A19)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Icon(Icons.directions_run,
|
||||
size: 80, color: Colors.white.withOpacity(0.3)),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Obx(() => IconButton(
|
||||
icon: Icon(
|
||||
syncService.isOnline
|
||||
? Icons.cloud_done
|
||||
: Icons.cloud_off,
|
||||
color:
|
||||
syncService.isOnline ? Colors.white : Colors.red),
|
||||
onPressed: () {},
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
||||
// 2. حالة المزامنة السريعة
|
||||
SliverToBoxAdapter(
|
||||
child: Obx(() => syncService.pendingCount > 0
|
||||
? Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
color: Colors.orange.withOpacity(0.2),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"لديك ${syncService.pendingCount} تمارين بانتظار المزامنة..",
|
||||
style:
|
||||
const TextStyle(fontSize: 12, color: Colors.orange),
|
||||
),
|
||||
backgroundColor: _paper,
|
||||
body: SafeArea(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(22, 14, 22, 28),
|
||||
sliver: SliverList.list(children: [
|
||||
Row(children: [
|
||||
Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
decoration: BoxDecoration(
|
||||
color: _green,
|
||||
borderRadius: BorderRadius.circular(13),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text('S',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 23,
|
||||
fontFamily: 'Georgia',
|
||||
fontStyle: FontStyle.italic)),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
),
|
||||
|
||||
// 3. أزرار البدء السريع (Quick Actions)
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("ابدأ رحلتك اليوم",
|
||||
style:
|
||||
TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
_buildStartCard(
|
||||
title: "ركض",
|
||||
icon: Icons.run_circle,
|
||||
color: const Color(0xFFFF5722),
|
||||
onTap: () =>
|
||||
workoutCtrl.startWorkout(WorkoutType.running),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
_buildStartCard(
|
||||
title: "مشي",
|
||||
icon: Icons.directions_walk,
|
||||
color: Colors.green,
|
||||
onTap: () =>
|
||||
workoutCtrl.startWorkout(WorkoutType.walking),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 4. عرض حالة التمرين الحالي (إذا كان نشطاً)
|
||||
SliverToBoxAdapter(
|
||||
child: Obx(() => workoutCtrl.currentWorkout.value != null
|
||||
? _buildActiveWorkoutCard(workoutCtrl)
|
||||
: const SizedBox.shrink()),
|
||||
),
|
||||
|
||||
// 5. قسم الإحصائيات أو التمرين الأخير
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("آخر تمرين",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text("عرض الكل",
|
||||
style: TextStyle(
|
||||
color: Color(0xFFFF5722), fontSize: 12)),
|
||||
],
|
||||
),
|
||||
const Divider(height: 30, color: Colors.white10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildMiniStat("المسافة", "0.0 كم"),
|
||||
_buildMiniStat("الوقت", "00:00"),
|
||||
_buildMiniStat("السعرات", "0"),
|
||||
],
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 10),
|
||||
const Text('SportPath',
|
||||
style: TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: -.4)),
|
||||
const Spacer(),
|
||||
Obx(() => Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 7),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
child: Row(children: [
|
||||
Icon(
|
||||
syncService.isOnline
|
||||
? Icons.cloud_done_outlined
|
||||
: Icons.cloud_off_outlined,
|
||||
size: 16,
|
||||
color: syncService.isOnline
|
||||
? _green
|
||||
: Colors.orange.shade800),
|
||||
const SizedBox(width: 5),
|
||||
Text(syncService.isOnline ? 'متصل' : 'دون اتصال',
|
||||
style:
|
||||
const TextStyle(color: _ink, fontSize: 11)),
|
||||
]),
|
||||
)),
|
||||
]),
|
||||
const SizedBox(height: 34),
|
||||
Text(_arabicToday(),
|
||||
style: const TextStyle(
|
||||
color: _green,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: .2)),
|
||||
const SizedBox(height: 8),
|
||||
const Text('خطوة صغيرة،\nفرق كبير.',
|
||||
style: TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 35,
|
||||
height: 1.18,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: -1.2)),
|
||||
const SizedBox(height: 12),
|
||||
const Text('خلّينا نبدأ حركة اليوم بإيقاع يناسبك.',
|
||||
style:
|
||||
TextStyle(color: _muted, fontSize: 14, height: 1.65)),
|
||||
const SizedBox(height: 22),
|
||||
_WeeklyPlanCard(
|
||||
onStartWalk: () =>
|
||||
workoutCtrl.startWorkout(WorkoutType.walking)),
|
||||
const SizedBox(height: 26),
|
||||
Row(children: [
|
||||
const Text('ابدأ الآن',
|
||||
style: TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600)),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
onPressed: () => Get.to(() => const HistoryScreen()),
|
||||
icon: const Icon(Icons.arrow_back, size: 15),
|
||||
label: const Text('سجل نشاطك'),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: _green,
|
||||
textStyle: const TextStyle(fontSize: 12)),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 11),
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: _ActionCard(
|
||||
title: 'مشي بالخارج',
|
||||
subtitle: 'سجّل المسافة والوقت',
|
||||
icon: Icons.directions_walk_rounded,
|
||||
tint: const Color(0xFFE8EFE5),
|
||||
onTap: () =>
|
||||
workoutCtrl.startWorkout(WorkoutType.walking))),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _ActionCard(
|
||||
title: 'جري خفيف',
|
||||
subtitle: 'على قدر طاقتك',
|
||||
icon: Icons.directions_run_rounded,
|
||||
tint: const Color(0xFFF0EAE0),
|
||||
onTap: () =>
|
||||
workoutCtrl.startWorkout(WorkoutType.running))),
|
||||
]),
|
||||
Obx(() => workoutCtrl.currentWorkout.value != null
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: _ActiveWorkoutCard(controller: workoutCtrl))
|
||||
: const SizedBox.shrink()),
|
||||
const SizedBox(height: 28),
|
||||
const Text('عادات تدعم يومك',
|
||||
style: TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600)),
|
||||
const SizedBox(height: 12),
|
||||
const _HabitCard(
|
||||
icon: Icons.restaurant_outlined,
|
||||
title: 'وجبتك القادمة',
|
||||
detail: 'سجّلها يدويًا الآن؛ تحليل الصور قيد الإعداد.',
|
||||
tag: 'تغذية'),
|
||||
const SizedBox(height: 9),
|
||||
const _HabitCard(
|
||||
icon: Icons.water_drop_outlined,
|
||||
title: 'اشرب كوب ماء',
|
||||
detail: 'تذكير بسيط للعناية بنفسك.',
|
||||
tag: 'عافية'),
|
||||
const SizedBox(height: 25),
|
||||
const Text('برنامج الأسبوع',
|
||||
style: TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600)),
|
||||
const SizedBox(height: 12),
|
||||
const _DayStrip(),
|
||||
const SizedBox(height: 25),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE8EEE5),
|
||||
borderRadius: BorderRadius.circular(18)),
|
||||
child: const Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(Icons.favorite_border, color: _green, size: 20),
|
||||
SizedBox(width: 11),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'ابدأ بهدوء، وتوقف إذا شعرت بألم أو دوخة. الخطة العامة لا تغني عن نصيحة مختص عند وجود حالة صحية.',
|
||||
style: TextStyle(
|
||||
color: _green, fontSize: 11, height: 1.7))),
|
||||
]),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStartCard(
|
||||
{required String title,
|
||||
required IconData icon,
|
||||
required Color color,
|
||||
required VoidCallback onTap}) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: color.withOpacity(0.3), width: 2),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, size: 40, color: color),
|
||||
const SizedBox(height: 10),
|
||||
Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold, color: color)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActiveWorkoutCard(WorkoutController ctrl) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFF5722),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const Text("التمرين قيد التسجيل...",
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildWhiteStat("المسافة",
|
||||
"${Formatters.distanceKm(ctrl.liveDistance.value)} كم"),
|
||||
_buildWhiteStat(
|
||||
"الوقت", Formatters.time(ctrl.elapsedSeconds.value)),
|
||||
_buildWhiteStat(
|
||||
"السرعة", Formatters.speedKmh(ctrl.liveSpeed.value)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () => ctrl.stopWorkout(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.red),
|
||||
child: const Text("إنهاء"),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildMiniStat(String label, String value) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(label, style: const TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
Text(value,
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
String _arabicToday() {
|
||||
const weekdays = [
|
||||
'الاثنين',
|
||||
'الثلاثاء',
|
||||
'الأربعاء',
|
||||
'الخميس',
|
||||
'الجمعة',
|
||||
'السبت',
|
||||
'الأحد'
|
||||
];
|
||||
const months = [
|
||||
'يناير',
|
||||
'فبراير',
|
||||
'مارس',
|
||||
'أبريل',
|
||||
'مايو',
|
||||
'يونيو',
|
||||
'يوليو',
|
||||
'أغسطس',
|
||||
'سبتمبر',
|
||||
'أكتوبر',
|
||||
'نوفمبر',
|
||||
'ديسمبر'
|
||||
];
|
||||
final now = DateTime.now();
|
||||
final day = now.day.toString().replaceAllMapped(
|
||||
RegExp(r'\d'), (match) => '٠١٢٣٤٥٦٧٨٩'[int.parse(match.group(0)!)]);
|
||||
return '${weekdays[now.weekday - 1]}، $day ${months[now.month - 1]}';
|
||||
}
|
||||
|
||||
class _WeeklyPlanCard extends StatelessWidget {
|
||||
const _WeeklyPlanCard({required this.onStartWalk});
|
||||
final VoidCallback onStartWalk;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: _green, borderRadius: BorderRadius.circular(22)),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Row(children: [
|
||||
const Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('خطة بداية متوازنة',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600)),
|
||||
SizedBox(height: 4),
|
||||
Text('أسبوع تمهيدي • حركة خفيفة',
|
||||
style: TextStyle(color: Color(0xFFDCE8DA), fontSize: 11)),
|
||||
])),
|
||||
SizedBox(
|
||||
width: 76,
|
||||
height: 70,
|
||||
child: CustomPaint(painter: _PathPainter())),
|
||||
]),
|
||||
const SizedBox(height: 17),
|
||||
Row(children: [
|
||||
const Expanded(
|
||||
child: Text('مشي مريح لمدة ٢٠ دقيقة',
|
||||
style: TextStyle(color: Colors.white, fontSize: 13))),
|
||||
TextButton(
|
||||
onPressed: onStartWalk,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: _green,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14)),
|
||||
child: const Text('ابدأ المشي',
|
||||
style:
|
||||
TextStyle(fontSize: 11, fontWeight: FontWeight.w600))),
|
||||
]),
|
||||
const SizedBox(height: 3),
|
||||
const Text('عدّل المدة أو خذ يوم راحة حسب شعورك.',
|
||||
style: TextStyle(color: Color(0xFFDCE8DA), fontSize: 10)),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
class _PathPainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()
|
||||
..color = const Color(0xFFB8CAA9)
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.5;
|
||||
final path = Path()
|
||||
..moveTo(4, size.height * .82)
|
||||
..cubicTo(size.width * .18, size.height * .12, size.width * .48,
|
||||
size.height * .98, size.width * .68, size.height * .38)
|
||||
..quadraticBezierTo(size.width * .86, size.height * .02, size.width * .98,
|
||||
size.height * .24);
|
||||
canvas.drawPath(path, paint);
|
||||
canvas.drawCircle(Offset(size.width * .68, size.height * .38), 4,
|
||||
Paint()..color = Colors.white);
|
||||
}
|
||||
|
||||
Widget _buildWhiteStat(String label, String value) {
|
||||
return Column(
|
||||
children: [
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||
}
|
||||
|
||||
class _ActionCard extends StatelessWidget {
|
||||
const _ActionCard(
|
||||
{required this.title,
|
||||
required this.subtitle,
|
||||
required this.icon,
|
||||
required this.tint,
|
||||
required this.onTap});
|
||||
final String title, subtitle;
|
||||
final IconData icon;
|
||||
final Color tint;
|
||||
final VoidCallback onTap;
|
||||
@override
|
||||
Widget build(BuildContext context) => Material(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(17),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(17),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
decoration: BoxDecoration(
|
||||
color: tint,
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
child: Icon(icon, color: _green, size: 21)),
|
||||
const SizedBox(height: 13),
|
||||
Text(title,
|
||||
style: const TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600)),
|
||||
const SizedBox(height: 3),
|
||||
Text(subtitle,
|
||||
style: const TextStyle(color: _muted, fontSize: 10)),
|
||||
]))),
|
||||
);
|
||||
}
|
||||
|
||||
class _ActiveWorkoutCard extends StatelessWidget {
|
||||
const _ActiveWorkoutCard({required this.controller});
|
||||
final WorkoutController controller;
|
||||
@override
|
||||
Widget build(BuildContext context) => Container(
|
||||
padding: const EdgeInsets.all(17),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF293A30),
|
||||
borderRadius: BorderRadius.circular(18)),
|
||||
child: Column(children: [
|
||||
const Row(children: [
|
||||
Icon(Icons.fiber_manual_record, size: 9, color: Color(0xFFB6D29D)),
|
||||
SizedBox(width: 8),
|
||||
Text('النشاط جارٍ',
|
||||
style:
|
||||
TextStyle(color: Colors.white, fontWeight: FontWeight.w600))
|
||||
]),
|
||||
const SizedBox(height: 15),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
||||
_LiveStat('المسافة',
|
||||
'${Formatters.distanceKm(controller.liveDistance.value)} كم'),
|
||||
_LiveStat(
|
||||
'الوقت', Formatters.time(controller.elapsedSeconds.value)),
|
||||
_LiveStat('السرعة',
|
||||
'${Formatters.speedKmh(controller.liveSpeed.value)} كم/س'),
|
||||
]),
|
||||
const SizedBox(height: 13),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton(
|
||||
onPressed: controller.stopWorkout,
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.white),
|
||||
child: const Text('إنهاء وحفظ'))),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
class _LiveStat extends StatelessWidget {
|
||||
const _LiveStat(this.label, this.value);
|
||||
final String label, value;
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(children: [
|
||||
Text(label,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.white70)),
|
||||
style: const TextStyle(color: Colors.white60, fontSize: 10)),
|
||||
const SizedBox(height: 3),
|
||||
Text(value,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white)),
|
||||
],
|
||||
);
|
||||
}
|
||||
color: Colors.white, fontSize: 14, fontWeight: FontWeight.w600))
|
||||
]);
|
||||
}
|
||||
|
||||
class _HabitCard extends StatelessWidget {
|
||||
const _HabitCard(
|
||||
{required this.icon,
|
||||
required this.title,
|
||||
required this.detail,
|
||||
required this.tag});
|
||||
final IconData icon;
|
||||
final String title, detail, tag;
|
||||
@override
|
||||
Widget build(BuildContext context) => Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(15)),
|
||||
child: Row(children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE8EFE5),
|
||||
borderRadius: BorderRadius.circular(13)),
|
||||
child: Icon(icon, color: _green, size: 20)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title,
|
||||
style: const TextStyle(
|
||||
color: _ink,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600)),
|
||||
const SizedBox(height: 2),
|
||||
Text(detail,
|
||||
style: const TextStyle(color: _muted, fontSize: 10))
|
||||
])),
|
||||
Text(tag,
|
||||
style: const TextStyle(
|
||||
color: _green, fontSize: 10, fontWeight: FontWeight.w600)),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
class _DayStrip extends StatelessWidget {
|
||||
const _DayStrip();
|
||||
static const days = [
|
||||
('ح', 'راحة'),
|
||||
('ن', 'مشي'),
|
||||
('ث', 'قوة'),
|
||||
('ر', 'مشي'),
|
||||
('خ', 'راحة'),
|
||||
('ج', 'نشاط'),
|
||||
('س', 'راحة')
|
||||
];
|
||||
@override
|
||||
Widget build(BuildContext context) => Row(children: [
|
||||
for (var i = 0; i < days.length; i++)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
end: i == days.length - 1 ? 0 : 7),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: i == 0 ? _green : Colors.white,
|
||||
borderRadius: BorderRadius.circular(13)),
|
||||
child: Column(children: [
|
||||
Text(days[i].$1,
|
||||
style: TextStyle(
|
||||
color: i == 0 ? Colors.white : _ink,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700)),
|
||||
const SizedBox(height: 4),
|
||||
Text(days[i].$2,
|
||||
style: TextStyle(
|
||||
color: i == 0 ? Colors.white70 : _muted,
|
||||
fontSize: 8))
|
||||
]),
|
||||
)))
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user