Skip to content

Commit

Permalink
Merge pull request #27 from mikyll/feature/web
Browse files Browse the repository at this point in the history
feat: web support
  • Loading branch information
mikyll authored Nov 13, 2024
2 parents 8246b2e + 4b2d7c9 commit b5c712f
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 149 deletions.
4 changes: 4 additions & 0 deletions app-mobile/flutter_application/lib/model/AppUpdater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class AppUpdater {
String newVersion = "";
String newVersionDownloadURL = "";

if (getPlatformType() == PlatformType.WEB) {
return (newVersionPresent, newVersion, newVersionDownloadURL);
}

http.Response response = await http.get(Uri.parse(
'https://api.github.com/repos/mikyll/ROQuiz/releases/latest'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class QuestionRepository {

/// Returns true if there is a more recent questions file
Future<(bool, DateTime, int)> checkQuestionUpdates() async {
if (getPlatformType() == PlatformType.MOBILE) {
return (false, DateTime.now(), 0);
}

DateTime date = await getLatestQuestionFileDate();
String content = await downloadFile();
int qNum = isValid(content);
Expand Down
306 changes: 157 additions & 149 deletions app-mobile/flutter_application/lib/views/ViewSettings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:roquiz/model/AppUpdater.dart';
import 'package:roquiz/model/PlatformType.dart';
import 'package:roquiz/model/Utils.dart';
import 'package:roquiz/persistence/QuestionRepository.dart';
import 'package:roquiz/persistence/Settings.dart';
Expand Down Expand Up @@ -526,164 +527,171 @@ class ViewSettingsState extends State<ViewSettings> {
primary: false,
children: [
// SETTING: New App Version Check
Row(
children: [
IconButtonWidget(
onTap: _isLoading
? null
: () {
_checkNewVersion();
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.sync_rounded,
iconSize: 35,
borderRadius: 5,
),
const SizedBox(width: 10),
Expanded(
child: InkWell(
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onDoubleTap: () {
_resetCheckAppUpdate();
},
child: const Text(
"Controllo nuove versioni app: ",
maxLines: 3,
softWrap: true,
style: TextStyle(fontSize: 20),
),
),
),
SizedBox(
width: 120.0,
child: Transform.scale(
scale: 1.5,
child: Checkbox(
value: _checkAppUpdate,
onChanged: (bool? value) =>
_selectCheckAppUpdate(value!),
getPlatformType() == PlatformType.WEB
? const SizedBox.shrink()
: Row(
children: [
IconButtonWidget(
onTap: _isLoading
? null
: () {
_checkNewVersion();
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.sync_rounded,
iconSize: 35,
borderRadius: 5,
),
))
],
),
const SizedBox(width: 10),
Expanded(
child: InkWell(
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onDoubleTap: () {
_resetCheckAppUpdate();
},
child: const Text(
"Controllo nuove versioni app: ",
maxLines: 3,
softWrap: true,
style: TextStyle(fontSize: 20),
),
),
),
SizedBox(
width: 120.0,
child: Transform.scale(
scale: 1.5,
child: Checkbox(
value: _checkAppUpdate,
onChanged: (bool? value) =>
_selectCheckAppUpdate(value!),
),
))
],
),
const SizedBox(height: 20),
// SETTING: New Questions Check
Row(
children: [
IconButtonWidget(
onTap: _isLoading
? null
: () {
_checkNewQuestions();
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.sync_rounded,
iconSize: 35,
borderRadius: 5,
),
const SizedBox(width: 10),
Expanded(
child: InkWell(
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onDoubleTap: () {
_resetCheckQuestionsUpdate();
},
child: const Text(
"Controllo nuove domande: ",
maxLines: 3,
softWrap: true,
style: TextStyle(fontSize: 20),
),
getPlatformType() == PlatformType.WEB
? const SizedBox.shrink()
: Row(
children: [
IconButtonWidget(
onTap: _isLoading
? null
: () {
_checkNewQuestions();
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.sync_rounded,
iconSize: 35,
borderRadius: 5,
),
const SizedBox(width: 10),
Expanded(
child: InkWell(
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onDoubleTap: () {
_resetCheckQuestionsUpdate();
},
child: const Text(
"Controllo nuove domande: ",
maxLines: 3,
softWrap: true,
style: TextStyle(fontSize: 20),
),
),
),
SizedBox(
width: 120.0,
child: Transform.scale(
scale: 1.5,
child: Checkbox(
value: _checkQuestionsUpdate,
onChanged: (bool? value) =>
_selectCheckQuestionsUpdate(value!)),
))
],
),
),
SizedBox(
width: 120.0,
child: Transform.scale(
scale: 1.5,
child: Checkbox(
value: _checkQuestionsUpdate,
onChanged: (bool? value) =>
_selectCheckQuestionsUpdate(value!)),
))
],
),
const SizedBox(height: 20),
// SETTING: Questions File
Row(
children: [
const Expanded(
child: Text(
"File domande: ",
maxLines: 2,
style: TextStyle(fontSize: 20),
),
),
const SizedBox(width: 5.0),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: SizedBox(
width: 100.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButtonWidget(
tooltip: _isLoading ? null : "Modifica",
onTap: _isLoading
? null
: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ViewEdit(
qRepo: widget.qRepo,
settings: widget.settings,
reloadTopics: widget.reloadTopics,
updateQuizDefaults:
_updateQuizDefaults,
),
),
);
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.edit,
iconSize: 35,
borderRadius: 5,
getPlatformType() == PlatformType.WEB
? const SizedBox.shrink()
: Row(
children: [
const Expanded(
child: Text(
"File domande: ",
maxLines: 2,
style: TextStyle(fontSize: 20),
),
const Spacer(flex: 1),
IconButtonWidget(
tooltip: _isLoading ? null : "Carica un file",
onTap: _isLoading
? null
: () {
_loadQuestionFilePath();
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.file_open_outlined,
iconSize: 35,
borderRadius: 5,
),
const SizedBox(width: 5.0),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: SizedBox(
width: 100.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButtonWidget(
tooltip: _isLoading ? null : "Modifica",
onTap: _isLoading
? null
: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ViewEdit(
qRepo: widget.qRepo,
settings: widget.settings,
reloadTopics:
widget.reloadTopics,
updateQuizDefaults:
_updateQuizDefaults,
),
),
);
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.edit,
iconSize: 35,
borderRadius: 5,
),
const Spacer(flex: 1),
IconButtonWidget(
tooltip: _isLoading ? null : "Carica un file",
onTap: _isLoading
? null
: () {
_loadQuestionFilePath();
},
lightPalette: MyThemes.lightIconButtonPalette,
darkPalette: MyThemes.darkIconButtonPalette,
width: 40.0,
height: 40.0,
icon: Icons.file_open_outlined,
iconSize: 35,
borderRadius: 5,
),
],
),
),
],
),
),
],
),
),
],
),
const SizedBox(height: 20),
// SETTING: USE MAX NUMBER OF QUESTIONS FOR EACH TOPIC
Row(
Expand Down

0 comments on commit b5c712f

Please sign in to comment.