commit ea09e31ea9435de8c2712d04ca2134c8ce00e935 Author: FyloZ Date: Thu Sep 10 16:53:54 2020 -0400 Init with basic main menu UI. diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a51af --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ae0eec --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.gradle +gradle +build +.idea diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..d4a781e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,77 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Kotlin application project to get you started. + */ + +plugins { + id("org.jetbrains.kotlin.jvm") version "1.4.0" + id("org.openjfx.javafxplugin") version "0.0.9" + id("org.jetbrains.dokka") version "1.4.0-rc" + id("com.leobia.gradle.sassjavacompiler") version "0.2.1" + + application +} + +repositories { + // Use jcenter for resolving dependencies. + // You can declare any Maven/Ivy/file repository here. + jcenter() + mavenCentral() +} + +dependencies { + implementation(platform("org.jetbrains.kotlin:kotlin-bom")) + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation("org.kodein.di:kodein-di:7.0.0") + implementation("org.kodein.di:kodein-di-generic-jvm:6.5.5") + implementation("org.kodein.di:kodein-di-framework-tornadofx-jvm:7.0.0") + implementation("io.github.microutils:kotlin-logging:1.5.9") + implementation("org.slf4j:slf4j-simple:1.7.26") +// implementation("org.dizitart:potassium-nitrite:3.4.2") + implementation("no.tornado:tornadofx:1.7.20") + implementation("com.jfoenix:jfoenix:9.0.10") + implementation("com.github.bkenn:kfoenix:0.1.3") { + exclude("com.jfoenix:jfoenix") + } + implementation("com.beust:klaxon:5.0.1") + + testImplementation("org.jetbrains.kotlin:kotlin-test") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit") + testImplementation("org.junit.jupiter:junit-jupiter:5.6.2") + testImplementation("io.mockk:mockk:1.10.0") +} + +javafx { + version = "14" + modules = listOf("javafx.controls", "javafx.graphics", "javafx.fxml") +} + +sassOptions { + inputPath = file("./src/main/resources/style/style.light.scss").canonicalPath + outputPath = file("./src/main/resources/style/compiled/").canonicalPath + outputStyle = "compressed" + isSass = false + isIndentWithTabs = false +} + +application { + // Define the main class for the application. + mainClassName = "Plannervio.AppKt" +} + +tasks.test { + useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + } +} + +tasks.withType { + dependsOn(tasks.compileSass) + kotlinOptions.jvmTarget = "11" +} + +tasks.dokkaHtml { + outputDirectory = "$buildDir/dokka" +} diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..fbd7c51 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..5093609 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,104 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..00758c6 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,18 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/6.5/userguide/multi_project_builds.html + */ + +rootProject.name = "Plannervio" +enableFeaturePreview("GRADLE_METADATA") + +pluginManagement { + repositories { + gradlePluginPortal() + jcenter() + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/model/BackgroundImage.kt b/src/main/kotlin/dev/fyloz/plannervio/core/model/BackgroundImage.kt new file mode 100644 index 0000000..e540866 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/model/BackgroundImage.kt @@ -0,0 +1,14 @@ +package dev.fyloz.plannervio.core.model + +data class BackgroundImage( + val path: String, + val bundled: Boolean = true +) { +} + +fun backgroundImageFactory( + path: String = "path", + bundled: Boolean = true +): BackgroundImage { + return BackgroundImage(path, bundled) +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/model/Board.kt b/src/main/kotlin/dev/fyloz/plannervio/core/model/Board.kt new file mode 100644 index 0000000..71587a3 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/model/Board.kt @@ -0,0 +1,34 @@ +package dev.fyloz.plannervio.core.model + +import javafx.beans.property.SimpleLongProperty +import javafx.beans.property.SimpleObjectProperty +import javafx.beans.property.SimpleStringProperty +import tornadofx.getValue + +open class Board( + id: Long, + name: String, + description: String, + backgroundImage: BackgroundImage +) { + val idProperty by lazy { SimpleLongProperty(this, "id", id) } + val id by idProperty + + val nameProperty by lazy { SimpleStringProperty(this, "name", name) } + val name by nameProperty + + val descriptionProperty by lazy { SimpleStringProperty(this, "description", description) } + val description by descriptionProperty + + val backgroundImageProperty by lazy { SimpleObjectProperty(this, "backgroundImage", backgroundImage) } + val backgroundImage by backgroundImageProperty +} + +fun boardFactory( + id: Long = 0L, + name: String = "board", + description: String = "description", + backgroundImage: BackgroundImage = backgroundImageFactory() +): Board { + return Board(id, name, description, backgroundImage) +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/model/PrivateBoard.kt b/src/main/kotlin/dev/fyloz/plannervio/core/model/PrivateBoard.kt new file mode 100644 index 0000000..7276d5f --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/model/PrivateBoard.kt @@ -0,0 +1,32 @@ +package dev.fyloz.plannervio.core.model + +import javafx.beans.property.SimpleListProperty +import javafx.beans.property.SimpleStringProperty +import tornadofx.getValue +import tornadofx.toObservable + +class PrivateBoard( + id: Long, + name: String, + description: String, + backgroundImage: BackgroundImage, + password: String, + users: MutableList +) : Board(id, name, description, backgroundImage) { + val passwordProperty = SimpleStringProperty(this, "password", password) + val password by passwordProperty + + val usersProperty = SimpleListProperty(this, "users", users.toObservable()) + val users by usersProperty +} + +fun privateBoardFactory( + id: Long = 0L, + name: String = "private board", + description: String = "description", + backgroundImage: BackgroundImage = backgroundImageFactory(), + password: String = "password", + users: MutableList = mutableListOf() +): PrivateBoard { + return PrivateBoard(id, name, description, backgroundImage, password, users) +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/model/Task.kt b/src/main/kotlin/dev/fyloz/plannervio/core/model/Task.kt new file mode 100644 index 0000000..e333449 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/model/Task.kt @@ -0,0 +1,17 @@ +package dev.fyloz.plannervio.core.model + +import javafx.beans.property.SimpleBooleanProperty +import javafx.beans.property.SimpleLongProperty +import javafx.beans.property.SimpleStringProperty + +data class Task ( + val id: Long, + val name: String, + val description: String, + val finished: Boolean +) { + val idProperty = SimpleLongProperty(id) + val nameProperty = SimpleStringProperty(name) + val descriptionProperty = SimpleStringProperty(description) + val finishedProperty = SimpleBooleanProperty(finished) +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/model/User.kt b/src/main/kotlin/dev/fyloz/plannervio/core/model/User.kt new file mode 100644 index 0000000..b5dbe8c --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/model/User.kt @@ -0,0 +1,8 @@ +package dev.fyloz.plannervio.core.model + +data class User( + val username: String, + val email: String, + val password: String +) { +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/model/view/BoardViewModel.kt b/src/main/kotlin/dev/fyloz/plannervio/core/model/view/BoardViewModel.kt new file mode 100644 index 0000000..1cca9c0 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/model/view/BoardViewModel.kt @@ -0,0 +1,16 @@ +package dev.fyloz.plannervio.core.model.view + +import dev.fyloz.plannervio.core.model.Board +import tornadofx.ItemViewModel + +class BoardViewModel(board: Board? = null) : ItemViewModel() { + + init { + if (board != null) item = board + } + + val id = bind(Board::idProperty) + val name = bind(Board::nameProperty) + val description = bind(Board::descriptionProperty) + val backgroundImage = bind(Board::backgroundImageProperty) +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/repository/IBoardRepository.kt b/src/main/kotlin/dev/fyloz/plannervio/core/repository/IBoardRepository.kt new file mode 100644 index 0000000..97eb99f --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/repository/IBoardRepository.kt @@ -0,0 +1,46 @@ +package dev.fyloz.plannervio.core.repository + +import dev.fyloz.plannervio.core.model.Board + +/** + * A data access object for boards. + */ +interface IBoardRepository { + + /** + * Verify if a given board exists in the repository. + * + * @param board The board + * @return If the board exists or not + */ + fun exists(board: Board): Boolean + + /** + * Find all boards in the repository. + * + * @return An immutable list containing all found boards + */ + fun findAll(): List + + /** + * Find the board with the given identifier in the repository. + * + * @param id The identifier + * @return The board found or null + */ + fun findById(id: Long): Board? + + /** + * Persist a given board in the repository. + * + * @param board The board + * @return The persisted board + */ + fun save(board: Board) + + /** + * Delete a given board from the repository. + */ + fun delete(board: Board) + +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/repository/ITaskRepository.kt b/src/main/kotlin/dev/fyloz/plannervio/core/repository/ITaskRepository.kt new file mode 100644 index 0000000..4ebf996 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/repository/ITaskRepository.kt @@ -0,0 +1,16 @@ +package dev.fyloz.plannervio.core.repository + +import dev.fyloz.plannervio.core.model.Board +import dev.fyloz.plannervio.core.model.Task + +interface ITaskRepository { + + fun exists(board: Board, task: Task): Boolean + + fun findAll(board: Board): List + + fun save(board: Board, task: Task) + + fun delete(board: Board, task: Task) + +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/repository/memory/MemoryBoardRepository.kt b/src/main/kotlin/dev/fyloz/plannervio/core/repository/memory/MemoryBoardRepository.kt new file mode 100644 index 0000000..a5b59dd --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/repository/memory/MemoryBoardRepository.kt @@ -0,0 +1,102 @@ +package dev.fyloz.plannervio.core.repository.memory + +import dev.fyloz.plannervio.core.model.* +import dev.fyloz.plannervio.core.model.Board +import dev.fyloz.plannervio.core.repository.IBoardRepository + +class MemoryBoardRepository : IBoardRepository { + private val boards = mutableListOf() + + init { + save( + boardFactory( + 0L, + "Board 1", + "Voluptates facere maiores quis suscipit nostrum. Et accusamus quas animi. Similique reiciendis ea iste cum sunt aut minus. Aut cupiditate consequatur dolor vel doloremque aut eius voluptas. Sed reprehenderit veniam odio voluptatem numquam doloribus. Consequuntur esse assumenda aut expedita voluptatibus.", + BackgroundImage("bundled_background_0.jpg") + ) + ) + save( + boardFactory( + 1L, + "test", + "Libero rerum sed dolore repudiandae id voluptatem. In iusto nesciunt nihil quia vel ut qui quae. Nihil eos similique corporis fugit autem reiciendis vel. Aut neque quas reprehenderit reiciendis officia non.", + BackgroundImage("bundled_background_1.jpg") + ) + ) + save( + privateBoardFactory( + 2L, + "Board 3", + "Pariatur error dolores beatae et rem minus a quia. Facilis nam esse repellat consequatur aperiam nostrum aut vel. Non ratione aut maiores beatae molestiae maxime ipsum molestiae. Asperiores est id in quia tempore soluta voluptatem atque.", + BackgroundImage("bundled_background_3.jpg"), + "password", + mutableListOf( + User("username", "username@email.com", "password") + ) + ) + ) + save( + boardFactory( + 3L, + "test", + "Libero rerum sed dolore repudiandae id voluptatem. In iusto nesciunt nihil quia vel ut qui quae. Nihil eos similique corporis fugit autem reiciendis vel. Aut neque quas reprehenderit reiciendis officia non.", + BackgroundImage("bundled_background_1.jpg") + ) + ) + save( + boardFactory( + 4L, + "test", + "Libero rerum sed dolore repudiandae id voluptatem. In iusto nesciunt nihil quia vel ut qui quae. Nihil eos similique corporis fugit autem reiciendis vel. Aut neque quas reprehenderit reiciendis officia non.", + BackgroundImage("bundled_background_1.jpg") + ) + ) + save( + boardFactory( + 5L, + "test", + "Libero rerum sed dolore repudiandae id voluptatem. In iusto nesciunt nihil quia vel ut qui quae. Nihil eos similique corporis fugit autem reiciendis vel. Aut neque quas reprehenderit reiciendis officia non.", + BackgroundImage("bundled_background_1.jpg") + ) + ) + save( + boardFactory( + 6L, + "test", + "Libero rerum sed dolore repudiandae id voluptatem. In iusto nesciunt nihil quia vel ut qui quae. Nihil eos similique corporis fugit autem reiciendis vel. Aut neque quas reprehenderit reiciendis officia non.", + BackgroundImage("bundled_background_1.jpg") + ) + ) + save( + boardFactory( + 7L, + "test", + "Libero rerum sed dolore repudiandae id voluptatem. In iusto nesciunt nihil quia vel ut qui quae. Nihil eos similique corporis fugit autem reiciendis vel. Aut neque quas reprehenderit reiciendis officia non.", + BackgroundImage("bundled_background_1.jpg") + ) + ) + } + + override fun exists(board: Board): Boolean { + return boards.contains(board) + } + + override fun findAll(): List { + return boards + } + + override fun findById(id: Long): Board? { + return boards.firstOrNull { + it.id == id + } + } + + override fun save(board: Board) { + boards.add(board) + } + + override fun delete(board: Board) { + boards.remove(board) + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/BackgroundImageService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/BackgroundImageService.kt new file mode 100644 index 0000000..69ea987 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/BackgroundImageService.kt @@ -0,0 +1,52 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.core.model.BackgroundImage +import javafx.scene.image.Image +import mu.KotlinLogging +import java.io.FileInputStream +import java.io.InputStream + +class BackgroundImageService : IBackgroundImageService { + private val logger = KotlinLogging.logger { } + + override fun loadImage(image: BackgroundImage): Image? { + val stream = getImageInputStream(image) + return if (stream != null) + Image(stream) + else { + logger.warn("Could not load image '${image.path}'") + null + } + } + + /** + * Gets the input stream for a given background image. + * + * @param image The background image + */ + fun getImageInputStream(image: BackgroundImage): InputStream? { + return if (image.bundled) { + getBundledImageInputStream(image) + } else { + getCustomImageInputStream(image) + } + } + + /** + * Gets the input stream for a given bundled background image. + * + * @param image The background image + */ + fun getBundledImageInputStream(image: BackgroundImage): InputStream? { + return ClassLoader.getSystemResourceAsStream("images/${image.path}") + } + + /** + * Gets the input stream for a given custom background image. + * + * @param image The background image + */ + fun getCustomImageInputStream(image: BackgroundImage): InputStream? { + return FileInputStream(image.path) + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/BoardService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/BoardService.kt new file mode 100644 index 0000000..0ffefde --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/BoardService.kt @@ -0,0 +1,15 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.core.repository.IBoardRepository +import dev.fyloz.plannervio.core.model.Board +import org.kodein.di.DI +import org.kodein.di.instance + +class BoardService(di: DI) : IBoardService { + override val repository: IBoardRepository by di.instance() + + override fun getBoards(): List { + return repository.findAll() + } + +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/I18nService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/I18nService.kt new file mode 100644 index 0000000..c8dc024 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/I18nService.kt @@ -0,0 +1,71 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.ui.i18n.MergedResourceBundle +import java.util.* + +/** + * Each instance of this service have a specific resource bundle and one for keywords. + * + * @param specificBundle The specific bundle. Should only be null when the service uses only the keyword's bundle. + * @param keywordsBundle The keyword's bundle + */ +class I18nService(specificBundle: ResourceBundle?, keywordsBundle: ResourceBundle) : II18nService { + override val bundle: ResourceBundle + + init { + bundle = if (specificBundle == null) + keywordsBundle + else + MergedResourceBundle(specificBundle, keywordsBundle) + } + + override fun getLocalizedString(key: II18nKey): String { + return bundle.getString(key.keyName) + } +} + +private const val keywordsServiceKey = "KEYWORDS" +private val keywordsBundle: ResourceBundle = getBundle(keywordsServiceKey.toLowerCase()) + +private val i18nServices: MutableMap = mutableMapOf( + keywordsServiceKey to I18nService(null, keywordsBundle) +) + +/** + * Locate an internationalization service for a given bundle name. + * If no service exists for the given bundle name, it gets created. + * + * @param bundleName The bundle's name. If null, an internationalization service using only keywords will be returned. + */ +fun locateI18nService(bundleName: String?): I18nService { + if (bundleName == null) { + return getService(keywordsServiceKey) + } + + if (!i18nServices.containsKey(bundleName)) { + i18nServices[bundleName] = I18nService(getBundle(bundleName), keywordsBundle) + } + + return getService(bundleName) +} + +/** + * Gets a internationalization service for a given bundle name. + * The service should exists before this method gets called. + * + * @param bundleName The bundle's name + * @throws IllegalStateException There was no service created for the bundle's name. (Should never happen) + */ +private fun getService(bundleName: String): I18nService { + return i18nServices[bundleName] + ?: throw IllegalStateException("An internationalization service was null after it's creation.") // Should never happen +} + +/** + * Load a bundle for the given bundle name. + * + * @param bundleName The bundle's name + */ +private fun getBundle(bundleName: String): ResourceBundle { + return ResourceBundle.getBundle("lang.${bundleName}") +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/IBackgroundImageService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/IBackgroundImageService.kt new file mode 100644 index 0000000..674d7e9 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/IBackgroundImageService.kt @@ -0,0 +1,21 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.core.model.BackgroundImage +import javafx.scene.image.Image + +/** + * A service for background images. + */ +interface IBackgroundImageService { + + /** + * Load the JavaFX image for a given BackgroundImage. + * + * If the file cannot be loaded, null will be returned. + * + * @param image The image to load + * @return The JavaFX image for the BackgroundImage + */ + fun loadImage(image: BackgroundImage): Image? + +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/IBoardService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/IBoardService.kt new file mode 100644 index 0000000..eff81c7 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/IBoardService.kt @@ -0,0 +1,19 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.core.repository.IBoardRepository +import dev.fyloz.plannervio.core.model.Board + +/** + * A service for boards. + */ +interface IBoardService { + val repository: IBoardRepository + + /** + * Get all boards. + * + * @return An immutable list containing all boards + */ + fun getBoards(): List + +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/II18nService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/II18nService.kt new file mode 100644 index 0000000..98663eb --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/II18nService.kt @@ -0,0 +1,46 @@ +package dev.fyloz.plannervio.core.service + +import java.util.* + +/** + * A service for internationalization. + */ +interface II18nService { + /** + * The resource bundle used by this service. + */ + val bundle: ResourceBundle + + /** + * Gets a localized string in the resource bundle for a given key. + * + * @param key The key of the localized string. + * @return The localized string for the given key. + */ + fun getLocalizedString(key: II18nKey): String +} + +/** + * A key in an internationalization resource bundle. + */ +interface II18nKey { + /** + * The name of the key. + */ + val keyName: String +} + +/** + * Creates a internationalization resource bundle key. + * + * @param keyName The name of the key in the resource bundle. + * + * @see II18nKey + */ +fun iI18nKeyFactory( + keyName: String = "name" +): II18nKey { + return object : II18nKey { + override val keyName: String = keyName + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/core/service/SvgService.kt b/src/main/kotlin/dev/fyloz/plannervio/core/service/SvgService.kt new file mode 100644 index 0000000..880d140 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/core/service/SvgService.kt @@ -0,0 +1,41 @@ +package dev.fyloz.plannervio.core.service + +import com.beust.klaxon.Klaxon +import com.jfoenix.svg.SVGGlyph +import javafx.scene.paint.Color +import mu.KotlinLogging +import tornadofx.SVGIcon + +private val logger = KotlinLogging.logger { } +private val storedSvgPaths: List = loadSvgPaths() + +fun svgGlyph(pathName: SvgPathName, size: Double = 16.0, color: Color = Color.BLACK): SVGGlyph? { + val svgPath = svgPath(pathName) ?: return null + val glyph = SVGGlyph(svgPath.path, color) + glyph.setSize(size, size) + return glyph +} + +private fun loadSvgPaths(): List { + val doc = SvgPath::class.java.getResource("/images/icons.json").readText() + return Klaxon().parseArray(doc) ?: throw IllegalStateException("Could not load svg paths.") +} + +private fun svgPath(pathName: SvgPathName): SvgPath? { + val svgPath = storedSvgPaths.firstOrNull { + pathName.pathName == it.name + } + if (svgPath == null) { + logger.warn("Svg path ${pathName.pathName} not loaded or not found") + } + return svgPath +} + +private data class SvgPath(val name: String, val path: String) + +enum class SvgPathName(val pathName: String) { + FORMAT_LIST_BULLETED("format_list_bulleted"), + STAR("star"), + HISTORY("history"), + COG("cog") +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/InternationalizedView.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/InternationalizedView.kt new file mode 100644 index 0000000..4096386 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/InternationalizedView.kt @@ -0,0 +1,16 @@ +package dev.fyloz.plannervio.ui + +import dev.fyloz.plannervio.ui.i18n.I18nKeywordKey +import java.util.* + +interface InternationalizedView { + val messages: ResourceBundle + + fun localizedMessage(key: Any): String { + return messages.getString(key.toString()) + } + + fun localizedKeyword(key: I18nKeywordKey): String { + return localizedMessage(key.toString()) + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/Plannervio.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/Plannervio.kt new file mode 100644 index 0000000..0e88365 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/Plannervio.kt @@ -0,0 +1,44 @@ +package dev.fyloz.plannervio.ui + +import dev.fyloz.plannervio.core.repository.IBoardRepository +import dev.fyloz.plannervio.core.repository.memory.MemoryBoardRepository +import dev.fyloz.plannervio.core.service.BackgroundImageService +import dev.fyloz.plannervio.core.service.BoardService +import dev.fyloz.plannervio.core.service.IBackgroundImageService +import dev.fyloz.plannervio.core.service.IBoardService +import dev.fyloz.plannervio.ui.style.Style +import dev.fyloz.plannervio.ui.view.MainView +import org.kodein.di.DI +import org.kodein.di.DIAware +import org.kodein.di.bind +import org.kodein.di.singleton +import org.kodein.di.tornadofx.installTornadoSource +import tornadofx.App +import tornadofx.launch +import tornadofx.loadFont +import tornadofx.reloadStylesheetsOnFocus + +fun main(args: Array) { + launch(args) +} + +class TodosApp : App(MainView::class, Style::class), DIAware { + override val di: DI + get() = DI { + installTornadoSource() + + bind() with singleton { MemoryBoardRepository() } + bind() with singleton { BoardService(di) } + bind() with singleton { BackgroundImageService() } + } + + init { + loadFonts() + reloadStylesheetsOnFocus() + } + + private fun loadFonts() { + loadFont("/style/font/biryani/Biryani-Regular.ttf", 12) + loadFont("/style/font/biryani/Biryani-DemiBold.ttf", 12) + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/I18nBoardSelectionViewKey.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/I18nBoardSelectionViewKey.kt new file mode 100644 index 0000000..b53026f --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/I18nBoardSelectionViewKey.kt @@ -0,0 +1,7 @@ +package dev.fyloz.plannervio.ui.i18n + +import dev.fyloz.plannervio.core.service.II18nKey + +enum class I18nBoardSelectionViewKey(override val keyName: String): II18nKey { + SIDEBAR_NO_BOARD_SELECTED_LABEL_TEXT("sidebar.no-board-selected.text") +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/I18nKeywordKey.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/I18nKeywordKey.kt new file mode 100644 index 0000000..3928813 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/I18nKeywordKey.kt @@ -0,0 +1,16 @@ +package dev.fyloz.plannervio.ui.i18n + +import dev.fyloz.plannervio.core.service.II18nKey + +enum class I18nKeywordKey(override val keyName: String) : II18nKey { + PUBLIC("public"), + PRIVATE("private"), + MEMBERS("members"), + NAME("name"), + DESCRIPTION("description") + ; + + override fun toString(): String { + return keyName + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/MergedResourceBundle.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/MergedResourceBundle.kt new file mode 100644 index 0000000..2f58bf6 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/i18n/MergedResourceBundle.kt @@ -0,0 +1,43 @@ +package dev.fyloz.plannervio.ui.i18n + +import java.util.* + +/** + * A mutable ResourceBundle containing one or more others ResourceBundle. + * + * @param initBundles The bundles contained by the merged bundle + */ +class MergedResourceBundle(vararg initBundles: ResourceBundle) : ResourceBundle() { + private val bundles: MutableList + + init { + bundles = initBundles.toMutableList() + } + + /** + * Adds a bundle to contained bundles. + * + * @param bundle The bundle to add + */ + operator fun plus(bundle: ResourceBundle) { + bundles + bundle + } + + /** + * Removes a bundle from contained bundles. + * + * @param bundle The bundle to remove + */ + operator fun minus(bundle: ResourceBundle) { + bundles - bundle + } + + override fun handleGetObject(key: String): Any? { + return bundles.firstOrNull { it.containsKey(key) }?.getObject(key) + } + + override fun getKeys(): Enumeration { + return Collections.enumeration(bundles.flatMap { Collections.list(it.keys) }) + } + +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/style/Style.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/style/Style.kt new file mode 100644 index 0000000..4f8d362 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/style/Style.kt @@ -0,0 +1,103 @@ +package dev.fyloz.plannervio.ui.style + +import javafx.scene.Cursor +import javafx.scene.paint.Color +import javafx.scene.paint.Paint +import kfoenix.JFXStylesheet.Companion.jfxButton +import kfoenix.JFXStylesheet.Companion.jfxRippler +import kfoenix.JFXStylesheet.Companion.jfxRipplerFill +import tornadofx.* + +val primaryTheme = mapOf( + 50 to c("#fcf2e7"), + 100 to c("#f8dec3"), + 200 to c("#f3c89c"), + 300 to c("#eeb274"), + 400 to c("#eaa256"), + 500 to c("#e69138"), + 600 to c("#e38932"), + 700 to c("#df7e2b"), + 800 to c("#db7424"), + 900 to c("#d56217") +) + +val accentTheme = mapOf( + 50 to c("#e8f0f8"), + 100 to c("#c5daee"), + 200 to c("#9ec2e3"), + 300 to c("#77aad7"), + 400 to c("#5a97cf"), + 500 to c("#3d85c6"), + 600 to c("#377dc0"), + 700 to c("#2f72b9"), + 800 to c("#2768b1"), + 900 to c("#1a55a4") +) + +class Style : Stylesheet() { + + companion object { + // Css properties + val jfxFocusColor by cssproperty>("-jfx-focus-color") + val jfxUnFocusColor by cssproperty>("-jfx-unfocus-color") + + // Jfx classes + val jfxTextField by cssclass() + + // Classes + val active by cssclass() + val appNameLabel by cssclass() + val navBar by cssclass() + val jfxSvgGlyphWrapper by cssclass() + } + + init { + label { + fontFamily = "Biryani Regular" + } + + navBar { + backgroundColor += primaryTheme.getValue(700) + prefWidth = 250.px + + label { + fontFamily = "Biryani DemiBold" + fontSize = 2.em + textFill = Color.WHITE + + and(appNameLabel) { + prefWidth = 250.px + } + } + + jfxTextField { + jfxFocusColor.value += primaryTheme.getValue(100) + jfxUnFocusColor.value += primaryTheme.getValue(100) + textFill = Color.WHITE + fontSize = 1.2.em + borderInsets += box(10.px) + } + + jfxButton { + cursor = Cursor.HAND + prefWidth = 250.px + + jfxRippler { + jfxRipplerFill.value = primaryTheme.getValue(100) + } + + and(active) { + backgroundColor += primaryTheme.getValue(300) + } + + jfxSvgGlyphWrapper { + padding = box(10.px, 15.px, 0.px, 0.px) + } + + label { + fontSize = 1.2.em + } + } + } + } +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/view/MainView.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/view/MainView.kt new file mode 100644 index 0000000..76a01c3 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/view/MainView.kt @@ -0,0 +1,85 @@ +package dev.fyloz.plannervio.ui.view + +import com.jfoenix.controls.JFXButton +import com.jfoenix.controls.JFXTextField +import dev.fyloz.plannervio.core.service.SvgPathName +import dev.fyloz.plannervio.ui.style.Style +import javafx.beans.property.SimpleBooleanProperty +import javafx.beans.property.SimpleObjectProperty +import javafx.geometry.Pos +import javafx.scene.layout.Priority +import tornadofx.* + +/** The app's main view */ +class MainView : AbstractView() { + private val presenter: MainViewPresenter by inject() + + override val root = borderpane { + left = vbox { + addClass(Style.navBar) + alignment = Pos.TOP_LEFT + + this += label { + addClass(Style.appNameLabel) + alignment = Pos.CENTER + text = "Plannervio" + } + this += JFXTextField().apply { + vgrow = Priority.NEVER + isLabelFloat = true + promptText = messages["search"] // TODO + vboxMargin(horizontal = 16, vertical = 20) + } + this += tabButton(Tab.BOARDS, presenter::onTabButtonClick).apply { + presenter.switchTab(this) // Default tab + } + this += tabButton(Tab.FAVORITES, presenter::onTabButtonClick) + this += tabButton(Tab.HISTORY, presenter::onTabButtonClick) + this += tabButton(Tab.SETTINGS, presenter::onTabButtonClick) + } + } +} + +class MainViewPresenter : Controller() { + private var activeTabButton: TabButton? = null + + /** Called when a [TabButton] has been clicked. */ + fun onTabButtonClick(button: TabButton) { + switchTab(button) + } + + /** Called when the search bar detects changes. Its content is contained in [searchQuery]. */ + fun onSearchChange(searchQuery: String) { + println(searchQuery) + } + + /** Switch the active tab to [button]'s tab. */ + fun switchTab(button: TabButton) { + activeTabButton?.active = false + button.active = true + activeTabButton = button + } +} + +/** The [TabButton] is a button linked to a [tab]. */ +class TabButton(tab: Tab, active: Boolean = false) : JFXButton() { + /** Specifies the [Tab] linked to the button. */ + val tabProperty by lazy { SimpleObjectProperty(tab) } + var tab: Tab by tabProperty + + /** Specifies if the button is active. */ + val activeProperty = SimpleBooleanProperty(this, "active", active) + var active: Boolean + get() = activeProperty.get() + set(value) { + toggleClass(Style.active, value) + activeProperty.set(value) + } +} + +enum class Tab(val icon: SvgPathName, val i18nText: String) { + BOARDS(SvgPathName.FORMAT_LIST_BULLETED, "tab.boards.label"), + FAVORITES(SvgPathName.STAR, "tab.favorites.label"), + HISTORY(SvgPathName.HISTORY, "tab.history.label"), + SETTINGS(SvgPathName.COG, "tab.settings.label") +} diff --git a/src/main/kotlin/dev/fyloz/plannervio/ui/view/UI.kt b/src/main/kotlin/dev/fyloz/plannervio/ui/view/UI.kt new file mode 100644 index 0000000..881d315 --- /dev/null +++ b/src/main/kotlin/dev/fyloz/plannervio/ui/view/UI.kt @@ -0,0 +1,99 @@ +package dev.fyloz.plannervio.ui.view + +import dev.fyloz.plannervio.core.service.locateI18nService +import dev.fyloz.plannervio.core.service.svgGlyph +import dev.fyloz.plannervio.ui.style.Style +import javafx.geometry.Pos +import javafx.scene.control.Label +import javafx.scene.layout.HBox +import javafx.scene.layout.Pane +import javafx.scene.layout.Region +import javafx.scene.layout.VBox +import javafx.scene.paint.Color +import kfoenix.JFXStylesheet.Companion.jfxRipplerFill +import kfoenix.jfxrippler +import tornadofx.* + +/** + * A view. Inheriting this class allows to automatically link the FXML file and the CSS files for the current theme to the fragment. + * If a presenter class is provided, the presenter will also be created. + * + * @constructor Initialize the view, linking the FXML and the CSS files. + */ +abstract class AbstractView : View() { + /** + * Gets the name of the view's files in kebab-case. + */ + val filename by lazy { + javaClass.simpleName + .split("(?=[A-Z])".toRegex()) + .map { it.toLowerCase() } + .filter { it.isNotEmpty() } + .filter { it != "view" } + .joinToString("-") + } + + protected val i18nService = locateI18nService(filename) + + init { + messages = i18nService.bundle + } + +// final override val root: Pane = loadFXML("/fxml/views/${filename}.fxml") +} + +/** + * A fragment of the view. Inheriting this class allows to automatically link the FXML file and the CSS files for the current theme to the fragment. + * + * @property view The view which the fragment is linked to. + * @constructor Initialize the fragment, linking the FXML and the CSS files. + */ +abstract class AbstractFragment(val view: AbstractView? = null) : Fragment() { + protected val i18nService = locateI18nService(view?.filename) + + init { + messages = i18nService.bundle + } +} + +/** Shorthand to create a [TabButton] in a [View]. */ +fun View.tabButton(tab: Tab, onClick: (TabButton) -> Unit): TabButton { + return TabButton(tab).apply { + alignment = Pos.BOTTOM_LEFT + textFill = Color.RED + graphic = hbox { + paddingTop = 2 + this += pane { + hboxMargin(top = 8) + addClass(Style.jfxSvgGlyphWrapper) + this += svgGlyph(tab.icon, size = 16.0, color = Color.WHITE)!! + } + this += Label(messages[tab.i18nText]) + } + setOnMouseClicked { onClick(this) } + } +} + +fun Region.vboxMargin(all: Number = 0) { + this.vboxMargin(all, all) +} + +fun Region.vboxMargin(horizontal: Number = 0, vertical: Number = 0) { + this.vboxMargin(vertical, horizontal, vertical, horizontal) +} + +fun Region.vboxMargin(top: Number = 0, right: Number = 0, bottom: Number = 0, left: Number = 0) { + VBox.setMargin(this, insets(top.toDouble(), right.toDouble(), bottom.toDouble(), left.toDouble())) +} + +fun Region.hboxMargin(all: Number = 0) { + this.hboxMargin(all, all) +} + +fun Region.hboxMargin(horizontal: Number = 0, vertical: Number = 0) { + this.hboxMargin(vertical, horizontal, vertical, horizontal) +} + +fun Region.hboxMargin(top: Number = 0, right: Number = 0, bottom: Number = 0, left: Number = 0) { + HBox.setMargin(this, insets(top.toDouble(), right.toDouble(), bottom.toDouble(), left.toDouble())) +} diff --git a/src/main/resources/images/bundled_background_0.jpg b/src/main/resources/images/bundled_background_0.jpg new file mode 100644 index 0000000..6a8acfa Binary files /dev/null and b/src/main/resources/images/bundled_background_0.jpg differ diff --git a/src/main/resources/images/bundled_background_1.jpg b/src/main/resources/images/bundled_background_1.jpg new file mode 100644 index 0000000..01a90d2 Binary files /dev/null and b/src/main/resources/images/bundled_background_1.jpg differ diff --git a/src/main/resources/images/bundled_background_2.jpg b/src/main/resources/images/bundled_background_2.jpg new file mode 100644 index 0000000..4a0169a Binary files /dev/null and b/src/main/resources/images/bundled_background_2.jpg differ diff --git a/src/main/resources/images/bundled_background_3.jpg b/src/main/resources/images/bundled_background_3.jpg new file mode 100644 index 0000000..9cf2ae6 Binary files /dev/null and b/src/main/resources/images/bundled_background_3.jpg differ diff --git a/src/main/resources/images/icons.json b/src/main/resources/images/icons.json new file mode 100644 index 0000000..d910e2f --- /dev/null +++ b/src/main/resources/images/icons.json @@ -0,0 +1,18 @@ +[ + { + "name": "format_list_bulleted", + "path": "M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" + }, + { + "name": "star", + "path": "M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z" + }, + { + "name": "history", + "path": "M13.5,8H12V13L16.28,15.54L17,14.33L13.5,12.25V8M13,3A9,9 0 0,0 4,12H1L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3" + }, + { + "name": "cog", + "path": "M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z" + } +] diff --git a/src/main/resources/lang/keywords_en.properties b/src/main/resources/lang/keywords_en.properties new file mode 100644 index 0000000..43bd8ff --- /dev/null +++ b/src/main/resources/lang/keywords_en.properties @@ -0,0 +1,7 @@ +members={0} Members +private=Private +public=Public +name=Name +description=Description +open=OPEN +search=Search... diff --git a/src/main/resources/lang/keywords_fr.properties b/src/main/resources/lang/keywords_fr.properties new file mode 100644 index 0000000..ec3de44 --- /dev/null +++ b/src/main/resources/lang/keywords_fr.properties @@ -0,0 +1,7 @@ +private=Privé +public=Publique +members={0} Membres +name=Nom +description=Description +open=OUVRIR +search=Recherche... diff --git a/src/main/resources/lang/main_en.properties b/src/main/resources/lang/main_en.properties new file mode 100644 index 0000000..e2ea74b --- /dev/null +++ b/src/main/resources/lang/main_en.properties @@ -0,0 +1,4 @@ +tab.boards.label=Boards +tab.favorites.label=Favorites +tab.history.label=Recents +tab.settings.label=Settings diff --git a/src/main/resources/lang/main_fr.properties b/src/main/resources/lang/main_fr.properties new file mode 100644 index 0000000..a344c60 --- /dev/null +++ b/src/main/resources/lang/main_fr.properties @@ -0,0 +1,4 @@ +tab.boards.label=Tableaux +tab.favorites.label=Favoris +tab.history.label=Récents +tab.settings.label=Paramètres diff --git a/src/main/resources/style/compiled/style.css b/src/main/resources/style/compiled/style.css new file mode 100644 index 0000000..aa8fa4f --- /dev/null +++ b/src/main/resources/style/compiled/style.css @@ -0,0 +1 @@ +.root{-fx-background-color:#fff;-fx-text-fill:black}.label{-fx-font-family:"Biryani Regular"}.text-field{-fx-cursor:text}.nav-bar{-fx-background-color:#df7e2b}.nav-bar .label{-fx-font-family:"Biryani DemiBold";-fx-font-size:2em;-fx-text-fill:white}.nav-bar .jfx-text-field{-jfx-focus-color:#f8dec3;-jfx-unfocus-color:#fff;-fx-background-color:#eaa256;-fx-font-size:1.2em;-fx-text-fill:white;-fx-prompt-text-fill:#f8dec3}.nav-bar .jfx-button{-fx-cursor:hand}.nav-bar .jfx-button .button-icon-wrapper{-fx-padding:0 15px 0 0}.nav-bar .jfx-button .label{-fx-font-size:1.2em}.nav-bar .active{-fx-background-radius:0;-fx-background-color:#eeb274}.label{-fx-font-family:"Biryani Regular"}.card{-fx-background-color:#fff;-fx-background-radius:3px;-fx-effect:dropshadow(three-pass-box, rgba(0,0,0,0.5), 5, 0, 0, 2)}.card .card-header .card-title{-fx-font-size:1.2em;-fx-font-weight:600}.card .card-header .card-subtitle{-fx-text-fill:rgba(0,0,0,0.6)}.card .card-content{-fx-text-fill:rgba(0,0,0,0.6)}.button{-fx-font-size:1.1em;-fx-padding:9px 16px 8px 16px;-fx-text-fill:white;-fx-background-radius:4px}.button.primary{-fx-background-color:#df7e2b;-fx-effect:dropshadow(three-pass-box, rgba(0,0,0,0.3), 3, 0, 0, 2)}.button.primary:pressed{-fx-background-color:#eaa256;-fx-effect:dropshadow(three-pass-box, rgba(0,0,0,0.5), 5, 0, 0, 2)}.button-icon{-fx-padding:5px;-fx-background-radius:24px;-fx-effect:dropshadow(three-pass-box, rgba(0,0,0,0.5), 5, 0, -1, 2)}.button-icon.primary{-fx-background-color:#df7e2b}.button-icon.accent{-fx-background-color:#2f72b9} \ No newline at end of file diff --git a/src/main/resources/style/font/biryani/Biryani-Bold.ttf b/src/main/resources/style/font/biryani/Biryani-Bold.ttf new file mode 100644 index 0000000..69a0d11 Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-Bold.ttf differ diff --git a/src/main/resources/style/font/biryani/Biryani-DemiBold.ttf b/src/main/resources/style/font/biryani/Biryani-DemiBold.ttf new file mode 100644 index 0000000..28ae09a Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-DemiBold.ttf differ diff --git a/src/main/resources/style/font/biryani/Biryani-ExtraBold.ttf b/src/main/resources/style/font/biryani/Biryani-ExtraBold.ttf new file mode 100644 index 0000000..f0b41b1 Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-ExtraBold.ttf differ diff --git a/src/main/resources/style/font/biryani/Biryani-Heavy.ttf b/src/main/resources/style/font/biryani/Biryani-Heavy.ttf new file mode 100644 index 0000000..a481725 Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-Heavy.ttf differ diff --git a/src/main/resources/style/font/biryani/Biryani-Light.ttf b/src/main/resources/style/font/biryani/Biryani-Light.ttf new file mode 100644 index 0000000..8fa7f2e Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-Light.ttf differ diff --git a/src/main/resources/style/font/biryani/Biryani-Regular.ttf b/src/main/resources/style/font/biryani/Biryani-Regular.ttf new file mode 100644 index 0000000..ba63844 Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-Regular.ttf differ diff --git a/src/main/resources/style/font/biryani/Biryani-UltraLight.ttf b/src/main/resources/style/font/biryani/Biryani-UltraLight.ttf new file mode 100644 index 0000000..542921c Binary files /dev/null and b/src/main/resources/style/font/biryani/Biryani-UltraLight.ttf differ diff --git a/src/main/resources/style/font/biryani/SIL Open Font License.txt b/src/main/resources/style/font/biryani/SIL Open Font License.txt new file mode 100644 index 0000000..a763b94 --- /dev/null +++ b/src/main/resources/style/font/biryani/SIL Open Font License.txt @@ -0,0 +1,43 @@ +Copyright (c) 2015 Dan Reynolds. Copyright (c) 2015 Mathieu Réguer. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the copyright statement(s). + +"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. + +5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/src/main/resources/style/font/hattori_hanzo/Creative Commons Attribution License.txt b/src/main/resources/style/font/hattori_hanzo/Creative Commons Attribution License.txt new file mode 100644 index 0000000..bd32fa8 --- /dev/null +++ b/src/main/resources/style/font/hattori_hanzo/Creative Commons Attribution License.txt @@ -0,0 +1,319 @@ +Creative Commons Legal Code + +Attribution 3.0 Unported + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined above) for the purposes of this + License. + c. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + d. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + e. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + f. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + g. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + h. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + i. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights in +other media and formats. Subject to Section 8(f), all rights not expressly +granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly made +subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(b), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(b), as requested. + b. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Section 3(b), in the case of an Adaptation, + a credit identifying the use of the Work in the Adaptation (e.g., + "French translation of the Work by Original Author," or "Screenplay + based on original Work by Original Author"). The credit required by + this Section 4 (b) may be implemented in any reasonable manner; + provided, however, that in the case of a Adaptation or Collection, at + a minimum such credit will appear, if a credit for all contributing + authors of the Adaptation or Collection appears, then as part of these + credits and in a manner at least as prominent as the credits for the + other contributing authors. For the avoidance of doubt, You may only + use the credit required by this Section for the purpose of attribution + in the manner set out above and, by exercising Your rights under this + License, You may not implicitly or explicitly assert or imply any + connection with, sponsorship or endorsement by the Original Author, + Licensor and/or Attribution Parties, as appropriate, of You or Your + use of the Work, without the separate, express prior written + permission of the Original Author, Licensor and/or Attribution + Parties. + c. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + +8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + +Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of this License. + + Creative Commons may be contacted at https://creativecommons.org/. \ No newline at end of file diff --git a/src/main/resources/style/font/hattori_hanzo/Hattori_Hanzo.ttf b/src/main/resources/style/font/hattori_hanzo/Hattori_Hanzo.ttf new file mode 100644 index 0000000..6799e87 Binary files /dev/null and b/src/main/resources/style/font/hattori_hanzo/Hattori_Hanzo.ttf differ diff --git a/src/main/resources/style/style.dark.scss b/src/main/resources/style/style.dark.scss new file mode 100644 index 0000000..f74746e --- /dev/null +++ b/src/main/resources/style/style.dark.scss @@ -0,0 +1,77 @@ +$dark-grey: #121212; +$dark-theme: ( + "00dp": $dark-grey, + "01dp": scale-color($dark-grey, $lightness: +5%), + "02dp": scale-color($dark-grey, $lightness: +7%), + "03dp": scale-color($dark-grey, $lightness: +8%), + "04dp": scale-color($dark-grey, $lightness: +9%), + "06dp": scale-color($dark-grey, $lightness: +11%), + "08dp": scale-color($dark-grey, $lightness: +12%), + "12dp": scale-color($dark-grey, $lightness: +14%), + "16dp": scale-color($dark-grey, $lightness: +15%), + "24dp": scale-color($dark-grey, $lightness: +16%), +); + +$primary-theme: ( + 50: #fcf2e7, + 100: #f8dec3, + 200: #f3c89c, + 300: #eeb274, + 400: #eaa256, + 500: #e69138, + 600: #e38932, + 700: #df7e2b, + 800: #db7424, + 900: #d56217 +); + +$accent-theme: ( + 50: #e8f0f8, + 100: #c5daee, + 200: #9ec2e3, + 300: #77aad7, + 400: #5a97cf, + 500: #3d85c6, + 600: #377dc0, + 700: #2f72b9, + 800: #2768b1, + 900: #1a55a4 +); + +//@font-face { +// font-family: Roboto; +// src: url("/home/william/Dev/Projects/todo/App/src/main/resources/style/font/Roboto/Roboto-Regular.ttf"); +//} + +.root { + -fx-background-color: map-get($dark-theme, "00dp"); +} + +.text { + -fx-text-fill: white; +} + +.board-selection { + .board { + -fx-background-color: map-get($dark-theme, "01dp"); + -fx-background-radius: 4px; + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, .3), 2, 0, 0, 5); + + &.add { + -fx-background-color: map-get($primary-theme, 700); + -fx-font-size: 10em; + -fx-text-fill: $dark-grey; + } + + &:hover { + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, .5), 6, 0, 0, 5); + } + } + + .sidebar { + //-fx-border-width: 0 0 0 2px; + //-fx-border-color: map-get($primary-theme, 700); + -fx-background-color: map-get($dark-theme, "01dp"); + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, .5), 6, 0, -2, 0); + } +} diff --git a/src/main/resources/style/style.light.scss b/src/main/resources/style/style.light.scss new file mode 100644 index 0000000..c2b6e41 --- /dev/null +++ b/src/main/resources/style/style.light.scss @@ -0,0 +1,64 @@ +@import 'theme'; + +$background: #ffffff; + +.root { + -fx-background-color: $background; + -fx-text-fill: black; +} + +.text-field { + -fx-cursor: text; +} + +.card { + -fx-background-color: $background; + -fx-background-radius: 3px; + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.5), 5, 0, 0, 2); + + .card-header { + .card-title { + -fx-font-size: 1.2em; + -fx-font-weight: 600; + } + + .card-subtitle { + -fx-text-fill: rgba(0, 0, 0, 0.6); + } + } + + .card-content { + -fx-text-fill: rgba(0, 0, 0, 0.6); + } +} + +.button { + -fx-font-size: 1.1em; + -fx-padding: 9px 16px 8px 16px; + -fx-text-fill: white; + -fx-background-radius: 4px; + + &.primary { + -fx-background-color: map-get($primary-theme, 700); + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.3), 3, 0, 0, 2); + + &:pressed { + -fx-background-color: map-get($primary-theme, 400); + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.5), 5, 0, 0, 2); + } + } +} + +.button-icon { + -fx-padding: 5px; + -fx-background-radius: 24px; + -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.5), 5, 0, -1, 2); + + &.primary { + -fx-background-color: map-get($primary-theme, 700); + } + + &.accent { + -fx-background-color: map-get($accent-theme, 700); + } +} diff --git a/src/main/resources/style/theme.scss b/src/main/resources/style/theme.scss new file mode 100644 index 0000000..e6bd8c9 --- /dev/null +++ b/src/main/resources/style/theme.scss @@ -0,0 +1,25 @@ +$primary-theme: ( + 50: #fcf2e7, + 100: #f8dec3, + 200: #f3c89c, + 300: #eeb274, + 400: #eaa256, + 500: #e69138, + 600: #e38932, + 700: #df7e2b, + 800: #db7424, + 900: #d56217 +); + +$accent-theme: ( + 50: #e8f0f8, + 100: #c5daee, + 200: #9ec2e3, + 300: #77aad7, + 400: #5a97cf, + 500: #3d85c6, + 600: #377dc0, + 700: #2f72b9, + 800: #2768b1, + 900: #1a55a4 +); diff --git a/src/test/kotlin/dev/fyloz/plannervio/core/service/BackgroundImageServiceTest.kt b/src/test/kotlin/dev/fyloz/plannervio/core/service/BackgroundImageServiceTest.kt new file mode 100644 index 0000000..87d9be4 --- /dev/null +++ b/src/test/kotlin/dev/fyloz/plannervio/core/service/BackgroundImageServiceTest.kt @@ -0,0 +1,67 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.core.model.BackgroundImage +import io.mockk.* +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import java.io.InputStream +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull + +class BackgroundImageServiceTest { + private val service: BackgroundImageService = spyk() + private val fakeInputStream: InputStream = mockk() + private val backgroundImage = BackgroundImage("image", true) + + @BeforeEach + internal fun setUp() { + clearAllMocks() + } + + @Nested + inner class LoadImage { + @Test + fun `Image is loaded`() { + every { service.getImageInputStream(backgroundImage) } returns fakeInputStream + + val found = service.loadImage(backgroundImage) + + assertNotNull(found) + } + + @Test + fun `Image is null`() { + every { service.getImageInputStream(backgroundImage) } returns null + + val found = service.loadImage(backgroundImage) + + assertNull(found) + } + } + + @Nested + inner class GetImageInputStream { + @Test + fun `call getBundledImageInputStream when bundled`() { + every { service.getBundledImageInputStream(backgroundImage) } returns fakeInputStream + + val found = service.getImageInputStream(backgroundImage) + + verify(exactly = 1) { service.getBundledImageInputStream(backgroundImage) } + assertEquals(fakeInputStream, found) + } + + @Test + fun `call getCustomImageInputStream when custom`() { + val customBackgroundImage = BackgroundImage("image", false) + every { service.getCustomImageInputStream(customBackgroundImage) } returns fakeInputStream + + val found = service.getImageInputStream(customBackgroundImage) + + verify(exactly = 1) { service.getCustomImageInputStream(customBackgroundImage) } + assertEquals(fakeInputStream, found) + } + } +} diff --git a/src/test/kotlin/dev/fyloz/plannervio/core/service/BoardServiceTest.kt b/src/test/kotlin/dev/fyloz/plannervio/core/service/BoardServiceTest.kt new file mode 100644 index 0000000..1871ddc --- /dev/null +++ b/src/test/kotlin/dev/fyloz/plannervio/core/service/BoardServiceTest.kt @@ -0,0 +1,55 @@ +package dev.fyloz.plannervio.core.service + +import dev.fyloz.plannervio.core.model.Board +import dev.fyloz.plannervio.core.model.boardFactory +import dev.fyloz.plannervio.core.repository.IBoardRepository +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.mockk +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import org.kodein.di.DI +import org.kodein.di.bind +import org.kodein.di.singleton +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class BoardServiceTest { + private val di: DI = DI { + bind() with singleton { repository } + } + + private val repository: IBoardRepository = mockk() + private val service: IBoardService = BoardService(di) + + @BeforeEach + fun setUp() { + clearAllMocks() + } + + @Nested + inner class GetBoards { + @Test + fun `all boards are included`() { + val boards: List = listOf( + boardFactory(0L), + boardFactory(1L) + ) + every { repository.findAll() } returns boards + + val found = service.getBoards() + + assertEquals(boards, found) + } + + @Test + fun `no boards are included`() { + every { repository.findAll() } returns listOf() + + val found = service.getBoards() + + assertTrue { found.isEmpty() } + } + } +} diff --git a/src/test/kotlin/dev/fyloz/plannervio/core/service/I18nServiceTest.kt b/src/test/kotlin/dev/fyloz/plannervio/core/service/I18nServiceTest.kt new file mode 100644 index 0000000..e46cc10 --- /dev/null +++ b/src/test/kotlin/dev/fyloz/plannervio/core/service/I18nServiceTest.kt @@ -0,0 +1,51 @@ +package dev.fyloz.plannervio.core.service + +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.mockk +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import java.util.* +import kotlin.test.assertEquals + +class I18nServiceTest { + private val specificBundle: ResourceBundle = mockk() + private val keywordsBundle: ResourceBundle = mockk() + + private val service: II18nService = I18nService(specificBundle, keywordsBundle) + + @BeforeEach + fun setUp() { + clearAllMocks() + } + + @Nested + inner class GetLocalizedString { + @Test + fun `contains specific bundle`() { + val key = iI18nKeyFactory("specific") + val value = "specific value" + every { specificBundle.containsKey(key.keyName) } returns true + every { specificBundle.getObject(key.keyName) } returns value + every { keywordsBundle.containsKey(key.keyName) } returns false + + val found = service.getLocalizedString(key) + + assertEquals(value, found) + } + + @Test + fun `contains keywords bundle`() { + val key = iI18nKeyFactory("keyword") + val value = "keyword value" + every { keywordsBundle.containsKey(key.keyName) } returns true + every { keywordsBundle.getObject(key.keyName) } returns value + every { specificBundle.containsKey(key.keyName) } returns false + + val found = service.getLocalizedString(key) + + assertEquals(value, found) + } + } +} diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties new file mode 100644 index 0000000..d265fd8 --- /dev/null +++ b/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +junit.jupiter.testinstance.lifecycle.default = per_class