Browse Source

fix: some position and bloc rebuilt

pull/19/head
AmirrezaChegini 3 weeks ago
parent
commit
ddd44491ee
  1. 4
      lib/features/level/presentation/bloc/level_bloc.dart
  2. 6
      lib/features/level/presentation/ui/level_page.dart
  3. 4
      lib/features/question/presentation/ui/question_page.dart
  4. 8
      lib/features/question/presentation/ui/screens/question_screen.dart

4
lib/features/level/presentation/bloc/level_bloc.dart

@ -42,9 +42,9 @@ class LevelBloc extends Bloc<LevelEvent, LevelState> {
LevelLocation(bottom: -30, left: 30, index: 1),
LevelLocation(bottom: 50, left: 100, index: 2),
LevelLocation(bottom: 150, left: 60, index: 3),
LevelLocation(bottom: 210, left: 120, index: 4),
LevelLocation(bottom: 210, left: 110, index: 4),
LevelLocation(bottom: 250, right: 60, index: 5),
LevelLocation(top: 150, right: 40, index: 6),
LevelLocation(top: 170, right: 40, index: 6),
LevelLocation(top: 70, right: 70, index: 7),
LevelLocation(top: -20, right: 70, index: 8),
];

6
lib/features/level/presentation/ui/level_page.dart

@ -45,9 +45,7 @@ class LevelPage extends StatelessWidget {
builder: (context, state) {
if (state.chooseLevel?.id != null) {
return Positioned(
bottom: MediaQuery
.viewPaddingOf(context)
.bottom + MySpaces.s10,
bottom: MediaQuery.viewPaddingOf(context).bottom + MySpaces.s10,
right: MySpaces.s16,
left: MySpaces.s16,
child: HintLevelWidget(
@ -137,7 +135,7 @@ class LevelPage extends StatelessWidget {
children: [
BottomPath(
width: context.widthScreen * 0.75,
height: context.heightScreen * 0.6,
height: context.heightScreen * 0.65,
),
...List.generate(
context.read<LevelBloc>().bottom8LevelList.length,

4
lib/features/question/presentation/ui/question_page.dart

@ -92,6 +92,8 @@ class QuestionPage extends StatelessWidget {
),
Spacer(),
BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.levelEntity?.id != current.levelEntity?.id,
builder: (context, state) => Text(
'${context.translate.step} ${state.levelEntity?.order ?? 1}',
style: Marhey.bold14.copyWith(
@ -119,6 +121,8 @@ class QuestionPage extends StatelessWidget {
Widget _stepper() {
return BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) => QuestionStepper(
length: state.levelEntity?.questions?.length ?? 0,
currentStep: state.currentQuestion?.order ?? 1,

8
lib/features/question/presentation/ui/screens/question_screen.dart

@ -37,6 +37,8 @@ class QuestionScreen extends StatelessWidget {
spacing: MySpaces.s4,
children: [
BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) => Text(
'${context.translate.question} ${state.currentQuestion?.order ?? 1} / ${(state.levelEntity?.questions?.length ?? 0) - 1}',
style: Marhey.medium12.copyWith(
@ -52,6 +54,8 @@ class QuestionScreen extends StatelessWidget {
),
),
BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) => Text(
state.currentQuestion?.title ?? '',
textAlign: TextAlign.center,
@ -84,6 +88,8 @@ class QuestionScreen extends StatelessWidget {
globalKey: context.read<QuestionBloc>().keys[index],
description: context.translate.tap_to_select,
child: BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) => AnswerBox(
key: Key('${state.currentQuestion?.id}'),
index: state.currentQuestion?.answers?[index].order ?? 1,
@ -105,6 +111,8 @@ class QuestionScreen extends StatelessWidget {
children: [
Spacer(),
BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) =>
previous.correctAnswer != current.correctAnswer,
builder: (context, state) => Stack(
clipBehavior: Clip.none,
children: [

Loading…
Cancel
Save