Skip to content

Commit

Permalink
remove MdcTheme and replace it with Material3 theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Balcan committed Dec 12, 2024
1 parent 4dec5be commit e757331
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 115 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/usescases/crash/CrashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
import cat.ereza.customactivityoncrash.config.CaocConfig
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.BuildConfig
import org.dhis2.R
import org.hisp.dhis.mobile.ui.designsystem.component.Button
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle
import org.hisp.dhis.mobile.ui.designsystem.component.ColorStyle
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
Expand All @@ -61,7 +61,7 @@ class CrashActivity : AppCompatActivity() {
return
}
setContent {
MdcTheme {
DHIS2Theme {
Scaffold(
floatingActionButton = {
CrashGoBackButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.DatePicker
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -19,7 +19,6 @@ import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.unit.dp
import com.google.android.material.composethemeadapter.MdcTheme
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import org.dhis2.R
Expand Down Expand Up @@ -55,6 +54,7 @@ import org.hisp.dhis.android.core.common.FeatureType
import org.hisp.dhis.android.core.common.ValueTypeRenderingType
import org.hisp.dhis.android.core.dataelement.DataElement
import org.hisp.dhis.android.core.organisationunit.OrganisationUnit
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
Expand Down Expand Up @@ -106,7 +106,7 @@ class DataSetSectionFragment : FragmentGlobalAbstract(), DataValueContract.View
return ComposeView(requireContext()).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
MdcTheme {
DHIS2Theme {
val localDensity = LocalDensity.current
val conf = LocalConfiguration.current
val tableConfState by presenterFragment.currentTableConfState().collectAsState()
Expand Down Expand Up @@ -191,9 +191,9 @@ class DataSetSectionFragment : FragmentGlobalAbstract(), DataValueContract.View

TableTheme(
tableColors = TableColors(
primary = MaterialTheme.colors.primary,
primaryLight = MaterialTheme.colors.primary.copy(alpha = 0.2f),
disabledSelectedBackground = MaterialTheme.colors.primary.copy(
primary = MaterialTheme.colorScheme.primary,
primaryLight = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f),
disabledSelectedBackground = MaterialTheme.colorScheme.primary.copy(
alpha = 0.5f,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.databinding.BindingAdapter
import com.google.android.material.composethemeadapter.MdcTheme
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme

@ExperimentalAnimationApi
@BindingAdapter("setReopen")
Expand All @@ -15,7 +15,7 @@ fun ComposeView.setReopenButton(viewModel: EventDetailsViewModel) {
setViewCompositionStrategy(
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed,
)
MdcTheme {
DHIS2Theme {
val eventDetail by viewModel.eventDetails.collectAsState()
ReopenButton(eventDetail.canReopen) { viewModel.onReopenClick() }
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/usescases/login/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.databinding.DataBindingUtil
import com.google.android.material.composethemeadapter.MdcTheme
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
Expand Down Expand Up @@ -64,6 +63,7 @@ import org.dhis2.utils.analytics.FORGOT_CODE
import org.dhis2.utils.session.PIN_DIALOG_TAG
import org.dhis2.utils.session.PinDialog
import org.hisp.dhis.android.core.user.openid.IntentWithRequestCode
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import timber.log.Timber
import java.io.BufferedReader
import java.io.File
Expand Down Expand Up @@ -202,7 +202,7 @@ class LoginActivity : ActivityGlobalAbstract(), LoginContracts.View {

binding.topbar.setContent {
val displayMoreActions by presenter.displayMoreActions().observeAsState(true)
MdcTheme {
DHIS2Theme {
LoginTopBar(
version = buildInfo(),
displayMoreActions = displayMoreActions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.livedata.observeAsState
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.bindings.app
import org.dhis2.commons.resources.ColorUtils
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.usescases.general.ActivityGlobalAbstract
import org.dhis2.usescases.login.LoginActivity
import org.dhis2.usescases.login.accounts.ui.AccountsScreen
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import timber.log.Timber
import java.io.File
import java.io.FileOutputStream
Expand Down Expand Up @@ -63,7 +63,7 @@ class AccountsActivity : ActivityGlobalAbstract() {
app().serverComponent()?.plus(AccountsModule())?.inject(this)

setContent {
MdcTheme {
DHIS2Theme {
val accounts = viewModel.accounts.observeAsState(listOf())
AccountsScreen(
accounts = accounts.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -45,60 +44,58 @@ fun AccountsScreen(
onAddAccountClicked: () -> Unit,
onImportDatabase: () -> Unit,
) {
MaterialTheme {
Column(
Modifier
.fillMaxWidth()
.background(colorResource(id = R.color.colorPrimary)),
) {
LoginTopBar(
version = LocalContext.current.buildInfo(),
onImportDatabase = onImportDatabase,
)

Column(
Modifier
.fillMaxWidth()
.background(colorResource(id = R.color.colorPrimary)),
verticalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxHeight()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp))
.background(Color.White),
) {
LoginTopBar(
version = LocalContext.current.buildInfo(),
onImportDatabase = onImportDatabase,
)

Column(
verticalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxHeight()
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp))
.background(Color.White),
LazyColumn(
Modifier
.weight(1f)
.padding(top = 16.dp),
) {
LazyColumn(
Modifier
.weight(1f)
.padding(top = 16.dp),
) {
items(accounts) {
AccountItem(
Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
it,
onAccountClicked,
)
}
items(accounts) {
AccountItem(
Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
it,
onAccountClicked,
)
}
Column(Modifier.padding(16.dp)) {
Button(
modifier = Modifier
.fillMaxWidth(),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(id = R.color.colorPrimary),
contentColor = Color.White,
),
elevation = ButtonDefaults.elevation(
defaultElevation = 5.dp,
pressedElevation = 15.dp,
disabledElevation = 0.dp,
}
Column(Modifier.padding(16.dp)) {
Button(
modifier = Modifier
.fillMaxWidth(),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(id = R.color.colorPrimary),
contentColor = Color.White,
),
elevation = ButtonDefaults.elevation(
defaultElevation = 5.dp,
pressedElevation = 15.dp,
disabledElevation = 0.dp,
),
onClick = { onAddAccountClicked() },
) {
Text(
text = stringResource(R.string.add_accout).toUpperCase(Locale.current),
fontFamily = FontFamily(
Font(R.font.rubik_regular, FontWeight.Medium),
),
onClick = { onAddAccountClicked() },
) {
Text(
text = stringResource(R.string.add_accout).toUpperCase(Locale.current),
fontFamily = FontFamily(
Font(R.font.rubik_regular, FontWeight.Medium),
),
)
}
)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/dhis2/usescases/login/ui/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -52,7 +52,7 @@ fun LoginTopBar(
modifier = Modifier
.fillMaxWidth()
.height(80.dp)
.background(MaterialTheme.colors.primary),
.background(MaterialTheme.colorScheme.primary),
) {
val (logoLayout, versionLabel) = createRefs()

Expand Down Expand Up @@ -90,7 +90,7 @@ fun LoginTopBar(
Icon(
imageVector = Icons.Filled.MoreVert,
contentDescription = "More options",
tint = MaterialTheme.colors.onPrimary,
tint = MaterialTheme.colorScheme.onPrimary,
)
}

Expand All @@ -110,7 +110,7 @@ fun LoginTopBar(
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_import_db),
contentDescription = "Import database",
tint = MaterialTheme.colors.primary,
tint = MaterialTheme.colorScheme.primary,
)

Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalConfiguration
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.usescases.searchTrackEntity.ui.WrappedSearchButton
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme

@ExperimentalAnimationApi
fun ComposeView?.setLandscapeOpenSearchButton(
searchTEIViewModel: SearchTEIViewModel,
onClick: () -> Unit,
) {
this?.setContent {
MdcTheme {
DHIS2Theme {
val screenState by searchTEIViewModel.screenState.observeAsState()
val teTypeName by searchTEIViewModel.teTypeName.observeAsState()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.dhis2.usescases.searchTrackEntity.listView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.bindings.dp
import org.dhis2.databinding.ResultSearchListBinding
import org.dhis2.usescases.searchTrackEntity.ui.SearchResultUi
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme

class SearchResultHolder(
val binding: ResultSearchListBinding,
Expand All @@ -27,7 +27,7 @@ class SearchResultHolder(
}
}
}.setContent {
MdcTheme {
DHIS2Theme {
SearchResultUi(
searchResult = item,
onSearchOutsideClick = onSearchOutsideProgram,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.fragment.app.viewModels
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.usescases.general.FragmentGlobalAbstract
import org.dhis2.usescases.main.MainActivity
import org.dhis2.usescases.main.MainNavigator
import org.dhis2.usescases.troubleshooting.ui.TroubleshootingScreen
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import javax.inject.Inject

const val OPEN_LANGUAGE_SECTION = "OPEN_LANGUAGE_SECTION"
Expand Down Expand Up @@ -62,7 +62,7 @@ class TroubleshootingFragment : FragmentGlobalAbstract() {
setViewCompositionStrategy(
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed,
)
MdcTheme {
DHIS2Theme {
TroubleshootingScreen(troubleshootingViewModel) {
refreshScreenLanguageChange()
}
Expand Down
1 change: 0 additions & 1 deletion commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ dependencies {
api(libs.google.gson)
api(libs.dagger)
kapt(libs.dagger.compiler)
api(libs.google.material.themeadapter)
api(libs.barcodeScanner.zxing)
api(libs.rx.java)
api(libs.rx.android)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.unit.Dp
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.material.composethemeadapter.MdcTheme
import org.dhis2.commons.R
import org.dhis2.commons.data.EnrollmentIconData
import org.dhis2.commons.databinding.ItemFieldValueBinding
Expand All @@ -33,6 +32,7 @@ import org.hisp.dhis.android.core.enrollment.Enrollment
import org.hisp.dhis.android.core.enrollment.EnrollmentStatus
import org.hisp.dhis.android.core.program.Program
import org.hisp.dhis.android.core.trackedentity.TrackedEntityAttributeValue
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import timber.log.Timber
import java.util.Date

Expand Down Expand Up @@ -85,7 +85,7 @@ fun List<Program>.getEnrollmentIconsData(
fun List<EnrollmentIconData>.paintAllEnrollmentIcons(parent: ComposeView) {
parent.apply {
setContent {
MdcTheme {
DHIS2Theme {
Row(
horizontalArrangement = spacedBy(Dp(4f)),
verticalAlignment = Alignment.CenterVertically,
Expand Down
1 change: 1 addition & 0 deletions compose-table/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ dependencies {
testImplementation(libs.bundles.table.test)
androidTestImplementation(libs.bundles.table.androidTest)
implementation(libs.dhis2.mobile.designsystem)
implementation(libs.androidx.material3)
}
Loading

0 comments on commit e757331

Please sign in to comment.