├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── anafthdev │ │ └── tictactoe │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── anafthdev │ │ │ └── tictactoe │ │ │ ├── common │ │ │ ├── GameEngine.kt │ │ │ └── Minimax.kt │ │ │ ├── data │ │ │ ├── GameMode.kt │ │ │ ├── PointType.kt │ │ │ ├── TicTacToeDestination.kt │ │ │ ├── TurnType.kt │ │ │ └── WinType.kt │ │ │ ├── extension │ │ │ ├── AppFile.kt │ │ │ ├── CollectionExt.kt │ │ │ ├── GameModeExt.kt │ │ │ ├── PointTypeExt.kt │ │ │ ├── PrimitiveExt.kt │ │ │ └── ToastExt.kt │ │ │ ├── model │ │ │ └── Player.kt │ │ │ ├── runtime │ │ │ ├── MainActivity.kt │ │ │ ├── TicTacToeApplication.kt │ │ │ └── navigation │ │ │ │ ├── DashboardAnimatedNavHost.kt │ │ │ │ ├── GameAnimatedNavHost.kt │ │ │ │ ├── ScoreAnimatedNavHost.kt │ │ │ │ └── TicTacToeNavigation.kt │ │ │ ├── theme │ │ │ ├── Color.kt │ │ │ ├── Theme.kt │ │ │ └── Type.kt │ │ │ ├── ui │ │ │ ├── dashboard │ │ │ │ ├── DashboardScreen.kt │ │ │ │ └── DashboardViewModel.kt │ │ │ ├── game │ │ │ │ ├── GameScreen.kt │ │ │ │ └── GameViewModel.kt │ │ │ └── score │ │ │ │ ├── ScoreScreen.kt │ │ │ │ └── ScoreViewModel.kt │ │ │ └── uicomponent │ │ │ ├── GameModeSelector.kt │ │ │ ├── Padding.kt │ │ │ ├── PlayerItem.kt │ │ │ ├── RoundItem.kt │ │ │ └── TicTacToeBoard.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_app_icon.xml │ │ ├── ic_award.xml │ │ ├── ic_dashboard.xml │ │ ├── ic_github_mark.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_setting.xml │ │ ├── ic_tic_tac_toe_o.xml │ │ ├── ic_tic_tac_toe_x.xml │ │ ├── ic_timer.xml │ │ ├── ic_trash.xml │ │ ├── splash_drawable.xml │ │ └── transparent.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-ldpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── com │ └── anafthdev │ └── tictactoe │ └── ExampleUnitTest.kt ├── app_icon.svg ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ic_launcher ├── android │ ├── ic_launcher-web.png │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ ├── mipmap-ldpi │ │ └── ic_launcher.png │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ ├── playstore-icon.png │ └── values │ │ └── ic_launcher_background.xml └── ios │ ├── AppIcon.appiconset │ ├── Contents.json │ ├── Icon-App-20x20@1x.png │ ├── Icon-App-20x20@2x.png │ ├── Icon-App-20x20@3x.png │ ├── Icon-App-29x29@1x.png │ ├── Icon-App-29x29@2x.png │ ├── Icon-App-29x29@3x.png │ ├── Icon-App-40x40@1x.png │ ├── Icon-App-40x40@2x.png │ ├── Icon-App-40x40@3x.png │ ├── Icon-App-60x60@2x.png │ ├── Icon-App-60x60@3x.png │ ├── Icon-App-76x76@1x.png │ ├── Icon-App-76x76@2x.png │ ├── Icon-App-83.5x83.5@2x.png │ └── ItunesArtwork@2x.png │ ├── iTunesArtwork@1x.png │ ├── iTunesArtwork@2x.png │ └── iTunesArtwork@3x.png ├── img ├── dashboard.jpg ├── game_1.jpg ├── game_2.jpg └── tic tac toe image feature.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 37 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compose-TicTacToe 2 | TicTacToe game made with Jetpack Compose 3 | 4 | https://play.google.com/store/apps/details?id=com.anafthdev.tictactoe 5 | 6 | ## Preview 7 |

8 | 9 | 10 |

11 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'dagger.hilt.android.plugin' 5 | id 'kotlin-kapt' 6 | id 'kotlin-parcelize' 7 | } 8 | 9 | android { 10 | namespace 'com.anafthdev.tictactoe' 11 | compileSdk 33 12 | 13 | defaultConfig { 14 | applicationId "com.anafthdev.tictactoe" 15 | minSdk 23 16 | targetSdk 33 17 | versionCode 1 18 | versionName "1.0.0" 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | vectorDrawables { 22 | useSupportLibrary true 23 | } 24 | } 25 | 26 | buildTypes { 27 | debug { 28 | minifyEnabled false 29 | kotlinOptions { 30 | freeCompilerArgs += [ 31 | '-Xopt-in=kotlin.RequiresOptIn' 32 | ] 33 | freeCompilerArgs += [ 34 | "-Xjvm-default=all", 35 | ] 36 | } 37 | } 38 | release { 39 | minifyEnabled true 40 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 41 | kotlinOptions { 42 | freeCompilerArgs += [ 43 | '-Xopt-in=kotlin.RequiresOptIn' 44 | ] 45 | freeCompilerArgs += [ 46 | "-Xjvm-default=all", 47 | ] 48 | } 49 | } 50 | } 51 | compileOptions { 52 | sourceCompatibility JavaVersion.VERSION_11 53 | targetCompatibility JavaVersion.VERSION_11 54 | } 55 | kotlinOptions { 56 | jvmTarget = '11' 57 | } 58 | buildFeatures { 59 | compose true 60 | } 61 | composeOptions { 62 | kotlinCompilerExtensionVersion '1.3.2' 63 | } 64 | packagingOptions { 65 | resources { 66 | excludes += '/META-INF/{AL2.0,LGPL2.1}' 67 | } 68 | } 69 | } 70 | 71 | dependencies { 72 | 73 | implementation 'androidx.core:core-ktx:1.9.0' 74 | implementation 'androidx.activity:activity-compose:1.6.1' 75 | implementation "androidx.compose.ui:ui:$compose_version" 76 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" 77 | implementation "androidx.compose.runtime:runtime-livedata:$compose_version" 78 | 79 | // Navigation 80 | implementation "androidx.navigation:navigation-compose:2.5.3" 81 | implementation "androidx.hilt:hilt-navigation-compose:1.0.0" 82 | 83 | // Material Design 84 | implementation 'com.google.android.material:material:1.7.0' 85 | implementation "androidx.compose.material:material:$compose_version" 86 | implementation "androidx.compose.material:material-icons-extended:$compose_version" 87 | implementation "androidx.compose.material3:material3:1.1.0-alpha03" 88 | 89 | // Dependency Injection 90 | implementation 'com.google.dagger:hilt-android:2.42' 91 | kapt 'androidx.hilt:hilt-compiler:1.0.0' 92 | kapt 'com.google.dagger:hilt-compiler:2.42' 93 | kapt 'com.google.dagger:hilt-android-compiler:2.39.1' 94 | 95 | // Datastore 96 | implementation "androidx.datastore:datastore:1.0.0" 97 | implementation "androidx.datastore:datastore-preferences:1.0.0" 98 | implementation "androidx.datastore:datastore-core:1.0.0" 99 | 100 | // Room 101 | implementation 'androidx.room:room-runtime:2.4.3' 102 | implementation 'androidx.room:room-ktx:2.4.3' 103 | kapt 'androidx.room:room-compiler:2.4.3' 104 | 105 | // Lifecycle 106 | implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.0-alpha03" 107 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1" 108 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' 109 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' 110 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 111 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' 112 | kapt 'androidx.lifecycle:lifecycle-common-java8:2.5.1' 113 | 114 | // Accompanist 115 | implementation "com.google.accompanist:accompanist-pager:$accompanist_version" 116 | implementation "com.google.accompanist:accompanist-flowlayout:$accompanist_version" 117 | implementation "com.google.accompanist:accompanist-navigation-material:$accompanist_version" 118 | implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist_version" 119 | implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version" 120 | 121 | 122 | // Other 123 | implementation 'com.jakewharton.timber:timber:5.0.1' 124 | implementation 'com.google.code.gson:gson:2.9.1' 125 | 126 | testImplementation 'junit:junit:4.13.2' 127 | androidTestImplementation 'androidx.test.ext:junit:1.1.4' 128 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' 129 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" 130 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" 131 | debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" 132 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/anafthdev/tictactoe/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.anafthdev.tictactoe", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/common/GameEngine.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.common 2 | 3 | import com.anafthdev.tictactoe.data.GameMode 4 | import com.anafthdev.tictactoe.data.PointType 5 | import com.anafthdev.tictactoe.data.TurnType 6 | import com.anafthdev.tictactoe.data.WinType 7 | import com.anafthdev.tictactoe.model.Player 8 | import kotlinx.coroutines.flow.MutableStateFlow 9 | import kotlinx.coroutines.flow.StateFlow 10 | import kotlinx.coroutines.flow.asStateFlow 11 | 12 | /** 13 | * Board 14 | * 0|1|2 15 | * 3|4|5 16 | * 6|7|8 17 | */ 18 | class GameEngine( 19 | private var playerOne: Player, 20 | private var playerTwo: Player, 21 | ) { 22 | 23 | private val minimax = Minimax(this) 24 | 25 | private val defaultBoard = ArrayList(9).apply { 26 | repeat(9) { i -> 27 | add(i, PointType.Empty) 28 | } 29 | } 30 | 31 | private val _board = MutableStateFlow(defaultBoard) 32 | val board: StateFlow> = _board.asStateFlow() 33 | 34 | private val _currentTurn = MutableStateFlow(TurnType.PlayerOne) 35 | val currentTurn: StateFlow = _currentTurn.asStateFlow() 36 | 37 | private var gameMode: GameMode = GameMode.Computer 38 | private var listener: Listener? = null 39 | 40 | private fun checkHorizontal(board: List): WinType { 41 | for (i in 0 until 3) { 42 | when { 43 | board[i * 3] == PointType.O && board[(i * 3) + 1] == PointType.O && board[(i * 3) + 2] == PointType.O -> { 44 | return WinType.O 45 | } 46 | board[i * 3] == PointType.X && board[(i * 3) + 1] == PointType.X && board[(i * 3) + 2] == PointType.X -> { 47 | return WinType.X 48 | } 49 | } 50 | } 51 | 52 | return WinType.None 53 | } 54 | 55 | private fun checkVertical(board: List): WinType { 56 | for (i in 0 until 3) { 57 | when { 58 | board[i] == PointType.O && board[i + 3] == PointType.O && board[i + 6] == PointType.O -> { 59 | return WinType.O 60 | } 61 | board[i] == PointType.X && board[i + 3] == PointType.X && board[i + 6] == PointType.X -> { 62 | return WinType.X 63 | } 64 | } 65 | } 66 | 67 | return WinType.None 68 | } 69 | 70 | private fun checkDiagonal(board: List): WinType { 71 | when { 72 | board[0] == PointType.O && board[4] == PointType.O && board[8] == PointType.O -> { 73 | return WinType.O 74 | } 75 | board[0] == PointType.X && board[4] == PointType.X && board[8] == PointType.X -> { 76 | return WinType.X 77 | } 78 | board[2] == PointType.O && board[4] == PointType.O && board[6] == PointType.O -> { 79 | return WinType.O 80 | } 81 | board[2] == PointType.X && board[4] == PointType.X && board[6] == PointType.X -> { 82 | return WinType.X 83 | } 84 | } 85 | 86 | return WinType.None 87 | } 88 | 89 | fun checkWin(board: List, invokeListener: Boolean = true): WinType { 90 | val wins = listOf(checkHorizontal(board), checkVertical(board), checkDiagonal(board)) 91 | // Timber.i("fingsbuk: kolll") 92 | val isTie = wins.all { it == WinType.None } and board.all { it != PointType.Empty } 93 | 94 | val winner = when { 95 | isTie -> WinType.Tie 96 | WinType.O in wins -> WinType.O 97 | WinType.X in wins -> WinType.X 98 | else -> WinType.None 99 | } 100 | 101 | if (invokeListener) { 102 | listener?.onWin(winner) 103 | } 104 | 105 | return winner 106 | } 107 | 108 | suspend fun updateBoard(index: Int) { 109 | val newPointType = if (currentTurn.value == TurnType.PlayerOne) playerOne.pointType else playerTwo.pointType 110 | val newBoard = ArrayList(board.value).apply { 111 | set(index, newPointType) 112 | } 113 | 114 | _board.emit(newBoard) 115 | 116 | val winner = checkWin(newBoard) 117 | 118 | val nextTurn = if (currentTurn.value == TurnType.PlayerOne) TurnType.PlayerTwo else TurnType.PlayerOne 119 | 120 | _currentTurn.emit(nextTurn) 121 | 122 | if (winner == WinType.None) { 123 | when (nextTurn) { 124 | TurnType.PlayerOne -> { 125 | if (playerOne.id == Player.Computer.id) { 126 | computerTurn(newBoard) 127 | } 128 | } 129 | TurnType.PlayerTwo -> { 130 | if (playerTwo.id == Player.Computer.id) { 131 | computerTurn(newBoard) 132 | } 133 | } 134 | } 135 | } 136 | } 137 | 138 | private suspend fun computerTurn(board: List) { 139 | val emptyIndex = arrayListOf() 140 | 141 | board.forEachIndexed { i, type -> 142 | if (type == PointType.Empty) emptyIndex.add(i) 143 | } 144 | 145 | if (emptyIndex.isNotEmpty()) { 146 | val nextIndex = minimax.getBestMove(board, playerTwo, playerOne) 147 | // val randomIndex = emptyIndex.random() 148 | 149 | updateBoard(nextIndex) 150 | } 151 | } 152 | 153 | suspend fun clearBoard() { 154 | _board.emit(defaultBoard) 155 | 156 | when (currentTurn.value) { 157 | TurnType.PlayerOne -> { 158 | if (playerOne.id == Player.Computer.id) { 159 | computerTurn(defaultBoard) 160 | } 161 | } 162 | TurnType.PlayerTwo -> { 163 | if (playerTwo.id == Player.Computer.id) { 164 | computerTurn(defaultBoard) 165 | } 166 | } 167 | } 168 | } 169 | 170 | fun updatePlayer(one: Player, two: Player) { 171 | playerOne = one 172 | playerTwo = two 173 | } 174 | 175 | fun setListener(l: Listener) { 176 | listener = l 177 | } 178 | 179 | interface Listener { 180 | 181 | fun onWin(type: WinType) 182 | } 183 | 184 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/common/Minimax.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.common 2 | 3 | import com.anafthdev.tictactoe.data.PointType 4 | import com.anafthdev.tictactoe.extension.toWinType 5 | import com.anafthdev.tictactoe.model.Player 6 | import kotlin.math.abs 7 | 8 | 9 | class Minimax(private val gameEngine: GameEngine) { 10 | 11 | private var maxDepth = 24 12 | 13 | private fun minimax( 14 | board: MutableList, 15 | computerPlayer: Player, 16 | humanPlayer: Player, 17 | depth: Int, 18 | isMax: Boolean 19 | ): Int { 20 | 21 | val winner = gameEngine.checkWin(board, false) 22 | 23 | val score = if (humanPlayer.pointType.toWinType() == winner) { 24 | -1 25 | } else if (computerPlayer.pointType.toWinType() == winner) { 26 | 1 27 | } else 0 28 | 29 | if (abs(score) == 1 || depth == 0 || board.none { it == PointType.Empty }) { 30 | return score 31 | } 32 | 33 | return if (isMax) { 34 | var highestVal = Int.MIN_VALUE 35 | board.forEachIndexed { index, pointType -> 36 | if (pointType == PointType.Empty) { 37 | board[index] = computerPlayer.pointType 38 | 39 | highestVal = highestVal.coerceAtLeast( 40 | minimax( 41 | board, 42 | computerPlayer, 43 | humanPlayer, 44 | depth - 1, 45 | false 46 | ) 47 | ) 48 | } 49 | } 50 | 51 | highestVal 52 | // Minimising player, find the minimum attainable value; 53 | } else { 54 | var lowestVal = Int.MAX_VALUE 55 | board.forEachIndexed { index, pointType -> 56 | if (pointType == PointType.Empty) { 57 | board[index] = humanPlayer.pointType 58 | 59 | lowestVal = lowestVal.coerceAtMost( 60 | minimax( 61 | board, 62 | computerPlayer, 63 | humanPlayer, 64 | depth - 1, 65 | true 66 | ) 67 | ) 68 | } 69 | } 70 | 71 | lowestVal 72 | } 73 | } 74 | 75 | fun getBestMove( 76 | board: List, 77 | computerPlayer: Player, 78 | humanPlayer: Player, 79 | ): Int { 80 | var index = -1 81 | var bestValue = Int.MIN_VALUE 82 | 83 | val mutableBoard = board.toMutableList() 84 | 85 | board.forEachIndexed { i, type -> 86 | if (type == PointType.Empty) { 87 | mutableBoard[i] = computerPlayer.pointType 88 | 89 | val moveValue = minimax(mutableBoard, computerPlayer, humanPlayer, maxDepth, false) 90 | 91 | if (moveValue > bestValue) { 92 | index = i 93 | bestValue = moveValue 94 | } 95 | } 96 | } 97 | 98 | return index 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/data/GameMode.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.data 2 | 3 | enum class GameMode { 4 | Computer, 5 | PvP, 6 | PvPBluetooth 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/data/PointType.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.data 2 | 3 | enum class PointType { 4 | Empty, 5 | X, 6 | O 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/data/TicTacToeDestination.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.data 2 | 3 | import androidx.navigation.NavType 4 | import androidx.navigation.navArgument 5 | 6 | sealed class TicTacToeDestination(val route: String) { 7 | 8 | class Dashboard { 9 | object Root: TicTacToeDestination("dashboard/root") 10 | object Home: TicTacToeDestination("dashboard/home") 11 | } 12 | 13 | class Score { 14 | object Root: TicTacToeDestination("score/root") 15 | object Home: TicTacToeDestination("score/home") 16 | } 17 | 18 | class Game { 19 | object Root: TicTacToeDestination("game/root") 20 | object Home: TicTacToeDestination( 21 | route = "game/home?" + 22 | "$ARG_GAME_MODE={$ARG_GAME_MODE}" 23 | ) { 24 | fun createRoute(gameMode: GameMode): String { 25 | return "game/home?" + 26 | "$ARG_GAME_MODE=${gameMode.ordinal}" 27 | } 28 | 29 | val arguments = listOf( 30 | navArgument(ARG_GAME_MODE) { 31 | type = NavType.IntType 32 | } 33 | ) 34 | } 35 | } 36 | 37 | } 38 | 39 | const val ARG_GAME_MODE = "game_mode" 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/data/TurnType.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.data 2 | 3 | enum class TurnType { 4 | PlayerOne, 5 | PlayerTwo 6 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/data/WinType.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.data 2 | 3 | enum class WinType { 4 | None, 5 | Tie, 6 | O, 7 | X 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/extension/AppFile.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.extension 2 | 3 | import android.content.Context 4 | import com.anafthdev.tictactoe.runtime.TicTacToeApplication 5 | 6 | lateinit var app: TicTacToeApplication 7 | 8 | lateinit var appContext: Context -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/extension/CollectionExt.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.extension 2 | 3 | fun Collection.to2DArray(len: Int): List> { 4 | val result = arrayListOf>() 5 | 6 | var counter = 1 7 | var value = arrayListOf() 8 | forEach { t -> 9 | if (counter == len) { 10 | counter = 1 11 | 12 | value.add(t) 13 | result.add(value) 14 | value = arrayListOf() 15 | } else { 16 | value.add(t) 17 | counter++ 18 | } 19 | } 20 | 21 | return result 22 | } 23 | 24 | fun Collection>.to1DArray(): List { 25 | val result = arrayListOf() 26 | 27 | forEach { inner -> 28 | inner.forEach { t -> result.add(t) } 29 | } 30 | 31 | return result 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/extension/GameModeExt.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.extension 2 | 3 | import com.anafthdev.tictactoe.data.GameMode 4 | 5 | val GameMode.modeName: String 6 | get() = when(this) { 7 | GameMode.Computer -> "Computer" 8 | GameMode.PvP -> "PvP" 9 | GameMode.PvPBluetooth -> "PvP Bluetooth" 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/extension/PointTypeExt.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.extension 2 | 3 | import com.anafthdev.tictactoe.data.PointType 4 | import com.anafthdev.tictactoe.data.WinType 5 | 6 | fun PointType.toWinType(): WinType { 7 | return when (this) { 8 | PointType.Empty -> WinType.None 9 | PointType.X -> WinType.X 10 | PointType.O -> WinType.O 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/extension/PrimitiveExt.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.extension 2 | 3 | infix fun Int.countMod(with: Int): Int { 4 | var num = this 5 | var count = 0 6 | 7 | while (num >= with) { 8 | num -= with 9 | count++ 10 | } 11 | 12 | return count 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/extension/ToastExt.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.extension 2 | 3 | import android.os.Build 4 | import android.os.Handler 5 | import android.os.Looper 6 | import android.widget.Toast 7 | 8 | private val mToastHandler by lazy { Handler(Looper.getMainLooper()) } 9 | 10 | private var mToast: Toast? = null 11 | 12 | fun Any?.toast(length: Int = Toast.LENGTH_SHORT) { 13 | postToast(toString(), length) 14 | } 15 | 16 | private fun postToast(text: String, duration: Int) { 17 | mToastHandler.post { 18 | setToast(text, duration) 19 | mToast?.show() 20 | } 21 | } 22 | 23 | private fun setToast(text: String, duration: Int) { 24 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { 25 | if (mToast == null) { 26 | mToast = Toast.makeText(appContext, text, duration) 27 | } else { 28 | mToast?.duration = duration 29 | mToast?.setText(text) 30 | } 31 | } else { 32 | if (mToast != null) { 33 | mToast?.cancel() 34 | mToast = null 35 | } 36 | mToast = Toast.makeText(appContext, text, duration) 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/model/Player.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.model 2 | 3 | import com.anafthdev.tictactoe.data.PointType 4 | 5 | data class Player( 6 | val id: Int, 7 | val win: Int, 8 | val name: String, 9 | var pointType: PointType 10 | ) { 11 | companion object { 12 | val Player1 = Player( 13 | id = 0, 14 | win = 0, 15 | name = "Player 1", 16 | pointType = PointType.X 17 | ) 18 | 19 | val Player2 = Player( 20 | id = 1, 21 | win = 0, 22 | name = "Player 2", 23 | pointType = PointType.O 24 | ) 25 | 26 | val Computer = Player( 27 | id = 2, 28 | win = 0, 29 | name = "Computer", 30 | pointType = PointType.O 31 | ) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/runtime/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.runtime 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.foundation.layout.fillMaxSize 7 | import androidx.compose.material3.MaterialTheme 8 | import androidx.compose.material3.Surface 9 | import androidx.compose.ui.Modifier 10 | import androidx.core.view.WindowCompat 11 | import com.anafthdev.tictactoe.runtime.navigation.TicTacToeNavigation 12 | import com.anafthdev.tictactoe.theme.TicTacToeTheme 13 | import dagger.hilt.android.AndroidEntryPoint 14 | 15 | @AndroidEntryPoint 16 | class MainActivity : ComponentActivity() { 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | 21 | WindowCompat.setDecorFitsSystemWindows(window, false) 22 | 23 | setContent { 24 | TicTacToeTheme { 25 | Surface( 26 | modifier = Modifier.fillMaxSize(), 27 | color = MaterialTheme.colorScheme.background 28 | ) { 29 | TicTacToeNavigation() 30 | } 31 | } 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/runtime/TicTacToeApplication.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.runtime 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import com.anafthdev.tictactoe.BuildConfig 6 | import com.anafthdev.tictactoe.extension.app 7 | import com.anafthdev.tictactoe.extension.appContext 8 | import dagger.hilt.android.HiltAndroidApp 9 | import timber.log.Timber 10 | 11 | @HiltAndroidApp 12 | class TicTacToeApplication : Application() { 13 | 14 | override fun onCreate() { 15 | super.onCreate() 16 | if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) 17 | } 18 | 19 | override fun attachBaseContext(base: Context) { 20 | super.attachBaseContext(base) 21 | app = this 22 | appContext = base 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/runtime/navigation/DashboardAnimatedNavHost.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.runtime.navigation 2 | 3 | import androidx.compose.animation.ExperimentalAnimationApi 4 | import androidx.compose.animation.fadeIn 5 | import androidx.compose.animation.fadeOut 6 | import androidx.hilt.navigation.compose.hiltViewModel 7 | import androidx.navigation.NavController 8 | import androidx.navigation.NavGraphBuilder 9 | import com.anafthdev.tictactoe.data.TicTacToeDestination 10 | import com.anafthdev.tictactoe.ui.dashboard.DashboardScreen 11 | import com.anafthdev.tictactoe.ui.dashboard.DashboardViewModel 12 | import com.google.accompanist.navigation.animation.composable 13 | import com.google.accompanist.navigation.animation.navigation 14 | 15 | @OptIn(ExperimentalAnimationApi::class) 16 | fun NavGraphBuilder.DashboardAnimatedNavHost(navController: NavController) { 17 | navigation( 18 | startDestination = TicTacToeDestination.Dashboard.Home.route, 19 | route = TicTacToeDestination.Dashboard.Root.route 20 | ) { 21 | composable( 22 | route = TicTacToeDestination.Dashboard.Home.route, 23 | enterTransition = { fadeIn() }, 24 | exitTransition = { fadeOut() }, 25 | popEnterTransition = { fadeIn() }, 26 | popExitTransition = { fadeOut() } 27 | ) { backEntry -> 28 | val viewModel = hiltViewModel(backEntry) 29 | 30 | DashboardScreen( 31 | navController = navController, 32 | viewModel = viewModel 33 | ) 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/runtime/navigation/GameAnimatedNavHost.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.runtime.navigation 2 | 3 | import androidx.compose.animation.ExperimentalAnimationApi 4 | import androidx.compose.animation.fadeIn 5 | import androidx.compose.animation.fadeOut 6 | import androidx.hilt.navigation.compose.hiltViewModel 7 | import androidx.navigation.NavController 8 | import androidx.navigation.NavGraphBuilder 9 | import com.anafthdev.tictactoe.data.TicTacToeDestination 10 | import com.anafthdev.tictactoe.ui.game.GameScreen 11 | import com.anafthdev.tictactoe.ui.game.GameViewModel 12 | import com.google.accompanist.navigation.animation.composable 13 | import com.google.accompanist.navigation.animation.navigation 14 | 15 | @OptIn(ExperimentalAnimationApi::class) 16 | fun NavGraphBuilder.GameAnimatedNavHost(navController: NavController) { 17 | navigation( 18 | startDestination = TicTacToeDestination.Game.Home.route, 19 | route = TicTacToeDestination.Game.Root.route 20 | ) { 21 | composable( 22 | route = TicTacToeDestination.Game.Home.route, 23 | arguments = TicTacToeDestination.Game.Home.arguments, 24 | enterTransition = { fadeIn() }, 25 | exitTransition = { fadeOut() }, 26 | popEnterTransition = { fadeIn() }, 27 | popExitTransition = { fadeOut() } 28 | ) { backEntry -> 29 | val viewModel = hiltViewModel(backEntry) 30 | 31 | GameScreen( 32 | navController = navController, 33 | viewModel = viewModel 34 | ) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/runtime/navigation/ScoreAnimatedNavHost.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.runtime.navigation 2 | 3 | import androidx.compose.animation.ExperimentalAnimationApi 4 | import androidx.compose.animation.fadeIn 5 | import androidx.compose.animation.fadeOut 6 | import androidx.hilt.navigation.compose.hiltViewModel 7 | import androidx.navigation.NavController 8 | import androidx.navigation.NavGraphBuilder 9 | import com.anafthdev.tictactoe.data.TicTacToeDestination 10 | import com.anafthdev.tictactoe.ui.score.ScoreScreen 11 | import com.anafthdev.tictactoe.ui.score.ScoreViewModel 12 | import com.google.accompanist.navigation.animation.composable 13 | import com.google.accompanist.navigation.animation.navigation 14 | 15 | @OptIn(ExperimentalAnimationApi::class) 16 | fun NavGraphBuilder.ScoreAnimatedNavHost(navController: NavController) { 17 | navigation( 18 | startDestination = TicTacToeDestination.Score.Home.route, 19 | route = TicTacToeDestination.Score.Root.route 20 | ) { 21 | composable( 22 | route = TicTacToeDestination.Score.Home.route, 23 | enterTransition = { fadeIn() }, 24 | exitTransition = { fadeOut() }, 25 | popEnterTransition = { fadeIn() }, 26 | popExitTransition = { fadeOut() } 27 | ) { backEntry -> 28 | val viewModel = hiltViewModel(backEntry) 29 | 30 | ScoreScreen( 31 | navController = navController, 32 | viewModel = viewModel 33 | ) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/runtime/navigation/TicTacToeNavigation.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.runtime.navigation 2 | 3 | import androidx.compose.animation.ExperimentalAnimationApi 4 | import androidx.compose.foundation.layout.fillMaxSize 5 | import androidx.compose.runtime.Composable 6 | import androidx.compose.runtime.SideEffect 7 | import androidx.compose.ui.Modifier 8 | import androidx.compose.ui.graphics.Color 9 | import androidx.navigation.compose.rememberNavController 10 | import com.anafthdev.tictactoe.data.TicTacToeDestination 11 | import com.google.accompanist.navigation.animation.AnimatedNavHost 12 | import com.google.accompanist.navigation.animation.rememberAnimatedNavController 13 | import com.google.accompanist.systemuicontroller.rememberSystemUiController 14 | 15 | @OptIn(ExperimentalAnimationApi::class) 16 | @Composable 17 | fun TicTacToeNavigation() { 18 | 19 | val navController = rememberAnimatedNavController() 20 | val systemUiController = rememberSystemUiController() 21 | 22 | SideEffect { 23 | systemUiController.setSystemBarsColor( 24 | color = Color.Transparent, 25 | darkIcons = true 26 | ) 27 | } 28 | 29 | AnimatedNavHost( 30 | navController = navController, 31 | startDestination = TicTacToeDestination.Dashboard.Root.route, 32 | modifier = Modifier 33 | .fillMaxSize() 34 | ) { 35 | DashboardAnimatedNavHost(navController) 36 | 37 | ScoreAnimatedNavHost(navController) 38 | 39 | GameAnimatedNavHost(navController) 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val md_theme_light_primary = Color(0xFFA63A23) 6 | val md_theme_light_onPrimary = Color(0xFFFFFFFF) 7 | val md_theme_light_primaryContainer = Color(0xFFFFDAD3) 8 | val md_theme_light_onPrimaryContainer = Color(0xFF3D0600) 9 | val md_theme_light_secondary = Color(0xFF77574F) 10 | val md_theme_light_onSecondary = Color(0xFFFFFFFF) 11 | val md_theme_light_secondaryContainer = Color(0xFFFFDAD3) 12 | val md_theme_light_onSecondaryContainer = Color(0xFF2C1510) 13 | val md_theme_light_tertiary = Color(0xFF6E5D2E) 14 | val md_theme_light_onTertiary = Color(0xFFFFFFFF) 15 | val md_theme_light_tertiaryContainer = Color(0xFFF8E0A6) 16 | val md_theme_light_onTertiaryContainer = Color(0xFF241A00) 17 | val md_theme_light_error = Color(0xFFBA1A1A) 18 | val md_theme_light_errorContainer = Color(0xFFFFDAD6) 19 | val md_theme_light_onError = Color(0xFFFFFFFF) 20 | val md_theme_light_onErrorContainer = Color(0xFF410002) 21 | val md_theme_light_background = Color(0xFFFFFBFF) 22 | val md_theme_light_onBackground = Color(0xFF201A19) 23 | val md_theme_light_surface = Color(0xFFFFFBFF) 24 | val md_theme_light_onSurface = Color(0xFF201A19) 25 | val md_theme_light_surfaceVariant = Color(0xFFF5DDD9) 26 | val md_theme_light_onSurfaceVariant = Color(0xFF534340) 27 | val md_theme_light_outline = Color(0xFF85736F) 28 | val md_theme_light_inverseOnSurface = Color(0xFFFBEEEB) 29 | val md_theme_light_inverseSurface = Color(0xFF362F2D) 30 | val md_theme_light_inversePrimary = Color(0xFFFFB4A4) 31 | val md_theme_light_shadow = Color(0xFF000000) 32 | val md_theme_light_surfaceTint = Color(0xFFA63A23) 33 | val md_theme_light_outlineVariant = Color(0xFFD8C2BD) 34 | val md_theme_light_scrim = Color(0xFF000000) 35 | 36 | val md_theme_dark_primary = Color(0xFFFFB4A4) 37 | val md_theme_dark_onPrimary = Color(0xFF630E00) 38 | val md_theme_dark_primaryContainer = Color(0xFF86220D) 39 | val md_theme_dark_onPrimaryContainer = Color(0xFFFFDAD3) 40 | val md_theme_dark_secondary = Color(0xFFE7BDB4) 41 | val md_theme_dark_onSecondary = Color(0xFF442A24) 42 | val md_theme_dark_secondaryContainer = Color(0xFF5D3F39) 43 | val md_theme_dark_onSecondaryContainer = Color(0xFFFFDAD3) 44 | val md_theme_dark_tertiary = Color(0xFFDBC58C) 45 | val md_theme_dark_onTertiary = Color(0xFF3C2F04) 46 | val md_theme_dark_tertiaryContainer = Color(0xFF544519) 47 | val md_theme_dark_onTertiaryContainer = Color(0xFFF8E0A6) 48 | val md_theme_dark_error = Color(0xFFFFB4AB) 49 | val md_theme_dark_errorContainer = Color(0xFF93000A) 50 | val md_theme_dark_onError = Color(0xFF690005) 51 | val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6) 52 | val md_theme_dark_background = Color(0xFF201A19) 53 | val md_theme_dark_onBackground = Color(0xFFEDE0DD) 54 | val md_theme_dark_surface = Color(0xFF201A19) 55 | val md_theme_dark_onSurface = Color(0xFFEDE0DD) 56 | val md_theme_dark_surfaceVariant = Color(0xFF534340) 57 | val md_theme_dark_onSurfaceVariant = Color(0xFFD8C2BD) 58 | val md_theme_dark_outline = Color(0xFFA08C88) 59 | val md_theme_dark_inverseOnSurface = Color(0xFF201A19) 60 | val md_theme_dark_inverseSurface = Color(0xFFEDE0DD) 61 | val md_theme_dark_inversePrimary = Color(0xFFA63A23) 62 | val md_theme_dark_shadow = Color(0xFF000000) 63 | val md_theme_dark_surfaceTint = Color(0xFFFFB4A4) 64 | val md_theme_dark_outlineVariant = Color(0xFF534340) 65 | val md_theme_dark_scrim = Color(0xFF000000) 66 | 67 | val seed = Color(0xFFEF6F53) 68 | 69 | val light_flirt = Color(0xFFb4007e) 70 | val light_flirtContainer = Color(0xFFffd8e8) 71 | val light_onFlirt = Color(0xFFffffff) 72 | val light_onFlirtContainer = Color(0xFF3d0027) 73 | 74 | val dark_flirt = Color(0xFFffafd5) 75 | val dark_flirtContainer = Color(0xFF620042) 76 | val dark_onFlirt = Color(0xFF8a005f) 77 | val dark_onFlirtContainer = Color(0xFFffd8e8) 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.theme 2 | 3 | import android.os.Build 4 | import androidx.compose.material3.* 5 | import androidx.compose.runtime.Composable 6 | import androidx.compose.ui.platform.LocalContext 7 | 8 | private val LightColors = lightColorScheme( 9 | primary = md_theme_light_primary, 10 | onPrimary = md_theme_light_onPrimary, 11 | primaryContainer = md_theme_light_primaryContainer, 12 | onPrimaryContainer = md_theme_light_onPrimaryContainer, 13 | secondary = md_theme_light_secondary, 14 | onSecondary = md_theme_light_onSecondary, 15 | secondaryContainer = md_theme_light_secondaryContainer, 16 | onSecondaryContainer = md_theme_light_onSecondaryContainer, 17 | tertiary = md_theme_light_tertiary, 18 | onTertiary = md_theme_light_onTertiary, 19 | tertiaryContainer = md_theme_light_tertiaryContainer, 20 | onTertiaryContainer = md_theme_light_onTertiaryContainer, 21 | error = md_theme_light_error, 22 | errorContainer = md_theme_light_errorContainer, 23 | onError = md_theme_light_onError, 24 | onErrorContainer = md_theme_light_onErrorContainer, 25 | background = md_theme_light_background, 26 | onBackground = md_theme_light_onBackground, 27 | surface = md_theme_light_surface, 28 | onSurface = md_theme_light_onSurface, 29 | surfaceVariant = md_theme_light_surfaceVariant, 30 | onSurfaceVariant = md_theme_light_onSurfaceVariant, 31 | outline = md_theme_light_outline, 32 | inverseOnSurface = md_theme_light_inverseOnSurface, 33 | inverseSurface = md_theme_light_inverseSurface, 34 | inversePrimary = md_theme_light_inversePrimary, 35 | surfaceTint = md_theme_light_surfaceTint, 36 | outlineVariant = md_theme_light_outlineVariant, 37 | scrim = md_theme_light_scrim, 38 | ) 39 | 40 | 41 | private val DarkColors = darkColorScheme( 42 | primary = md_theme_dark_primary, 43 | onPrimary = md_theme_dark_onPrimary, 44 | primaryContainer = md_theme_dark_primaryContainer, 45 | onPrimaryContainer = md_theme_dark_onPrimaryContainer, 46 | secondary = md_theme_dark_secondary, 47 | onSecondary = md_theme_dark_onSecondary, 48 | secondaryContainer = md_theme_dark_secondaryContainer, 49 | onSecondaryContainer = md_theme_dark_onSecondaryContainer, 50 | tertiary = md_theme_dark_tertiary, 51 | onTertiary = md_theme_dark_onTertiary, 52 | tertiaryContainer = md_theme_dark_tertiaryContainer, 53 | onTertiaryContainer = md_theme_dark_onTertiaryContainer, 54 | error = md_theme_dark_error, 55 | errorContainer = md_theme_dark_errorContainer, 56 | onError = md_theme_dark_onError, 57 | onErrorContainer = md_theme_dark_onErrorContainer, 58 | background = md_theme_dark_background, 59 | onBackground = md_theme_dark_onBackground, 60 | surface = md_theme_dark_surface, 61 | onSurface = md_theme_dark_onSurface, 62 | surfaceVariant = md_theme_dark_surfaceVariant, 63 | onSurfaceVariant = md_theme_dark_onSurfaceVariant, 64 | outline = md_theme_dark_outline, 65 | inverseOnSurface = md_theme_dark_inverseOnSurface, 66 | inverseSurface = md_theme_dark_inverseSurface, 67 | inversePrimary = md_theme_dark_inversePrimary, 68 | surfaceTint = md_theme_dark_surfaceTint, 69 | outlineVariant = md_theme_dark_outlineVariant, 70 | scrim = md_theme_dark_scrim, 71 | ) 72 | 73 | @Composable 74 | fun TicTacToeTheme( 75 | darkTheme: Boolean = false, 76 | // Dynamic color is available on Android 12+ 77 | dynamicColor: Boolean = true, 78 | content: @Composable () -> Unit 79 | ) { 80 | val colorScheme = when { 81 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 82 | val context = LocalContext.current 83 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) 84 | } 85 | darkTheme -> DarkColors 86 | else -> LightColors 87 | } 88 | 89 | MaterialTheme( 90 | colorScheme = colorScheme, 91 | typography = Typography, 92 | content = content 93 | ) 94 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.theme 2 | 3 | import androidx.compose.material3.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | bodyLarge = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp, 15 | lineHeight = 24.sp, 16 | letterSpacing = 0.5.sp 17 | ) 18 | /* Other default text styles to override 19 | titleLarge = TextStyle( 20 | fontFamily = FontFamily.Default, 21 | fontWeight = FontWeight.Normal, 22 | fontSize = 22.sp, 23 | lineHeight = 28.sp, 24 | letterSpacing = 0.sp 25 | ), 26 | labelSmall = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Medium, 29 | fontSize = 11.sp, 30 | lineHeight = 16.sp, 31 | letterSpacing = 0.5.sp 32 | ) 33 | */ 34 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/ui/dashboard/DashboardScreen.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.ui.dashboard 2 | 3 | import android.content.Intent 4 | import android.net.Uri 5 | import androidx.compose.foundation.Image 6 | import androidx.compose.foundation.layout.* 7 | import androidx.compose.foundation.text.ClickableText 8 | import androidx.compose.material3.* 9 | import androidx.compose.runtime.Composable 10 | import androidx.compose.runtime.LaunchedEffect 11 | import androidx.compose.runtime.remember 12 | import androidx.compose.ui.Alignment 13 | import androidx.compose.ui.Modifier 14 | import androidx.compose.ui.draw.clip 15 | import androidx.compose.ui.platform.LocalContext 16 | import androidx.compose.ui.res.painterResource 17 | import androidx.compose.ui.text.SpanStyle 18 | import androidx.compose.ui.text.buildAnnotatedString 19 | import androidx.compose.ui.text.font.FontWeight 20 | import androidx.compose.ui.text.style.TextAlign 21 | import androidx.compose.ui.text.withStyle 22 | import androidx.compose.ui.unit.dp 23 | import androidx.navigation.NavController 24 | import com.anafthdev.tictactoe.R 25 | import com.anafthdev.tictactoe.data.GameMode 26 | import com.anafthdev.tictactoe.data.TicTacToeDestination 27 | import com.anafthdev.tictactoe.uicomponent.GameModeSelector 28 | 29 | @Composable 30 | fun DashboardScreen( 31 | navController: NavController, 32 | viewModel: DashboardViewModel 33 | ) { 34 | 35 | val context = LocalContext.current 36 | 37 | val playButtonEnabled = remember(viewModel.bluetoothAvailable, viewModel.selectedGameMode) { 38 | if (!viewModel.bluetoothAvailable && viewModel.selectedGameMode == GameMode.PvPBluetooth) { 39 | return@remember false 40 | } 41 | 42 | return@remember true 43 | } 44 | 45 | LaunchedEffect(context) { 46 | viewModel.checkBluetooth(context) 47 | } 48 | 49 | Column( 50 | horizontalAlignment = Alignment.CenterHorizontally, 51 | verticalArrangement = Arrangement.Center, 52 | modifier = Modifier 53 | .fillMaxSize() 54 | ) { 55 | Image( 56 | painter = painterResource(id = R.drawable.ic_app_icon), 57 | contentDescription = null, 58 | modifier = Modifier 59 | .size(96.dp) 60 | .clip(MaterialTheme.shapes.large) 61 | ) 62 | 63 | Spacer(modifier = Modifier.padding(8.dp)) 64 | 65 | GameModeSelector( 66 | gameModes = GameMode.values(), 67 | selectedGameMode = viewModel.selectedGameMode, 68 | onGameModeChanged = viewModel::updateGameMode, 69 | modifier = Modifier 70 | .fillMaxWidth(0.6f) 71 | ) 72 | 73 | Spacer(modifier = Modifier.padding(8.dp)) 74 | 75 | OutlinedButton( 76 | enabled = playButtonEnabled, 77 | onClick = { 78 | navController.navigate( 79 | TicTacToeDestination.Game.Home.createRoute( 80 | gameMode = viewModel.selectedGameMode 81 | ) 82 | ) 83 | } 84 | ) { 85 | Text("Play") 86 | } 87 | 88 | Spacer(modifier = Modifier.padding(16.dp)) 89 | 90 | Row( 91 | verticalAlignment = Alignment.CenterVertically 92 | ) { 93 | // IconButton( 94 | // onClick = { 95 | // navController.navigate(TicTacToeDestination.Score.Home.route) 96 | // } 97 | // ) { 98 | // Icon( 99 | // painter = painterResource(id = R.drawable.ic_award), 100 | // contentDescription = null 101 | // ) 102 | // } 103 | 104 | IconButton( 105 | onClick = { 106 | context.startActivity( 107 | Intent(Intent.ACTION_VIEW).apply { 108 | flags = Intent.FLAG_ACTIVITY_NEW_TASK 109 | data = Uri.parse("https://github.com/kafri8889/Compose-Classic-Snake-Game") 110 | } 111 | ) 112 | } 113 | ) { 114 | Icon( 115 | painter = painterResource(id = R.drawable.ic_github_mark), 116 | contentDescription = null 117 | ) 118 | } 119 | } 120 | 121 | Spacer(modifier = Modifier.padding(16.dp)) 122 | 123 | OpenSourceText() 124 | } 125 | } 126 | 127 | @Composable 128 | fun OpenSourceText() { 129 | 130 | val context = LocalContext.current 131 | 132 | val openSourceProjectMsg = buildAnnotatedString { 133 | withStyle( 134 | style = LocalTextStyle.current.copy( 135 | textAlign = TextAlign.Center, 136 | fontWeight = FontWeight.Light 137 | ).toSpanStyle() 138 | ) { 139 | append("This is an open source project, source code can be found on ") 140 | 141 | pushStringAnnotation(tag = "github", annotation = "https://google.com/policy") 142 | 143 | withStyle( 144 | style = SpanStyle( 145 | color = MaterialTheme.colorScheme.primary, 146 | fontWeight = FontWeight.Medium 147 | ) 148 | ) { 149 | append("GitHub") 150 | } 151 | 152 | pop() 153 | 154 | append(" or by clicking on the GitHub icon above") 155 | } 156 | } 157 | 158 | Text( 159 | text = "Open Source", 160 | style = MaterialTheme.typography.titleLarge.copy( 161 | fontWeight = FontWeight.Light 162 | ) 163 | ) 164 | 165 | Spacer(modifier = Modifier.padding(8.dp)) 166 | 167 | ClickableText( 168 | text = openSourceProjectMsg, 169 | style = LocalTextStyle.current.copy( 170 | textAlign = TextAlign.Center 171 | ), 172 | onClick = { offset -> 173 | openSourceProjectMsg.getStringAnnotations( 174 | tag = "github", 175 | start = offset, 176 | end = offset 177 | ).firstOrNull()?.let { _ -> 178 | context.startActivity( 179 | Intent(Intent.ACTION_VIEW).apply { 180 | flags = Intent.FLAG_ACTIVITY_NEW_TASK 181 | data = Uri.parse("https://github.com/kafri8889/Compose-Classic-Snake-Game") 182 | } 183 | ) 184 | } 185 | }, 186 | modifier = Modifier 187 | .fillMaxWidth(0.7f) 188 | ) 189 | } 190 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/ui/dashboard/DashboardViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.ui.dashboard 2 | 3 | import android.content.Context 4 | import android.content.pm.PackageManager 5 | import androidx.compose.runtime.getValue 6 | import androidx.compose.runtime.mutableStateOf 7 | import androidx.compose.runtime.setValue 8 | import androidx.lifecycle.ViewModel 9 | import com.anafthdev.tictactoe.data.GameMode 10 | import dagger.hilt.android.lifecycle.HiltViewModel 11 | import javax.inject.Inject 12 | 13 | @HiltViewModel 14 | class DashboardViewModel @Inject constructor(): ViewModel() { 15 | 16 | var selectedGameMode by mutableStateOf(GameMode.Computer) 17 | private set 18 | 19 | var bluetoothAvailable by mutableStateOf(false) 20 | private set 21 | 22 | fun checkBluetooth(context: Context) { 23 | bluetoothAvailable = context.packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH) 24 | } 25 | 26 | fun updateGameMode(mode: GameMode) { 27 | selectedGameMode = mode 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/ui/game/GameScreen.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.ui.game 2 | 3 | import androidx.compose.foundation.background 4 | import androidx.compose.foundation.layout.* 5 | import androidx.compose.material3.MaterialTheme 6 | import androidx.compose.runtime.Composable 7 | import androidx.compose.runtime.LaunchedEffect 8 | import androidx.compose.ui.Alignment 9 | import androidx.compose.ui.Modifier 10 | import androidx.compose.ui.unit.dp 11 | import androidx.navigation.NavController 12 | import com.anafthdev.tictactoe.data.PointType 13 | import com.anafthdev.tictactoe.data.TurnType 14 | import com.anafthdev.tictactoe.data.WinType 15 | import com.anafthdev.tictactoe.extension.toast 16 | import com.anafthdev.tictactoe.uicomponent.PlayerItem 17 | import com.anafthdev.tictactoe.uicomponent.RoundItem 18 | import com.anafthdev.tictactoe.uicomponent.TicTacToeBoard 19 | 20 | @Composable 21 | fun GameScreen( 22 | navController: NavController, 23 | viewModel: GameViewModel 24 | ) { 25 | LaunchedEffect(viewModel.winner) { 26 | when (viewModel.winner) { 27 | WinType.Tie -> "Tie".toast() 28 | WinType.O -> { 29 | if (viewModel.playerOne.pointType == PointType.O) "${viewModel.playerOne.name} win".toast() 30 | else "${viewModel.playerTwo.name} win".toast() 31 | } 32 | WinType.X -> { 33 | if (viewModel.playerOne.pointType == PointType.X) "${viewModel.playerOne.name} win".toast() 34 | else "${viewModel.playerTwo.name} win".toast() 35 | } 36 | WinType.None -> {} 37 | } 38 | 39 | viewModel.clearBoard() 40 | } 41 | 42 | Column( 43 | modifier = Modifier 44 | .systemBarsPadding() 45 | .fillMaxSize() 46 | .background(MaterialTheme.colorScheme.surface) 47 | ) { 48 | Row( 49 | verticalAlignment = Alignment.CenterVertically, 50 | horizontalArrangement = Arrangement.SpaceBetween, 51 | modifier = Modifier 52 | .padding(16.dp) 53 | .fillMaxWidth() 54 | ) { 55 | PlayerItem( 56 | player = viewModel.playerOne, 57 | playerTurn = viewModel.currentTurn == TurnType.PlayerOne 58 | ) 59 | 60 | RoundItem( 61 | round = viewModel.round, 62 | draw = viewModel.draw 63 | ) 64 | 65 | PlayerItem( 66 | player = viewModel.playerTwo, 67 | playerTurn = viewModel.currentTurn == TurnType.PlayerTwo 68 | ) 69 | } 70 | 71 | Box( 72 | contentAlignment = Alignment.Center, 73 | modifier = Modifier 74 | .weight(1f) 75 | ) { 76 | TicTacToeBoard( 77 | board = viewModel.board, 78 | onClick = { row, col -> 79 | viewModel.updateBoard(row, col) 80 | }, 81 | modifier = Modifier 82 | .fillMaxWidth() 83 | .aspectRatio(1f / 1f) 84 | ) 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/ui/game/GameViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.ui.game 2 | 3 | import androidx.compose.runtime.getValue 4 | import androidx.compose.runtime.mutableStateListOf 5 | import androidx.compose.runtime.mutableStateOf 6 | import androidx.compose.runtime.setValue 7 | import androidx.lifecycle.SavedStateHandle 8 | import androidx.lifecycle.ViewModel 9 | import androidx.lifecycle.viewModelScope 10 | import com.anafthdev.tictactoe.common.GameEngine 11 | import com.anafthdev.tictactoe.data.* 12 | import com.anafthdev.tictactoe.extension.to2DArray 13 | import com.anafthdev.tictactoe.model.Player 14 | import dagger.hilt.android.lifecycle.HiltViewModel 15 | import kotlinx.coroutines.launch 16 | import javax.inject.Inject 17 | 18 | @HiltViewModel 19 | class GameViewModel @Inject constructor( 20 | savedStateHandle: SavedStateHandle 21 | ): ViewModel() { 22 | 23 | val board = mutableStateListOf>() 24 | 25 | var currentTurn by mutableStateOf(TurnType.PlayerOne) 26 | private set 27 | 28 | var playerOne by mutableStateOf(Player.Player1) 29 | private set 30 | 31 | var playerTwo by mutableStateOf(Player.Player2) 32 | private set 33 | 34 | var gameMode by mutableStateOf(GameMode.Computer) 35 | private set 36 | 37 | var winner by mutableStateOf(WinType.None) 38 | private set 39 | 40 | var round by mutableStateOf(1) 41 | private set 42 | 43 | var draw by mutableStateOf(0) 44 | private set 45 | 46 | private val gameEngine = GameEngine( 47 | playerOne = playerOne, 48 | playerTwo = playerTwo 49 | ) 50 | 51 | private val _gameMode = savedStateHandle.getStateFlow(ARG_GAME_MODE, 0) 52 | 53 | init { 54 | gameEngine.setListener(object : GameEngine.Listener { 55 | override fun onWin(type: WinType) { 56 | winner = type 57 | 58 | when { 59 | playerOne.pointType == PointType.O && winner == WinType.O -> { 60 | playerOne = playerOne.copy(win = playerOne.win + 1) 61 | } 62 | playerOne.pointType == PointType.X && winner == WinType.X -> { 63 | playerOne = playerOne.copy(win = playerOne.win + 1) 64 | } 65 | playerTwo.pointType == PointType.O && winner == WinType.O -> { 66 | playerTwo = playerTwo.copy(win = playerTwo.win + 1) 67 | } 68 | playerTwo.pointType == PointType.X && winner == WinType.X -> { 69 | playerTwo = playerTwo.copy(win = playerTwo.win + 1) 70 | } 71 | winner == WinType.Tie -> { 72 | draw += 1 73 | } 74 | } 75 | 76 | if (winner != WinType.None) { 77 | round++ 78 | } 79 | } 80 | }) 81 | 82 | viewModelScope.launch { 83 | gameEngine.board.collect { mBoard -> 84 | board.apply { 85 | clear() 86 | addAll(mBoard.to2DArray(3)) 87 | } 88 | } 89 | } 90 | 91 | viewModelScope.launch { 92 | gameEngine.currentTurn.collect { turn -> 93 | currentTurn = turn 94 | } 95 | } 96 | 97 | viewModelScope.launch { 98 | _gameMode.collect { ordinal -> 99 | val mode = GameMode.values()[ordinal] 100 | 101 | gameMode = mode 102 | 103 | when (mode) { 104 | GameMode.Computer -> { 105 | playerOne = Player.Player1 106 | playerTwo = Player.Computer 107 | } 108 | GameMode.PvP -> { 109 | playerOne = Player.Player1 110 | playerTwo = Player.Player2 111 | } 112 | GameMode.PvPBluetooth -> {} 113 | } 114 | 115 | gameEngine.updatePlayer( 116 | one = playerOne, 117 | two = playerTwo 118 | ) 119 | } 120 | } 121 | } 122 | 123 | fun updateBoard(row: Int, col: Int) { 124 | val index = board[0].size * row + col 125 | 126 | viewModelScope.launch { 127 | gameEngine.updateBoard(index) 128 | } 129 | } 130 | 131 | fun clearBoard() { 132 | winner = WinType.None 133 | 134 | viewModelScope.launch { 135 | gameEngine.clearBoard() 136 | } 137 | } 138 | 139 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/ui/score/ScoreScreen.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.ui.score 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.navigation.NavController 5 | 6 | @Composable 7 | fun ScoreScreen( 8 | navController: NavController, 9 | viewModel: ScoreViewModel 10 | ) { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/ui/score/ScoreViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.ui.score 2 | 3 | import androidx.lifecycle.ViewModel 4 | import dagger.hilt.android.lifecycle.HiltViewModel 5 | import javax.inject.Inject 6 | 7 | @HiltViewModel 8 | class ScoreViewModel @Inject constructor(): ViewModel() { 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/uicomponent/GameModeSelector.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.uicomponent 2 | 3 | import androidx.compose.animation.* 4 | import androidx.compose.animation.core.animateFloatAsState 5 | import androidx.compose.animation.core.tween 6 | import androidx.compose.foundation.layout.Arrangement 7 | import androidx.compose.foundation.layout.Row 8 | import androidx.compose.material.icons.Icons 9 | import androidx.compose.material.icons.rounded.ArrowBackIos 10 | import androidx.compose.material.icons.rounded.ArrowForwardIos 11 | import androidx.compose.material3.* 12 | import androidx.compose.runtime.* 13 | import androidx.compose.ui.Alignment 14 | import androidx.compose.ui.Modifier 15 | import androidx.compose.ui.graphics.graphicsLayer 16 | import androidx.compose.ui.platform.LocalConfiguration 17 | import androidx.compose.ui.platform.LocalDensity 18 | import androidx.compose.ui.unit.dp 19 | import com.anafthdev.tictactoe.data.GameMode 20 | import com.anafthdev.tictactoe.extension.modeName 21 | import timber.log.Timber 22 | 23 | @OptIn(ExperimentalAnimationApi::class) 24 | @Composable 25 | fun GameModeSelector( 26 | gameModes: Array, 27 | selectedGameMode: GameMode, 28 | modifier: Modifier = Modifier, 29 | onGameModeChanged: (GameMode) -> Unit 30 | ) { 31 | 32 | val density = LocalDensity.current 33 | val config = LocalConfiguration.current 34 | 35 | val selectedGameModeIndex = remember(selectedGameMode, gameModes) { 36 | Timber.i("$selectedGameMode -> $gameModes") 37 | gameModes.indexOfFirst { it == selectedGameMode }.also { 38 | Timber.i("selectedGameModeIndex: $it") 39 | } 40 | } 41 | 42 | val backButtonAlpha by animateFloatAsState( 43 | targetValue = if (selectedGameModeIndex <= 0) 0f else 1f, 44 | animationSpec = tween(500) 45 | ) 46 | 47 | val forwardButtonAlpha by animateFloatAsState( 48 | targetValue = if (selectedGameModeIndex >= gameModes.lastIndex) 0f else 1f, 49 | animationSpec = tween(500) 50 | ) 51 | 52 | var enterAnimOffset by remember { 53 | mutableStateOf(with(density) { config.screenWidthDp.dp.roundToPx() }) 54 | } 55 | var exitAnimOffset by remember { 56 | mutableStateOf(with(density) { -config.screenWidthDp.dp.roundToPx() }) 57 | } 58 | 59 | Row( 60 | verticalAlignment = Alignment.CenterVertically, 61 | horizontalArrangement = Arrangement.SpaceBetween, 62 | modifier = modifier 63 | ) { 64 | IconButton( 65 | onClick = { 66 | if (selectedGameModeIndex > 0) { 67 | onGameModeChanged(gameModes[selectedGameModeIndex - 1]) 68 | 69 | // Left 70 | enterAnimOffset = with(density) { -config.screenWidthDp.dp.roundToPx() } 71 | exitAnimOffset = with(density) { config.screenWidthDp.dp.roundToPx() } 72 | } 73 | }, 74 | modifier = Modifier 75 | .graphicsLayer { 76 | alpha = backButtonAlpha 77 | } 78 | ) { 79 | Icon( 80 | imageVector = Icons.Rounded.ArrowBackIos, 81 | contentDescription = null 82 | ) 83 | } 84 | 85 | AnimatedContent( 86 | targetState = selectedGameMode, 87 | transitionSpec = { 88 | slideInHorizontally( 89 | initialOffsetX = { enterAnimOffset }, 90 | animationSpec = tween(600) 91 | ) with slideOutHorizontally( 92 | targetOffsetX = { exitAnimOffset }, 93 | animationSpec = tween(600) 94 | ) 95 | } 96 | ) { mode -> 97 | Text( 98 | text = mode.modeName, 99 | style = MaterialTheme.typography.titleLarge 100 | ) 101 | } 102 | 103 | IconButton( 104 | onClick = { 105 | if (selectedGameModeIndex < gameModes.lastIndex) { 106 | onGameModeChanged(gameModes[selectedGameModeIndex + 1]) 107 | 108 | // Right 109 | enterAnimOffset = with(density) { config.screenWidthDp.dp.roundToPx() } 110 | exitAnimOffset = with(density) { -config.screenWidthDp.dp.roundToPx() } 111 | } 112 | }, 113 | modifier = Modifier 114 | .graphicsLayer { 115 | alpha = forwardButtonAlpha 116 | } 117 | ) { 118 | Icon( 119 | imageVector = Icons.Rounded.ArrowForwardIos, 120 | contentDescription = null 121 | ) 122 | } 123 | } 124 | 125 | } 126 | 127 | enum class GameModeSelectorDirection { 128 | LEFT, 129 | RIGHT 130 | } 131 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/uicomponent/Padding.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.uicomponent 2 | 3 | import androidx.compose.foundation.layout.Column 4 | import androidx.compose.foundation.layout.ColumnScope 5 | import androidx.compose.foundation.layout.padding 6 | import androidx.compose.runtime.Composable 7 | import androidx.compose.ui.Modifier 8 | import androidx.compose.ui.unit.Dp 9 | 10 | @Composable 11 | fun ColumnScope.Padding( 12 | all: Dp, 13 | content: @Composable ColumnScope.() -> Unit 14 | ) { 15 | Column( 16 | modifier = Modifier 17 | .padding(all) 18 | ) { 19 | content() 20 | } 21 | } 22 | 23 | @Composable 24 | fun Padding( 25 | all: Dp, 26 | content: @Composable () -> Unit 27 | ) { 28 | Column( 29 | modifier = Modifier 30 | .padding(all) 31 | ) { 32 | content() 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/uicomponent/PlayerItem.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.uicomponent 2 | 3 | import androidx.compose.animation.animateColorAsState 4 | import androidx.compose.animation.core.tween 5 | import androidx.compose.foundation.BorderStroke 6 | import androidx.compose.foundation.Image 7 | import androidx.compose.foundation.layout.* 8 | import androidx.compose.foundation.shape.CircleShape 9 | import androidx.compose.material3.Card 10 | import androidx.compose.material3.MaterialTheme 11 | import androidx.compose.material3.Text 12 | import androidx.compose.runtime.Composable 13 | import androidx.compose.runtime.getValue 14 | import androidx.compose.ui.Alignment 15 | import androidx.compose.ui.Modifier 16 | import androidx.compose.ui.draw.clip 17 | import androidx.compose.ui.draw.drawBehind 18 | import androidx.compose.ui.geometry.CornerRadius 19 | import androidx.compose.ui.res.painterResource 20 | import androidx.compose.ui.text.font.FontWeight 21 | import androidx.compose.ui.unit.dp 22 | import com.anafthdev.tictactoe.R 23 | import com.anafthdev.tictactoe.data.PointType 24 | import com.anafthdev.tictactoe.model.Player 25 | import com.anafthdev.tictactoe.theme.light_onFlirtContainer 26 | 27 | @Composable 28 | fun PlayerItem( 29 | player: Player, 30 | playerTurn: Boolean, 31 | modifier: Modifier = Modifier 32 | ) { 33 | 34 | Column( 35 | horizontalAlignment = Alignment.CenterHorizontally 36 | ) { 37 | Card(modifier = modifier) { 38 | Column( 39 | horizontalAlignment = Alignment.CenterHorizontally, 40 | modifier = Modifier 41 | .padding(16.dp) 42 | ) { 43 | Text( 44 | text = player.name, 45 | style = MaterialTheme.typography.bodySmall.copy( 46 | fontWeight = FontWeight.Bold 47 | ) 48 | ) 49 | 50 | Spacer(modifier = Modifier.height(16.dp)) 51 | 52 | PlayerPointType( 53 | playerTurn = playerTurn, 54 | pointType = player.pointType 55 | ) 56 | } 57 | } 58 | 59 | Spacer(modifier = Modifier.height(8.dp)) 60 | 61 | Card( 62 | shape = CircleShape, 63 | border = BorderStroke( 64 | width = 1.dp, 65 | color = MaterialTheme.colorScheme.onSurfaceVariant 66 | ) 67 | ) { 68 | Text( 69 | text = "Win rounds: ${player.win}", 70 | style = MaterialTheme.typography.labelMedium.copy( 71 | fontWeight = FontWeight.Medium, 72 | color = MaterialTheme.colorScheme.tertiary 73 | ), 74 | modifier = Modifier 75 | .padding( 76 | horizontal = 8.dp, 77 | vertical = 4.dp 78 | ) 79 | ) 80 | } 81 | } 82 | } 83 | 84 | @Composable 85 | private fun PlayerPointType( 86 | playerTurn: Boolean, 87 | pointType: PointType 88 | ) { 89 | // val imageRes = remember(pointType) { 90 | // when (pointType) { 91 | // PointType.Empty -> R.drawable.transparent 92 | // PointType.X -> R.drawable.ic_tic_tac_toe_x 93 | // PointType.O -> R.drawable.ic_tic_tac_toe_o 94 | // } 95 | // } 96 | 97 | val pointTypeBackground by animateColorAsState( 98 | targetValue = if (playerTurn) light_onFlirtContainer 99 | else MaterialTheme.colorScheme.background, 100 | animationSpec = tween(500) 101 | ) 102 | 103 | Box( 104 | modifier = Modifier 105 | .clip(MaterialTheme.shapes.large) 106 | .drawBehind { 107 | drawRoundRect( 108 | color = pointTypeBackground, 109 | cornerRadius = CornerRadius( 110 | x = CircleShape.topStart.toPx(size, this), 111 | y = CircleShape.bottomEnd.toPx(size, this) 112 | ) 113 | ) 114 | } 115 | ) { 116 | PlayerPointTypeImage(pointType = pointType) 117 | } 118 | } 119 | 120 | @Composable 121 | private fun PlayerPointTypeImage( 122 | pointType: PointType 123 | ) { 124 | Image( 125 | painter = painterResource( 126 | id = when (pointType) { 127 | PointType.Empty -> R.drawable.transparent 128 | PointType.X -> R.drawable.ic_tic_tac_toe_x 129 | PointType.O -> R.drawable.ic_tic_tac_toe_o 130 | } 131 | ), 132 | contentDescription = null, 133 | modifier = Modifier 134 | .padding( 135 | horizontal = 12.dp, 136 | vertical = 4.dp 137 | ) 138 | .size(24.dp) 139 | ) 140 | } 141 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/uicomponent/RoundItem.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.uicomponent 2 | 3 | import androidx.compose.foundation.layout.* 4 | import androidx.compose.foundation.shape.RoundedCornerShape 5 | import androidx.compose.material3.Card 6 | import androidx.compose.material3.CardDefaults 7 | import androidx.compose.material3.MaterialTheme 8 | import androidx.compose.material3.Text 9 | import androidx.compose.runtime.Composable 10 | import androidx.compose.ui.Alignment 11 | import androidx.compose.ui.Modifier 12 | import androidx.compose.ui.text.buildAnnotatedString 13 | import androidx.compose.ui.text.font.FontWeight 14 | import androidx.compose.ui.text.style.BaselineShift 15 | import androidx.compose.ui.text.withStyle 16 | import androidx.compose.ui.unit.dp 17 | 18 | @Composable 19 | fun RoundItem( 20 | draw: Int, 21 | round: Int, 22 | modifier: Modifier = Modifier 23 | ) { 24 | 25 | Column( 26 | horizontalAlignment = Alignment.CenterHorizontally, 27 | modifier = modifier 28 | ) { 29 | Card( 30 | shape = RoundedCornerShape(100), 31 | colors = CardDefaults.cardColors( 32 | containerColor = MaterialTheme.colorScheme.tertiaryContainer 33 | ) 34 | ) { 35 | Column( 36 | horizontalAlignment = Alignment.CenterHorizontally, 37 | verticalArrangement = Arrangement.Center, 38 | modifier = Modifier 39 | .padding(8.dp) 40 | .size(56.dp) 41 | ) { 42 | Text( 43 | text = buildAnnotatedString { 44 | withStyle( 45 | MaterialTheme.typography.titleMedium.copy( 46 | fontWeight = FontWeight.ExtraBold 47 | ).toSpanStyle() 48 | ) { 49 | append("$round") 50 | } 51 | 52 | withStyle( 53 | MaterialTheme.typography.bodyMedium.copy( 54 | fontWeight = FontWeight.ExtraBold, 55 | baselineShift = BaselineShift.Superscript 56 | ).toSpanStyle() 57 | ) { 58 | append( 59 | when (round) { 60 | 1 -> "st" 61 | 2 -> "nd" 62 | 3 -> "rd" 63 | else -> "th" 64 | } 65 | ) 66 | } 67 | } 68 | ) 69 | 70 | Text( 71 | text = "Round", 72 | style = MaterialTheme.typography.labelSmall 73 | ) 74 | } 75 | } 76 | 77 | Spacer(modifier = Modifier.height(16.dp)) 78 | 79 | Text( 80 | text = buildAnnotatedString { 81 | withStyle( 82 | MaterialTheme.typography.titleSmall.toSpanStyle() 83 | ) { 84 | append("Draw: ") 85 | } 86 | 87 | withStyle( 88 | MaterialTheme.typography.titleSmall.copy( 89 | color = MaterialTheme.colorScheme.primary 90 | ).toSpanStyle() 91 | ) { 92 | append("$draw times") 93 | } 94 | } 95 | ) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/anafthdev/tictactoe/uicomponent/TicTacToeBoard.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe.uicomponent 2 | 3 | import androidx.compose.animation.AnimatedVisibility 4 | import androidx.compose.animation.ExperimentalAnimationApi 5 | import androidx.compose.animation.core.tween 6 | import androidx.compose.animation.scaleIn 7 | import androidx.compose.animation.scaleOut 8 | import androidx.compose.foundation.Image 9 | import androidx.compose.foundation.clickable 10 | import androidx.compose.foundation.layout.* 11 | import androidx.compose.foundation.shape.CircleShape 12 | import androidx.compose.material3.Divider 13 | import androidx.compose.runtime.Composable 14 | import androidx.compose.runtime.remember 15 | import androidx.compose.ui.Modifier 16 | import androidx.compose.ui.draw.clip 17 | import androidx.compose.ui.res.painterResource 18 | import androidx.compose.ui.unit.Density 19 | import androidx.compose.ui.unit.Dp 20 | import androidx.compose.ui.unit.IntOffset 21 | import androidx.compose.ui.unit.dp 22 | import androidx.compose.ui.zIndex 23 | import com.anafthdev.tictactoe.R 24 | import com.anafthdev.tictactoe.data.PointType 25 | 26 | @OptIn(ExperimentalAnimationApi::class) 27 | @Composable 28 | fun TicTacToeBoard( 29 | board: List>, 30 | modifier: Modifier = Modifier, 31 | onClick: (row: Int, col: Int) -> Unit 32 | ) { 33 | 34 | val dividerWidth = remember { 8.dp } 35 | 36 | BoxWithConstraints(modifier = modifier) { 37 | val tileSize = remember(maxWidth, dividerWidth) { 38 | (maxWidth / 3) - dividerWidth / 1.5f 39 | } 40 | 41 | for ((row, pointTypeRow) in board.withIndex()) { 42 | for ((col, pointType) in pointTypeRow.withIndex()) { 43 | val endPadding = remember { 44 | when { 45 | col != 0 -> dividerWidth 46 | else -> 0.dp 47 | } 48 | } 49 | 50 | val bottomPadding = remember { 51 | when { 52 | row != 0 -> dividerWidth 53 | else -> 0.dp 54 | } 55 | } 56 | 57 | Box( 58 | modifier = Modifier 59 | .zIndex(1f) 60 | .offset( 61 | x = (tileSize * col) + (endPadding * col), 62 | y = (tileSize * row) + (bottomPadding * row) 63 | ) 64 | .size(tileSize) 65 | .clickable { 66 | if (pointType == PointType.Empty) { 67 | onClick(row, col) 68 | } 69 | } 70 | ) { 71 | AnimatedVisibility( 72 | visible = pointType != PointType.Empty, 73 | enter = scaleIn( 74 | animationSpec = tween(200) 75 | ), 76 | exit = scaleOut( 77 | animationSpec = tween(200) 78 | ), 79 | modifier = Modifier 80 | .padding(8.dp) 81 | .matchParentSize() 82 | ) { 83 | PointTypeImage( 84 | pointType = pointType 85 | ) 86 | } 87 | } 88 | } 89 | } 90 | 91 | for (i in 0 until 2) { 92 | val padding = remember { 93 | when { 94 | i != 0 -> dividerWidth 95 | else -> 0.dp 96 | } 97 | } 98 | 99 | BoardDivider( 100 | maxHeight = maxHeight, 101 | dividerThickness = { dividerWidth }, 102 | offsetVert = { 103 | IntOffset( 104 | x = (tileSize * (i + 1) + padding) 105 | .toPx() 106 | .toInt(), 107 | y = 0.dp 108 | .toPx() 109 | .toInt() 110 | ) 111 | }, 112 | offsetHorz = { 113 | IntOffset( 114 | x = 0.dp 115 | .toPx() 116 | .toInt(), 117 | y = (tileSize * (i + 1) + padding) 118 | .toPx() 119 | .toInt() 120 | ) 121 | } 122 | ) 123 | } 124 | } 125 | } 126 | 127 | @Composable 128 | private fun BoardDivider( 129 | maxHeight: Dp, 130 | dividerThickness: () -> Dp, 131 | offsetHorz: Density.() -> IntOffset, 132 | offsetVert: Density.() -> IntOffset 133 | ) { 134 | 135 | Divider( 136 | thickness = dividerThickness(), 137 | modifier = Modifier 138 | .offset { 139 | offsetVert() 140 | } 141 | .size(dividerThickness(), maxHeight) 142 | .clip(CircleShape) 143 | ) 144 | 145 | Divider( 146 | thickness = dividerThickness(), 147 | modifier = Modifier 148 | .offset { 149 | offsetHorz() 150 | } 151 | .fillMaxWidth() 152 | .height(dividerThickness()) 153 | .clip(CircleShape) 154 | ) 155 | } 156 | 157 | @Composable 158 | private fun BoxScope.PointTypeImage( 159 | pointType: PointType 160 | ) { 161 | Image( 162 | painter = painterResource( 163 | id = when (pointType) { 164 | PointType.Empty -> R.drawable.transparent 165 | PointType.X -> R.drawable.ic_tic_tac_toe_x 166 | PointType.O -> R.drawable.ic_tic_tac_toe_o 167 | } 168 | ), 169 | contentDescription = null, 170 | modifier = Modifier 171 | .matchParentSize() 172 | ) 173 | } 174 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_app_icon.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 10 | 12 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_award.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dashboard.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_github_mark.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_setting.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tic_tac_toe_o.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tic_tac_toe_x.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_timer.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_trash.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/transparent.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ffffff 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TicTacToe 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/test/java/com/anafthdev/tictactoe/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.anafthdev.tictactoe 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | compose_version = '1.3.1' 4 | kotlin_version = '1.7.20' 5 | accompanist_version = '0.28.0' 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.google.dagger:hilt-android-gradle-plugin:2.42' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | }// Top-level build file where you can add configuration options common to all sub-projects/modules. 17 | plugins { 18 | id 'com.android.application' version '7.3.1' apply false 19 | id 'com.android.library' version '7.3.1' apply false 20 | id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Dec 28 09:29:11 ICT 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /ic_launcher/android/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/ic_launcher-web.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /ic_launcher/android/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ic_launcher/android/playstore-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/android/playstore-icon.png -------------------------------------------------------------------------------- /ic_launcher/android/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images":[ 3 | { 4 | "idiom":"iphone", 5 | "size":"20x20", 6 | "scale":"2x", 7 | "filename":"Icon-App-20x20@2x.png" 8 | }, 9 | { 10 | "idiom":"iphone", 11 | "size":"20x20", 12 | "scale":"3x", 13 | "filename":"Icon-App-20x20@3x.png" 14 | }, 15 | { 16 | "idiom":"iphone", 17 | "size":"29x29", 18 | "scale":"1x", 19 | "filename":"Icon-App-29x29@1x.png" 20 | }, 21 | { 22 | "idiom":"iphone", 23 | "size":"29x29", 24 | "scale":"2x", 25 | "filename":"Icon-App-29x29@2x.png" 26 | }, 27 | { 28 | "idiom":"iphone", 29 | "size":"29x29", 30 | "scale":"3x", 31 | "filename":"Icon-App-29x29@3x.png" 32 | }, 33 | { 34 | "idiom":"iphone", 35 | "size":"40x40", 36 | "scale":"2x", 37 | "filename":"Icon-App-40x40@2x.png" 38 | }, 39 | { 40 | "idiom":"iphone", 41 | "size":"40x40", 42 | "scale":"3x", 43 | "filename":"Icon-App-40x40@3x.png" 44 | }, 45 | { 46 | "idiom":"iphone", 47 | "size":"60x60", 48 | "scale":"2x", 49 | "filename":"Icon-App-60x60@2x.png" 50 | }, 51 | { 52 | "idiom":"iphone", 53 | "size":"60x60", 54 | "scale":"3x", 55 | "filename":"Icon-App-60x60@3x.png" 56 | }, 57 | { 58 | "idiom":"iphone", 59 | "size":"76x76", 60 | "scale":"2x", 61 | "filename":"Icon-App-76x76@2x.png" 62 | }, 63 | { 64 | "idiom":"ipad", 65 | "size":"20x20", 66 | "scale":"1x", 67 | "filename":"Icon-App-20x20@1x.png" 68 | }, 69 | { 70 | "idiom":"ipad", 71 | "size":"20x20", 72 | "scale":"2x", 73 | "filename":"Icon-App-20x20@2x.png" 74 | }, 75 | { 76 | "idiom":"ipad", 77 | "size":"29x29", 78 | "scale":"1x", 79 | "filename":"Icon-App-29x29@1x.png" 80 | }, 81 | { 82 | "idiom":"ipad", 83 | "size":"29x29", 84 | "scale":"2x", 85 | "filename":"Icon-App-29x29@2x.png" 86 | }, 87 | { 88 | "idiom":"ipad", 89 | "size":"40x40", 90 | "scale":"1x", 91 | "filename":"Icon-App-40x40@1x.png" 92 | }, 93 | { 94 | "idiom":"ipad", 95 | "size":"40x40", 96 | "scale":"2x", 97 | "filename":"Icon-App-40x40@2x.png" 98 | }, 99 | { 100 | "idiom":"ipad", 101 | "size":"76x76", 102 | "scale":"1x", 103 | "filename":"Icon-App-76x76@1x.png" 104 | }, 105 | { 106 | "idiom":"ipad", 107 | "size":"76x76", 108 | "scale":"2x", 109 | "filename":"Icon-App-76x76@2x.png" 110 | }, 111 | { 112 | "idiom":"ipad", 113 | "size":"83.5x83.5", 114 | "scale":"2x", 115 | "filename":"Icon-App-83.5x83.5@2x.png" 116 | }, 117 | { 118 | "size" : "1024x1024", 119 | "idiom" : "ios-marketing", 120 | "scale" : "1x", 121 | "filename" : "ItunesArtwork@2x.png" 122 | } 123 | ], 124 | "info":{ 125 | "version":1, 126 | "author":"easyappicon" 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/AppIcon.appiconset/ItunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/AppIcon.appiconset/ItunesArtwork@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/iTunesArtwork@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/iTunesArtwork@1x.png -------------------------------------------------------------------------------- /ic_launcher/ios/iTunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/iTunesArtwork@2x.png -------------------------------------------------------------------------------- /ic_launcher/ios/iTunesArtwork@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/ic_launcher/ios/iTunesArtwork@3x.png -------------------------------------------------------------------------------- /img/dashboard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/img/dashboard.jpg -------------------------------------------------------------------------------- /img/game_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/img/game_1.jpg -------------------------------------------------------------------------------- /img/game_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/img/game_2.jpg -------------------------------------------------------------------------------- /img/tic tac toe image feature.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kafri8889/Compose-TicTacToe/2d95d88dd6149d716f0de131e3c2552ec1308ccc/img/tic tac toe image feature.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "TicTacToe" 16 | include ':app' 17 | --------------------------------------------------------------------------------