Louis
08/30/2022, 2:53 PMdimsuz
08/30/2022, 3:36 PMText
composables in the Box
, with the former having + 1.sp
, but it doesn't align as perfectly as in the screenshot.Moritz Post
08/30/2022, 3:52 PMAfzal Najam
08/30/2022, 4:45 PMHasan Nagizade
08/30/2022, 7:06 PMMarko Novakovic
08/30/2022, 7:18 PM@Composable
fun Example() {
Row(modifier = Modifier.fillMaxWidth()) {
Text(
text = "Left",
modifier = Modifier.weight(1f),
)
Text(
text = "Right",
modifier = Modifier.weight(1f),
)
}
}
to:
@Composable
fun Example(
left: @Composable (Modifier) -> Unit,
right: @Composable (Modifier) -> Unit,
modifier: Modifier = Modifier,
) {
Row(modifier = modifier.fillMaxWidth()) {
left(Modifier.weight(1f))
right(Modifier.weight(1f))
}
}
am asking because of passing Modifier
to parameter `@Composable`s.
I want to hide Modifier.weight(1f)
and I want everything using Example
to have exactly 2 elements that occupy 50%/50% of space, without wrapping left
and right
into Box
, for example, and applying Modifier.weight(1f)
to Box
containerOthman El Jazouli
08/30/2022, 9:29 PMNestedScrollConnection
as part of a collapsable view with LazyColumn work,
Box(
modifier = Modifier
.fillMaxSize()
.nestedScroll(nestedScrollConnection)
) {
LazyColumn ..
CollapsingView..
}
the idea is I want to get notified when user stops scrolling + they no longer interact with view, onPostScroll
unfortunately is fired when scrolling stops regardless if I still have my finger down, any idea if there is a workaround?Luke
08/31/2022, 2:49 AMfengdai
08/31/2022, 3:18 AMLineHeightStyle(
alignment = LineHeightStyle.Alignment.Center,
trim = LineHeightStyle.Trim.None
)
with this error message:
java.lang.NoSuchMethodError: No virtual method getCenter-PIaL0Z0()I in class Landroidx/compose/ui/text/style/LineHeightStyle$Alignment$Companion; or its super classes
Ji Sungbin
08/31/2022, 3:28 AM@Composable
private fun QuackSelectedTabUnderBar(
modifier: Modifier = Modifier,
color: QuackColor,
offsetProvider: Density.() -> IntOffset,
widthProvider: Density.() -> Dp,
) {
val density = LocalDensity.current
Box(
modifier = Modifier
.offset(offset = offsetProvider)
.then(other = modifier)
.height(height = QuackTabUnderBarHeight)
.width(width = density.widthProvider())
.background(color = color.value)
)
}
I used Modifier.offset(offset: Density.() -> IntOffset)
for moving offset.AmrJyniat
08/31/2022, 7:26 AMLazyColumn
crops half of its last item, am I missing anything?
Code in 🧵iroyo
08/31/2022, 12:31 PMPost
is (in theory) stable but a ImmutableList of Post is not... Am I missing something?
stable class Post {
stable val id: String
stable val title: String
stable val subtitle: String
stable val description: String
stable val tags: ImmutableList<String>
stable val imageUrl: String
stable val type: PostType
<runtime stability> =
}
the strange thing is the empty “<runtime stability>”
then I wrap this into a sealed with 3 states (this is for extra context but not directly related)
stable class Content {
stable val showError: Boolean
stable val tags: ImmutableList<Tag>
unstable val posts: ImmutableList<Post> <------- ?¿?¿?¿
}
the Compose result is:
restartable scheme("[androidx.compose.ui.UiComposable, [_]]") fun DiscoverList(
stable scrollState: LazyGridState
unstable items: ImmutableList<Post> <-------- ?¿?¿
stable onItemViewed: Function2<Post, Int, Unit>
stable onItemClicked: Function2<Post, Int, Unit>
stable header: Function2<Composer, Int, Unit>
)
Post is a simple data class… is it because it has a List of Strings?Alan Lee
08/31/2022, 3:44 PMMarco Pierucci
08/31/2022, 4:19 PMFatal Exception: java.lang.IllegalStateException: LayoutCoordinates androidx.compose.ui.node.InnerPlaceable@25c38a is not attached!
Im stuck with compose 1.0.5 and whenever I try to update (1.2.0-rc02 and accompanist 0.24.12-rc) crashes start popping into firebase.
I have some Integration test running ok, and cant even reproduce locally but the amount of crashes in FB is significant to ignore.
The stack-trace ( Full in 🧵 ) does not helps ( at least to mee)Aaron Waller
08/31/2022, 5:20 PMSusheel
08/31/2022, 8:31 PMRoudy Korkis Kanaan
09/01/2022, 3:28 AMval imageLoader = remember {
ImageLoader.Builder(context)
.bitmapFactoryMaxParallelism(10)
.respectCacheHeaders(false)
.build()
}
(I was playing around the bitmap parallelism and cache headers, I also tried providing disk/cache policies and enabling them in the ImageRequest
but it seems like Coil is quite slow to load the images after they are cached.
I tried my same code but use picasso-compose and the images load instantly (After being cached) whereas using Coil there's a split second load, I added a debugger to Coil to make sure it's not loading the image again from the internet (and it's not)
The above was on production build for both Coil and Picasso
Has anyone experience some performance issues with Coil in Compose?svenjacobs
09/01/2022, 5:25 AMshared
module under commonMain
. Now I have the problem that the Compose compiler determines all of my (immutable) data classes as unstable because they are placed in a different module. I cannot add the Compose runtime dependency to commonMain
because this is not a multiplatform dependency and the project just won’t compile when doing so. Of course I could add wrapper classes like described in the linked article and use them only for Android, but this would mean I would have to start using generic types in my ViewModels extensively to ensure that I still share most of the business logic. Isn’t there another way of telling the Compose compiler which classes are actually immutable/stable, maybe via command line arguments or a configuration similar to ProGuard/R8?
I’m using version 1.3.0
of Compose compiler.Mohan manu
09/01/2022, 5:26 AMHasan Nagizade
09/01/2022, 7:08 AMAli Albaali
09/01/2022, 12:01 PMRow
. I want each of them to fill all the available space, when their size isn’t equal (one small, one large), but apply Modifier.weight(1F)
when both are large, so they would extend to the next line.
Any thoughts on how to achieve that?coolchandrakumar
09/01/2022, 1:01 PMLazyColumn {
items(10) {
CustomLookAheadLayout {
Text(text = "First Item")
Text(text = "Second Item")
}
}
}
Still I get error. Is this yet to support ?Rebecca Franks
09/01/2022, 1:46 PM@RequiresApi(Build.VERSION_CODES.S)
fun Modifier.blur(): Modifier = then(
graphicsLayer {
renderEffect = RenderEffect.createBlurEffect(10f, 10f, Shader.TileMode.CLAMP)
.asComposeRenderEffect()
}
)
dazza5000
09/01/2022, 2:14 PMjayteealao
09/01/2022, 2:52 PMChris Fillmore
09/01/2022, 3:19 PMziv kesten
09/01/2022, 3:41 PMBackHandler
might not be intercepting back press?
I am using it in a fragment:
@AndroidEntryPoint
class MyFragment : BaseFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return ComposeView(requireContext()).apply {
setContent {
BackHandler {
// not called when back press
someAction()
}
}
Aaron Waller
09/01/2022, 3:50 PMJasmin Fajkic
09/01/2022, 5:48 PMJasmin Fajkic
09/01/2022, 5:48 PMinterface SessionManager {
val currentProfileComplete: Boolean
val hasSavedProfile: Boolean
val session: Session
fun killSession()
fun saveProfile(profile: ProfileResponse?)
suspend fun getCurrentUserId(): Resource<Int>?
}
data class Session(
var profile: ProfileResponse?,
var isAuthenticated: Boolean,
)
class SessionManagerImpl @Inject constructor(
private val credentialsManager: CredentialsManager,
) : SessionManager {
private var _session = MutableStateFlow(Session(null, false))
override val session = _session.asStateFlow().value
override fun killSession() {
credentialsManager.removeCredentials()
_session.update { it.copy(profile = null, isAuthenticated = false) }
}
override fun saveProfile(profile: ProfileResponse?) {
Log.d("Prof", profile.toString())
_session.value = Session(profile, isAuthenticated = true)
}
override suspend fun getCurrentUserId(): Resource<Int>? {
return when (val userId = credentialsManager.getUserIdFromToken()) {
is Resource.Success -> userId
is Resource.Error -> null
else -> null
}
}
override val hasSavedProfile = session.profile != null
override val currentProfileComplete =
hasSavedProfile && (session.profile?.status != null || session.profile?.status === "completed")
}
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@Inject
lateinit var sessionManager: SessionManager
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
val intent = Intent()
FirebaseApp.initializeApp(this)
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener(this) { pendingDynamicLinkData: PendingDynamicLinkData? ->
if (pendingDynamicLinkData != null) {
intent.data = pendingDynamicLinkData.link
this.startActivity(intent)
}
}
.addOnFailureListener(this) { e -> Log.w(TAG, "getDynamicLink:onFailure", e) }
setContent {
PhoenixTheme {
BottomTabView(sessionManager)
}
}
}
}
Stylianos Gakis
09/01/2022, 5:53 PMoverride val session = _session.asStateFlow().value
I think it's there. You're assigning the initial value of _session
into session
and that's it, you never change thatJasmin Fajkic
09/01/2022, 5:54 PMStylianos Gakis
09/01/2022, 5:55 PMJasmin Fajkic
09/01/2022, 5:56 PMinterface SessionManager {
val currentProfileComplete: Boolean
val hasSavedProfile: Boolean
val session: StateFlow<Session>
fun killSession()
fun saveProfile(profile: ProfileResponse?)
suspend fun getCurrentUserId(): Resource<Int>?
}
data class Session(
var profile: ProfileResponse?,
var isAuthenticated: Boolean,
)
Stylianos Gakis
09/01/2022, 6:01 PMJasmin Fajkic
09/01/2022, 6:01 PMval session = sessionManager.session.collectAsState()
Stylianos Gakis
09/01/2022, 6:04 PMsession =
flow { while(true) { emit(smth); delay(500); emit(smthElse); delay(500); } }.stateIn(...)
And see if this updates your UI.Jasmin Fajkic
09/01/2022, 6:27 PM@Composable
fun Login(navigateToMain: () ->Unit, sessionManager: SessionManager) {
val loginViewModel: LoginViewModel = hiltViewModel()
val loginState = loginViewModel.loginState.collectAsState().value
val session = sessionManager.session.collectAsState()
val session1 = loginViewModel.sessionManager.session.collectAsState()
val coroutineScope = rememberCoroutineScope()
LaunchedEffect(session.value.isAuthenticated) {
if(session.value.isAuthenticated) {
navigateToMain()
}
}
Log.d("ISAUTH1", session.value.toString())
Log.d("ISAUTH2", session1.value.toString())
@Module
@InstallIn(SingletonComponent::class)
object SessionManagerModule {
@Provides
fun providesSessionManager(
credentialsManager: CredentialsManager,
): SessionManager =
SessionManagerImpl(credentialsManager)
}
@Provides
@Singleton
fun providesSessionManager(
credentialsManager: CredentialsManager,
): SessionManager =
SessionManagerImpl(credentialsManager)
Stylianos Gakis
09/01/2022, 8:41 PM