forked from iSoron/uhabits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize packages; implement checkmarks
- Loading branch information
Showing
100 changed files
with
1,753 additions
and
509 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-24.4 KB
core/assets/test/components/old/habits/show/FrequencyCard/render.png
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-14.5 KB
core/assets/test/components/old/habits/show/OverviewCard/render.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
core/src/commonMain/kotlin/org/isoron/platform/concurrency/Tasks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (C) 2016-2019 Álinson Santos Xavier <[email protected]> | ||
* | ||
* This file is part of Loop Habit Tracker. | ||
* | ||
* Loop Habit Tracker is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* Loop Habit Tracker is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.isoron.platform.concurrency | ||
|
||
/** | ||
* A TaskRunner provides the ability of running tasks in different queues. The | ||
* class is also observable, and notifies listeners when new tasks are started | ||
* or finished. | ||
* | ||
* Two queues are available: a foreground queue and a background queue. These | ||
* two queues may run in parallel, depending on the hardware. Multiple tasks | ||
* submitted to the same queue, however, always run sequentially, in the order | ||
* they were enqueued. | ||
*/ | ||
interface TaskRunner { | ||
|
||
val listeners: MutableList<Listener> | ||
|
||
val activeTaskCount: Int | ||
|
||
fun runInBackground(task: () -> Unit) | ||
|
||
fun runInForeground(task: () -> Unit) | ||
|
||
interface Listener { | ||
fun onTaskStarted() | ||
fun onTaskFinished() | ||
} | ||
} | ||
|
||
/** | ||
* Sequential implementation of TaskRunner. Both background and foreground | ||
* queues run in the same thread, so they block each other. | ||
*/ | ||
class SequentialTaskRunner : TaskRunner { | ||
|
||
override val listeners = mutableListOf<TaskRunner.Listener>() | ||
|
||
override var activeTaskCount = 0 | ||
|
||
override fun runInBackground(task: () -> Unit) { | ||
activeTaskCount += 1 | ||
for (l in listeners) l.onTaskStarted() | ||
task() | ||
activeTaskCount -= 1 | ||
for (l in listeners) l.onTaskFinished() | ||
} | ||
|
||
override fun runInForeground(task: () -> Unit) = runInBackground(task) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
core/src/commonMain/kotlin/org/isoron/platform/gui/Colors.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2016-2019 Álinson Santos Xavier <[email protected]> | ||
* | ||
* This file is part of Loop Habit Tracker. | ||
* | ||
* Loop Habit Tracker is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* Loop Habit Tracker is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.isoron.platform.gui | ||
|
||
data class PaletteColor(val index: Int) | ||
|
||
data class Color(val red: Double, | ||
val green: Double, | ||
val blue: Double, | ||
val alpha: Double) { | ||
|
||
val luminosity: Double | ||
get() { | ||
return 0.21 * red + 0.72 * green + 0.07 * blue | ||
} | ||
|
||
constructor(rgb: Int) : this(((rgb shr 16) and 0xFF) / 255.0, | ||
((rgb shr 8) and 0xFF) / 255.0, | ||
((rgb shr 0) and 0xFF) / 255.0, | ||
1.0) | ||
|
||
fun blendWith(other: Color, weight: Double): Color { | ||
return Color(red * (1 - weight) + other.red * weight, | ||
green * (1 - weight) + other.green * weight, | ||
blue * (1 - weight) + other.blue * weight, | ||
alpha * (1 - weight) + other.alpha * weight) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.