public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-flutter-frontend] fix text selection theme
Date: Mon, 12 Sep 2022 11:24:03 +0200	[thread overview]
Message-ID: <20220912092403.1608055-1-d.csapak@proxmox.com> (raw)

by default, flutter derives the text selection theme from the global
MaterialApp defined themes primary color, which is problematic in our
case, since we often have the same primary color as background for text
fields. This resulted in the cursorColor/selectionHandleColor to be the
same as the background, making them invisible.

Fix it by creating a manual textSelectionTheme with colors that properly
contrast the background. (The color works well for both light and dark mode)

The selectionHandleColor is modifed with an opacity of 0.4 like flutter
does by default.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 lib/main.dart | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/main.dart b/lib/main.dart
index d3709f9..0245552 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -134,6 +134,11 @@ class MyApp extends StatelessWidget {
             backgroundColor: ProxmoxColors.supportBlue, // primary
             foregroundColor: Colors.white, // onPrimary
           ),
+          textSelectionTheme: TextSelectionThemeData(
+            selectionColor: ProxmoxColors.orange.withOpacity(0.4),
+            selectionHandleColor: ProxmoxColors.orange,
+            cursorColor: ProxmoxColors.orange,
+          ),
         ),
         darkTheme: ThemeData(
           colorScheme: ColorScheme.dark(
@@ -170,6 +175,11 @@ class MyApp extends StatelessWidget {
                 TextStyle(fontFamily: "Open Sans", fontWeight: FontWeight.w700),
           ),
           scaffoldBackgroundColor: ProxmoxColors.grey,
+          textSelectionTheme: TextSelectionThemeData(
+            selectionColor: ProxmoxColors.orange.withOpacity(0.4),
+            selectionHandleColor: ProxmoxColors.orange,
+            cursorColor: ProxmoxColors.orange,
+          ),
         ),
         builder: (context, child) {
           return StreamListener(
-- 
2.30.2





             reply	other threads:[~2022-09-12  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  9:24 Dominik Csapak [this message]
2022-09-12 15:07 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220912092403.1608055-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal