diff --git a/lib/Core/main.dart b/lib/Core/main.dart index 64b4685..1a5387e 100644 --- a/lib/Core/main.dart +++ b/lib/Core/main.dart @@ -1,7 +1,9 @@ // ignore_for_file: prefer_const_constructors, unnecessary_import +import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hive_flutter/hive_flutter.dart'; +import '../Constant/constant.dart'; import '../Layouts/Pages/page_home.dart'; import '../Layouts/Pages/page_start_screen.dart'; @@ -14,11 +16,59 @@ void main() async{ )); } -class MyApp extends StatelessWidget { +class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + + @override + void initState(){ + super.initState(); + + setAudio(); + + audioPlayer.onPlayerStateChanged.listen((state) { + setState(() { + isPlaying = state == PlayerState.PLAYING; + }); + }); + + audioPlayer.onDurationChanged.listen((newDuration) { + setState(() { + duration = newDuration; + }); + }); + + audioPlayer.onAudioPositionChanged.listen((newPosition) { + setState(() { + position = newPosition ; + }); + }); + + if (isPlaying == false) { + audioPlayer.resume(); + } + } + + Future setAudio() async{ + audioPlayer.setReleaseMode(ReleaseMode.LOOP); + final player = AudioCache(prefix: 'assets/audio/'); + final url = await player.load('backgroundAudio.mp3'); + audioPlayer.setUrl(url.path,isLocal: true); + } + + @override + void dispose(){ + audioPlayer.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - // TODO: Force the Screen to be portrait SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, @@ -28,4 +78,6 @@ class MyApp extends StatelessWidget { } + + \ No newline at end of file diff --git a/lib/Layouts/Pages/page_RateUs.dart b/lib/Layouts/Pages/page_RateUs.dart new file mode 100644 index 0000000..8f268aa --- /dev/null +++ b/lib/Layouts/Pages/page_RateUs.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:rating_dialog/rating_dialog.dart'; +import 'package:flappy_bird/Constant/constant.dart'; + + +class RateUs extends StatelessWidget { + RateUs({Key? key}) : super(key: key); + double rating = 4.0; + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: background(im), + child: RatingDialog( title: Text(" Rate Us", style: TextStyle(fontSize: 25,fontFamily: "Magic4",color: Colors.blueAccent,)), + // message: Text(" Tap to start Rating "), + image: Icon(Icons.star,size: 100,color: Colors.red), + submitButtonText: 'Submit', + onSubmitted: (response) + { + print('onSubmitPressed: rating = ${response.rating}'); + print('Comment :${response.comment}'); + }))); + + + + } +} + diff --git a/lib/Layouts/Pages/page_leader_board.dart b/lib/Layouts/Pages/page_leader_board.dart deleted file mode 100644 index ff629f0..0000000 --- a/lib/Layouts/Pages/page_leader_board.dart +++ /dev/null @@ -1,96 +0,0 @@ -// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, avoid_unnecessary_containers, avoid_print - -import 'package:flappy_bird/Constant/constant.dart'; -import 'package:flappy_bird/Layouts/Pages/page_share_app.dart'; -import 'package:flutter/material.dart'; -import 'package:hive_flutter/hive_flutter.dart'; - -import '../../Database/database.dart'; - -class LeaderBoard extends StatefulWidget { - const LeaderBoard({Key? key}) : super(key: key); - - @override - State createState() => _LeaderBoardState(); -} - -class _LeaderBoardState extends State { - @override - Widget build(BuildContext context) { - try { - TOP_SCORE = read(1); - }catch(error){ - print('$error'); - } - return Scaffold( - body: Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - decoration: background(im), - child: Column( - children: [ - Expanded(flex: 1, child: Container( - margin: EdgeInsets.only(top: 20,left: 8), - child: Row( - children: [ - IconButton(onPressed: (){ - Navigator.pop(context); - }, icon: Icon(Icons.arrow_back_ios_rounded,color: Colors.white,)) - ], - ), - ),), - Expanded( - flex: 4, - child: Container( - width: MediaQuery.of(context).size.width * 0.78, - height: MediaQuery.of(context).size.height * 0.3, - margin: EdgeInsets.symmetric(horizontal: 16), - padding: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: Colors.black, width: 2), - color: Colors.white54,boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.6),blurRadius: 1.0,offset: Offset(5,5))]), - child: Column( - children: [ - Text("Leader Board",style: TextStyle(fontSize: 35,fontFamily: "Magic4")), - SizedBox( - width: MediaQuery.of(context).size.width * 0.6, - height: MediaQuery.of(context).size.height * 0.57, - child: ListView.builder(itemBuilder: (context, index) { - return Column( - children: [ - Container( - child:Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("Mohab",style: TextStyle(fontSize: 25,fontFamily: "Magic4")), - Text("Score : $TOP_SCORE",style: TextStyle(fontSize: 25,fontFamily: "Magic4")), - ], - ), - ), - Divider(thickness: 3,) - ], - ); - },), - ) - ], - ), - ), - ), - Expanded(flex: 1, child: Container( - margin: EdgeInsets.symmetric(vertical: 40), - width: 120, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: Colors.cyan.shade300, - ), - onPressed: (){ - Navigator.push(context, MaterialPageRoute(builder: (context) => ShareApp(),),); - }, child: Icon(Icons.share_rounded,size: 30,), ), - )), - ], - ), - ), - ); - } -} diff --git a/lib/Layouts/Pages/page_settings.dart b/lib/Layouts/Pages/page_settings.dart index bb3f560..2cdad46 100644 --- a/lib/Layouts/Pages/page_settings.dart +++ b/lib/Layouts/Pages/page_settings.dart @@ -14,47 +14,7 @@ class Settings extends StatefulWidget { } class _SettingsState extends State { - @override - void initState(){ - super.initState(); - - setAudio(); - - audioPlayer.onPlayerStateChanged.listen((state) { - setState(() { - isPlaying = state == PlayerState.PLAYING; - }); - }); - - audioPlayer.onDurationChanged.listen((newDuration) { - setState(() { - duration = newDuration; - }); - }); - - audioPlayer.onAudioPositionChanged.listen((newPosition) { - setState(() { - position = newPosition ; - }); - }); - - } - - Future setAudio() async{ - audioPlayer.setReleaseMode(ReleaseMode.LOOP); - final player = AudioCache(prefix: 'assets/audio/'); - final url = await player.load('backgroundAudio.mp3'); - - audioPlayer.setUrl(url.path,isLocal: true); - } - - @override - - void dispose(){ - audioPlayer.dispose(); - super.dispose(); - } @override Widget build(BuildContext context) { return Scaffold( @@ -68,9 +28,7 @@ class _SettingsState extends State { margin: EdgeInsets.only(top: 20,left: 8), child: Row( children: [ - IconButton(onPressed: (){ - Navigator.pop(context); - }, icon: Icon(Icons.arrow_back_ios_rounded,color: Colors.white,)) + ], ), ),), @@ -130,6 +88,7 @@ class _SettingsState extends State { GestureDetector(onTap: () async { //TODO: play Music + isPlaying = false; if (isPlaying == false) { await audioPlayer.resume(); @@ -137,7 +96,7 @@ class _SettingsState extends State { },child: Icon(Icons.music_note_rounded,size: 40,)), GestureDetector(onTap: () async - { + { isPlaying = true; //TODO: play Music if (isPlaying == true) { await audioPlayer.pause(); @@ -173,10 +132,7 @@ class _SettingsState extends State { style: ElevatedButton.styleFrom( primary: Colors.cyan.shade300, ), - onPressed: () async { - if (isPlaying == true) { - await audioPlayer.pause(); - } + onPressed: () { writeBackground(0, im); Navigator.push(context, MaterialPageRoute(builder: (context) => StartScreen(),),); }, child: Text("Apply",style: TextStyle(fontFamily: "Magic4",fontSize: 30),) ), diff --git a/lib/Layouts/Pages/page_share_app.dart b/lib/Layouts/Pages/page_share_app.dart deleted file mode 100644 index 08ea692..0000000 --- a/lib/Layouts/Pages/page_share_app.dart +++ /dev/null @@ -1,183 +0,0 @@ -// ignore_for_file: prefer_const_constructors, avoid_print - -import 'dart:async'; - -import 'package:flappy_bird/Layouts/web/web_email.dart'; -import 'package:flutter/material.dart'; -import 'dart:io'; -import 'package:webview_flutter/webview_flutter.dart'; -import '../web/web_facebook.dart'; -import '../web/web_email.dart'; -import '../web/web_instagram.dart'; -import '../web/web_whatsapp.dart'; - -final backgroundColors = [ - Color(0XFF8122BF), - Color(0XFFCA32F5), - Color(0XFFF2B634), -]; - -class ShareApp extends StatefulWidget { - const ShareApp({Key? key}) : super(key: key); - - @override - State createState() => _ShareAppState(); -} - -class _ShareAppState extends State { - - @override - void initState() { - super.initState(); - // Enable hybrid composition. - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); - } - - @override - Widget build(BuildContext context) { - return Theme( - data: ThemeData.light(), - child: DecoratedBox( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: backgroundColors, - )), - child: Scaffold( - backgroundColor: Colors.transparent, - body: Center( - child: SocialShareButton(children: [ - IconButton( - onPressed: () { - print('Icon 1'); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => whatsapp()), - ); - }, icon: Icon(Icons.whatsapp)), - IconButton( - onPressed: () { - print('Icon 2'); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => email()), - ); - }, icon: Icon(Icons.email_outlined)), - IconButton( - onPressed: () { - print('Icon 3'); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => facebook()), - ); - }, icon: Icon(Icons.facebook)), - IconButton( - onPressed: () { - print('Icon 4'); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => instagram()), - ); - }, icon: Icon(Icons.camera_alt)) - ],), - )))); - } -} - -class SocialShareButton extends StatefulWidget { - - SocialShareButton({Key? key, this.height = 100, required this.children, this.buttonColor = Colors.black, this.childrenColor = Colors.white, this.buttonLabel =' SHARE'}) : super(key: key); - final double height; - final List children; - final Color buttonColor; - final Color childrenColor; - final String buttonLabel ; - - final _buttonkey = GlobalKey(); - double _buttonWidth = 0.0; - - @override - State createState() => _SocialShareButtonState(); -} -class _SocialShareButtonState extends State { - - final double height =100; - - final _buttonkey = GlobalKey(); - double _buttonWidth = 0.0; - bool _expanded = false; - - @override - void initState() { - WidgetsBinding.instance.addPostFrameCallback((_) { - setState(() { - _buttonWidth =_buttonkey.currentContext!.size!.width + 14; - }); - }); - super.initState(); - } - Widget _buildBottomWidget(){ - final borderRadius = BorderRadius.circular(8); - return Material( - elevation: 5, - color: widget.buttonColor, - shape: RoundedRectangleBorder( - borderRadius: borderRadius , - ), - child: InkWell( - onTap: (){ - setState(() { - _expanded =! _expanded; - }); - }, - borderRadius: borderRadius, - child:Container( - - width: _buttonWidth, - height: widget.height/2, - alignment: Alignment.center, - child: Text( widget.buttonLabel , textAlign: TextAlign.center,style: - TextStyle(color: Colors.white,fontSize: 18,fontWeight: FontWeight.bold), - ) - ))); - } - - Widget _buildTopWidget(){ - - return Container( - decoration: BoxDecoration( - color: widget.childrenColor, - borderRadius: BorderRadius.vertical(top: Radius.circular(25)) - ), - - height: height / 2, - child: Row( - mainAxisSize: MainAxisSize.min, - key: _buttonkey, - children: widget.children, - - ), - ); - } - - - @override - Widget build(BuildContext context) { -final movement = widget.height/4; - return TweenAnimationBuilder( - tween: !_expanded? Tween(begin: 0.0, end: 1.0): Tween(begin: 1.0, end: 0.0), - duration: _buttonWidth ==0 ? const Duration(milliseconds: 1) :const Duration(milliseconds: 400 ), - builder:(context, value,_){ - return Container( - height: widget.height, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Transform.translate(offset: Offset(0.0,movement * value ),child:_buildTopWidget()), - Transform.translate(offset: Offset(0.0, - movement * value ),child: _buildBottomWidget() - - ) ], - ), - ); - - });} -} diff --git a/lib/Layouts/Pages/page_start_screen.dart b/lib/Layouts/Pages/page_start_screen.dart index 0f22285..98066a5 100644 --- a/lib/Layouts/Pages/page_start_screen.dart +++ b/lib/Layouts/Pages/page_start_screen.dart @@ -1,10 +1,11 @@ // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, prefer_const_constructors_in_immutables import 'package:flappy_bird/Constant/constant.dart'; -import 'package:flappy_bird/Layouts/Pages/page_share_app.dart'; import 'package:flappy_bird/Layouts/Widgets/widget_alert.dart'; import 'package:flappy_bird/Layouts/Widgets/widget_bird.dart'; import 'package:flutter/material.dart'; import '../Widgets/widget_Button.dart'; +import '../Pages/page_RateUs.dart'; +import 'package:rating_dialog/rating_dialog.dart'; class StartScreen extends StatefulWidget { const StartScreen({Key? key}) : super(key: key); @@ -40,7 +41,7 @@ class _StartScreenState extends State { children: [ SizedBox(width: 8,), Button(height: 60,width: 110,icon: Icon(Icons.settings,size: 40,color: Colors.grey.shade900,),type: Navigation.settings.name,), - Button(height: 60,width: 110,icon: Icon(Icons.leaderboard_rounded,size: 40,color: Colors.deepOrange,),type: Navigation.leaderBord.name,), + Button(height: 60,width: 110,icon: Icon(Icons.star,size: 40,color: Colors.deepOrange,),type: Navigation.leaderBord.name,), SizedBox(width: 8,), ], ), @@ -48,12 +49,6 @@ class _StartScreenState extends State { ),), Expanded(flex: 2, child: SizedBox()), Expanded(flex: 1, child: InkWell(onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ShareApp(), - ), - ); },child: GestureDetector(onTap: (){ showDialog(context: context, builder: (context) { return Alert(); diff --git a/lib/Layouts/Widgets/widget_Button.dart b/lib/Layouts/Widgets/widget_Button.dart index 49d7a0b..f2a13b4 100644 --- a/lib/Layouts/Widgets/widget_Button.dart +++ b/lib/Layouts/Widgets/widget_Button.dart @@ -1,11 +1,12 @@ // ignore_for_file: prefer_const_constructors, prefer_const_constructors_in_immutables import 'package:flappy_bird/Constant/constant.dart'; -import 'package:flappy_bird/Layouts/Pages/page_share_app.dart'; +import 'package:flappy_bird/Layouts/Pages/page_RateUs.dart'; import 'package:flutter/material.dart'; import '../Pages/page_home.dart'; -import '../Pages/page_leader_board.dart'; import '../Pages/page_settings.dart'; +import '../Pages/page_RateUs.dart'; + class Button extends StatelessWidget { Icon? icon; @@ -57,9 +58,11 @@ class Button extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => LeaderBoard(), + builder: (context) => RateUs(), ), ); + + } }, ); diff --git a/pubspec.lock b/pubspec.lock index 88c9ce7..d9b8949 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -237,6 +237,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + flutter_rating_bar: + dependency: transitive + description: + name: flutter_rating_bar + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" flutter_switch: dependency: "direct main" description: @@ -506,6 +513,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + rating_dialog: + dependency: "direct main" + description: + name: rating_dialog + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" shelf: dependency: transitive description: @@ -525,6 +539,20 @@ packages: description: flutter source: sdk version: "0.0.99" + smooth_star_rating: + dependency: "direct main" + description: + name: smooth_star_rating + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + smooth_star_rating_null_safety: + dependency: "direct main" + description: + name: smooth_star_rating_null_safety + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4+2" source_gen: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d02a3ed..2d2637b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,6 +45,9 @@ dependencies: path_provider: ^2.0.3 url_launcher: ^6.1.5 webview_flutter: ^2.0.2 + smooth_star_rating: ^1.0.4+2 + rating_dialog: + smooth_star_rating_null_safety: ^1.0.4+2 dev_dependencies: flutter_test: