Skip to content

Commit

Permalink
Merge pull request #265 from PermanentOrg/feature/VSP-1347
Browse files Browse the repository at this point in the history
Implementation of onboarding screen: ...
  • Loading branch information
flaviahandrea-vsp authored Mar 27, 2024
2 parents 226b54f + df44479 commit f6c097a
Show file tree
Hide file tree
Showing 20 changed files with 346 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class MainActivity : PermanentBaseActivity(), Toolbar.OnMenuItemClickListener {
val archiveSettingsRightIcon =
menuItem.actionView?.findViewById<ImageView>(R.id.ivRightIcon)
val icon =
if (submenuVisible) R.drawable.ic_drop_up_white else R.drawable.ic_drop_down_white
if (submenuVisible) R.drawable.ic_arrow_drop_up_white else R.drawable.ic_arrow_drop_down_white
archiveSettingsRightIcon?.setImageResource(icon)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fun ArchiveOnboardingScreen(

HorizontalPager(pageCount = 2, state = pagerState, userScrollEnabled = false) { page ->
if (page == 0) WelcomePage(isTablet, pagerState, viewModel.getAccountName().value)
else TypeSelectionPage()
else TypeSelectionPage(isTablet, pagerState)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,134 @@
@file:OptIn(ExperimentalFoundationApi::class)

package org.permanent.permanent.ui.archiveOnboarding.compose

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.PagerState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.permanent.permanent.R
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.ButtonIconAlignment
import org.permanent.permanent.ui.composeComponents.CustomDropdown
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton

@Composable
fun TypeSelectionPage() {
fun TypeSelectionPage(isTablet: Boolean, pagerState: PagerState) {
val context = LocalContext.current
val coroutineScope = rememberCoroutineScope()
val whiteColor = Color(ContextCompat.getColor(context, R.color.white))
val regularFont = FontFamily(Font(R.font.open_sans_regular_ttf))

// if (isTablet) {
// TabletBody(whiteColor, regularFont)
// } else {
PhoneBody(whiteColor, regularFont, coroutineScope, pagerState)
// }
}

@Composable
private fun PhoneBody(
whiteColor: Color,
regularFont: FontFamily,
coroutineScope: CoroutineScope,
pagerState: PagerState
) {
Column(
modifier = Modifier
.fillMaxHeight()
.padding(vertical = 32.dp),
verticalArrangement = Arrangement.spacedBy(24.dp)
) {
val titleText = stringResource(id = R.string.create_your_first_archive_title)
val boldedWord = "archive"
val start = titleText.indexOf(boldedWord)
val spanStyles = listOf(
AnnotatedString.Range(
SpanStyle(fontWeight = FontWeight.Bold),
start = start,
end = start + boldedWord.length
)
)

Text(
text = stringResource(id = R.string.create_your_first_archive_title),
text = AnnotatedString(text = titleText, spanStyles = spanStyles),
fontSize = 32.sp,
lineHeight = 48.sp,
color = whiteColor,
fontFamily = regularFont
)

Text(
text = stringResource(id = R.string.create_your_first_archive_description),
fontSize = 14.sp,
lineHeight = 24.sp,
color = whiteColor,
fontFamily = regularFont
)

CustomDropdown()

Spacer(modifier = Modifier.weight(1f))

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(24.dp)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
iconAlignment = ButtonIconAlignment.START
) {
coroutineScope.launch {
pagerState.animateScrollToPage(0)
}
}
}

Box(
modifier = Modifier
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
ButtonColor.LIGHT,
text = stringResource(id = R.string.next)
) {
coroutineScope.launch {
pagerState.animateScrollToPage(2)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
Expand All @@ -27,13 +28,14 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.permanent.permanent.R
import org.permanent.permanent.ui.composeComponents.ButtonStyle
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.TextAndIconButton

@Composable
Expand Down Expand Up @@ -115,7 +117,7 @@ private fun TabletBody(
.width(168.dp)
) {
TextAndIconButton(
ButtonStyle.LIGHT,
ButtonColor.LIGHT,
text = stringResource(id = R.string.get_started),
showButtonEnabled = true
) {
Expand Down Expand Up @@ -172,7 +174,7 @@ private fun PhoneBody(
Spacer(modifier = Modifier.weight(1.0f))

TextAndIconButton(
ButtonStyle.LIGHT,
ButtonColor.LIGHT,
text = stringResource(id = R.string.get_started),
showButtonEnabled = true
) {
Expand All @@ -181,4 +183,11 @@ private fun PhoneBody(
}
}
}
}

@Preview
@Composable
fun WelcomePagePhonePreview() {
val pagerState = rememberPagerState(initialPage = 0)
WelcomePage(false, pagerState, "Jane Doe")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.permanent.permanent.ui.composeComponents

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat
import org.permanent.permanent.R

@Composable
fun CustomDropdown() {
val context = LocalContext.current
val whiteColor = Color(ContextCompat.getColor(context, R.color.white))
val purpleColor = Color(ContextCompat.getColor(context, R.color.barneyPurple))
val accentColor = Color(ContextCompat.getColor(context, R.color.colorAccent))
val semiboldFont = FontFamily(Font(R.font.open_sans_semibold_ttf))
val regularFont = FontFamily(Font(R.font.open_sans_regular_ttf))

Button(modifier = Modifier
.fillMaxWidth()
.height(112.dp)
.background(
Brush.horizontalGradient(listOf(purpleColor, accentColor)),
RoundedCornerShape(12.dp)
),
colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
shape = RoundedCornerShape(12.dp),
onClick = { }) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.Top,
horizontalArrangement = Arrangement.spacedBy(24.dp)
) {
Image(
painter = painterResource(id = R.drawable.ic_heart_white),
colorFilter = ColorFilter.tint(whiteColor),
contentDescription = "",
modifier = Modifier.size(16.dp)
)

Column(
modifier = Modifier.weight(1.0f, fill = false),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = stringResource(id = R.string.individual),
color = whiteColor,
fontSize = 14.sp,
lineHeight = 24.sp,
fontFamily = semiboldFont,
)

Text(
text = stringResource(id = R.string.individual_description),
color = whiteColor,
fontSize = 12.sp,
lineHeight = 16.sp,
fontFamily = regularFont,
)
}

Image(
painter = painterResource(id = R.drawable.ic_arrow_drop_down),
colorFilter = ColorFilter.tint(whiteColor),
contentDescription = "Drop down",
modifier = Modifier.size(12.dp)
)
}
}
}
Loading

0 comments on commit f6c097a

Please sign in to comment.