some ui changes

This commit is contained in:
neon443
2025-04-08 10:37:05 +05:30
parent fe46be8ee7
commit 137495db26
2 changed files with 62 additions and 42 deletions

View File

@@ -432,7 +432,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"MineSwift/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"MineSwift/Preview Content\"";
DEVELOPMENT_TEAM = P6PV2R9443; DEVELOPMENT_TEAM = 8626DL2GW3;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -470,7 +470,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"MineSwift/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"MineSwift/Preview Content\"";
DEVELOPMENT_TEAM = P6PV2R9443; DEVELOPMENT_TEAM = 8626DL2GW3;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;

View File

@@ -26,6 +26,7 @@ struct MinesweeperView: View {
var body: some View { var body: some View {
VStack { VStack {
ZStack {
VStack(spacing: 0) { VStack(spacing: 0) {
ForEach(0..<rows, id: \..self) { row in ForEach(0..<rows, id: \..self) { row in
HStack(spacing: 0) { HStack(spacing: 0) {
@@ -57,6 +58,32 @@ struct MinesweeperView: View {
} }
.clipShape(RoundedRectangle(cornerRadius: 10)) .clipShape(RoundedRectangle(cornerRadius: 10))
if game.gameOver {
Text("Game Over")
.font(.largeTitle)
.bold()
.foregroundColor(.red)
.shadow(radius: 10)
.shadow(radius: 10)
.shadow(radius: 10)
} else if game.gameWon {
Text("You Win!")
.font(.largeTitle)
.bold()
.foregroundColor(.green)
.shadow(radius: 10)
.shadow(radius: 10)
.shadow(radius: 10)
}
if game.gameOver || game.gameWon {
Button() {
} label: {
Text("Restart game")
}
}
}
List { List {
Toggle(isOn: $flag, label: { Toggle(isOn: $flag, label: {
Text("Flag Mode") Text("Flag Mode")
@@ -67,16 +94,6 @@ struct MinesweeperView: View {
.padding() .padding()
.frame(alignment: .center) .frame(alignment: .center)
} }
if game.gameOver {
Text("Game Over")
.font(.largeTitle)
.foregroundColor(.red)
} else if game.gameWon {
Text("You Win!")
.font(.largeTitle)
.foregroundColor(.green)
}
} }
.padding() .padding()
} }
@@ -94,15 +111,18 @@ struct CellView: View {
var body: some View { var body: some View {
ZStack { ZStack {
if isHighlighted { if cell.state == .revealed {
Color.gray.opacity(0.1) Color.black.opacity(isHighlighted ? 0.5 : 1)
.animation(.easeInOut(duration: 0.3), value: isHighlighted)
} else if cell.state == .revealed {
Color.black
} else { } else {
Color.blue Color.blue.opacity(isHighlighted ? 0.8 : 1)
// .animation(.spring(duration: 0.1), value: isHighlighted)
} }
// if isHighlighted {
// Color.gray.opacity(0.05)
// .animation(.spring(duration: 0.1), value: isHighlighted)
// }
if cell.state == .revealed { if cell.state == .revealed {
if cell.isMine { if cell.isMine {
Image(systemName: "multiply") Image(systemName: "multiply")
@@ -130,5 +150,5 @@ struct CellView: View {
} }
#Preview { #Preview {
MinesweeperView(rows: 10, cols: 10, bombs: 5) MinesweeperView(rows: 10, cols: 10, bombs: 10)
} }