Skip to content

Commit 95cdf8e

Browse files
committed
Add placeholder when the editor is empty
1 parent f2b5ba8 commit 95cdf8e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import androidx.core.view.isGone
4141
import androidx.core.view.isVisible
4242
import androidx.fragment.app.Fragment
4343
import androidx.fragment.app.activityViewModels
44+
import androidx.lifecycle.lifecycleScope
4445
import androidx.navigation.fragment.findNavController
4546
import com.infomaniak.lib.core.utils.FilePicker
4647
import com.infomaniak.lib.core.utils.SnackbarUtils.showSnackbar
@@ -78,6 +79,9 @@ import com.infomaniak.mail.utils.extensions.AttachmentExtensions.openAttachment
7879
import dagger.hilt.android.AndroidEntryPoint
7980
import io.sentry.Sentry
8081
import io.sentry.SentryLevel
82+
import kotlinx.coroutines.flow.filterNotNull
83+
import kotlinx.coroutines.flow.launchIn
84+
import kotlinx.coroutines.flow.onEach
8185
import javax.inject.Inject
8286

8387
@AndroidEntryPoint
@@ -308,6 +312,11 @@ class NewMessageFragment : Fragment() {
308312
if (context.isNightModeEnabled()) editor.addCss(context.readRawResource(R.raw.custom_dark_mode))
309313

310314
addCss(context.readRawResource(R.raw.style))
315+
316+
isEmptyFlow
317+
.filterNotNull()
318+
.onEach { isEditorEmpty -> newMessagePlaceholder.isVisible = isEditorEmpty }
319+
.launchIn(lifecycleScope)
311320
}
312321

313322
setupSendButton()

app/src/main/res/layout/fragment_new_message.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@
297297
android:layout_width="match_parent"
298298
android:layout_height="wrap_content" />
299299

300+
<TextView
301+
android:id="@+id/newMessagePlaceholder"
302+
android:layout_width="wrap_content"
303+
android:layout_height="wrap_content"
304+
android:layout_gravity="center_vertical"
305+
android:layout_marginStart="@dimen/marginStandardMedium"
306+
android:text="@string/newMessagePlaceholderTitle"
307+
android:textColor="@color/tertiaryTextColor"
308+
android:visibility="gone"
309+
tools:visibility="visible" />
310+
300311
</FrameLayout>
301312

302313
<LinearLayout

0 commit comments

Comments
 (0)