diff --git a/MoreChess.xcodeproj/project.pbxproj b/MoreChess.xcodeproj/project.pbxproj index b0ea801..f8e2ef3 100644 --- a/MoreChess.xcodeproj/project.pbxproj +++ b/MoreChess.xcodeproj/project.pbxproj @@ -54,6 +54,8 @@ B9FAC9472BB06C0C002A20F7 /* ClientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC9462BB06C0C002A20F7 /* ClientView.swift */; }; B9FAC9492BB06C91002A20F7 /* SimpleNavigationBackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC9482BB06C91002A20F7 /* SimpleNavigationBackButton.swift */; }; B9FAC94B2BB06FB2002A20F7 /* WaitingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC94A2BB06FB2002A20F7 /* WaitingView.swift */; }; + B9FAC94F2BB2E833002A20F7 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC94E2BB2E833002A20F7 /* Color.swift */; }; + B9FAC9512BB2F46D002A20F7 /* Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC9502BB2F46D002A20F7 /* Style.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -118,6 +120,8 @@ B9FAC9462BB06C0C002A20F7 /* ClientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientView.swift; sourceTree = ""; }; B9FAC9482BB06C91002A20F7 /* SimpleNavigationBackButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleNavigationBackButton.swift; sourceTree = ""; }; B9FAC94A2BB06FB2002A20F7 /* WaitingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitingView.swift; sourceTree = ""; }; + B9FAC94E2BB2E833002A20F7 /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; + B9FAC9502BB2F46D002A20F7 /* Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Style.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -171,6 +175,7 @@ B9ABF7A42BAEF04C00907C61 /* DataAccess */, B9ABF7A52BAEF0C500907C61 /* Models */, B9FAC91C2BAF0CDE002A20F7 /* Utils */, + B9FAC94D2BB2E821002A20F7 /* Resources */, B95CE50F2AD4CB5B00978591 /* MoreChessApp.swift */, B95CE5112AD4CB5E00978591 /* Assets.xcassets */, B9FAC9182BAF070C002A20F7 /* Launch Screen.storyboard */, @@ -338,6 +343,15 @@ path = Game; sourceTree = ""; }; + B9FAC94D2BB2E821002A20F7 /* Resources */ = { + isa = PBXGroup; + children = ( + B9FAC94E2BB2E833002A20F7 /* Color.swift */, + B9FAC9502BB2F46D002A20F7 /* Style.swift */, + ); + path = Resources; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -498,6 +512,7 @@ buildActionMask = 2147483647; files = ( B9FAC92A2BAF29DF002A20F7 /* Players.swift in Sources */, + B9FAC94F2BB2E833002A20F7 /* Color.swift in Sources */, B9FAC93F2BB059CD002A20F7 /* GameService.swift in Sources */, B9ABF7AB2BAEF1EB00907C61 /* BoardView.swift in Sources */, B9FAC9172BAEFFAC002A20F7 /* LayoutState.swift in Sources */, @@ -527,6 +542,7 @@ B94B61F52B68F8D700C998F3 /* PieceGenerator.swift in Sources */, B9FAC9432BB06315002A20F7 /* LobbyRepository.swift in Sources */, B9FAC91B2BAF0CA7002A20F7 /* Pieces.swift in Sources */, + B9FAC9512BB2F46D002A20F7 /* Style.swift in Sources */, B9FAC91F2BAF0D6A002A20F7 /* Player.swift in Sources */, B9FAC9152BAEF6C3002A20F7 /* PositioningInteractor.swift in Sources */, ); diff --git a/Shared/Assets.xcassets/AccentColor.colorset/Contents.json b/Shared/Assets.xcassets/AccentColor.colorset/Contents.json index eb87897..f45993a 100644 --- a/Shared/Assets.xcassets/AccentColor.colorset/Contents.json +++ b/Shared/Assets.xcassets/AccentColor.colorset/Contents.json @@ -1,6 +1,51 @@ { "colors" : [ { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.253", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "light" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.253", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.993", + "red" : "0.451" + } + }, "idiom" : "universal" } ], diff --git a/Shared/Assets.xcassets/Background.colorset/Contents.json b/Shared/Assets.xcassets/Background.colorset/Contents.json new file mode 100644 index 0000000..6ee398c --- /dev/null +++ b/Shared/Assets.xcassets/Background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.921", + "green" : "0.921", + "red" : "0.921" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.261", + "green" : "0.261", + "red" : "0.261" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Shared/Assets.xcassets/Foreground.colorset/Contents.json b/Shared/Assets.xcassets/Foreground.colorset/Contents.json new file mode 100644 index 0000000..1efebff --- /dev/null +++ b/Shared/Assets.xcassets/Foreground.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.261", + "green" : "0.261", + "red" : "0.261" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Shared/Presentation/ContentView.swift b/Shared/Presentation/ContentView.swift index 9124309..66ade71 100644 --- a/Shared/Presentation/ContentView.swift +++ b/Shared/Presentation/ContentView.swift @@ -14,11 +14,9 @@ struct ContentView: View { Group { if appState.lobbyState.inGame == false { LobbyView(lobbyInteractor: LobbyInteractor(appState: appState)) - } else { GameView() } - } .environment(appState) } // body diff --git a/Shared/Presentation/Elements/SolidButtonStyle.swift b/Shared/Presentation/Elements/SolidButtonStyle.swift index 916d360..318ef79 100644 --- a/Shared/Presentation/Elements/SolidButtonStyle.swift +++ b/Shared/Presentation/Elements/SolidButtonStyle.swift @@ -12,7 +12,7 @@ struct SolidButtonStyle: ButtonStyle { configuration.label .padding() .background(.tint) - .foregroundStyle(.background) + .foregroundStyle(Color.background) .font(.headline) .clipShape(Capsule()) .scaleEffect(configuration.isPressed ? 1.2 : 1) @@ -24,4 +24,5 @@ struct SolidButtonStyle: ButtonStyle { Button("Press Me") { } .buttonStyle(SolidButtonStyle()) + .style() } diff --git a/Shared/Presentation/Game/GameView.swift b/Shared/Presentation/Game/GameView.swift index d1b6637..5f87496 100644 --- a/Shared/Presentation/Game/GameView.swift +++ b/Shared/Presentation/Game/GameView.swift @@ -37,6 +37,7 @@ struct GameView: View { Text("Row count: \(appState.gameState.rowCount), Column count: \(appState.gameState.columnCount)") } // VStack + .style() } // body @ViewBuilder func playConditionView() -> some View { diff --git a/Shared/Presentation/Lobby/ClientView.swift b/Shared/Presentation/Lobby/ClientView.swift index 769fc62..792a90a 100644 --- a/Shared/Presentation/Lobby/ClientView.swift +++ b/Shared/Presentation/Lobby/ClientView.swift @@ -25,6 +25,7 @@ struct ClientView: View { .navigationTitle("Join") .navigationBarTitleDisplayMode(.inline) .simpleNavigationBackButton(dismiss: dismiss) + .style() .onAppear(perform: lobbyInteractor.fetchAvailableGames) } } diff --git a/Shared/Presentation/Lobby/HostingView.swift b/Shared/Presentation/Lobby/HostingView.swift index ffdeb33..a7f8561 100644 --- a/Shared/Presentation/Lobby/HostingView.swift +++ b/Shared/Presentation/Lobby/HostingView.swift @@ -17,7 +17,6 @@ struct HostingView: View { VStack { Text("Hosting") Text("share this code to other player: \(gameService.gameId)-\(gameService.clientId)") - Spacer().frame(height: 20) HStack { @@ -28,6 +27,7 @@ struct HostingView: View { .navigationTitle("Host") .navigationBarTitleDisplayMode(.inline) .simpleNavigationBackButton(dismiss: dismiss) + .style() .onAppear { lobbyInteractor.checkForOpponentClient(gameService: gameService) } diff --git a/Shared/Presentation/Lobby/LobbyView.swift b/Shared/Presentation/Lobby/LobbyView.swift index c6c9ed0..dcedad2 100644 --- a/Shared/Presentation/Lobby/LobbyView.swift +++ b/Shared/Presentation/Lobby/LobbyView.swift @@ -16,6 +16,7 @@ struct LobbyView: View { var body: some View { NavigationStack(path: pathBinding()) { + home() .navigationDestination(for: LobbyState.LobbyPages.self) { destination in switch destination { @@ -31,6 +32,7 @@ struct LobbyView: View { private func home() -> some View { VStack { Text("Host or join a new game") + HStack { Button("Host") { lobbyInteractor.select(serviceType: .host) @@ -43,6 +45,7 @@ struct LobbyView: View { .buttonStyle(SolidButtonStyle()) } // HStack } + .style() .navigationTitle("More Chess 🐴") .navigationBarTitleDisplayMode(.inline) } diff --git a/Shared/Resources/Color.swift b/Shared/Resources/Color.swift new file mode 100644 index 0000000..2bca157 --- /dev/null +++ b/Shared/Resources/Color.swift @@ -0,0 +1,13 @@ +// +// Color.swift +// MoreChess (iOS) +// +// Created by Richard Adem on 3/26/24. +// + +import SwiftUI + +extension Color { + static let foreground = Color("Foreground") + static let background = Color("Background") +} diff --git a/Shared/Resources/Style.swift b/Shared/Resources/Style.swift new file mode 100644 index 0000000..823aa7f --- /dev/null +++ b/Shared/Resources/Style.swift @@ -0,0 +1,24 @@ +// +// Style.swift +// MoreChess (iOS) +// +// Created by Richard Adem on 3/26/24. +// + +import SwiftUI + +// Add this to the root of your view. +struct StyleModifier: ViewModifier { + func body(content: Content) -> some View { + content + .frame(maxWidth: .infinity, maxHeight: .infinity) // TODO: add option to disable this line. + .background(Color.background) + .foregroundStyle(Color.foreground) + } +} + +extension View { + func style() -> some View { + modifier(StyleModifier()) + } +}