Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making 3 different thread view types - Tree style - List - List with only direct replies Doing some other small refactors - Some refactors on post card stuff --------- Co-authored-by: John Oberhauser <j.git-global@obez.io>
- Loading branch information
1 parent
e9a48c6
commit 92d5a81
Showing
38 changed files
with
1,309 additions
and
459 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
core/common/src/main/java/social/firefly/common/tree/TreeNode.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,25 @@ | ||
package social.firefly.common.tree | ||
|
||
class MutableTreeNode<T>( | ||
override val value: T | ||
): TreeNode<T> { | ||
private val _branches: MutableList<TreeNode<T>> = mutableListOf() | ||
override val branches: List<TreeNode<T>> = _branches | ||
|
||
override val isLeaf: Boolean | ||
get() = branches.isEmpty() | ||
|
||
fun add(tree: TreeNode<T>) { | ||
_branches.add(tree) | ||
} | ||
|
||
fun remove(tree: TreeNode<T>) { | ||
_branches.remove(tree) | ||
} | ||
} | ||
|
||
interface TreeNode<T> { | ||
val branches: List<TreeNode<T>> | ||
val isLeaf: Boolean | ||
val value: T | ||
} |
54 changes: 54 additions & 0 deletions
54
core/common/src/main/java/social/firefly/common/tree/TreeUtils.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,54 @@ | ||
package social.firefly.common.tree | ||
|
||
fun <T> TreeNode<T>.toDepthList( | ||
depth: Int = 0, | ||
depthLines: List<Int> = listOf(), | ||
): List<DepthItem<T>> = buildList { | ||
var newDepthLines = buildList { | ||
addAll(depthLines) | ||
if (!isLeaf) { | ||
add(depth) | ||
} | ||
} | ||
add( | ||
DepthItem( | ||
value, | ||
depth, | ||
newDepthLines, | ||
) | ||
) | ||
branches.forEachIndexed { index, treeNode -> | ||
if (index == branches.size - 1) { | ||
newDepthLines = newDepthLines.toMutableList().apply { | ||
remove(depth) | ||
} | ||
} | ||
addAll( | ||
treeNode.toDepthList( | ||
depth + 1, | ||
newDepthLines, | ||
) | ||
) | ||
} | ||
} | ||
|
||
data class DepthItem<T>( | ||
val value: T, | ||
val depth: Int, | ||
val depthLines: List<Int>, | ||
) | ||
|
||
fun <T> List<T>.toTree( | ||
identifier: (T) -> String, | ||
parentIdentifier: (T) -> String?, | ||
): TreeNode<T>? { | ||
val nodes = mutableMapOf<String, MutableTreeNode<T>>() | ||
|
||
forEach { | ||
val newNode = MutableTreeNode(it) | ||
nodes[parentIdentifier(it)]?.add(newNode) | ||
nodes[identifier(it)] = newNode | ||
} | ||
|
||
return nodes[identifier(first())] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="32dp" | ||
android:height="32dp" | ||
android:viewportWidth="256" | ||
android:viewportHeight="256"> | ||
<path | ||
android:pathData="M32,64a8,8 0,0 1,8 -8L216,56a8,8 0,0 1,0 16L40,72A8,8 0,0 1,32 64ZM40,136L216,136a8,8 0,0 0,0 -16L40,120a8,8 0,0 0,0 16ZM144,184L40,184a8,8 0,0 0,0 16L144,200a8,8 0,0 0,0 -16ZM232,184L216,184L216,168a8,8 0,0 0,-16 0v16L184,184a8,8 0,0 0,0 16h16v16a8,8 0,0 0,16 0L216,200h16a8,8 0,0 0,0 -16Z" | ||
android:fillColor="#000000"/> | ||
</vector> |
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="32dp" | ||
android:height="32dp" | ||
android:viewportWidth="256" | ||
android:viewportHeight="256"> | ||
<path | ||
android:pathData="M176,152h32a16,16 0,0 0,16 -16L224,104a16,16 0,0 0,-16 -16L176,88a16,16 0,0 0,-16 16v8L88,112L88,80h8a16,16 0,0 0,16 -16L112,32A16,16 0,0 0,96 16L64,16A16,16 0,0 0,48 32L48,64A16,16 0,0 0,64 80h8L72,192a24,24 0,0 0,24 24h64v8a16,16 0,0 0,16 16h32a16,16 0,0 0,16 -16L224,192a16,16 0,0 0,-16 -16L176,176a16,16 0,0 0,-16 16v8L96,200a8,8 0,0 1,-8 -8L88,128h72v8A16,16 0,0 0,176 152ZM64,32L96,32L96,64L64,64ZM176,192h32v32L176,224ZM176,104h32v32L176,136Z" | ||
android:fillColor="#000000"/> | ||
</vector> |
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
14 changes: 13 additions & 1 deletion
14
core/ui/common/src/main/java/social/firefly/core/ui/common/dropdown/FfDropDownItem.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
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.