-
Notifications
You must be signed in to change notification settings - Fork 20
/
HomeDialogs.kt
162 lines (147 loc) · 5.07 KB
/
HomeDialogs.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*
*/
@file:Suppress("TooManyFunctions")
package com.wire.android.ui.home
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.wire.android.R
import com.wire.android.ui.common.WireDialog
import com.wire.android.ui.common.WireDialogButtonProperties
import com.wire.android.ui.common.WireDialogButtonType
import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration
import com.wire.android.ui.theme.WireTheme
import com.wire.android.util.CustomTabsHelper
import com.wire.android.util.ui.PreviewMultipleThemes
@Composable
fun FileRestrictionDialog(
isFileSharingEnabled: Boolean,
hideDialogStatus: () -> Unit,
) {
val text: String =
stringResource(id = if (isFileSharingEnabled) R.string.sharing_files_enabled else R.string.sharing_files_disabled)
WireDialog(
title = stringResource(id = R.string.team_settings_changed),
text = text,
onDismiss = hideDialogStatus,
optionButton1Properties = WireDialogButtonProperties(
onClick = hideDialogStatus,
text = stringResource(id = R.string.label_ok),
type = WireDialogButtonType.Primary,
)
)
}
@Composable
fun SelfDeletingMessagesDialog(
areSelfDeletingMessagesEnabled: Boolean,
enforcedTimeout: SelfDeletionDuration,
hideDialogStatus: () -> Unit,
) {
val formattedTimeout = enforcedTimeout.longLabel.asString()
val text: String = when {
areSelfDeletingMessagesEnabled && enforcedTimeout == SelfDeletionDuration.None -> {
stringResource(id = R.string.self_deleting_messages_team_setting_enabled)
}
areSelfDeletingMessagesEnabled -> {
stringResource(
R.string.self_deleting_messages_team_setting_enabled_enforced_timeout,
formattedTimeout
)
}
else -> {
stringResource(id = R.string.self_deleting_messages_team_setting_disabled)
}
}
WireDialog(
title = stringResource(id = R.string.team_settings_changed),
text = text,
onDismiss = hideDialogStatus,
optionButton1Properties = WireDialogButtonProperties(
onClick = hideDialogStatus,
text = stringResource(id = R.string.label_ok),
type = WireDialogButtonType.Primary,
)
)
}
@Composable
fun GuestRoomLinkFeatureFlagDialog(
isGuestRoomLinkEnabled: Boolean,
onDismiss: () -> Unit,
) {
val text: String =
stringResource(id = if (isGuestRoomLinkEnabled) R.string.guest_room_link_enabled else R.string.guest_room_link_disabled)
WireDialog(
title = stringResource(id = R.string.team_settings_changed),
text = text,
onDismiss = onDismiss,
optionButton1Properties = WireDialogButtonProperties(
onClick = onDismiss,
text = stringResource(id = R.string.label_ok),
type = WireDialogButtonType.Primary,
)
)
}
@Composable
fun WelcomeNewUserDialog(
dismissDialog: () -> Unit,
context: Context = LocalContext.current
) {
val welcomeToNewAndroidUrl = stringResource(id = R.string.url_welcome_to_new_android)
WireDialog(
title = stringResource(id = R.string.welcome_migration_dialog_title),
text = stringResource(id = R.string.welcome_migration_dialog_content),
onDismiss = dismissDialog,
optionButton1Properties = WireDialogButtonProperties(
onClick = {
dismissDialog.invoke()
CustomTabsHelper.launchUrl(context, welcomeToNewAndroidUrl)
},
text = stringResource(id = R.string.label_learn_more),
type = WireDialogButtonType.Primary,
),
optionButton2Properties = WireDialogButtonProperties(
onClick = dismissDialog,
text = stringResource(id = R.string.welcome_migration_dialog_continue),
type = WireDialogButtonType.Primary,
)
)
}
@PreviewMultipleThemes
@Composable
fun previewFileRestrictionDialog() {
WireTheme {
FileRestrictionDialog(true) {}
}
}
@PreviewMultipleThemes
@Composable
fun previewGuestRoomLinkFeatureFlagDialog() {
WireTheme {
GuestRoomLinkFeatureFlagDialog(true) {}
}
}
@PreviewMultipleThemes
@Composable
fun previewWelcomeNewUserDialog() {
WireTheme {
WelcomeNewUserDialog({})
}
}