You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
4.3 KiB
110 lines
4.3 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_audios.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/gap.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/screen_size.dart';
|
|
import 'package:hadi_hoda_flutter/core/widgets/animations/slide_down_fade.dart';
|
|
import 'package:hadi_hoda_flutter/features/question/presentation/bloc/question_bloc.dart';
|
|
import 'package:hadi_hoda_flutter/features/question/presentation/bloc/question_state.dart';
|
|
import 'package:hadi_hoda_flutter/features/question/presentation/ui/screens/diamond_screen.dart';
|
|
import 'package:hadi_hoda_flutter/features/question/presentation/ui/screens/question_screen.dart';
|
|
import 'package:hadi_hoda_flutter/features/question/presentation/ui/widgets/glassy_button.dart';
|
|
import 'package:hadi_hoda_flutter/features/question/presentation/ui/widgets/question_title.dart';
|
|
import 'package:showcaseview/showcaseview.dart';
|
|
|
|
class QuestionPage extends StatelessWidget {
|
|
const QuestionPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ShowCaseWidget(
|
|
builder: (context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
height: context.heightScreen,
|
|
width: context.widthScreen,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [Color(0XFF6930DA), Color(0XFF263AA1)],
|
|
),
|
|
image: DecorationImage(
|
|
image: AssetImage(MyAssets.pattern),
|
|
scale: 3,
|
|
repeat: ImageRepeat.repeat,
|
|
colorFilter: ColorFilter.mode(
|
|
Colors.black.withValues(alpha: 0.3),
|
|
BlendMode.srcIn,
|
|
),
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: MySpaces.s16,
|
|
vertical: MySpaces.s22,
|
|
),
|
|
child: Column(
|
|
children: [
|
|
_topButtons(context),
|
|
MySpaces.s10.gapHeight,
|
|
Expanded(
|
|
child: BlocBuilder<QuestionBloc, QuestionState>(
|
|
buildWhen: (previous, current) =>
|
|
(previous.currentQuestion?.order !=
|
|
current.currentQuestion?.order),
|
|
builder: (context, state) {
|
|
if (state.currentQuestion?.order ==
|
|
state.levelEntity?.questions?.length) {
|
|
return DiamondScreen();
|
|
} else {
|
|
return QuestionScreen();
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _topButtons(BuildContext context) {
|
|
return SlideDownFade(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
GlassyButton(
|
|
image: MyAssets.home,
|
|
audio: MyAudios.back,
|
|
onTap: () =>
|
|
context.read<QuestionBloc>().goToHomePage(context: context),
|
|
),
|
|
BlocBuilder<QuestionBloc, QuestionState>(
|
|
buildWhen: (previous, current) =>
|
|
previous.currentQuestion?.id != current.currentQuestion?.id,
|
|
builder: (context, state) => QuestionTitle(
|
|
step: state.levelEntity?.order,
|
|
currentQuestion: state.currentQuestion?.order,
|
|
questionLength: state.levelEntity?.questions?.length,
|
|
),
|
|
),
|
|
StreamBuilder<double>(
|
|
initialData: 1,
|
|
stream: context.read<QuestionBloc>().volumeStream,
|
|
builder: (context, snapshot) => GlassyButton(
|
|
image: snapshot.data == 0 ? MyAssets.unMusic : MyAssets.music,
|
|
onTap: () => context.read<QuestionBloc>().changeMute(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|