Skip to content

Commit

Permalink
Merge pull request #214 from lihenggui/mercury
Browse files Browse the repository at this point in the history
Update GitHub action scripts
  • Loading branch information
lihenggui authored Jul 6, 2023
2 parents 11c6ad4 + e41ba4f commit e1a4136
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 35 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@ on:
push:
branches:
- main
paths-ignore:
- '.idea/**'
- '.gitattributes'
- '.github/**.json'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- 'NOTICE'
pull_request:
paths-ignore:
- '.idea/**'
- '.gitattributes'
- '.github/**.json'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- 'NOTICE'
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true

- name: Build app
run: ./gradlew :app-compose:assembleRelease
run: ./gradlew :app-compose:assembleRelease :app-compose:bundleRelease

- name: Create Release
id: create_release
Expand Down Expand Up @@ -86,6 +86,17 @@ jobs:
name: mappings
path: "app-compose/build/outputs/mapping/marketRelease"

- name: Publish to Play Store internal test track
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'lihenggui/Blocker'
uses: r0adkll/upload-google-play@v1.1.1
with:
serviceAccountJsonPlainText: ${{ secrets.ANDROID_SERVICE_ACCOUNT_JSON }}
packageName: com.merxury.blocker
releaseFiles: app-compose/build/outputs/bundle/marketRelease/app-compose-market-release.aab
track: beta
inAppUpdatePriority: 2
mappingFile: app-compose/build/outputs/mapping/marketRelease/mapping.txt

- name: Set apk path
id: apk-path
run: |
Expand All @@ -99,4 +110,4 @@ jobs:
id: apk-info
uses: zhaobozhen/apk-info-action@1.1.2
with:
apk-path: ${{ steps.apk-path.outputs.foss_path }}
apk-path: ${{ steps.apk-path.outputs.foss_path }}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.Orientation.Horizontal
import androidx.compose.foundation.gestures.Orientation.Vertical
import androidx.compose.foundation.gestures.ScrollableState
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsDraggedAsState
Expand Down Expand Up @@ -56,16 +57,13 @@ private const val INACTIVE_TO_DORMANT_COOL_DOWN = 2_000L
* Its thumb disappears when the scrolling container is dormant.
* @param modifier a [Modifier] for the [Scrollbar]
* @param state the driving state for the [Scrollbar]
* @param scrollInProgress a flag indicating if the scrolling container for the scrollbar is
* currently scrolling
* @param orientation the orientation of the scrollbar
* @param onThumbDisplaced the fast scroll implementation
*/
@Composable
fun FastScrollbar(
fun ScrollableState.FastScrollbar(
modifier: Modifier = Modifier,
state: ScrollbarState,
scrollInProgress: Boolean,
orientation: Orientation,
onThumbDisplaced: (Float) -> Unit,
) {
Expand All @@ -77,7 +75,6 @@ fun FastScrollbar(
state = state,
thumb = {
FastScrollbarThumb(
scrollInProgress = scrollInProgress,
interactionSource = interactionSource,
orientation = orientation,
)
Expand All @@ -91,15 +88,12 @@ fun FastScrollbar(
* Its thumb disappears when the scrolling container is dormant.
* @param modifier a [Modifier] for the [Scrollbar]
* @param state the driving state for the [Scrollbar]
* @param scrollInProgress a flag indicating if the scrolling container for the scrollbar is
* currently scrolling
* @param orientation the orientation of the scrollbar
*/
@Composable
fun DecorativeScrollbar(
fun ScrollableState.DecorativeScrollbar(
modifier: Modifier = Modifier,
state: ScrollbarState,
scrollInProgress: Boolean,
orientation: Orientation,
) {
val interactionSource = remember { MutableInteractionSource() }
Expand All @@ -111,7 +105,6 @@ fun DecorativeScrollbar(
thumb = {
DecorativeScrollbarThumb(
interactionSource = interactionSource,
scrollInProgress = scrollInProgress,
orientation = orientation,
)
},
Expand All @@ -122,8 +115,7 @@ fun DecorativeScrollbar(
* A scrollbar thumb that is intended to also be a touch target for fast scrolling.
*/
@Composable
private fun FastScrollbarThumb(
scrollInProgress: Boolean,
private fun ScrollableState.FastScrollbarThumb(
interactionSource: InteractionSource,
orientation: Orientation,
) {
Expand All @@ -137,7 +129,6 @@ private fun FastScrollbarThumb(
}
.background(
color = scrollbarThumbColor(
scrollInProgress = scrollInProgress,
interactionSource = interactionSource,
),
shape = RoundedCornerShape(16.dp),
Expand All @@ -149,8 +140,7 @@ private fun FastScrollbarThumb(
* A decorative scrollbar thumb for communicating a user's position in a list solely.
*/
@Composable
private fun DecorativeScrollbarThumb(
scrollInProgress: Boolean,
private fun ScrollableState.DecorativeScrollbarThumb(
interactionSource: InteractionSource,
orientation: Orientation,
) {
Expand All @@ -164,7 +154,6 @@ private fun DecorativeScrollbarThumb(
}
.background(
color = scrollbarThumbColor(
scrollInProgress = scrollInProgress,
interactionSource = interactionSource,
),
shape = RoundedCornerShape(16.dp),
Expand All @@ -174,19 +163,18 @@ private fun DecorativeScrollbarThumb(

/**
* The color of the scrollbar thumb as a function of its interaction state.
* @param scrollInProgress if the scrolling container is currently scrolling
* @param interactionSource source of interactions in the scrolling container
*/
@Composable
private fun scrollbarThumbColor(
scrollInProgress: Boolean,
private fun ScrollableState.scrollbarThumbColor(
interactionSource: InteractionSource,
): Color {
var state by remember { mutableStateOf(Dormant) }
val pressed by interactionSource.collectIsPressedAsState()
val hovered by interactionSource.collectIsHoveredAsState()
val dragged by interactionSource.collectIsDraggedAsState()
val active = pressed || hovered || dragged || scrollInProgress
val active = (canScrollForward || canScrollForward) &&
(pressed || hovered || dragged || isScrollInProgress)

val color by animateColorAsState(
targetValue = when (state) {
Expand All @@ -202,7 +190,7 @@ private fun scrollbarThumbColor(
LaunchedEffect(active) {
when (active) {
true -> state = Active
false -> {
false -> if (state == Active) {
state = Inactive
delay(INACTIVE_TO_DORMANT_COOL_DOWN)
state = Dormant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ internal inline fun <LazyState : ScrollableState, LazyStateItem> LazyState.inter

if (firstItemIndex < 0) return Float.NaN

val firstItemSize = itemSize(firstItem)
if (firstItemSize == 0) return Float.NaN

val itemOffset = offset(firstItem).toFloat()
val offsetPercentage = abs(itemOffset) / itemSize(firstItem)
val offsetPercentage = abs(itemOffset) / firstItemSize

val nextItem = nextItemOnMainAxis(firstItem) ?: return firstItemIndex + offsetPercentage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ fun Scrollbar(
a = currentThumbDisplacement + delta,
b = destinationThumbDisplacement,
)

else -> max(
a = currentThumbDisplacement + delta,
b = destinationThumbDisplacement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.unit.dp
import com.merxury.blocker.core.designsystem.component.scrollbar.FastScrollbar
import com.merxury.blocker.core.designsystem.component.scrollbar.rememberFastScroller
import com.merxury.blocker.core.designsystem.component.scrollbar.scrollbarState
import com.merxury.blocker.core.ui.TrackScrollJank
import com.merxury.blocker.core.ui.applist.model.AppItem

@Composable
Expand All @@ -55,6 +56,7 @@ fun AppList(
val scrollbarState = listState.scrollbarState(
itemsAvailable = appList.size,
)
TrackScrollJank(scrollableState = listState, stateName = "app:list")
Box(modifier.fillMaxSize()) {
LazyColumn(
modifier = modifier,
Expand Down Expand Up @@ -86,14 +88,13 @@ fun AppList(
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
}
}
FastScrollbar(
listState.FastScrollbar(
modifier = Modifier
.fillMaxHeight()
.padding(horizontal = 2.dp)
.align(Alignment.CenterEnd),
state = scrollbarState,
orientation = Orientation.Vertical,
scrollInProgress = listState.isScrollInProgress,
onThumbDisplaced = listState.rememberFastScroller(
itemsAvailable = appList.size,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ fun ComponentList(
)
}
}
FastScrollbar(
listState.FastScrollbar(
modifier = Modifier
.fillMaxHeight()
.padding(horizontal = 2.dp)
.align(Alignment.CenterEnd),
state = scrollbarState,
orientation = Vertical,
scrollInProgress = listState.isScrollInProgress,
onThumbDisplaced = listState.rememberFastScroller(
itemsAvailable = components.size,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ fun GeneralRulesList(
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
}
}
FastScrollbar(
listState.FastScrollbar(
modifier = Modifier
.fillMaxHeight()
.padding(horizontal = 2.dp)
.align(Alignment.CenterEnd),
state = scrollbarState,
orientation = Vertical,
scrollInProgress = listState.isScrollInProgress,
onThumbDisplaced = listState.rememberFastScroller(
itemsAvailable = rules.size,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ fun RuleMatchedAppList(
)
}
}
FastScrollbar(
listState.FastScrollbar(
modifier = Modifier
.fillMaxHeight()
.padding(horizontal = 2.dp)
.align(Alignment.CenterEnd),
state = scrollbarState,
orientation = Vertical,
scrollInProgress = listState.isScrollInProgress,
onThumbDisplaced = listState.rememberFastScroller(
itemsAvailable = ruleMatchedAppListUiState.list.size,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,13 @@ fun ComponentSearchResultContent(
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
}
}
FastScrollbar(
listState.FastScrollbar(
modifier = Modifier
.fillMaxHeight()
.padding(horizontal = 2.dp)
.align(Alignment.CenterEnd),
state = scrollbarState,
orientation = Vertical,
scrollInProgress = listState.isScrollInProgress,
onThumbDisplaced = listState.rememberFastScroller(
itemsAvailable = componentTabUiState.list.size,
),
Expand Down

0 comments on commit e1a4136

Please sign in to comment.