-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently just displays trending within a given period TODO: Offer the language and spoken language filtering options TODO: Button to view awesome lists
- Loading branch information
Showing
16 changed files
with
696 additions
and
5 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ommonMain/graphql/com/materiiapps/gloom/gql/fragments/TrendingRepository.fragment.graphql
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,20 @@ | ||
fragment TrendingRepository on Repository { | ||
id | ||
name | ||
description | ||
openGraphImageUrl | ||
usesCustomOpenGraphImage | ||
starsSince(period: $period) | ||
contributorsCount | ||
viewerHasStarred | ||
stargazerCount | ||
primaryLanguage { | ||
color | ||
name | ||
} | ||
owner { | ||
__typename | ||
avatarUrl | ||
login | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
api/src/commonMain/graphql/com/materiiapps/gloom/gql/queries/Trending.query.graphql
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,5 @@ | ||
query Trending($period: TrendingPeriod!) { | ||
trendingRepositories(period: $period, mobileSortOrder: true) { | ||
...TrendingRepository | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
ui/src/androidMain/kotlin/com/materiiapps/gloom/ui/util/NumberFormatter.android.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,35 @@ | ||
package com.materiiapps.gloom.ui.util | ||
|
||
import android.icu.number.Notation | ||
import android.icu.text.CompactDecimalFormat | ||
import android.os.Build | ||
import java.text.DecimalFormat | ||
import java.util.Locale | ||
import android.icu.number.NumberFormatter as AndroidNumberFormatter | ||
|
||
actual object NumberFormatter { | ||
|
||
actual fun compact(count: Int): String { | ||
return when { | ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> { | ||
AndroidNumberFormatter | ||
.withLocale(Locale.getDefault()) | ||
.notation(Notation.compactShort()) | ||
.format(count) | ||
.toString() | ||
} | ||
|
||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> { | ||
CompactDecimalFormat | ||
.getInstance( | ||
Locale.getDefault(), | ||
CompactDecimalFormat.CompactStyle.SHORT | ||
) | ||
.format(count) | ||
} | ||
|
||
else -> DecimalFormat().format(count) | ||
} | ||
} | ||
|
||
} |
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
79 changes: 79 additions & 0 deletions
79
ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/component/filter/ChoiceInputChip.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,79 @@ | ||
package com.materiiapps.gloom.ui.component.filter | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.ExpandMore | ||
import androidx.compose.material3.DropdownMenu | ||
import androidx.compose.material3.DropdownMenuItem | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.InputChip | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.DpOffset | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.enums.enumEntries | ||
|
||
/** | ||
* An [InputChip] used to make a single selection from a set | ||
* of options using an enum. | ||
* | ||
* Clicking the chip will open a dropdown containing all the entries | ||
* contained in the provided enum [E], once the user selects an item [onChoiceSelected] | ||
* will be called and the dropdown dismissed. | ||
* | ||
* @param E The enum used to supply the choices | ||
* | ||
* @param defaultValue The default value, if the current choice differs from this value then | ||
* the chip will be marked as selected | ||
* @param currentValue The currently chosen item | ||
* @param onChoiceSelected Called when the user makes their choice | ||
* @param modifier The [Modifier] for this chip | ||
* @param label Factory function used to get a localized label for the enum entry, defaults to the enum entries name. | ||
* It is not reccommended to override the text style or add anything more than a [Text] component. | ||
*/ | ||
@Composable | ||
inline fun <reified E: Enum<E>> ChoiceInputChip( | ||
defaultValue: E, | ||
currentValue: E, | ||
crossinline onChoiceSelected: (E) -> Unit, | ||
modifier: Modifier = Modifier, | ||
crossinline label: @Composable (E) -> Unit = { Text(it.name) } | ||
) { | ||
var dropdownVisible by remember { mutableStateOf(false) } | ||
|
||
InputChip( | ||
onClick = { dropdownVisible = true }, | ||
selected = currentValue != defaultValue, | ||
label = { label(currentValue) }, | ||
trailingIcon = { | ||
Icon( | ||
imageVector = Icons.Outlined.ExpandMore, | ||
contentDescription = null | ||
) | ||
}, | ||
modifier = modifier | ||
) | ||
|
||
Box { | ||
DropdownMenu( | ||
expanded = dropdownVisible, | ||
onDismissRequest = { dropdownVisible = false }, | ||
offset = DpOffset(0.dp, 24.dp) | ||
) { | ||
enumEntries<E>().forEach { entry -> | ||
DropdownMenuItem( | ||
text = { label(entry) }, | ||
onClick = { | ||
dropdownVisible = false | ||
if (currentValue != entry) onChoiceSelected(entry) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
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.