Files
Remever/lib/screens/statistick/statistick_screen.dart

248 lines
8.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:remever/common/resources.dart';
import 'package:remever/common/widgets/typography.dart';
import 'package:remever/common/widgets/wspace.dart';
import 'package:remever/components/extensions/context.dart';
import 'package:remever/gen/assets.gen.dart';
import 'package:share_plus/share_plus.dart';
import 'package:intl/intl.dart';
@RoutePage()
class StatistickScreen extends StatelessWidget {
StatistickScreen({super.key});
final DateTime today = DateTime.now();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.bg,
appBar: _buildAppBar(context),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16).r,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16).r,
child: Container(
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.all(Radius.circular(12)).r,
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 16).r,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: AppTypography(
"Лучший результат за день",
type: Medium16px(),
),
),
Center(
child: AppTypography(
DateFormat('dd.MM.yyyy').format(today),
type: Regular14px(),
color: AppColors.disabled,
),
),
HSpace(16),
_buildTodayStats(),
HSpace(32),
_buildSectionHeader(
"Повторили карточек",
Assets.icons.statsRepeat,
),
HSpace(16),
_buildStatisticsList([
{"label": "За сегодня", "value": "77"},
{"label": "За эту неделю", "value": "188"},
{"label": "За прошлую неделю", "value": "33"},
{"label": "За последний месяц", "value": "1669"},
{"label": "За все время", "value": "1345669"},
]),
HSpace(32),
_buildSectionHeader(
"Всего изучено карточек",
Assets.icons.statsBest,
),
HSpace(16),
_buildStatisticsList([
{"label": "За сегодня", "value": "77"},
{"label": "За эту неделю", "value": "188"},
{"label": "За прошлую неделю", "value": "33"},
{"label": "За последний месяц", "value": "1669"},
{"label": "За все время", "value": "1345669"},
]),
HSpace(32),
_buildSectionHeader(
"Прошли тренировок",
Assets.icons.statsTime,
),
HSpace(16),
_buildStatisticsList([
{"label": "За сегодня", "value": "77"},
{"label": "За эту неделю", "value": "188"},
{"label": "За прошлую неделю", "value": "33"},
{"label": "За последний месяц", "value": "1669"},
{"label": "За все время", "value": "1345669"},
]),
HSpace(32),
_buildSectionHeader(
"Вырос уровень у карточек",
Assets.icons.statsUp,
),
HSpace(16),
_buildStatisticsList([
{"label": "За сегодня", "value": "77"},
{"label": "За эту неделю", "value": "188"},
{"label": "За прошлую неделю", "value": "33"},
{"label": "За последний месяц", "value": "1669"},
{"label": "За все время", "value": "1345669"},
]),
HSpace(32),
_buildSectionHeader(
"Снизился уровень у карточек",
Assets.icons.statsDown,
),
HSpace(16),
_buildStatisticsList([
{"label": "За сегодня", "value": "77"},
{"label": "За эту неделю", "value": "188"},
{"label": "За прошлую неделю", "value": "33"},
{"label": "За последний месяц", "value": "1669"},
{"label": "За все время", "value": "1345669"},
]),
],
),
),
),
),
),
),
);
}
Widget _buildTodayStats() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
spacing: 8.r,
children: [
_buildStatBlock(
"230",
"повторили\nкарточек",
Color(0xFFD7E6F4),
Color(0xFF0058AB),
),
_buildStatBlock(
"19",
"прошли\nтренировок",
Color(0xFFFFE4E6),
Color(0xFFFF5C69),
),
_buildStatBlock(
"196",
"вырос\nуровень",
Color(0xFFD7F4EA),
Color(0xFF008456),
),
],
);
}
/// AppBar экрана настроек
AppBar _buildAppBar(BuildContext context) {
return AppBar(
toolbarHeight: 66.h,
backgroundColor: AppColors.white,
shadowColor: Colors.transparent,
centerTitle: true,
leadingWidth: 0,
title: AppTypography('Статистика', type: SemiBold20px()),
actions: [
IconButton(
onPressed: () => Share.share('Зацени мою статистику в REMEVER'),
icon: Assets.icons.settingsShare.image(height: 24.h, width: 24.w),
color: Colors.black,
),
],
);
}
// Вспомогательные методы
Widget _buildStatBlock(
String value,
String label,
Color color,
Color textColor,
) {
return Expanded(
child: Container(
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(12).r,
),
padding: EdgeInsets.all(12).r,
child: Column(
children: [
AppTypography(value, type: Bold24px(), color: textColor),
AppTypography(
label,
type: Regular12px(),
color: textColor,
maxLines: 2,
textAlign: TextAlign.center,
),
],
),
),
);
}
Widget _buildSectionHeader(String title, AssetGenImage icon) {
return Row(
children: [
icon.image(height: 20.h, width: 20.w),
WSpace(4),
AppTypography(title, type: Medium16px()),
],
);
}
Widget _buildStatisticsList(List<Map<String, String>> data) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12)).r,
color: AppColors.bg,
),
child: Padding(
padding: const EdgeInsets.all(12).r,
child: Column(
spacing: 8.r,
children:
data
.map(
(e) => Row(
children: [
Expanded(
child: AppTypography(
e['label']!,
type: Regular16px(),
),
),
Assets.icons.statsCard.image(height: 18.h, width: 18.w),
AppTypography(e["value"]!, type: Regular16px()),
],
),
)
.toList(),
),
),
);
}
}