mirror of
https://github.com/lichess-org/mobile.git
synced 2026-05-26 13:50:52 +00:00
Add streak counter
This commit is contained in:
Binary file not shown.
@@ -355,6 +355,20 @@
|
||||
"css": "chess_rook",
|
||||
"code": 62535,
|
||||
"src": "fontawesome5"
|
||||
},
|
||||
{
|
||||
"uid": "360cdd9b28e88dda5e237ad35196e494",
|
||||
"css": "streak",
|
||||
"code": 59414,
|
||||
"src": "custom_icons",
|
||||
"selected": true,
|
||||
"svg": {
|
||||
"path": "M168 33.2L138.7 101.6 85.9 48.8 56.6 80.1 109.4 130.9 43 158.2 117.2 232.4 201.2 220.7 296.9 316.4Q306.6 306.6 318.4 298.8 324.2 293 332 289.1L230.5 191.4 242.2 107.4ZM529.3 181.6Q484.4 181.6 476.6 220.7 517.6 285.2 517.6 345.7 490.2 324.2 460.9 312.5 435.5 302.7 412.1 304.7 373 304.7 339.8 328.1 285.2 367.2 273.4 449.2 261.7 535.2 294.9 608.4T392.6 705.1Q412.1 712.9 438.5 710.9T470.7 699.2L486.3 671.9 502 699.2Q509.8 714.8 535.2 722.7 558.6 730.5 578.1 730.5 605.5 728.5 630.9 716.8L554.7 642.6Q537.1 625 539.1 601.6 543 580.1 558.6 566.4 576.2 550.8 595.7 548.8 599.6 546.9 605.5 548.8 625 548.8 636.7 562.5L718.8 640.6Q757.8 584 767.6 513.7T742.2 393.6 650.4 334H648.4Q634.8 332 615.2 332 582 335.9 550.8 351.6 558.6 271.5 529.3 181.6ZM603.5 584H599.6Q591.8 585.9 584 592.8T576.2 605.5Q574.2 611.3 580.1 617.2L740.2 773.4 752 785.2 742.2 796.9Q734.4 806.6 716.8 818.4 693.4 834 658.2 851.6 810.5 941.4 964.8 957 962.9 822.3 857.4 662.1 845.7 683.6 830.1 704.1T806.6 734.4L796.9 744.1 783.2 755.9 771.5 744.1 611.3 587.9Q607.4 584 603.5 584Z",
|
||||
"width": 1020
|
||||
},
|
||||
"search": [
|
||||
"streak"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -71,6 +71,8 @@ class LichessIcons {
|
||||
IconData(0xe813, fontFamily: _kFontFam, fontPackage: _kFontPkg);
|
||||
static const IconData racing_kings =
|
||||
IconData(0xe814, fontFamily: _kFontFam, fontPackage: _kFontPkg);
|
||||
static const IconData streak =
|
||||
IconData(0xe816, fontFamily: _kFontFam, fontPackage: _kFontPkg);
|
||||
static const IconData step_backward =
|
||||
IconData(0xf048, fontFamily: _kFontFam, fontPackage: _kFontPkg);
|
||||
static const IconData fast_backward =
|
||||
|
||||
@@ -117,7 +117,7 @@ class _Body extends ConsumerWidget {
|
||||
Padding(
|
||||
padding: Styles.bodySectionBottomPadding,
|
||||
child: CardButton(
|
||||
icon: const Icon(LichessIcons.target, size: 44),
|
||||
icon: const Icon(LichessIcons.streak, size: 44),
|
||||
title: const Text('Puzzle Streak'),
|
||||
subtitle: Text(context.l10n.puzzleStreakDescription),
|
||||
onTap: connectivity.when(
|
||||
|
||||
@@ -8,6 +8,8 @@ import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/common/styles.dart';
|
||||
import 'package:lichess_mobile/src/common/lichess_icons.dart';
|
||||
import 'package:lichess_mobile/src/common/lichess_colors.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/table_board_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform.dart';
|
||||
@@ -21,7 +23,6 @@ import 'package:lichess_mobile/src/utils/chessground_compat.dart';
|
||||
|
||||
import 'puzzle_view_model.dart';
|
||||
import 'puzzle_feedback_widget.dart';
|
||||
import 'puzzle_session_widget.dart';
|
||||
|
||||
class PuzzleStreakScreen extends StatelessWidget {
|
||||
const PuzzleStreakScreen({super.key});
|
||||
@@ -111,6 +112,9 @@ class _Body extends ConsumerWidget {
|
||||
final viewModelProvider =
|
||||
puzzleViewModelProvider(initialPuzzleContext, streak: streak);
|
||||
final puzzleState = ref.watch(viewModelProvider);
|
||||
final streakColor = defaultTargetPlatform == TargetPlatform.iOS
|
||||
? LichessColors.brag
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -148,45 +152,30 @@ class _Body extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomTable: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (puzzleState.glicko != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10.0,
|
||||
left: 10.0,
|
||||
right: 10.0,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(context.l10n.rating),
|
||||
const SizedBox(width: 5.0),
|
||||
TweenAnimationBuilder<double>(
|
||||
tween: Tween<double>(
|
||||
begin: puzzleState.glicko!.rating,
|
||||
end: puzzleState.nextContext?.glicko?.rating ??
|
||||
puzzleState.glicko!.rating,
|
||||
),
|
||||
duration: const Duration(milliseconds: 500),
|
||||
builder: (context, double rating, _) {
|
||||
return Text(
|
||||
rating.truncate().toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
bottomTable: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10.0,
|
||||
left: 10.0,
|
||||
right: 10.0,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
LichessIcons.streak,
|
||||
size: 40.0,
|
||||
color: streakColor,
|
||||
),
|
||||
const SizedBox(width: 8.0),
|
||||
Text(
|
||||
(puzzleState.streakIndex ?? 0).toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 30.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: streakColor,
|
||||
),
|
||||
),
|
||||
PuzzleSessionWidget(
|
||||
initialPuzzleContext: initialPuzzleContext,
|
||||
viewModelProvider: viewModelProvider,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -206,10 +206,12 @@ class PuzzleViewModel extends _$PuzzleViewModel {
|
||||
final sessionNotifier =
|
||||
puzzleSessionProvider(context.userId, context.theme).notifier;
|
||||
|
||||
ref.read(sessionNotifier).addAttempt(
|
||||
state.puzzle.puzzle.id,
|
||||
win: result == PuzzleResult.win,
|
||||
);
|
||||
if (streak != null) {
|
||||
ref.read(sessionNotifier).addAttempt(
|
||||
state.puzzle.puzzle.id,
|
||||
win: result == PuzzleResult.win,
|
||||
);
|
||||
}
|
||||
|
||||
final service = ref.read(defaultPuzzleServiceProvider);
|
||||
final repo = ref.read(puzzleRepositoryProvider);
|
||||
|
||||
Reference in New Issue
Block a user