Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/data/nollning_26/uppdrag/clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/done_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/ej_vald.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_done.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_locked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/knapp_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/pixelart_resa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/pixelart_spel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/pixelart_älg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/rubrik1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/rubrik2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/data/nollning_26/uppdrag/vald.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fonts/LoRes12OT-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/PressStart2P-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/VT323-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/consolas.ttf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The font consolas already exists in the nollning branch.

Binary file not shown.
15 changes: 14 additions & 1 deletion lib/screens/home/nollningHome26.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,20 @@ class _NollningHomePageState extends State<NollningHomePage> {
Container(
width: screenWidth / buttonSize,
child: InkWell(
onTap: () => (Navigator.push(context, MaterialPageRoute(builder: (context) => QuestHomeScreen()))),
// onTap: () => (Navigator.push(context, MaterialPageRoute(builder: (context) => QuestHomeScreen()))),
onTap: () => {showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(t.localeName == "sv" ? "Stopp!" : "Stop!"),
content: Text(t.localeName == "sv"
? "Uppdragen kommer att släppas snart! (men inte än)"
: "The quests will be released soon! (but not yet)"),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text("OK"))
],
))},
child: generateButton(buttonImage, "Side\nQuest"),
),
)
Expand Down
221 changes: 221 additions & 0 deletions lib/screens/nollning/questscreen_26/highscore.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
import 'package:flutter/material.dart';
import 'package:fsek_mobile/api_client/lib/api_client.dart';
import 'package:fsek_mobile/services/api.service.dart';
import 'package:fsek_mobile/l10n/app_localizations.dart';

class HighscoreScreen extends StatefulWidget {
final double availableWidth;
final double availableHeight;

HighscoreScreen({
required this.availableHeight,
required this.availableWidth,
});

@override
_HighscoreScreenState createState() => _HighscoreScreenState();
}

class _HighscoreScreenState extends State<HighscoreScreen> {
Map<NollningGroupRead, int> groupPointsMap = {};
NollningRead? nollning;

String avklarad = "assets/data/nollning_25/uppdrag/bricka-avklarad.png";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should copy required files from nollning_25 to nollning_26 since we're later removing nollning_25 from pubspec?

String bedomning = "assets/data/nollning_25/uppdrag/bricka-bedomning.png";
String misslyckad = "assets/data/nollning_25/uppdrag/bricka-misslyckad.png";
String start = "assets/data/nollning_25/uppdrag/bricka-start.png";
String rubrik = "assets/data/nollning_25/uppdrag/rubrik.png";

@override
void initState() {
super.initState();
_loadInitData();
}

@override
void dispose() {
super.dispose();
}

void _loadInitData() async {
final nollningResponse = await ApiService.apiClient
.getNollningApi()
.nollningGetNollningByYear(year: DateTime.now().year);
final nollningData = nollningResponse.data;

if (nollningData != null) {
List<NollningGroupRead> mentorGroups = nollningData.nollningGroups
.where((group) => group.group.groupType.name == "mentor")
.toList();
for (final nollningGroup in mentorGroups) {
final groupMissions = await ApiService.apiClient
.getNollningApi()
.nollningGetGroupMissionsFromNollningGroup(
nollningGroupId: nollningGroup.id,
);

int totalPoints = 0;
if (groupMissions.data != null && groupMissions.data!.isNotEmpty) {
for (final gm in groupMissions.data!.toList()) {
if (gm.isAccepted == "Accepted") {
totalPoints += gm.points;
}
}
}
groupPointsMap[nollningGroup] = totalPoints;
}
}

setState(() {
this.nollning = nollningData;
});
}

List<Widget> _createHighscoreCards(BuildContext context) {
var t = AppLocalizations.of(context)!;
List<Widget> highscoreCards = [];

Map<NollningGroupRead, int> sortedMap = Map.fromEntries(
groupPointsMap.entries.toList()
..sort((a, b) => b.value.compareTo(a.value)),
);

int pos = 1;

sortedMap.forEach((key, value) {
highscoreCards.add(highscoreCard(key, value, pos, context));
pos++;
});

return highscoreCards;
}

Widget highscoreCard(
NollningGroupRead group,
int points,
int position,
BuildContext context,
) {
var t = AppLocalizations.of(context)!;
return Center(
child: Container(
height: widget.availableHeight / 15,
width: widget.availableWidth - 40,
child: Card(
shadowColor: Colors.transparent,
color: Colors.transparent,
child: Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
child: Text(
position.toString(),
style: TextStyle(
color: _getPositionColor(position),
fontFamily: "LoRes12OT",
fontWeight: FontWeight.w800,
fontSize: widget.availableWidth / 15,
),
),
),
Container(
width: widget.availableWidth / 3,
height: widget.availableHeight / 10,
child: Center(
child: Text(
textAlign: TextAlign.center,
group.group.name.length <= 40
? group.group.name
: group.group.name.substring(0, 20) + "...",
style: TextStyle(
fontFamily: "LoRes12OT",
fontWeight: FontWeight.w600,
fontSize: group.group.name.length <= 10
? widget.availableWidth / 15
: (group.group.name.length <= 20
? widget.availableWidth / 15
: widget.availableWidth / 30),
color: _getPositionColor(position),
),
),
),
),
Center(
child: Text(
_pointsToString(points),
style: TextStyle(
fontFamily: "LoRes12OT",
fontWeight: FontWeight.normal,
fontSize: widget.availableWidth / 15,
color: _getPositionColor(position),
),
),
),
],
),
],
),
),
),
);
}

@override
Widget build(BuildContext context) {
var t = AppLocalizations.of(context)!;

if (this.nollning == null) {
return Center(child: CircularProgressIndicator());
}

return Container(
height: widget.availableHeight,
width: widget.availableWidth,
child: Stack(
children: [
SingleChildScrollView(
child: Column(
children: [
Padding(
padding: EdgeInsets.only(top: widget.availableHeight * 0.01),
child: Text(
"HIGH SCORES",
style: TextStyle(
fontFamily: "LoRes12OT",
fontSize: widget.availableWidth / 10,
color: Colors.white, // justera efter din bakgrund
),
),
),
..._createHighscoreCards(context),
],
),
),
],
),
);
}

Color _getPositionColor(int pos) {
switch (pos % 4) {
case 0:
return Colors.indigo;
case 1:
return Colors.yellow;
case 2:
return Colors.pink;
default:
return Colors.cyan;
}
}

String _pointsToString(int points) {
String pointString = points.toString();
while (pointString.length < 6) {
pointString = "0" + pointString;
}
return pointString;
}
}
121 changes: 101 additions & 20 deletions lib/screens/nollning/questscreen_26/quest_home.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,119 @@
import 'package:flutter/material.dart';
import 'package:fsek_mobile/l10n/app_localizations.dart';
import 'package:fsek_mobile/screens/nollning/questscreen_26/highscore.dart';
import 'package:fsek_mobile/screens/nollning/questscreen_26/quests.dart';

class QuestHomeScreen extends StatefulWidget {
@override
_QuestHomeScreenState createState() => _QuestHomeScreenState();
}

class _QuestHomeScreenState extends State<QuestHomeScreen> {
void initState() {
super.initState();
String rubrik = "assets/data/nollning_26/uppdrag/rubrik1.png";
Color backgroundColor = Color(0xFF00487B);
TabController? _controller;

void _handleTabChange() {
setState(() {
rubrik = _controller!.index == 0
? "assets/data/nollning_26/uppdrag/rubrik1.png"
: "assets/data/nollning_26/uppdrag/rubrik2.png";
backgroundColor = _controller!.index == 0
? Color(0xFF00487B)
: Colors.black;
});
}

@override
Widget build(BuildContext context) {
var t = AppLocalizations.of(context)!;
void dispose() {
_controller?.removeListener(_handleTabChange);
super.dispose();
}

@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;

return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
scrolledUnderElevation: 0.0,
),
body: InteractiveViewer(
panEnabled: true,
child: Container(
height: screenHeight,
width: screenWidth,
child: Align(alignment: Alignment.center, child: Text("Sidequests!")),
),
return DefaultTabController(
length: 2,
child: Builder(
builder: (context) {
final controller = DefaultTabController.of(context);
if (_controller != controller) {
_controller?.removeListener(_handleTabChange);
_controller = controller;
_controller?.addListener(_handleTabChange);
}
return Scaffold(
body: Container(
height: screenHeight,
width: screenWidth,
child: Stack(
children: [
Positioned.fill(child: ColoredBox(color: backgroundColor)),
Column(
children: [
Container(
width: screenWidth,
height: screenHeight / 8,
child: Stack(
children: [
Positioned.fill(
child: Padding(
padding: EdgeInsets.only(
top: screenHeight * 0.03,
bottom: screenHeight * 0.01,
),
child: Image.asset(rubrik, fit: BoxFit.fill),
),
),
Positioned.fill(
child: Row(
children: [
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _controller?.animateTo(0),
),
),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _controller?.animateTo(1),
),
),
],
),
),
],
),
),
Container(
width: screenWidth,
height: screenHeight - (screenHeight / 8),
child: TabBarView(
children: [
QuestScreen(
availableHeight:
screenHeight - (screenHeight / 8),
availableWidth: screenWidth,
),
HighscoreScreen(
availableHeight:
screenHeight - (screenHeight / 8),
availableWidth: screenWidth,
),
],
),
),
],
),
],
),
),
);
},
),
);
}
}
}
Loading