Skip to content

Commit

Permalink
Add a quick screen to show UiConfiguration values (#1516)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Sep 27, 2023
1 parent 6e98c9b commit 69b9452
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ enum class Screen {
RepoSearch(httpClient, modifier)
}
},
UiConfiguration {
@Composable
override fun Show(httpClient: HttpClient, modifier: Modifier) {
UiConfigurationValues(modifier)
}
},
;

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2023 Square, Inc.
*
* 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 com.example.redwood.testing.presenter

import androidx.compose.runtime.Composable
import app.cash.redwood.Modifier
import app.cash.redwood.compose.current
import app.cash.redwood.layout.compose.Column
import app.cash.redwood.ui.Margin
import app.cash.redwood.ui.UiConfiguration
import app.cash.redwood.ui.dp
import com.example.redwood.testing.compose.Text

@Composable
fun UiConfigurationValues(modifier: Modifier) {
Column(margin = Margin(16.dp), modifier = modifier) {
val uiConfiguration = UiConfiguration.current

Text("Dark mode: ${uiConfiguration.darkMode}")

val safeAreaInsets = uiConfiguration.safeAreaInsets
Text("Safe area insets:")
Text("- top: ${safeAreaInsets.top}")
Text("- bottom: ${safeAreaInsets.bottom}")
Text("- start: ${safeAreaInsets.start}")
Text("- end: ${safeAreaInsets.end}")

val viewportSize = uiConfiguration.viewportSize
Text("Viewport size:")
Text("- width: ${viewportSize.width}")
Text("- height: ${viewportSize.height}")

Text("Density: ${uiConfiguration.density}")
}
}

0 comments on commit 69b9452

Please sign in to comment.