Skip to content

Commit

Permalink
Merge branch 'main' into rewrite/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
lillithkt committed Nov 27, 2023
2 parents bc070ba + bca4cba commit 6cf4389
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 342 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [aenriii, ImLvna, uninit-org]
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
path: genesis/genesisApi/build
key: ${{ runner.os }}-genesis-genesisApi-${{ hashFiles('genesis/genesisApi/**') }}



- name: Setup Android SDK
if: matrix.os == 'ubuntu-latest'
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:

- name: Release
uses: softprops/action-gh-release@v1
if: github.event_name != 'release'
if: github.event_name == 'release'
with:
files: |
appDesktop/build/compose/binaries/main/deb/*.deb
Expand Down
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions appAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,4 @@ android {
kotlin {
jvmToolchain(17)
}

buildTypes {
getByName("release") {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type. Make sure to use a build
// variant with `isDebuggable=false`.
isMinifyEnabled = true

// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
isShrinkResources = true

// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt")
)
}
}
}
16 changes: 0 additions & 16 deletions genesis/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,5 @@ android {
kotlin {
jvmToolchain(17)
}

buildTypes {
getByName("release") {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type. Make sure to use a build
// variant with `isDebuggable=false`.
isMinifyEnabled = true

// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt")
)
}
}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package xyz.genesisapp.genesis.app

import androidx.compose.runtime.Composable
import io.github.aakira.napier.Antilog
import io.github.aakira.napier.DebugAntilog

actual fun getPlatformName(): String = "Android"
actual fun getAntiLog(): Antilog = DebugAntilog()

@Composable
fun MainView() = App()
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.currentOrThrow
import io.github.aakira.napier.Antilog
import io.github.aakira.napier.DebugAntilog
import io.github.aakira.napier.Napier
import org.jetbrains.compose.resources.ExperimentalResourceApi
Expand All @@ -31,7 +32,7 @@ import xyz.genesisapp.genesis.app.ui.screens.RootScreen
@OptIn(ExperimentalResourceApi::class)
@Composable
fun App() {
Napier.base(DebugAntilog())
Napier.base(getAntiLog())
val preferencesModule = preferencesModule()
KoinApplication(application = {
modules(
Expand Down Expand Up @@ -90,4 +91,6 @@ fun App() {

}

expect fun getPlatformName(): String
expect fun getPlatformName(): String

expect fun getAntiLog(): Antilog
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import xyz.genesisapp.genesis.app.ui.screens.client.ClientTab
class DataStore() : EventBus("DataStore") {

var mobileUi by mutableStateOf(false)
var showGuilds by mutableStateOf(false)
val shiggyEasterEgg by mutableStateOf(getTimeInMillis() % 10 == 0L)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.currentOrThrow
import io.github.aakira.napier.Napier
import io.kamel.core.ExperimentalKamelApi
Expand Down Expand Up @@ -176,143 +175,134 @@ class ChannelsScreen(
mutableStateOf(currentChannel)
}

dataStore.compositionOnGuildSelect {
navigator.push(ChannelsScreen(genesisClient.guilds[it], guild.id))
}
Events(
dataStore.events.quietRegister<Snowflake>("GUILD_SELECT") {
navigator.push(ChannelsScreen(genesisClient.guilds[it], guild.id))
}
)

Row(
Scaffold(
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
) {
AnimatedVisibility(visible = dataStore.showGuilds || !dataStore.mobileUi) {

Scaffold(
modifier = Modifier
.width(
200.dp
),
bottomBar = {
AnimatedVisibility(
visible = !dataStore.mobileUi,
// slide in from bottom
enter = slideInVertically(initialOffsetY = { it }),
exit = slideOutVertically(targetOffsetY = { it })
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
.background(color = MaterialTheme.colorScheme.primary)
) {
val modifier = Modifier.align(Alignment.CenterVertically)
Avatar(genesisClient.normalUser, modifier = modifier)
Text(
genesisClient.normalUser.displayName,
modifier = modifier.width(100.dp),
fontSize = MaterialTheme.typography.labelMedium.fontSize
)
Button(
onClick = {
dataStore.selectClientTab(ClientTab.SETTINGS)

}
) {
Text("Settings")
}
}
}
}
.width(
200.dp
),
bottomBar = {
AnimatedVisibility(
visible = !dataStore.mobileUi,
// slide in from bottom
enter = slideInVertically(initialOffsetY = { it }),
exit = slideOutVertically(targetOffsetY = { it })
) {
LazyColumn(
Row(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.padding(bottom = 48.dp)
.height(48.dp)
.background(color = MaterialTheme.colorScheme.primary)
) {
val modifier = Modifier.align(Alignment.CenterVertically)
Avatar(genesisClient.normalUser, modifier = modifier)
Text(
genesisClient.normalUser.displayName,
modifier = modifier.width(100.dp),
fontSize = MaterialTheme.typography.labelMedium.fontSize
)
Button(
onClick = {
dataStore.selectClientTab(ClientTab.SETTINGS)

val uncategorized = mutableMapOf<Snowflake, Channel>()
val categories = mutableMapOf<Snowflake, Channel>()

guild.channels.forEach {
if (it.type == ChannelType.GUILD_CATEGORY) {
categories[it.id] = it
}
) {
Text("Settings")
}
guild.channels.forEach {
if (it.type != ChannelType.GUILD_CATEGORY) {
if (it.parentId != null) {
if (categories[it.parentId!!]?.children?.contains(it.id) == true) {
return@forEach
}
categories[it.parentId!!]!!.children.add(it.id)
} else {
uncategorized[it.id] = it
}
}
}
}
) {
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.padding(bottom = 48.dp)
) {

val uncategorized = mutableMapOf<Snowflake, Channel>()
val categories = mutableMapOf<Snowflake, Channel>()

guild.channels.forEach {
if (it.type == ChannelType.GUILD_CATEGORY) {
categories[it.id] = it
}
}
guild.channels.forEach {
if (it.type != ChannelType.GUILD_CATEGORY) {
if (it.parentId != null) {
if (categories[it.parentId!!]?.children?.contains(it.id) == true) {
return@forEach
}
categories[it.parentId!!]!!.children.add(it.id)
} else {
uncategorized[it.id] = it
}
}
}

val sortedCategories = categories.values.sortedBy { it.position }
val sortedUncategorized = uncategorized.values.sortedBy { it.position }
val iterator = sortedCategories.iterator()
while (iterator.hasNext()) {
val category = iterator.next()
category.children =
category.children.sortedBy { guild.channels.find { it2 -> it2.id == it }!!.position }
.toMutableList()
}
val sortedCategories = categories.values.sortedBy { it.position }
val sortedUncategorized = uncategorized.values.sortedBy { it.position }
val iterator = sortedCategories.iterator()
while (iterator.hasNext()) {
val category = iterator.next()
category.children =
category.children.sortedBy { guild.channels.find { it2 -> it2.id == it }!!.position }
.toMutableList()
}


item {
val modifier = Modifier
.fillMaxWidth()
.height(48.dp)
if (guild.banner != null) {
KamelImageBox(
resource = asyncPainterResource(
guild.banner!!.toUrl(AssetType.Banner, guild.id, 480),
),
modifier = modifier,
onFailure = {
Text(guild.name)
}
)
{
Text(guild.name)
}
item {
val modifier = Modifier
.fillMaxWidth()
.height(48.dp)
if (guild.banner != null) {
KamelImageBox(
resource = asyncPainterResource(
guild.banner!!.toUrl(AssetType.Banner, guild.id, 480),
),
modifier = modifier,
onFailure = {
Text(guild.name)
}
)
{
Text(guild.name)
}
}
}



if (sortedUncategorized.isNotEmpty())
item {
Category(null, sortedUncategorized) {
lastChannel = currentChannel
currentChannel = it.id
dataStore.selectChannel(it.id)
}
}

items(
items = sortedCategories,
key = { it.id }
) { category ->
val children = category.children.map { channelId ->
guild.channels.find { it2 -> it2.id == channelId }!!
}
Category(category, children) {
lastChannel = currentChannel
currentChannel = it.id
dataStore.selectChannel(it.id)
}
if (sortedUncategorized.isNotEmpty())
item {
Category(null, sortedUncategorized) {
lastChannel = currentChannel
currentChannel = it.id
dataStore.selectChannel(it.id)
}
}

items(
items = sortedCategories,
key = { it.id }
) { category ->
val children = category.children.map { channelId ->
guild.channels.find { it2 -> it2.id == channelId }!!
}
Category(category, children) {
lastChannel = currentChannel
currentChannel = it.id
dataStore.selectChannel(it.id)
}
}

}
Navigator(ChatScreen(genesisClient.channels[currentChannel], lastChannel))
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class ChatScreen(
AnimatedVisibility(visible = dataStore.mobileUi) {
Button(
onClick = {
dataStore.showGuilds = !dataStore.showGuilds
dataStore.events.emit("GUILDS_TOGGLE", true)
},
modifier = Modifier.align(alignment = Alignment.CenterVertically)
) {
Expand Down
Loading

0 comments on commit 6cf4389

Please sign in to comment.