Skip to content

Commit

Permalink
Merge pull request #360 from jakepurple13/develop
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
jakepurple13 authored Jan 10, 2022
2 parents fc572f4 + 0797ea6 commit 171020a
Show file tree
Hide file tree
Showing 51 changed files with 1,840 additions and 998 deletions.
4 changes: 2 additions & 2 deletions Models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ dependencies {
implementation androidCore
implementation appCompat
testImplementation Deps.junit
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation Deps.androidJunit
androidTestImplementation Deps.androidEspresso

//Rx
implementation rxkotlin
Expand Down
2 changes: 1 addition & 1 deletion Models/src/main/java/com/programmersbox/models/Models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface ApiService: Serializable {
fun getChapterInfo(chapterModel: ChapterModel): Single<List<Storage>>

fun getSourceByUrl(url: String): Single<ItemModel> = Single.create {
it.onSuccess(ItemModel("", "", "", "", this))
it.onSuccess(ItemModel("", "", url, "", this))
}

val serviceName: String get() = this::class.java.name
Expand Down
5 changes: 2 additions & 3 deletions UIViews/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ dependencies {
implementation preference
implementation 'androidx.window:window:1.0.0-rc01'
testImplementation Deps.junit
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation Deps.androidJunit
androidTestImplementation Deps.androidEspresso

implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation play_services
Expand Down Expand Up @@ -136,7 +136,6 @@ dependencies {
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist"
implementation "me.onebone:toolbar-compose:2.3.0"
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:1.0.3'
implementation "io.coil-kt:coil-compose:1.4.0"

implementation datastore.datastore
}
294 changes: 151 additions & 143 deletions UIViews/src/main/java/com/programmersbox/uiviews/AllFragment.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ abstract class BaseMainActivity : AppCompatActivity() {
navGraphIds = navGraphIds,
fragmentManager = supportFragmentManager,
containerId = R.id.mainShows,
intent = intent
intent = intent,
dynamicDestinations = mapOf(
R.navigation.recent_nav to { f, n -> genericInfo.recentNavSetup(f, n) },
R.navigation.all_nav to { f, n -> genericInfo.allNavSetup(f, n) },
R.navigation.setting_nav to { f, n -> genericInfo.settingNavSetup(f, n) }
)
)

currentNavController = controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import androidx.compose.runtime.rxjava2.subscribeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.*
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.ComposeView
Expand Down Expand Up @@ -178,9 +181,7 @@ class DetailsFragment : Fragment() {
val statusBarColor = swatchInfo.value?.rgb?.toComposeColor()?.animate()

LaunchedEffect(statusBarColor) {
statusBarColor?.value?.let { s ->
systemUiController.setStatusBarColor(color = s, darkIcons = s.luminance() > .5f)
}
statusBarColor?.value?.let { s -> systemUiController.setStatusBarColor(color = s) }
}

val windowSize = requireActivity().rememberWindowSizeClass()
Expand Down Expand Up @@ -1172,7 +1173,7 @@ class DetailsFragment : Fragment() {
if (infoModel.source.canPlay) {
OutlinedButton(
onClick = {
genericInfo.chapterOnClick(c, chapters, infoModel, context)
genericInfo.chapterOnClick(c, chapters, infoModel, context, findNavController())
insertRecent()
if (!read.fastAny { it.url == c.url }) markAs(true)
},
Expand Down Expand Up @@ -1509,7 +1510,7 @@ class DetailsFragment : Fragment() {
super.onDestroy()
disposable.dispose()
val window = requireActivity().window
ValueAnimator.ofArgb(window.statusBarColor, requireContext().colorFromTheme(R.attr.colorPrimaryVariant))
ValueAnimator.ofArgb(window.statusBarColor, requireContext().colorFromTheme(R.attr.colorSurface))
.apply { addUpdateListener { window.statusBarColor = it.animatedValue as Int } }
.start()
}
Expand Down
227 changes: 114 additions & 113 deletions UIViews/src/main/java/com/programmersbox/uiviews/FavoriteFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,134 +147,135 @@ class FavoriteFragment : Fragment() {

val showing = favoriteItems.filter { it.title.contains(searchText, true) && it.source in viewModel.selectedSources }

var showBanner by remember { mutableStateOf(false) }

val scrollBehavior = remember { TopAppBarDefaults.pinnedScrollBehavior() }

M3OtakuBannerBox(
showBanner = showBanner,
placeholder = logo.logoId
) { itemInfo ->
CollapsingToolbarScaffold(
modifier = Modifier,
state = rememberCollapsingToolbarScaffoldState(),
scrollStrategy = ScrollStrategy.EnterAlwaysCollapsed,
toolbar = {
Column(
verticalArrangement = Arrangement.spacedBy(4.dp),
modifier = Modifier.background(TopAppBarDefaults.smallTopAppBarColors().containerColor(scrollBehavior.scrollFraction).value)
) {
SmallTopAppBar(
scrollBehavior = scrollBehavior,
navigationIcon = { IconButton(onClick = { findNavController().popBackStack() }) { Icon(Icons.Default.ArrowBack, null) } },
title = { Text(stringResource(R.string.viewFavoritesMenu)) },
actions = {

val rotateIcon: @Composable (SortFavoritesBy<*>) -> Float = {
animateFloatAsState(if (it == viewModel.sortedBy && viewModel.reverse) 180f else 0f).value
}

GroupButton(
selected = viewModel.sortedBy,
options = listOf(
GroupButtonModel(SortFavoritesBy.TITLE) {
Icon(
Icons.Default.SortByAlpha,
null,
modifier = Modifier.rotate(rotateIcon(SortFavoritesBy.TITLE))
)
},
GroupButtonModel(SortFavoritesBy.COUNT) {
Icon(
Icons.Default.Sort,
null,
modifier = Modifier.rotate(rotateIcon(SortFavoritesBy.COUNT))
)
},
GroupButtonModel(SortFavoritesBy.CHAPTERS) {
Icon(
Icons.Default.ReadMore,
null,
modifier = Modifier.rotate(rotateIcon(SortFavoritesBy.CHAPTERS))
)
}
)
) { if (viewModel.sortedBy != it) viewModel.sortedBy = it else viewModel.reverse = !viewModel.reverse }
CollapsingToolbarScaffold(
modifier = Modifier,
state = rememberCollapsingToolbarScaffoldState(),
scrollStrategy = ScrollStrategy.EnterAlwaysCollapsed,
toolbar = {
Column(
verticalArrangement = Arrangement.spacedBy(4.dp),
modifier = Modifier.background(TopAppBarDefaults.smallTopAppBarColors().containerColor(scrollBehavior.scrollFraction).value)
) {
SmallTopAppBar(
scrollBehavior = scrollBehavior,
navigationIcon = { IconButton(onClick = { findNavController().popBackStack() }) { Icon(Icons.Default.ArrowBack, null) } },
title = { Text(stringResource(R.string.viewFavoritesMenu)) },
actions = {

val rotateIcon: @Composable (SortFavoritesBy<*>) -> Float = {
animateFloatAsState(if (it == viewModel.sortedBy && viewModel.reverse) 180f else 0f).value
}
)

MdcTheme {
OutlinedTextField(
value = searchText,
onValueChange = { searchText = it },
label = {
androidx.compose.material.Text(
resources.getQuantityString(
R.plurals.numFavorites,
showing.size,
showing.size
GroupButton(
selected = viewModel.sortedBy,
options = listOf(
GroupButtonModel(SortFavoritesBy.TITLE) {
Icon(
Icons.Default.SortByAlpha,
null,
modifier = Modifier.rotate(rotateIcon(SortFavoritesBy.TITLE))
)
},
GroupButtonModel(SortFavoritesBy.COUNT) {
Icon(
Icons.Default.Sort,
null,
modifier = Modifier.rotate(rotateIcon(SortFavoritesBy.COUNT))
)
},
GroupButtonModel(SortFavoritesBy.CHAPTERS) {
Icon(
Icons.Default.ReadMore,
null,
modifier = Modifier.rotate(rotateIcon(SortFavoritesBy.CHAPTERS))
)
)
},
trailingIcon = {
androidx.compose.material.IconButton(onClick = { searchText = "" }) {
androidx.compose.material.Icon(Icons.Default.Cancel, null)
}
},
)
) { if (viewModel.sortedBy != it) viewModel.sortedBy = it else viewModel.reverse = !viewModel.reverse }
}
)

MdcTheme {
OutlinedTextField(
value = searchText,
onValueChange = { searchText = it },
label = {
androidx.compose.material.Text(
resources.getQuantityString(
R.plurals.numFavorites,
showing.size,
showing.size
)
)
},
trailingIcon = {
androidx.compose.material.IconButton(onClick = { searchText = "" }) {
androidx.compose.material.Icon(Icons.Default.Cancel, null)
}
},
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 5.dp),
singleLine = true,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(onSearch = { focusManager.clearFocus() })
)
}

LazyRow(
horizontalArrangement = Arrangement.spacedBy(5.dp),
modifier = Modifier.padding(horizontal = 5.dp, vertical = 4.dp)
) {

item {
CustomChip(
"ALL",
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 5.dp),
singleLine = true,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(onSearch = { focusManager.clearFocus() })
.combinedClickable(
onClick = { viewModel.resetSources() },
onLongClick = { viewModel.selectedSources.clear() }
),
backgroundColor = M3MaterialTheme.colorScheme.primary,
textColor = M3MaterialTheme.colorScheme.onPrimary
)
}

LazyRow(
horizontalArrangement = Arrangement.spacedBy(5.dp),
modifier = Modifier.padding(horizontal = 5.dp, vertical = 4.dp)
items(
(allSources.fastMap(ApiService::serviceName) + showing.fastMap(DbModel::source))
.groupBy { it }
.toList()
.sortedBy { it.first }
) {

item {
CustomChip(
"ALL",
modifier = Modifier
.combinedClickable(
onClick = { viewModel.resetSources() },
onLongClick = { viewModel.selectedSources.clear() }
),
backgroundColor = M3MaterialTheme.colorScheme.primary,
textColor = M3MaterialTheme.colorScheme.onPrimary
)
}

items(
(allSources.fastMap(ApiService::serviceName) + showing.fastMap(DbModel::source))
.groupBy { it }
.toList()
.sortedBy { it.first }
) {
CustomChip(
"${it.first}: ${it.second.size - 1}",
modifier = Modifier
.combinedClickable(
onClick = { viewModel.newSource(it.first) },
onLongClick = { viewModel.singleSource(it.first) }
),
backgroundColor = animateColorAsState(
if (it.first in viewModel.selectedSources) M3MaterialTheme.colorScheme.primary
else M3MaterialTheme.colorScheme.surface
).value,
textColor = animateColorAsState(
if (it.first in viewModel.selectedSources) M3MaterialTheme.colorScheme.onPrimary
else M3MaterialTheme.colorScheme.onSurface
).value
)
}
CustomChip(
"${it.first}: ${it.second.size - 1}",
modifier = Modifier
.combinedClickable(
onClick = { viewModel.newSource(it.first) },
onLongClick = { viewModel.singleSource(it.first) }
),
backgroundColor = animateColorAsState(
if (it.first in viewModel.selectedSources) M3MaterialTheme.colorScheme.primary
else M3MaterialTheme.colorScheme.surface
).value,
textColor = animateColorAsState(
if (it.first in viewModel.selectedSources) M3MaterialTheme.colorScheme.onPrimary
else M3MaterialTheme.colorScheme.onSurface
).value
)
}
}
}
) {
}
) {
var showBanner by remember { mutableStateOf(false) }

M3OtakuBannerBox(
showBanner = showBanner,
placeholder = logo.logoId
) { itemInfo ->
Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { p ->
if (showing.isEmpty()) {
Box(
Expand Down
Loading

0 comments on commit 171020a

Please sign in to comment.