Merge branch 'develop' into feature/fga/waiting_ss_room

This commit is contained in:
ganfra 2023-07-07 11:34:45 +02:00
commit 10c2859fac
249 changed files with 3147 additions and 677 deletions

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* 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 io.element.android.libraries.designsystem.preview
import android.content.res.Configuration
import androidx.compose.ui.tooling.preview.Preview
/**
* Marker for a night mode preview.
*
* Previews with such marker will be rendered in night mode during screenshot testing.
*
* NB: Length of this constant is kept to a minimum to avoid screenshot file names being too long.
*/
const val NIGHT_MODE_NAME = "N"
/**
* Marker for a day mode preview.
*
* This marker is currently not used during screenshot testing, it mainly act as a counterpart to [NIGHT_MODE_NAME].
*
* NB: Length of this constant is kept to a minimum to avoid screenshot file names being too long.
*/
const val DAY_MODE_NAME = "D"
/**
* Generates 2 previews of the composable it is applied to: day and night mode.
*
* NB: Content should be wrapped into [ElementPreview] to apply proper theming.
*/
@Preview(name = DAY_MODE_NAME)
@Preview(name = NIGHT_MODE_NAME, uiMode = Configuration.UI_MODE_NIGHT_YES)
annotation class DayNightPreviews

View file

@ -17,6 +17,7 @@
package io.element.android.libraries.designsystem.preview
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@ -28,8 +29,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.element.android.libraries.theme.ElementTheme
import io.element.android.libraries.designsystem.theme.components.Surface
import io.element.android.libraries.theme.ElementTheme
@Composable
fun ElementPreviewLight(
@ -62,29 +63,35 @@ fun ElementThemedPreview(
vertical: Boolean = true,
content: @Composable () -> Unit,
) {
Box(modifier = Modifier
.background(Color.Gray)
.padding(4.dp)) {
Box(
modifier = Modifier
.background(Color.Gray)
.padding(4.dp)
) {
if (vertical) {
Column {
ElementPreviewLight(
ElementPreview(
darkTheme = false,
showBackground = showBackground,
content = content,
)
Spacer(modifier = Modifier.height(4.dp))
ElementPreviewDark(
ElementPreview(
darkTheme = true,
showBackground = showBackground,
content = content
)
}
} else {
Row {
ElementPreviewLight(
ElementPreview(
darkTheme = false,
showBackground = showBackground,
content = content,
)
Spacer(modifier = Modifier.width(4.dp))
ElementPreviewDark(
ElementPreview(
darkTheme = true,
showBackground = showBackground,
content = content
)
@ -95,18 +102,17 @@ fun ElementThemedPreview(
@Composable
@Suppress("ModifierMissing")
private fun ElementPreview(
darkTheme: Boolean,
showBackground: Boolean,
fun ElementPreview(
darkTheme: Boolean = isSystemInDarkTheme(),
showBackground: Boolean = true,
content: @Composable () -> Unit
) {
ElementTheme(darkTheme = darkTheme) {
if (showBackground) {
// If we have a proper contentColor applied we need a Surface instead of a Box
Surface { content() }
Surface(content = content)
} else {
content()
}
}
}

View file

@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="54dp"
android:viewportWidth="50"
android:viewportHeight="54">
<path
android:pathData="M25,54L18.938,48L31.062,48L25,54Z"
android:fillColor="#EBEEF2"/>
<path
android:pathData="M25,25m-25,0a25,25 0,1 1,50 0a25,25 0,1 1,-50 0"
android:fillColor="#EBEEF2"/>
<group>
<clip-path
android:pathData="M13,13h24v24h-24z"/>
<path
android:pathData="M25,13C20.356,13 16.6,16.858 16.6,21.629C16.6,26.769 21.904,33.857 24.088,36.556C24.568,37.148 25.444,37.148 25.924,36.556C28.096,33.857 33.4,26.769 33.4,21.629C33.4,16.858 29.644,13 25,13ZM25,24.71C23.344,24.71 22,23.33 22,21.629C22,19.928 23.344,18.547 25,18.547C26.656,18.547 28,19.928 28,21.629C28,23.33 26.656,24.71 25,24.71Z"
android:fillColor="#101317"/>
</group>
</vector>

View file

@ -3,21 +3,17 @@
android:height="54dp"
android:viewportWidth="50"
android:viewportHeight="54">
<path
android:pathData="M25,54L18.938,48L31.062,48L25,54Z"
android:fillColor="#1B1D22"/>
<path
android:pathData="M25,25m-25,0a25,25 0,1 1,50 0a25,25 0,1 1,-50 0"
android:fillColor="#1B1D22"/>
<group>
<clip-path
android:pathData="M0,0h50v108h-50z"/>
android:pathData="M13,13h24v24h-24z"/>
<path
android:pathData="M25,54L18.94,48L31.06,48L25,54Z"
android:fillColor="#1B1D22"/>
<path
android:pathData="M25,25m-25,0a25,25 0,1 1,50 0a25,25 0,1 1,-50 0"
android:fillColor="#1B1D22"/>
<group>
<clip-path
android:pathData="M13,13h24v24h-24z"/>
<path
android:pathData="M25,13C20.36,13 16.6,16.86 16.6,21.63C16.6,26.77 21.9,33.86 24.09,36.56C24.57,37.15 25.44,37.15 25.92,36.56C28.1,33.86 33.4,26.77 33.4,21.63C33.4,16.86 29.64,13 25,13ZM25,24.71C23.34,24.71 22,23.33 22,21.63C22,19.93 23.34,18.55 25,18.55C26.66,18.55 28,19.93 28,21.63C28,23.33 26.66,24.71 25,24.71Z"
android:fillColor="#ffffff"/>
</group>
android:pathData="M25,13C20.356,13 16.6,16.858 16.6,21.629C16.6,26.769 21.904,33.857 24.088,36.556C24.568,37.148 25.444,37.148 25.924,36.556C28.096,33.857 33.4,26.769 33.4,21.629C33.4,16.858 29.644,13 25,13ZM25,24.71C23.344,24.71 22,23.33 22,21.629C22,19.928 23.344,18.547 25,18.547C26.656,18.547 28,19.928 28,21.629C28,23.33 26.656,24.71 25,24.71Z"
android:fillColor="#ffffff"/>
</group>
</vector>