Skip to content

Commit

Permalink
chore: Update Modals and Alerts buttons
Browse files Browse the repository at this point in the history
- Apply elm theme on Modals and Dialogs Alerts
- Optimise Code

fix: LEARNER-10083
  • Loading branch information
omerhabib26 committed Sep 3, 2024
1 parent 3a2b767 commit d9a9235
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import org.openedx.core.R
import org.openedx.core.ui.PrimaryButton
import org.openedx.core.ui.TertiaryButton
import org.openedx.core.ui.theme.OpenEdXTheme
import org.openedx.core.ui.theme.appColors
import org.openedx.core.ui.theme.appShapes
Expand Down Expand Up @@ -110,7 +110,7 @@ private fun InfoDialog(
textAlign = TextAlign.Center,
style = MaterialTheme.appTypography.bodyMedium
)
PrimaryButton(
TertiaryButton(
modifier = Modifier.wrapContentSize(),
text = stringResource(R.string.core_ok),
onClick = onClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.openedx.core.R
import org.openedx.core.presentation.dialog.DefaultDialogBox
import org.openedx.core.ui.PrimaryButton
import org.openedx.core.ui.TertiaryButton
import org.openedx.core.ui.theme.OpenEdXTheme
import org.openedx.core.ui.theme.appColors
Expand Down Expand Up @@ -107,7 +106,7 @@ fun ThankYouDialog(
text = stringResource(id = R.string.core_not_now),
onClick = onNotNowClick
)
PrimaryButton(
TertiaryButton(
modifier = Modifier.wrapContentSize(),
text = stringResource(id = R.string.core_rate_us),
onClick = onRateUsClick
Expand Down Expand Up @@ -186,7 +185,7 @@ fun FeedbackDialog(
text = stringResource(id = R.string.core_not_now),
onClick = onNotNowClick
)
PrimaryButton(
TertiaryButton(
modifier = Modifier.wrapContentSize(),
enabled = feedback.value.isNotEmpty(),
text = stringResource(id = R.string.core_share_feedback),
Expand Down Expand Up @@ -241,7 +240,7 @@ fun RateDialog(
text = stringResource(id = R.string.core_not_now),
onClick = onNotNowClick
)
PrimaryButton(
TertiaryButton(
modifier = Modifier.wrapContentSize(),
enabled = rating.intValue > 0,
text = stringResource(id = R.string.core_submit),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.openedx.core.R
import org.openedx.core.ui.PrimaryButton
import org.openedx.core.ui.TertiaryButton
import org.openedx.core.ui.noRippleClickable
import org.openedx.core.ui.statusBarsInset
Expand Down Expand Up @@ -233,7 +232,7 @@ fun AppUpgradeRequiredButtons(
onClick = onAccountSettingsClick
)
}
PrimaryButton(
TertiaryButton(
modifier = Modifier.wrapContentSize(),
text = stringResource(id = R.string.core_update),
onClick = onUpdateClick
Expand All @@ -253,7 +252,7 @@ fun AppUpgradeDialogButtons(
text = stringResource(id = R.string.core_not_now),
onClick = onNotNowClick
)
PrimaryButton(
TertiaryButton(
modifier = Modifier.wrapContentSize(),
text = stringResource(id = R.string.core_update),
onClick = onUpdateClick
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/org/openedx/core/ui/ComposeCommon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ fun BrandButton(
onClick: () -> Unit,
enabled: Boolean = true,
textColor: Color = MaterialTheme.appColors.primaryButtonText,
backgroundColor: Color = Color(0xFFED5C13),//MaterialTheme.appColors.primaryButtonBackground,
backgroundColor: Color = MaterialTheme.appColors.primaryButtonBackground,
content: (@Composable RowScope.() -> Unit)? = null,
) {
Button(
Expand All @@ -1081,7 +1081,7 @@ fun BrandButton(
?.let { "btn_${text.tagId()}" } ?: ""
)
.then(modifier)
.height(42.dp),
.heightIn(min = 42.dp),
shape = MaterialTheme.appShapes.buttonShape,
colors = ButtonDefaults.buttonColors(
backgroundColor = backgroundColor,
Expand All @@ -1095,7 +1095,8 @@ fun BrandButton(
modifier = Modifier.testTag("txt_${text.tagId()}"),
text = text,
style = MaterialTheme.appTypography.labelLarge,
color = textColor
color = textColor,
textAlign = TextAlign.Center
)
} else {
content()
Expand All @@ -1119,7 +1120,7 @@ fun OutlineBrandButton(
modifier = Modifier
.testTag("btn_${text.tagId()}")
.then(modifier)
.height(42.dp),
.heightIn(min = 42.dp),
onClick = onClick,
enabled = enabled,
border = BorderStroke(1.dp, if (enabled) borderColor else borderColor.copy(alpha = 0.3f)),
Expand All @@ -1135,6 +1136,7 @@ fun OutlineBrandButton(
text = text,
style = MaterialTheme.appTypography.labelLarge,
color = if (enabled) textColor else textColor.copy(alpha = 0.3f),
textAlign = TextAlign.Center
)
} else {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import org.openedx.core.extension.setWidthPercent
import org.openedx.core.ui.AutoSizeText
import org.openedx.core.ui.BrandButton
import org.openedx.core.ui.OutlinePrimaryButton
import org.openedx.core.ui.PrimaryButton
import org.openedx.core.ui.TextIcon
import org.openedx.core.ui.theme.OpenEdXTheme
import org.openedx.core.ui.theme.appColors
Expand Down Expand Up @@ -203,13 +202,13 @@ private fun ChapterEndDialogScreen(
)
Spacer(Modifier.height(42.dp))
if (nextSectionName.isNotEmpty()) {
BrandButton(
PrimaryButton(
text = stringResource(id = R.string.course_next_section),
content = {
TextIcon(
text = stringResource(id = R.string.course_next_section),
painter = painterResource(org.openedx.core.R.drawable.core_ic_forward),
color = MaterialTheme.appColors.primaryButtonText,
color = MaterialTheme.appColors.secondaryButtonText,
textStyle = MaterialTheme.appTypography.labelLarge,
iconModifier = Modifier.rotate(if (isVerticalNavigation) 90f else 0f)
)
Expand All @@ -221,13 +220,6 @@ private fun ChapterEndDialogScreen(
OutlinePrimaryButton(
text = stringResource(id = R.string.course_back_to_outline),
onClick = onBackButtonClick,
content = {
AutoSizeText(
text = stringResource(id = R.string.course_back_to_outline),
style = MaterialTheme.appTypography.bodyMedium,
color = MaterialTheme.appColors.primaryButtonBorderedText
)
}
)
if (nextSectionName.isNotEmpty()) {
Spacer(Modifier.height(24.dp))
Expand Down Expand Up @@ -318,13 +310,13 @@ private fun ChapterEndDialogScreenLandscape(
horizontalAlignment = Alignment.CenterHorizontally
) {
if (nextSectionName.isNotEmpty()) {
BrandButton(
PrimaryButton(
text = stringResource(id = R.string.course_next_section),
content = {
TextIcon(
text = stringResource(id = R.string.course_next_section),
painter = painterResource(org.openedx.core.R.drawable.core_ic_forward),
color = MaterialTheme.appColors.primaryButtonText,
color = MaterialTheme.appColors.secondaryButtonText,
textStyle = MaterialTheme.appTypography.labelLarge
)
},
Expand All @@ -334,14 +326,7 @@ private fun ChapterEndDialogScreenLandscape(
}
OutlinePrimaryButton(
text = stringResource(id = R.string.course_back_to_outline),
onClick = onBackButtonClick,
content = {
AutoSizeText(
text = stringResource(id = R.string.course_back_to_outline),
style = MaterialTheme.appTypography.bodyMedium,
color = MaterialTheme.appColors.primaryButtonBorderedText
)
}
onClick = onBackButtonClick
)
if (nextSectionName.isNotEmpty()) {
Spacer(Modifier.height(24.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,10 @@ private fun NotSupportedUnitScreen(
PrimaryButton(modifier = Modifier
.width(216.dp)
.height(42.dp),
text = stringResource(id = courseR.string.course_open_in_browser),
onClick = {
uriHandler.openUri(uri)
}) {
Text(
text = stringResource(id = courseR.string.course_open_in_browser),
color = MaterialTheme.appColors.primaryButtonText,
style = MaterialTheme.appTypography.labelLarge
)
}
})
Spacer(Modifier.height(20.dp))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,11 @@ private fun FindACourseButton(
BrandButton(
modifier = modifier
.padding(horizontal = 8.dp, vertical = 20.dp),
text = stringResource(id = R.string.dashboard_find_a_course),
onClick = {
findACourseClick()
}
) {
Text(
color = MaterialTheme.appColors.primaryButtonText,
text = stringResource(id = R.string.dashboard_find_a_course)
)
}
)
}

@Composable
Expand Down Expand Up @@ -1099,7 +1095,10 @@ private fun NoCoursesInfoPreview() {
.fillMaxSize()
.background(MaterialTheme.appColors.background),
) {
NoCoursesInfo()
NoCoursesInfo(modifier = Modifier.align(Alignment.Center))
FindACourseButton(
modifier = Modifier.align(Alignment.BottomCenter),
findACourseClick = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
Expand Down Expand Up @@ -613,16 +612,11 @@ private fun DiscussionThreadsScreen(
onCreatePostClick()
},
content = {
Icon(
painter = painterResource(id = discussionR.drawable.discussion_ic_add_comment),
contentDescription = null,
tint = MaterialTheme.appColors.primary
)
Spacer(modifier = Modifier.width(6.dp))
Text(
IconText(
text = stringResource(id = discussionR.string.discussion_create_post),
painter = painterResource(id = discussionR.drawable.discussion_ic_add_comment),
color = MaterialTheme.appColors.primary,
style = MaterialTheme.appTypography.labelLarge
textStyle = MaterialTheme.appTypography.labelLarge,
)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import androidx.fragment.app.DialogFragment
import org.koin.android.ext.android.inject
import org.openedx.core.config.Config
import org.openedx.core.presentation.dialog.DefaultDialogBox
import org.openedx.core.ui.BrandButton
import org.openedx.core.ui.OutlineBrandButton
import org.openedx.core.ui.OutlinePrimaryButton
import org.openedx.core.ui.PrimaryButton
import org.openedx.core.ui.TextIcon
import org.openedx.core.ui.theme.OpenEdXTheme
import org.openedx.core.ui.theme.appColors
Expand Down Expand Up @@ -119,21 +119,21 @@ private fun CalendarAccessDialog(
style = MaterialTheme.appTypography.bodyMedium,
color = MaterialTheme.appColors.textDark
)
BrandButton(
PrimaryButton(
onClick = {
onGrantCalendarAccessClick()
},
content = {
TextIcon(
text = stringResource(id = R.string.profile_grant_access_calendar),
icon = Icons.AutoMirrored.Filled.OpenInNew,
color = MaterialTheme.appColors.primaryButtonText,
color = MaterialTheme.appColors.secondaryButtonText,
textStyle = MaterialTheme.appTypography.labelLarge,
iconModifier = Modifier.padding(start = 4.dp)
)
}
)
OutlineBrandButton(
OutlinePrimaryButton(
text = stringResource(id = CoreR.string.core_cancel),
onClick = { onCancelClick() }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ private fun NewCalendarDialog(
textAlign = TextAlign.Center,
color = MaterialTheme.appColors.textDark
)
OutlineBrandButton(
text = stringResource(id = CoreR.string.core_cancel),
onClick = { onCancelClick() }
)
BrandButton(
text = stringResource(id = R.string.profile_begin_syncing),
onClick = {
Expand All @@ -185,6 +181,10 @@ private fun NewCalendarDialog(
)
}
)
OutlineBrandButton(
text = stringResource(id = CoreR.string.core_cancel),
onClick = { onCancelClick() }
)
}
}
}
Expand Down
Loading

0 comments on commit d9a9235

Please sign in to comment.