Skip to content

Commit

Permalink
navigation solution.
Browse files Browse the repository at this point in the history
  • Loading branch information
yolcura1@gmail.com authored and yolcura1@gmail.com committed Apr 17, 2020
1 parent cd73ba7 commit 89766ba
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 45 deletions.
8 changes: 7 additions & 1 deletion lib/screens/quiz.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:define9/main.dart';
import 'package:define9/shared/finishedprocess.dart';
import 'package:define9/shared/lockprocess.dart';
import 'package:define9/shared/show_alert.dart';
import 'package:define9/shared/tokenprocess.dart';
import 'package:flutter/material.dart';
import '../shared/shared.dart';
Expand Down Expand Up @@ -183,7 +185,11 @@ class QuestionPage extends StatelessWidget {
Widget build(BuildContext context) {
var state = Provider.of<QuizState>(context);
token = Provider.of<Token>(context);

List<TopicFinished> topicFinished = Provider.of<List<TopicFinished>>(context);
if(FinishedProcess.getState().isFinished(topicFinished, quiz.topic))
{
return getAlertDialog( "title", "description");
}
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expand Down
36 changes: 4 additions & 32 deletions lib/screens/topics.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:define9/shared/finishedprocess.dart';
import 'package:define9/shared/lockprocess.dart';
import 'package:define9/shared/show_alert.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';

import '../screens/screens.dart';
import '../services/services.dart';
import '../shared/shared.dart';
import '../screens/screens.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class TopicsScreen extends StatelessWidget {
@override
Expand Down Expand Up @@ -46,35 +47,6 @@ class TopicsScreen extends StatelessWidget {
}
}

showAlertDialog(BuildContext context, var title, var description) {
// set up the buttons
Widget remindButton = FlatButton(
child: Text("Devam"),
onPressed: () {
Navigator.pop(context);
},
);

// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text(
title,
),
content:
Text(description),
actions: [
remindButton,
],
);

// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}

class TopicItem extends StatelessWidget {
final Topic topic;
Expand Down
15 changes: 3 additions & 12 deletions lib/shared/finishedprocess.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,15 @@ class FinishedProcess{
}
/// Database write to update quiz information if it is finished
Future<void> updateTopicFinished(topic) {
Global.lockReportRef.upsert(
({


'${topic}': { 'title': topic}

}),
);
checkLock(topic);
}
checkLock(topic){
Global.lockReportRef.getDocument().then((snapshot) {
if(isFinished(snapshot, topic)){
checkLock(topicFinished, topic){
if(isFinished(topicFinished, topic)){

navigatorKey.currentState.pushNamed("/topics");

}
});

}

}
62 changes: 62 additions & 0 deletions lib/shared/show_alert.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../main.dart';

showAlertDialog(BuildContext context, var title, var description) {
// set up the buttons
Widget remindButton = FlatButton(
child: Text("Devam"),
onPressed: () {
Navigator.pop(context);
},
);

// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text(
title,
),
content:
Text(description),
actions: [
remindButton,
],
);

// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}


getAlertDialog(var title, var description) {
// set up the buttons
Widget remindButton = FlatButton(
child: Text("Devam"),
onPressed: () {
navigatorKey.currentState.pushNamed("/topics");

},
);

// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text(
title,
),
content:
Text(description),
actions: [
remindButton,
],
);


return alert;

}

0 comments on commit 89766ba

Please sign in to comment.