Skip to content

Commit

Permalink
Merge pull request #82 from teogor/refactor/codebase-and-update-compi…
Browse files Browse the repository at this point in the history
…ler-options

Refactor Codebase and Update Compiler Options for Opt-In Annotations
  • Loading branch information
teogor authored Sep 4, 2024
2 parents bfa31fa + 3bca044 commit 7b7dc5a
Show file tree
Hide file tree
Showing 62 changed files with 647 additions and 411 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ apiValidation {
* Subprojects that are excluded from API validation
*/
ignoredProjects.addAll(excludedProjects.map { it.name })

/**
* Non-public markers that are excluded from API validation
*/
nonPublicMarkers.addAll(listOf(
"dev.teogor.sudoklify.ExperimentalSudoklifyApi",
"dev.teogor.sudoklify.InternalSudoklifyApi"
))
}

subprojects {
Expand Down
161 changes: 161 additions & 0 deletions demo/composeApp/api/android/composeApp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
public final class dev/teogor/sudoklify/multiplatform/AppKt {
public static final fun App (Ldev/teogor/sudoklify/multiplatform/SudokuGameViewModel;Landroidx/compose/runtime/Composer;II)V
}

public final class dev/teogor/sudoklify/multiplatform/Cell {
public static final field $stable I
public fun <init> (IZZIII)V
public final fun component1 ()I
public final fun component2 ()Z
public final fun component3 ()Z
public final fun component4 ()I
public final fun component5 ()I
public final fun component6 ()I
public final fun copy (IZZIII)Ldev/teogor/sudoklify/multiplatform/Cell;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/Cell;IZZIIIILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/Cell;
public fun equals (Ljava/lang/Object;)Z
public final fun getCol ()I
public final fun getRow ()I
public final fun getSolution ()I
public final fun getValue ()I
public fun hashCode ()I
public final fun isError ()Z
public final fun isGiven ()Z
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/Cell$Position {
public static final field $stable I
public fun <init> (II)V
public final fun component1 ()I
public final fun component2 ()I
public final fun copy (II)Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/Cell$Position;IIILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public fun equals (Ljava/lang/Object;)Z
public final fun getCol ()I
public final fun getRow ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/ComposableSingletons$AppKt {
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/ComposableSingletons$AppKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$composeApp_release ()Lkotlin/jvm/functions/Function3;
}

public final class dev/teogor/sudoklify/multiplatform/ComposableSingletons$MainActivityKt {
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/ComposableSingletons$MainActivityKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$composeApp_release ()Lkotlin/jvm/functions/Function2;
}

public final class dev/teogor/sudoklify/multiplatform/ComposableSingletons$SudokuBoardKt {
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/ComposableSingletons$SudokuBoardKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$composeApp_release ()Lkotlin/jvm/functions/Function2;
}

public abstract class dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Active : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$Active;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Completed : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public fun <init> (Z)V
public final fun component1 ()Z
public final fun copy (Z)Ldev/teogor/sudoklify/multiplatform/GameState$Completed;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/GameState$Completed;ZILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/GameState$Completed;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public final fun isWon ()Z
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Loading : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$NotStarted : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$NotStarted;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Paused : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$Paused;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/MainActivity : androidx/activity/ComponentActivity {
public static final field $stable I
public fun <init> ()V
}

public final class dev/teogor/sudoklify/multiplatform/MainActivityKt {
public static final fun AppAndroidPreview (Landroidx/compose/runtime/Composer;I)V
}

public final class dev/teogor/sudoklify/multiplatform/SudokuBoardKt {
public static final fun SudokuBoard (Ldev/teogor/sudoklify/components/Dimension;Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)V
public static final fun SudokuCell (Ldev/teogor/sudoklify/multiplatform/Cell;Landroidx/compose/ui/Modifier;Landroidx/compose/runtime/Composer;II)V
}

public final class dev/teogor/sudoklify/multiplatform/SudokuGameState {
public static final field $stable I
public fun <init> (Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Ljava/util/List;Z)V
public final fun component1 ()Ljava/util/List;
public final fun component2 ()Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public final fun component3 ()Ljava/util/List;
public final fun component4 ()Z
public final fun copy (Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Ljava/util/List;Z)Ldev/teogor/sudoklify/multiplatform/SudokuGameState;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/SudokuGameState;Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Ljava/util/List;ZILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/SudokuGameState;
public fun equals (Ljava/lang/Object;)Z
public final fun getGrid ()Ljava/util/List;
public final fun getMistakes ()Ljava/util/List;
public final fun getSelectedCell ()Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public fun hashCode ()I
public final fun isSolved ()Z
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/SudokuGameViewModel : androidx/lifecycle/ViewModel {
public static final field $stable I
public field sudokuPuzzle Ldev/teogor/sudoklify/puzzle/SudokuPuzzle;
public field sudokuSolver Ldev/teogor/sudoklify/solver/SudoklifySolverEngine;
public field sudokuSpec Ldev/teogor/sudoklify/puzzle/SudokuSpec;
public fun <init> ()V
public final fun generateSudoku (Ldev/teogor/sudoklify/components/Dimension;Ldev/teogor/sudoklify/components/Difficulty;Ldev/teogor/sudoklify/components/Seed;)V
public final fun getGameState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getSudokuGameState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getSudokuPuzzle ()Ldev/teogor/sudoklify/puzzle/SudokuPuzzle;
public final fun getSudokuSolver ()Ldev/teogor/sudoklify/solver/SudoklifySolverEngine;
public final fun getSudokuSpec ()Ldev/teogor/sudoklify/puzzle/SudokuSpec;
public final fun makeMove (III)V
public final fun resetGame ()V
public final fun selectCell (II)V
public final fun setSudokuPuzzle (Ldev/teogor/sudoklify/puzzle/SudokuPuzzle;)V
public final fun setSudokuSolver (Ldev/teogor/sudoklify/solver/SudoklifySolverEngine;)V
public final fun setSudokuSpec (Ldev/teogor/sudoklify/puzzle/SudokuSpec;)V
}

159 changes: 159 additions & 0 deletions demo/composeApp/api/desktop/composeApp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
public final class dev/teogor/sudoklify/multiplatform/AppKt {
public static final fun App (Ldev/teogor/sudoklify/multiplatform/SudokuGameViewModel;Landroidx/compose/runtime/Composer;II)V
}

public final class dev/teogor/sudoklify/multiplatform/Cell {
public static final field $stable I
public fun <init> (IZZIII)V
public final fun component1 ()I
public final fun component2 ()Z
public final fun component3 ()Z
public final fun component4 ()I
public final fun component5 ()I
public final fun component6 ()I
public final fun copy (IZZIII)Ldev/teogor/sudoklify/multiplatform/Cell;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/Cell;IZZIIIILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/Cell;
public fun equals (Ljava/lang/Object;)Z
public final fun getCol ()I
public final fun getRow ()I
public final fun getSolution ()I
public final fun getValue ()I
public fun hashCode ()I
public final fun isError ()Z
public final fun isGiven ()Z
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/Cell$Position {
public static final field $stable I
public fun <init> (II)V
public final fun component1 ()I
public final fun component2 ()I
public final fun copy (II)Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/Cell$Position;IIILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public fun equals (Ljava/lang/Object;)Z
public final fun getCol ()I
public final fun getRow ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/ComposableSingletons$AppKt {
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/ComposableSingletons$AppKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$composeApp ()Lkotlin/jvm/functions/Function3;
}

public final class dev/teogor/sudoklify/multiplatform/ComposableSingletons$MainKt {
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/ComposableSingletons$MainKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public static field lambda-2 Lkotlin/jvm/functions/Function3;
public fun <init> ()V
public final fun getLambda-1$composeApp ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-2$composeApp ()Lkotlin/jvm/functions/Function3;
}

public final class dev/teogor/sudoklify/multiplatform/ComposableSingletons$SudokuBoardKt {
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/ComposableSingletons$SudokuBoardKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$composeApp ()Lkotlin/jvm/functions/Function2;
}

public abstract class dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Active : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$Active;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Completed : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public fun <init> (Z)V
public final fun component1 ()Z
public final fun copy (Z)Ldev/teogor/sudoklify/multiplatform/GameState$Completed;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/GameState$Completed;ZILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/GameState$Completed;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public final fun isWon ()Z
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Loading : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$NotStarted : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$NotStarted;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/GameState$Paused : dev/teogor/sudoklify/multiplatform/GameState {
public static final field $stable I
public static final field INSTANCE Ldev/teogor/sudoklify/multiplatform/GameState$Paused;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/MainKt {
public static final fun main ()V
public static synthetic fun main ([Ljava/lang/String;)V
}

public final class dev/teogor/sudoklify/multiplatform/SudokuBoardKt {
public static final fun SudokuBoard (Ldev/teogor/sudoklify/components/Dimension;Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)V
public static final fun SudokuCell (Ldev/teogor/sudoklify/multiplatform/Cell;Landroidx/compose/ui/Modifier;Landroidx/compose/runtime/Composer;II)V
}

public final class dev/teogor/sudoklify/multiplatform/SudokuGameState {
public static final field $stable I
public fun <init> (Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Ljava/util/List;Z)V
public final fun component1 ()Ljava/util/List;
public final fun component2 ()Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public final fun component3 ()Ljava/util/List;
public final fun component4 ()Z
public final fun copy (Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Ljava/util/List;Z)Ldev/teogor/sudoklify/multiplatform/SudokuGameState;
public static synthetic fun copy$default (Ldev/teogor/sudoklify/multiplatform/SudokuGameState;Ljava/util/List;Ldev/teogor/sudoklify/multiplatform/Cell$Position;Ljava/util/List;ZILjava/lang/Object;)Ldev/teogor/sudoklify/multiplatform/SudokuGameState;
public fun equals (Ljava/lang/Object;)Z
public final fun getGrid ()Ljava/util/List;
public final fun getMistakes ()Ljava/util/List;
public final fun getSelectedCell ()Ldev/teogor/sudoklify/multiplatform/Cell$Position;
public fun hashCode ()I
public final fun isSolved ()Z
public fun toString ()Ljava/lang/String;
}

public final class dev/teogor/sudoklify/multiplatform/SudokuGameViewModel : androidx/lifecycle/ViewModel {
public static final field $stable I
public field sudokuPuzzle Ldev/teogor/sudoklify/puzzle/SudokuPuzzle;
public field sudokuSolver Ldev/teogor/sudoklify/solver/SudoklifySolverEngine;
public field sudokuSpec Ldev/teogor/sudoklify/puzzle/SudokuSpec;
public fun <init> ()V
public final fun generateSudoku (Ldev/teogor/sudoklify/components/Dimension;Ldev/teogor/sudoklify/components/Difficulty;Ldev/teogor/sudoklify/components/Seed;)V
public final fun getGameState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getSudokuGameState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getSudokuPuzzle ()Ldev/teogor/sudoklify/puzzle/SudokuPuzzle;
public final fun getSudokuSolver ()Ldev/teogor/sudoklify/solver/SudoklifySolverEngine;
public final fun getSudokuSpec ()Ldev/teogor/sudoklify/puzzle/SudokuSpec;
public final fun makeMove (III)V
public final fun resetGame ()V
public final fun selectCell (II)V
public final fun setSudokuPuzzle (Ldev/teogor/sudoklify/puzzle/SudokuPuzzle;)V
public final fun setSudokuSolver (Ldev/teogor/sudoklify/solver/SudoklifySolverEngine;)V
public final fun setSudokuSpec (Ldev/teogor/sudoklify/puzzle/SudokuSpec;)V
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewmodel.compose.viewModel
import dev.teogor.paletteon.PaletteonDynamicTheme
import dev.teogor.paletteon.ui.components.PaletteonThemedSurface
import dev.teogor.sudoklify.ExperimentalSudoklifyApi
import dev.teogor.sudoklify.components.Difficulty
import dev.teogor.sudoklify.components.Dimension
import dev.teogor.sudoklify.components.Seed
Expand All @@ -49,13 +47,10 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
*
* @param sudokuGameViewModel The ViewModel managing the game state and logic. Defaults to a new instance.
*/
@OptIn(ExperimentalSudoklifyApi::class)
@Composable
@Preview
fun App(
sudokuGameViewModel: SudokuGameViewModel = viewModel {
SudokuGameViewModel(SavedStateHandle())
},
sudokuGameViewModel: SudokuGameViewModel = viewModel { SudokuGameViewModel() },
) {
PaletteonDynamicTheme(
seedColor = Color.Magenta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package dev.teogor.sudoklify.multiplatform

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import dev.teogor.sudoklify.ExperimentalSudoklifyApi
import dev.teogor.sudoklify.SudoklifyArchitect
import dev.teogor.sudoklify.components.Difficulty
import dev.teogor.sudoklify.components.Dimension
Expand All @@ -37,13 +35,8 @@ import kotlinx.coroutines.flow.update

/**
* ViewModel responsible for managing the state of the Sudoku game.
*
* @param savedStateHandle The handle for saving and restoring the state.
*/
@OptIn(ExperimentalSudoklifyApi::class)
class SudokuGameViewModel(
savedStateHandle: SavedStateHandle,
) : ViewModel() {
class SudokuGameViewModel : ViewModel() {
private val architect = SudoklifyArchitect(loadPresetSchemas())

private val _gameState = MutableStateFlow<GameState>(GameState.NotStarted)
Expand All @@ -63,10 +56,6 @@ class SudokuGameViewModel(
lateinit var sudokuPuzzle: SudokuPuzzle
lateinit var sudokuSolver: SudoklifySolverEngine<Cell>

init {
_gameState.value = GameState.Loading
}

/**
* Generates a new Sudoku puzzle based on the provided dimension, difficulty, and seed.
*
Expand Down
Loading

0 comments on commit 7b7dc5a

Please sign in to comment.