NEW: MIH MineSweeper Package pt4

This commit is contained in:
2025-10-31 11:55:31 +02:00
parent d6f1629485
commit 771d809ce2

View File

@@ -274,7 +274,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
alertBody: Column( alertBody: Column(
children: [ children: [
Text( Text(
"Your lost this game of MIH MineSweeper!!!", "Your lost this game of MIH Minesweeper!!!",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
@@ -405,7 +405,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
alertBody: Column( alertBody: Column(
children: [ children: [
Text( Text(
"Your won this game of MIH MineSweeper!!!", "Your won this game of MIH Minesweeper!!!",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
@@ -565,226 +565,246 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
MihMineSweeperProvider mihMineSweeperProvider, MihMineSweeperProvider mihMineSweeperProvider,
MihBannerAdProvider adProvider, MihBannerAdProvider adProvider,
Widget? child) { Widget? child) {
return Stack( return Column(
alignment: Alignment.topCenter,
children: [ children: [
MihSingleChildScroll( Expanded(
child: board.isEmpty && squaresLeft < 0 child: Stack(
// Start Up Message before setting up game alignment: Alignment.topCenter,
? Padding( children: [
padding: const EdgeInsets.symmetric(horizontal: 10.0), MihSingleChildScroll(
child: Column( child: board.isEmpty && squaresLeft < 0
mainAxisAlignment: MainAxisAlignment.center, // Start Up Message before setting up game
crossAxisAlignment: CrossAxisAlignment.center, ? Padding(
children: [ padding:
const SizedBox(height: 50), const EdgeInsets.symmetric(horizontal: 10.0),
Icon( child: Column(
MihIcons.mineSweeper, mainAxisAlignment: MainAxisAlignment.center,
size: 165, crossAxisAlignment: CrossAxisAlignment.center,
color: MihColors.getSecondaryColor( children: [
MzansiInnovationHub.of(context)!.theme.mode == const SizedBox(height: 50),
"Dark"), Icon(
), MihIcons.mineSweeper,
const SizedBox(height: 10), size: 165,
Text(
"Welcom to Minesweeper, the first game of MIH.",
textAlign: TextAlign.center,
overflow: TextOverflow.visible,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
const SizedBox(height: 25),
Center(
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
color: MihColors.getSecondaryColor( color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
.theme .theme
.mode == .mode ==
"Dark"), "Dark"),
), ),
children: [ const SizedBox(height: 10),
TextSpan(text: "Press "), Text(
WidgetSpan( "Welcom to Minesweeper, the first game of MIH.",
alignment: PlaceholderAlignment.middle, textAlign: TextAlign.center,
child: Icon( overflow: TextOverflow.visible,
Icons.menu, style: TextStyle(
size: 20, fontSize: 25,
color: MihColors.getSecondaryColor( fontWeight: FontWeight.bold,
MzansiInnovationHub.of(context)! color: MihColors.getSecondaryColor(
.theme MzansiInnovationHub.of(context)!
.mode == .theme
"Dark"), .mode ==
"Dark"),
),
),
const SizedBox(height: 25),
Center(
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
children: [
TextSpan(text: "Press "),
WidgetSpan(
alignment:
PlaceholderAlignment.middle,
child: Icon(
Icons.menu,
size: 20,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
TextSpan(
text:
" to start a new game or learn how to play the minesweeper."),
],
),
),
),
],
),
)
// Display Game Board when game started
: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Display game status
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0),
child: Text(
'Mines: ${mihMineSweeperProvider.totalMines}',
textAlign: TextAlign.left,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0),
child: Text(
_formatTime().replaceAll("00:", ""),
textAlign: TextAlign.right,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold),
),
), ),
), ),
TextSpan(
text:
" to start a new game or learn how to play the minesweeper."),
], ],
), ),
), Text(
), mihMineSweeperProvider.difficulty,
], textAlign: TextAlign.center,
), style: TextStyle(
) fontSize: 24,
// Display Game Board when game started fontWeight: FontWeight.bold,
: Column( color: getDifficultyColor(
mainAxisAlignment: MainAxisAlignment.start, mihMineSweeperProvider),
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Display game status
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0),
child: Text(
'Mines: ${mihMineSweeperProvider.totalMines}',
textAlign: TextAlign.left,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold),
), ),
), ),
),
Expanded( // const SizedBox(
child: Padding( // height: 30,
padding: const EdgeInsets.symmetric( // ),
horizontal: 10.0), // The Board Grid
child: Text( SizedBox(
_formatTime().replaceAll("00:", ""), width: mihMineSweeperProvider.columnCount *
textAlign: TextAlign.right, 40.0, // Control size based on columns
style: const TextStyle( height: mihMineSweeperProvider.rowCount *
fontSize: 24, 40.0, // Control size based on rows
fontWeight: FontWeight.bold), child: GridView.builder(
physics:
const NeverScrollableScrollPhysics(), // Prevent scrolling
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
mihMineSweeperProvider.columnCount,
crossAxisSpacing: 0,
mainAxisSpacing: 0,
),
itemCount: mihMineSweeperProvider.rowCount *
mihMineSweeperProvider.columnCount,
itemBuilder: (context, index) {
int r = index ~/
mihMineSweeperProvider
.columnCount; // Integer division for row
int c = index %
mihMineSweeperProvider
.columnCount; // Remainder for column
return MineTile(
square: board[r][c],
onTap: () => handleTap(
profileProvider,
mihMineSweeperProvider,
adProvider,
r,
c),
onLongPress: () => handleLongPress(r, c),
);
},
), ),
), ),
), SizedBox(height: 30),
], // const SizedBox(height: 100),
), ],
Text(
mihMineSweeperProvider.difficulty,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: getDifficultyColor(mihMineSweeperProvider),
), ),
), ),
Positioned(
// const SizedBox( right: 10,
// height: 30, bottom: 10,
// ), child: MihFloatingMenu(
// The Board Grid animatedIcon: AnimatedIcons.menu_close,
SizedBox( children: [
width: mihMineSweeperProvider.columnCount * SpeedDialChild(
40.0, // Control size based on columns child: Icon(
height: mihMineSweeperProvider.rowCount * Icons.rule_rounded,
40.0, // Control size based on rows color: MihColors.getPrimaryColor(
child: GridView.builder( MzansiInnovationHub.of(context)!.theme.mode ==
physics: "Dark"),
const NeverScrollableScrollPhysics(), // Prevent scrolling
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
mihMineSweeperProvider.columnCount,
crossAxisSpacing: 0,
mainAxisSpacing: 0,
), ),
itemCount: mihMineSweeperProvider.rowCount * label: "Learn how to play",
mihMineSweeperProvider.columnCount, labelBackgroundColor: MihColors.getGreenColor(
itemBuilder: (context, index) { MzansiInnovationHub.of(context)!.theme.mode ==
int r = index ~/ "Dark"),
mihMineSweeperProvider labelStyle: TextStyle(
.columnCount; // Integer division for row color: MihColors.getPrimaryColor(
int c = index % MzansiInnovationHub.of(context)!.theme.mode ==
mihMineSweeperProvider "Dark"),
.columnCount; // Remainder for column fontWeight: FontWeight.bold,
),
return MineTile( backgroundColor: MihColors.getGreenColor(
square: board[r][c], MzansiInnovationHub.of(context)!.theme.mode ==
onTap: () => handleTap(profileProvider, "Dark"),
mihMineSweeperProvider, adProvider, r, c), onTap: () {
onLongPress: () => handleLongPress(r, c), mihMineSweeperProvider.setToolIndex(2);
);
}, },
), ),
), SpeedDialChild(
SizedBox(height: 30), child: Icon(
MihBannerAd(), Icons.add,
// const SizedBox(height: 100), color: MihColors.getPrimaryColor(
], MzansiInnovationHub.of(context)!.theme.mode ==
), "Dark"),
),
label: board.isEmpty && squaresLeft < 0
? "Start Game"
: "Reset Game",
labelBackgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
labelStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontWeight: FontWeight.bold,
),
backgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onTap: () {
showStartGameWindow(
mihMineSweeperProvider, adProvider);
},
),
]),
)
],
),
), ),
Positioned( MihBannerAd(),
right: 10, SizedBox(height: 15),
bottom: 10,
child: MihFloatingMenu(
animatedIcon: AnimatedIcons.menu_close,
children: [
SpeedDialChild(
child: Icon(
Icons.rule_rounded,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
label: "Learn how to play",
labelBackgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
labelStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontWeight: FontWeight.bold,
),
backgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onTap: () {
mihMineSweeperProvider.setToolIndex(2);
},
),
SpeedDialChild(
child: Icon(
Icons.add,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
label: board.isEmpty && squaresLeft < 0
? "Start Game"
: "Reset Game",
labelBackgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
labelStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontWeight: FontWeight.bold,
),
backgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onTap: () {
showStartGameWindow(mihMineSweeperProvider, adProvider);
},
),
]),
)
], ],
); );
}, },