From 15d80da2e45e730047326e42563018db444140ef Mon Sep 17 00:00:00 2001 From: hab Date: Tue, 30 Aug 2022 22:30:11 +0200 Subject: [PATCH] create leaderboard score update setting --- lib/Layouts/Pages/page_leader_board.dart | 93 ++++++++ lib/Layouts/Pages/page_settings.dart | 289 +++++++---------------- lib/Layouts/Pages/page_share_app.dart | 3 - lib/Layouts/Widgets/widget_Button.dart | 3 +- 4 files changed, 177 insertions(+), 211 deletions(-) create mode 100644 lib/Layouts/Pages/page_leader_board.dart diff --git a/lib/Layouts/Pages/page_leader_board.dart b/lib/Layouts/Pages/page_leader_board.dart new file mode 100644 index 0000000..a8bc2ac --- /dev/null +++ b/lib/Layouts/Pages/page_leader_board.dart @@ -0,0 +1,93 @@ +// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, avoid_unnecessary_containers + +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'; + +class LeaderBoard extends StatefulWidget { + const LeaderBoard({Key? key}) : super(key: key); + + @override + State createState() => _LeaderBoardState(); +} + +class _LeaderBoardState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/pics/background-day.png"), + fit: BoxFit.fill), + ), + 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 fd4e27a..6d88785 100644 --- a/lib/Layouts/Pages/page_settings.dart +++ b/lib/Layouts/Pages/page_settings.dart @@ -1,10 +1,7 @@ // ignore_for_file: prefer_const_constructors, sized_box_for_whitespace - -import 'package:audioplayers/audioplayers.dart'; +// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, avoid_unnecessary_containers +import 'package:flappy_bird/Layouts/Pages/page_share_app.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_switch/flutter_switch.dart'; -import 'page_home.dart'; -import '../../constant/constant.dart'; class Settings extends StatefulWidget { const Settings({Key? key}) : super(key: key); @@ -12,217 +9,95 @@ class Settings extends StatefulWidget { @override State createState() => _SettingsState(); } - class _SettingsState extends State { - final audioPlayer = AudioPlayer(); - bool isPlaying = false; - Duration duration = Duration.zero; - Duration position = Duration.zero; - - @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); - - // String url ='https://www.youtube.com/watch?v=qCQOrHxktcA'; - //audioPlayer.setUrl(url); - final player = AudioCache(prefix: 'assets/audio/'); - final url = await player.load('Bones.mp3'); - - audioPlayer.setUrl(url.path, isLocal: true); - } - - @override - void dispose() { - audioPlayer.dispose(); - super.dispose(); - } - @override Widget build(BuildContext context) { return Scaffold( - body: Column( - children: [ - Container( - width: 250, - height: 200, - child: Row( - children: [ - Text( - "THEME ", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), - ), - FlutterSwitch( - width: 125.0, - height: 55.0, - valueFontSize: 25.0, - toggleSize: 45.0, - value: theme, - borderRadius: 30.0, - padding: 8.0, - showOnOff: true, - onToggle: (val) { - setState(() { - theme = val; - }); - }, - ), - Container( - width: 50, - ), - ], - ), + body: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/pics/background-day.png"), + fit: BoxFit.fill), ), - Row( + child: Column( children: [ - Text( - "Characters", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), - ), - IconButton( - onPressed: () { - setState(() { - c = Colors.yellow; - }); - }, - icon: Image.asset("assets/pics/bird.png"), - iconSize: 100, - ), - IconButton( - onPressed: () { - setState(() { - c = Colors.blue; - }); - }, - icon: Image.asset("assets/pics/m.png"), - iconSize: 100, - ), - IconButton( - onPressed: () { - setState(() { - c = Colors.red; - }); - }, - icon: Image.asset("assets/pics/redbird.png"), - iconSize: 100, - ) - ], - ), - Row( - children: [ - Text( - "Difficulty", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), - ), - ButtonBar( - children: [ - ElevatedButton( - onPressed: () { - setState(() { - velocity = 1.0; - }); - }, - style: ElevatedButton.styleFrom( - primary: Colors.white, - onPrimary: Colors.blueGrey, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide(color: Colors.blueGrey))), - child: Text("EASY"), - ), - ElevatedButton( - onPressed: () { - setState(() { - velocity = 2.5; - }); - }, - style: ElevatedButton.styleFrom( - primary: Colors.white, - onPrimary: Colors.blueGrey, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide(color: Colors.blueGrey))), - child: Text("MEDIUM"), - ), - ElevatedButton( - onPressed: () { - setState(() { - velocity = 3.0; - }); - }, - style: ElevatedButton.styleFrom( - primary: Colors.white, - onPrimary: Colors.blueGrey, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide(color: Colors.blueGrey))), - child: Text("HARD"), + 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: Container( + padding: EdgeInsets.only(left: 10), + child: Column( + children: [ + Text("Setting",style: TextStyle(fontSize: 35,fontFamily: "Magic4")), + SizedBox(height: 50,), + Center(child: Text("Characters",style: TextStyle(fontSize: 20,fontFamily: "Magic4")),), + SizedBox(height: 10,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Image.asset("assets/pics/bluebird.png",width: 63,height: 60,), + Image.asset("assets/pics/bluebird.png",width: 63,height: 60,), + Image.asset("assets/pics/redbird.png",width: 63,height: 60,), + ], + ), + Center(child: Text("Themes",style: TextStyle(fontSize: 20,fontFamily: "Magic4")),), + SizedBox(height: 20,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Image.asset("assets/pics/background-day.png",width: 73,height: 70,), + Image.asset("assets/pics/background-night.png",width: 73,height: 70,), + Image.asset("assets/pics/background-after-night.png",width: 63,height: 66,), + ], + ), + SizedBox(height: 20,), + Center(child: Text("Music",style: TextStyle(fontSize: 20,fontFamily: "Magic4")),), + SizedBox(height: 20,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Icon(Icons.music_note_rounded,size: 40,), + Icon(Icons.music_off_rounded,size: 40), + ], + ), + SizedBox(height: 40,), + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: Colors.cyan.shade300, + ), + onPressed: (){ + Navigator.push(context, MaterialPageRoute(builder: (context) => ShareApp(),),); + }, child: Text("Apply",style: TextStyle(fontFamily: "Magic4",fontSize: 30),) ), + + ], + ), ), - ], - ) - ], - ), - SizedBox(height: 30), - Row( - children: [ - Text( - "Sound ", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), - ), - SizedBox(width: 20), - CircleAvatar( - radius: 25, - child: IconButton( - icon: Icon(isPlaying ? Icons.music_note : Icons.music_off), - iconSize: 40, - onPressed: () async { - - if (isPlaying) { - await audioPlayer.pause(); - - } else { - await audioPlayer.resume(); - } - }, ), ), - SizedBox( - width: 70), - ElevatedButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => HomePage()), - );}, - child: Text(" Apply ")) - + Expanded(flex: 1, child: SizedBox(),) ], ), - - ], - )); + ), + ); } -} +} \ No newline at end of file diff --git a/lib/Layouts/Pages/page_share_app.dart b/lib/Layouts/Pages/page_share_app.dart index d3fc974..08ea692 100644 --- a/lib/Layouts/Pages/page_share_app.dart +++ b/lib/Layouts/Pages/page_share_app.dart @@ -92,15 +92,12 @@ class SocialShareButton extends StatefulWidget { 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; diff --git a/lib/Layouts/Widgets/widget_Button.dart b/lib/Layouts/Widgets/widget_Button.dart index 6331aa4..2a5dfa1 100644 --- a/lib/Layouts/Widgets/widget_Button.dart +++ b/lib/Layouts/Widgets/widget_Button.dart @@ -4,6 +4,7 @@ import 'package:flappy_bird/Constant/constant.dart'; import 'package:flappy_bird/Layouts/Pages/page_share_app.dart'; import 'package:flutter/material.dart'; import '../Pages/page_home.dart'; +import '../Pages/page_leader_board.dart'; import '../Pages/page_settings.dart'; class Button extends StatelessWidget { @@ -49,7 +50,7 @@ class Button extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => ShareApp(), + builder: (context) => LeaderBoard(), ), ); }