Skip to content

Commit

Permalink
Merge pull request #12 from SalmaBasem20191743/main
Browse files Browse the repository at this point in the history
Rate Us
  • Loading branch information
moha-b authored Sep 1, 2022
2 parents eaf3bc9 + 0c93085 commit 415d823
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 340 deletions.
56 changes: 54 additions & 2 deletions lib/Core/main.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -14,11 +16,59 @@ void main() async{
));
}

class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

@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,
Expand All @@ -28,4 +78,6 @@ class MyApp extends StatelessWidget {
}





31 changes: 31 additions & 0 deletions lib/Layouts/Pages/page_RateUs.dart
Original file line number Diff line number Diff line change
@@ -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}');
})));



}
}

96 changes: 0 additions & 96 deletions lib/Layouts/Pages/page_leader_board.dart

This file was deleted.

52 changes: 4 additions & 48 deletions lib/Layouts/Pages/page_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,7 @@ class Settings extends StatefulWidget {
}
class _SettingsState extends State<Settings> {

@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(
Expand All @@ -68,9 +28,7 @@ class _SettingsState extends State<Settings> {
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,))

],
),
),),
Expand Down Expand Up @@ -130,14 +88,15 @@ class _SettingsState extends State<Settings> {
GestureDetector(onTap: () async
{
//TODO: play Music
isPlaying = false;
if (isPlaying == false)
{
await audioPlayer.resume();
}

},child: Icon(Icons.music_note_rounded,size: 40,)),
GestureDetector(onTap: () async
{
{ isPlaying = true;
//TODO: play Music
if (isPlaying == true) {
await audioPlayer.pause();
Expand Down Expand Up @@ -173,10 +132,7 @@ class _SettingsState extends State<Settings> {
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),) ),
Expand Down
Loading

0 comments on commit 415d823

Please sign in to comment.