NEW: MIH MineSweeper Package pt2

This commit is contained in:
2025-10-29 13:06:55 +02:00
parent f548db7d82
commit 23c3cf4173
19 changed files with 1805 additions and 146 deletions

View File

@@ -0,0 +1,42 @@
class MinesweeperPlayerScore {
String app_id;
String username;
String proPicUrl;
String difficulty;
String game_time;
double game_score;
DateTime played_date;
MinesweeperPlayerScore({
required this.app_id,
required this.username,
required this.proPicUrl,
required this.difficulty,
required this.game_time,
required this.game_score,
required this.played_date,
});
factory MinesweeperPlayerScore.fromJson(Map<String, dynamic> json) {
return MinesweeperPlayerScore(
app_id: json['app_id'],
username: json['username'],
proPicUrl: json['proPicUrl'],
difficulty: json['difficulty'],
game_time: json['game_time'],
game_score: json['game_score'],
played_date: DateTime.parse(json['played_date']),
);
}
Map<String, dynamic> toJson() {
return {
'app_id': app_id,
'username': username,
'proPicUrl': proPicUrl,
'difficulty': difficulty,
'game_time': game_score,
'played_date': played_date.toIso8601String(),
};
}
}

View File

@@ -10,6 +10,7 @@ class MihDropdownField extends StatefulWidget {
final bool editable;
final bool enableSearch;
final FormFieldValidator<String>? validator;
final Function(String?)? onSelected;
const MihDropdownField({
super.key,
@@ -20,6 +21,7 @@ class MihDropdownField extends StatefulWidget {
required this.editable,
required this.enableSearch,
this.validator,
this.onSelected,
});
@override
@@ -153,6 +155,7 @@ class _MihDropdownFieldState extends State<MihDropdownField> {
),
onSelected: (String? selectedValue) {
field.didChange(selectedValue);
widget.onSelected?.call(selectedValue);
},
menuStyle: MenuStyle(
backgroundColor: WidgetStatePropertyAll(

View File

@@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/minesweeper_player_score.dart';
class MihMineSweeperProvider extends ChangeNotifier {
String difficulty;
@@ -6,9 +7,12 @@ class MihMineSweeperProvider extends ChangeNotifier {
int rowCount;
int columnCount;
int totalMines;
List<MinesweeperPlayerScore>? leaderboard;
List<MinesweeperPlayerScore>? myScoreboard;
List<ImageProvider<Object>?> leaderboardUserPictures = [];
MihMineSweeperProvider({
this.difficulty = "Normal",
this.difficulty = "Easy",
this.toolIndex = 0,
this.rowCount = 10,
this.columnCount = 10,
@@ -16,7 +20,7 @@ class MihMineSweeperProvider extends ChangeNotifier {
});
void reset() {
difficulty = "Normal";
difficulty = "Easy";
toolIndex = 0;
rowCount = 10;
columnCount = 10;
@@ -48,4 +52,30 @@ class MihMineSweeperProvider extends ChangeNotifier {
this.totalMines = totalMines;
notifyListeners();
}
void setLeaderboard({required List<MinesweeperPlayerScore>? leaderboard}) {
if (leaderboard == null) {
this.leaderboard = [];
} else {
this.leaderboard = leaderboard;
}
notifyListeners();
}
void setMyScoreboard({
required List<MinesweeperPlayerScore>? myScoreboard,
}) {
if (myScoreboard == null) {
this.myScoreboard = [];
} else {
this.myScoreboard = myScoreboard;
}
notifyListeners();
}
void setLeaderboardUserPictures(
{required List<ImageProvider<Object>?> leaderboardUserPictures}) {
this.leaderboardUserPictures = leaderboardUserPictures;
notifyListeners();
}
}