-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HMA-5074 HMA-5073: Added InsetView and InsetTextView in Compose (#111)
* HMA-5074: Added InsetView in Compose * fix padding on sample * spotless * address comments * Fix padding order * address feedback * address comment
- Loading branch information
1 parent
56e6e97
commit 80e72f7
Showing
26 changed files
with
671 additions
and
61 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...ents-compose/src/main/java/uk/gov/hmrc/components/compose/molecule/inset/InsetTextView.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,42 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.hmrc.components.compose.molecule.inset | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextAlign | ||
import uk.gov.hmrc.components.compose.ui.theme.HmrcTheme.typography | ||
import uk.gov.hmrc.components.compose.ui.theme.hmrc_spacing_8 | ||
|
||
@Composable | ||
fun InsetTextView( | ||
text: String, | ||
modifier: Modifier = Modifier | ||
) { | ||
InsetView( | ||
modifier = modifier, | ||
childView = { | ||
Text( | ||
modifier = Modifier.padding(vertical = hmrc_spacing_8), | ||
text = text, | ||
style = typography.body, | ||
textAlign = TextAlign.Start, | ||
) | ||
} | ||
) | ||
} |
52 changes: 52 additions & 0 deletions
52
components-compose/src/main/java/uk/gov/hmrc/components/compose/molecule/inset/InsetView.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,52 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.hmrc.components.compose.molecule.inset | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material3.Divider | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.RectangleShape | ||
import uk.gov.hmrc.components.compose.ui.theme.HmrcTheme.colors | ||
import uk.gov.hmrc.components.compose.ui.theme.hmrc_spacing_16 | ||
import uk.gov.hmrc.components.compose.ui.theme.hmrc_spacing_4 | ||
|
||
@Composable | ||
fun InsetView( | ||
modifier: Modifier = Modifier, | ||
childView: @Composable () -> Unit, | ||
) { | ||
Column { | ||
Row(modifier = modifier.height(IntrinsicSize.Min)) { | ||
Divider( | ||
color = colors.hmrcGrey2, | ||
modifier = Modifier | ||
.fillMaxHeight() | ||
.clip(RectangleShape) | ||
.padding(end = hmrc_spacing_16) | ||
.width(hmrc_spacing_4) | ||
) | ||
childView() | ||
} | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
...pose/src/main/java/uk/gov/hmrc/components/compose/molecule/titleBodyView/TitleBodyView.kt
This file was deleted.
Oops, something went wrong.
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
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
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
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
41 changes: 41 additions & 0 deletions
41
...ain/java/uk/gov/hmrc/sample_compose_fragments/presentation/extension/ModifierExtension.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,41 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.hmrc.sample_compose_fragments.presentation.extension | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.wrapContentHeight | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.composed | ||
import androidx.compose.ui.graphics.ImageBitmap | ||
import androidx.compose.ui.graphics.ImageShader | ||
import androidx.compose.ui.graphics.ShaderBrush | ||
import androidx.compose.ui.graphics.TileMode | ||
import androidx.compose.ui.res.imageResource | ||
import uk.gov.hmrc.sample_compose_components.R | ||
|
||
internal fun Modifier.addPlaceholderModifier(): Modifier = composed { | ||
val image = ImageBitmap.imageResource(id = R.drawable.checked_tile) | ||
val repeatImage = remember(image) { | ||
ShaderBrush(ImageShader(image, TileMode.Repeated, TileMode.Repeated)) | ||
} | ||
this.then( | ||
wrapContentHeight() | ||
.fillMaxWidth() | ||
.background(repeatImage) | ||
) | ||
} |
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
49 changes: 49 additions & 0 deletions
49
...ov/hmrc/sample_compose_fragments/presentation/fragment/molecules/InsetTextViewFragment.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,49 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.hmrc.sample_compose_fragments.presentation.fragment.molecules | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.ui.Modifier | ||
import androidx.fragment.app.Fragment | ||
import uk.gov.hmrc.components.compose.ui.theme.HmrcTheme | ||
import uk.gov.hmrc.components.compose.ui.theme.HmrcTheme.colors | ||
import uk.gov.hmrc.sample_compose_components.R | ||
import uk.gov.hmrc.sample_compose_components.databinding.FragmentComposeExampleBinding | ||
import uk.gov.hmrc.sample_compose_fragments.presentation.screens.InsetTextViewScreen | ||
|
||
class InsetTextViewFragment : Fragment(R.layout.fragment_compose_example) { | ||
|
||
private lateinit var binding: FragmentComposeExampleBinding | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding = FragmentComposeExampleBinding.bind(view) | ||
binding.composeView.setContent { | ||
HmrcTheme() { | ||
Surface( | ||
modifier = Modifier.fillMaxHeight().fillMaxWidth(), | ||
color = colors.hmrcPageBackground | ||
) { | ||
InsetTextViewScreen() | ||
} | ||
} | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...uk/gov/hmrc/sample_compose_fragments/presentation/fragment/molecules/InsetViewFragment.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,51 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package uk.gov.hmrc.sample_compose_fragments.presentation.fragment.molecules | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.ui.Modifier | ||
import androidx.fragment.app.Fragment | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import uk.gov.hmrc.components.compose.ui.theme.HmrcTheme | ||
import uk.gov.hmrc.components.compose.ui.theme.HmrcTheme.colors | ||
import uk.gov.hmrc.sample_compose_components.R | ||
import uk.gov.hmrc.sample_compose_components.databinding.FragmentComposeExampleBinding | ||
import uk.gov.hmrc.sample_compose_fragments.presentation.screens.InsetViewScreen | ||
|
||
@AndroidEntryPoint | ||
class InsetViewFragment : Fragment(R.layout.fragment_compose_example) { | ||
|
||
private lateinit var binding: FragmentComposeExampleBinding | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding = FragmentComposeExampleBinding.bind(view) | ||
binding.composeView.setContent { | ||
HmrcTheme() { | ||
Surface( | ||
modifier = Modifier.fillMaxHeight().fillMaxWidth(), | ||
color = colors.hmrcPageBackground | ||
) { | ||
InsetViewScreen() | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.