mirror of https://github.com/tasks/tasks
Send share invites for Tasks.org & sabre/dav
parent
5201bca714
commit
5513d42777
@ -1,9 +1,43 @@
|
|||||||
package org.tasks.compose
|
package org.tasks.compose
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.ContentAlpha
|
||||||
|
import androidx.compose.material.MaterialTheme
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextFieldDefaults
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
object Constants {
|
object Constants {
|
||||||
const val ICON_ALPHA = 0.54f
|
const val ICON_ALPHA = 0.54f
|
||||||
val KEYLINE_FIRST = 16.dp
|
val KEYLINE_FIRST = 16.dp
|
||||||
val HALF_KEYLINE = 8.dp
|
val HALF_KEYLINE = 8.dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TextButton(@StringRes text: Int, onClick: () -> Unit) {
|
||||||
|
androidx.compose.material.TextButton(
|
||||||
|
onClick = onClick,
|
||||||
|
colors = textButtonColors()
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
stringResource(text).toUpperCase(Locale.getDefault()),
|
||||||
|
style = MaterialTheme.typography.button
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun textButtonColors() = ButtonDefaults.textButtonColors(
|
||||||
|
contentColor = MaterialTheme.colors.secondary
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun textFieldColors() = TextFieldDefaults.textFieldColors(
|
||||||
|
cursorColor = MaterialTheme.colors.secondary,
|
||||||
|
focusedLabelColor = MaterialTheme.colors.secondary.copy(alpha = ContentAlpha.high),
|
||||||
|
focusedIndicatorColor = MaterialTheme.colors.secondary.copy(alpha = ContentAlpha.high),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@ -0,0 +1,111 @@
|
|||||||
|
package org.tasks.compose
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.material.AlertDialog
|
||||||
|
import androidx.compose.material.Icon
|
||||||
|
import androidx.compose.material.MaterialTheme
|
||||||
|
import androidx.compose.material.OutlinedTextField
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.darkColors
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Email
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import org.tasks.R
|
||||||
|
import org.tasks.compose.Constants.TextButton
|
||||||
|
import org.tasks.compose.Constants.textFieldColors
|
||||||
|
import org.tasks.compose.ShareInvite.ShareInvite
|
||||||
|
|
||||||
|
@Preview(showBackground = true, backgroundColor = 0xFFFFFF)
|
||||||
|
@Composable
|
||||||
|
private fun Invite() = MaterialTheme {
|
||||||
|
ShareInvite(mutableStateOf(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true, backgroundColor = 0x202124)
|
||||||
|
@Composable
|
||||||
|
private fun InviteDark() = MaterialTheme(darkColors()) {
|
||||||
|
ShareInvite(mutableStateOf(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true, backgroundColor = 0xFFFFFF)
|
||||||
|
@Composable
|
||||||
|
private fun InviteFilled() = MaterialTheme {
|
||||||
|
ShareInvite(mutableStateOf("user@example.com"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true, backgroundColor = 0x202124)
|
||||||
|
@Composable
|
||||||
|
private fun InviteDarkFilled() = MaterialTheme(darkColors()) {
|
||||||
|
ShareInvite(mutableStateOf("user@example.com"))
|
||||||
|
}
|
||||||
|
|
||||||
|
object ShareInvite {
|
||||||
|
@Composable
|
||||||
|
fun ShareInviteDialog(
|
||||||
|
openDialog: MutableState<Boolean>,
|
||||||
|
invite: (String?) -> Unit,
|
||||||
|
) {
|
||||||
|
val email = rememberSaveable { mutableStateOf("") }
|
||||||
|
// TODO: remove after beta02 release: https://issuetracker.google.com/issues/181282423
|
||||||
|
val enableHack = rememberSaveable { mutableStateOf(true) }
|
||||||
|
if (openDialog.value) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = {},
|
||||||
|
text = { ShareInvite(email, enableHack) },
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(text = R.string.invite, onClick = {
|
||||||
|
enableHack.value = false
|
||||||
|
invite(email.value)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(text = R.string.cancel, onClick = {
|
||||||
|
enableHack.value = false
|
||||||
|
invite(null as String?)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
email.value = ""
|
||||||
|
enableHack.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ShareInvite(email: MutableState<String>, enableHack: MutableState<Boolean> = mutableStateOf(true)) {
|
||||||
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.share_list),
|
||||||
|
style = MaterialTheme.typography.h6,
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(Constants.KEYLINE_FIRST))
|
||||||
|
OutlinedTextField(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
value = email.value,
|
||||||
|
label = { Text(stringResource(R.string.email)) },
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
|
||||||
|
onValueChange = { email.value = it },
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Email,
|
||||||
|
contentDescription = stringResource(id = R.string.email)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
enabled = enableHack.value,
|
||||||
|
textStyle = MaterialTheme.typography.body1,
|
||||||
|
colors = textFieldColors(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM15,6c1.1,0 2,0.9 2,2s-0.9,2 -2,2 -2,-0.9 -2,-2 0.9,-2 2,-2zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4zM9,18c0.22,-0.72 3.31,-2 6,-2 2.7,0 5.8,1.29 6,2L9,18zM6,15v-3h3v-2L6,10L6,7L4,7v3L1,10v2h3v3z"/>
|
||||||
|
</vector>
|
||||||
@ -1,48 +1,64 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/root_layout"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_height="match_parent"
|
android:id="@+id/root_layout"
|
||||||
android:descendantFocusability="beforeDescendants"
|
android:layout_width="match_parent"
|
||||||
android:focusableInTouchMode="true"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:descendantFocusability="beforeDescendants"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/toolbar"/>
|
<include layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<include layout="@layout/progress_view"/>
|
<include layout="@layout/progress_view"/>
|
||||||
|
|
||||||
<ScrollView
|
<FrameLayout
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<ScrollView
|
||||||
android:id="@+id/name_layout"
|
android:layout_width="fill_parent"
|
||||||
style="@style/TagSettingsRow"
|
android:layout_height="wrap_content">
|
||||||
android:hint="@string/display_name">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<LinearLayout
|
||||||
android:id="@+id/name"
|
android:layout_width="match_parent"
|
||||||
style="@style/TagSettingsEditText"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textCapSentences|textAutoCorrect" />
|
android:orientation="vertical">
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/name_layout"
|
||||||
|
style="@style/TagSettingsRow"
|
||||||
|
android:hint="@string/display_name">
|
||||||
|
|
||||||
<include layout="@layout/list_settings_color"/>
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/name"
|
||||||
|
style="@style/TagSettingsEditText"
|
||||||
|
android:inputType="textCapSentences|textAutoCorrect" />
|
||||||
|
|
||||||
<include layout="@layout/list_settings_icon"/>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<androidx.compose.ui.platform.ComposeView
|
<include layout="@layout/list_settings_color"/>
|
||||||
android:id="@+id/people"
|
|
||||||
android:layout_width="match_parent"
|
<include layout="@layout/list_settings_icon"/>
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
<androidx.compose.ui.platform.ComposeView
|
||||||
|
android:id="@+id/people"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</ScrollView>
|
||||||
|
|
||||||
</ScrollView>
|
<androidx.compose.ui.platform.ComposeView
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/keyline_first"
|
||||||
|
android:layout_gravity="end|bottom"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Loading…
Reference in New Issue