From 8e77f99c027b4b24413bfa94a07b8a09b1c4d7d5 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 17 Dec 2025 04:21:12 +0300 Subject: [PATCH] stuff --- .../forms/InputButtonsQuestionForm.tsx | 6 ++--- .../components/forms/SimpleQuestionForm.tsx | 6 ++--- .../lib/presentation/widgets/card_viewer.dart | 24 ++++--------------- .../lib/presentation/widgets/mnemo_text.dart | 3 ++- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/mnemo_cards_admin/src/components/forms/InputButtonsQuestionForm.tsx b/mnemo_cards_admin/src/components/forms/InputButtonsQuestionForm.tsx index d2bf592..5445597 100644 --- a/mnemo_cards_admin/src/components/forms/InputButtonsQuestionForm.tsx +++ b/mnemo_cards_admin/src/components/forms/InputButtonsQuestionForm.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useRef, useMemo } from 'react' +import { useState, useEffect, useRef } from 'react' import type { InputButtonsQuestion, TestButton } from '@/types/questions' import { QuestionType } from '@/types/questions' import { Label } from '@/components/ui/label' @@ -42,9 +42,9 @@ export function InputButtonsQuestionForm({ // Track the initial question to detect when we're editing a different question const initialQuestionRef = useRef(question.id) - // Initialize state when question prop changes (e.g., when editing a different question) + // Initialize state when question id changes (e.g., when editing a different question) useEffect(() => { - // Only sync if the question id changed (different question) or if this is the first render + // Only sync if the question id changed (different question) if (initialQuestionRef.current !== question.id) { initialQuestionRef.current = question.id setWord(question.word || '') diff --git a/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx b/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx index 2e237bc..760b92c 100644 --- a/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx +++ b/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useRef, useMemo } from 'react' +import { useState, useEffect, useRef } from 'react' import type { SimpleQuestion, TestButton } from '@/types/questions' import { QuestionType } from '@/types/questions' import { Label } from '@/components/ui/label' @@ -41,9 +41,9 @@ export function SimpleQuestionForm({ // Track the initial question to detect when we're editing a different question const initialQuestionRef = useRef(question.id) - // Initialize state when question prop changes (e.g., when editing a different question) + // Initialize state when question id changes (e.g., when editing a different question) useEffect(() => { - // Only sync if the question id changed (different question) or if this is the first render + // Only sync if the question id changed (different question) if (initialQuestionRef.current !== question.id) { initialQuestionRef.current = question.id setWord(question.word || '') diff --git a/mnemo_cards_web_v2/lib/presentation/widgets/card_viewer.dart b/mnemo_cards_web_v2/lib/presentation/widgets/card_viewer.dart index 9a9bfce..57fc9a6 100644 --- a/mnemo_cards_web_v2/lib/presentation/widgets/card_viewer.dart +++ b/mnemo_cards_web_v2/lib/presentation/widgets/card_viewer.dart @@ -386,8 +386,8 @@ class _CardSide extends StatelessWidget { @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - final cardWidth = math.min(screenSize.width * 0.9, 600.0); final cardHeight = math.min(screenSize.height * 0.7, 800.0); + final cardWidth = math.min(screenSize.width * 0.9, cardHeight * 0.66); final theme = Theme.of(context); final colorScheme = theme.colorScheme; @@ -484,10 +484,10 @@ class _CardSide extends StatelessWidget { child: SingleChildScrollView( child: MnemoText( card.mnemo, - textStyle: const TextStyle( + textStyle: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, - color: AppColors.mnemoRed, + color: colorScheme.onSurface, ), textAlign: TextAlign.center, maxLines: 4, @@ -558,20 +558,6 @@ class _CardSide extends StatelessWidget { return Image.network( imageUrl, fit: BoxFit.cover, - loadingBuilder: (context, child, loadingProgress) { - if (loadingProgress == null) { - return child; - } - return Center( - child: CircularProgressIndicator( - value: loadingProgress.expectedTotalBytes != null - ? loadingProgress.cumulativeBytesLoaded / - loadingProgress.expectedTotalBytes! - : null, - color: packColor, - ), - ); - }, errorBuilder: (context, error, stackTrace) { return Container( color: packColor.withOpacity(0.1), @@ -659,11 +645,11 @@ class _CardSide extends StatelessWidget { ) else Text( - 'Нет текста на обратной стороне', + card.original!, style: TextStyle( fontSize: 24, fontWeight: FontWeight.w400, - color: colorScheme.onSurface.withOpacity(0.38), + color: colorScheme.onSurface, ), textAlign: TextAlign.center, ), diff --git a/mnemo_cards_web_v2/lib/presentation/widgets/mnemo_text.dart b/mnemo_cards_web_v2/lib/presentation/widgets/mnemo_text.dart index 8c9fe41..95d2340 100644 --- a/mnemo_cards_web_v2/lib/presentation/widgets/mnemo_text.dart +++ b/mnemo_cards_web_v2/lib/presentation/widgets/mnemo_text.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../../utils/color_extension.dart'; +import '../theme/app_colors.dart'; /// Виджет для отображения текста с форматированием /// @@ -44,7 +45,7 @@ class MnemoText extends StatelessWidget { final matches = RegExp(r'\{(.*?)\}').allMatches(formattedText); // Цвет по умолчанию для выделенного текста - Color highlightColor = color ?? Colors.red; + Color highlightColor = color ?? AppColors.mnemoRed; final List spans = []; RegExpMatch? lastMatch;