Browse Source
Merge pull request 'feature/audio' (#31) from feature/audio into develop
Merge pull request 'feature/audio' (#31) from feature/audio into develop
Reviewed-on: https://git.nwhco.ir/amirreza.chegini/hade_hoda_flutter/pulls/31pull/32/head
31 changed files with 454 additions and 53 deletions
-
BINassets/audios/back.mp3
-
BINassets/audios/click_button.mp3
-
BINassets/audios/diamond_end.mp3
-
BINassets/audios/diamond_increase.mp3
-
BINassets/audios/home.mp3
-
BINassets/audios/incorrect_answer.mp3
-
BINassets/audios/question.mp3
-
BINassets/audios/right_answer.mp3
-
8lib/common_ui/resources/my_audios.dart
-
4lib/core/constants/my_constants.dart
-
12lib/core/middlewares/my_middlewares.dart
-
13lib/core/routers/my_routes.dart
-
51lib/core/services/audio_service.dart
-
5lib/core/widgets/button/my_blue_button.dart
-
3lib/core/widgets/button/my_yellow_button.dart
-
8lib/core/widgets/dialog/about_us_dialog.dart
-
104lib/core/widgets/dialog/exit_dialog.dart
-
4lib/core/widgets/dialog/hadith_dialog.dart
-
11lib/core/widgets/dialog/styles/dialog_background.dart
-
82lib/core/widgets/dialog/styles/dialog_button.dart
-
55lib/core/widgets/inkwell/my_inkwell.dart
-
34lib/features/home/presentation/bloc/home_bloc.dart
-
43lib/features/home/presentation/ui/home_page.dart
-
9lib/features/intro/presentation/bloc/intro_bloc.dart
-
6lib/features/language/presentation/bloc/language_bloc.dart
-
2lib/features/question/presentation/bloc/question_bloc.dart
-
9lib/init_bindings.dart
-
6lib/l10n/app_en.arb
-
24lib/l10n/app_localizations.dart
-
13lib/l10n/app_localizations_en.dart
-
1pubspec.yaml
@ -0,0 +1,8 @@ |
|||||
|
class MyAudios { |
||||
|
static const MyAudios _i = MyAudios._internal(); |
||||
|
const MyAudios._internal(); |
||||
|
factory MyAudios() => _i; |
||||
|
|
||||
|
static const String homeMusic = 'assets/audios/home.mp3'; |
||||
|
static const String clickButton = 'assets/audios/click_button.mp3'; |
||||
|
} |
||||
@ -0,0 +1,104 @@ |
|||||
|
import 'dart:ui'; |
||||
|
|
||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:flutter/services.dart'; |
||||
|
import 'package:go_router/go_router.dart'; |
||||
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart'; |
||||
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart'; |
||||
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_text_style.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/utils/my_localization.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/utils/set_platform_size.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/widgets/dialog/styles/dialog_background.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/widgets/dialog/styles/dialog_button.dart'; |
||||
|
|
||||
|
Future<void> showExitDialog({required BuildContext context}) async { |
||||
|
await showDialog( |
||||
|
context: context, |
||||
|
builder: (context) => ExitDialog(), |
||||
|
barrierColor: MyColors.purple.withValues(alpha: 0.82), |
||||
|
useSafeArea: false, |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
class ExitDialog extends StatelessWidget { |
||||
|
const ExitDialog({super.key}); |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return Scaffold( |
||||
|
backgroundColor: MyColors.transparent, |
||||
|
body: BackdropFilter( |
||||
|
filter: ImageFilter.blur(sigmaX: 6, sigmaY: 6), |
||||
|
child: Center( |
||||
|
child: Padding( |
||||
|
padding: EdgeInsets.symmetric( |
||||
|
horizontal: setSize(context: context, mobile: 18, tablet: 160) ?? 0, |
||||
|
), |
||||
|
child: DialogBackground( |
||||
|
height: 260, |
||||
|
child: Column( |
||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
|
children: [ |
||||
|
Text( |
||||
|
context.translate.want_to_exit, |
||||
|
style: MYTextStyle.titr0.copyWith(color: Color(0XFF322386)), |
||||
|
), |
||||
|
Text( |
||||
|
context.translate.exit_dialog_desc, |
||||
|
style: MYTextStyle.titr3.copyWith(color: Color(0XFF6272A9)), |
||||
|
textAlign: TextAlign.center, |
||||
|
), |
||||
|
Row( |
||||
|
spacing: MySpaces.s20, |
||||
|
children: [ |
||||
|
Expanded( |
||||
|
child: DialogButton( |
||||
|
onTap: () { |
||||
|
context.pop(); |
||||
|
}, |
||||
|
height: 72, |
||||
|
color: Color(0XFFC0BDD3), |
||||
|
child: Text( |
||||
|
context.translate.cancel, |
||||
|
style: MYTextStyle.button2.copyWith( |
||||
|
shadows: [ |
||||
|
BoxShadow( |
||||
|
color: Color(0XFF9895AE), |
||||
|
offset: Offset(0, 3.32), |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
Expanded( |
||||
|
child: DialogButton( |
||||
|
onTap: () { |
||||
|
SystemNavigator.pop(); |
||||
|
}, |
||||
|
height: 72, |
||||
|
color: Color(0XFFD42427), |
||||
|
child: Text( |
||||
|
context.translate.exit, |
||||
|
style: MYTextStyle.button2.copyWith( |
||||
|
shadows: [ |
||||
|
BoxShadow( |
||||
|
color: Color(0XFFC82020), |
||||
|
offset: Offset(0, 3.32), |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/widgets/inkwell/my_inkwell.dart'; |
||||
|
|
||||
|
class DialogButton extends StatelessWidget { |
||||
|
const DialogButton({ |
||||
|
super.key, |
||||
|
this.color, |
||||
|
this.height = 72.0, |
||||
|
this.child, |
||||
|
this.onTap, |
||||
|
}); |
||||
|
|
||||
|
final Color? color; |
||||
|
final double height; |
||||
|
final Widget? child; |
||||
|
final VoidCallback? onTap; |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return ClipPath( |
||||
|
clipper: ButtonDialogClipper(), |
||||
|
child: Material( |
||||
|
type: MaterialType.transparency, |
||||
|
child: MyInkwell( |
||||
|
onTap: onTap, |
||||
|
child: Ink( |
||||
|
height: height, |
||||
|
color: color, |
||||
|
child: Center( |
||||
|
child: child, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
class ButtonDialogClipper extends CustomClipper<Path> { |
||||
|
@override |
||||
|
Path getClip(Size size) { |
||||
|
final path = Path(); |
||||
|
path.moveTo(size.width * 0.01841077, size.height * 0.8753694); |
||||
|
path.cubicTo( |
||||
|
size.width * 0.05368083, |
||||
|
size.height * 1.03396, |
||||
|
size.width * 0.888405, |
||||
|
size.height * 1.04665, |
||||
|
size.width * 0.961125, |
||||
|
size.height * 0.881918); |
||||
|
path.cubicTo( |
||||
|
size.width * 1.02749, |
||||
|
size.height * 0.732121, |
||||
|
size.width * 1.00029, |
||||
|
size.height * 0.195965, |
||||
|
size.width * 0.943774, |
||||
|
size.height * 0.0891425); |
||||
|
path.cubicTo( |
||||
|
size.width * 0.866786, |
||||
|
size.height * -0.0565611, |
||||
|
size.width * 0.122135, |
||||
|
size.height * -0.00478720, |
||||
|
size.width * 0.0598435, |
||||
|
size.height * 0.109607); |
||||
|
path.cubicTo( |
||||
|
size.width * 0.00172381, |
||||
|
size.height * 0.216429, |
||||
|
size.width * -0.0181157, |
||||
|
size.height * 0.711249, |
||||
|
size.width * 0.01841077, |
||||
|
size.height * 0.8753694); |
||||
|
path.close(); |
||||
|
return path; |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
bool shouldReclip(CustomClipper<Path> oldClipper) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_audios.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/constants/my_constants.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/services/audio_service.dart'; |
||||
|
import 'package:hadi_hoda_flutter/init_bindings.dart'; |
||||
|
|
||||
|
class MyInkwell extends StatefulWidget { |
||||
|
const MyInkwell({ |
||||
|
super.key, |
||||
|
this.onTap, |
||||
|
this.child, |
||||
|
this.borderRadius, |
||||
|
this.highlightColor, |
||||
|
this.splashColor, |
||||
|
}); |
||||
|
|
||||
|
final VoidCallback? onTap; |
||||
|
final Widget? child; |
||||
|
final BorderRadius? borderRadius; |
||||
|
final Color? highlightColor; |
||||
|
final Color? splashColor; |
||||
|
|
||||
|
@override |
||||
|
State<MyInkwell> createState() => _MyInkwellState(); |
||||
|
} |
||||
|
|
||||
|
class _MyInkwellState extends State<MyInkwell> { |
||||
|
final AudioService audioService = locator( |
||||
|
instanceName: MyConstants.effectAudioService, |
||||
|
); |
||||
|
|
||||
|
@override |
||||
|
void initState() { |
||||
|
super.initState(); |
||||
|
} |
||||
|
|
||||
|
void playAudio() { |
||||
|
audioService.setAudio(assetPath: MyAudios.clickButton); |
||||
|
audioService.play(); |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return InkWell( |
||||
|
onTap: () { |
||||
|
playAudio(); |
||||
|
widget.onTap?.call(); |
||||
|
}, |
||||
|
borderRadius: widget.borderRadius, |
||||
|
highlightColor: widget.highlightColor, |
||||
|
splashColor: widget.splashColor, |
||||
|
child: widget.child, |
||||
|
); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue