-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb07e89
commit 63a1535
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/src/main/java/org/thoughtcrime/securesms/compose/ComposeFragment.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,34 @@ | ||
package org.thoughtcrime.securesms.compose | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.ComposeView | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.platform.ViewCompositionStrategy | ||
import org.signal.core.ui.theme.SignalTheme | ||
import org.thoughtcrime.securesms.LoggingFragment | ||
import org.thoughtcrime.securesms.util.DynamicTheme | ||
|
||
/** | ||
* Generic ComposeFragment which can be subclassed to build UI with compose. | ||
*/ | ||
abstract class ComposeFragment : LoggingFragment() { | ||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return ComposeView(requireContext()).apply { | ||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) | ||
setContent { | ||
SignalTheme( | ||
isDarkMode = DynamicTheme.isDarkTheme(LocalContext.current) | ||
) { | ||
SheetContent() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
abstract fun SheetContent() | ||
} |