From 06581e21e9e439e45e472b756c6f31a5b83a3e6f Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 16 Jan 2021 21:50:01 +0100 Subject: [PATCH] chore: Minor design tweaks --- lib/components/avatar.dart | 8 ++++++-- lib/utils/string_color.dart | 11 ++++++++++- lib/views/chat_list.dart | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/components/avatar.dart b/lib/components/avatar.dart index 0a35c1cd..70bee188 100644 --- a/lib/components/avatar.dart +++ b/lib/components/avatar.dart @@ -39,7 +39,9 @@ class Avatar extends StatelessWidget { child: Text( fallbackLetters, style: TextStyle( - color: Colors.white, + color: Theme.of(context).brightness == Brightness.light + ? name?.darkColor + : name?.lightColor ?? Colors.white, fontSize: 18, ), ), @@ -55,7 +57,9 @@ class Avatar extends StatelessWidget { width: size, height: size, color: noPic - ? name?.lightColor ?? Theme.of(context).secondaryHeaderColor + ? Theme.of(context).brightness == Brightness.light + ? name?.lightColor + : name?.darkColor ?? Theme.of(context).secondaryHeaderColor : Theme.of(context).secondaryHeaderColor, child: noPic ? textWidget diff --git a/lib/utils/string_color.dart b/lib/utils/string_color.dart index f96c2e17..f1c5d6ca 100644 --- a/lib/utils/string_color.dart +++ b/lib/utils/string_color.dart @@ -10,12 +10,21 @@ extension StringColor on String { return HSLColor.fromAHSL(1, number, 1, 0.35).toColor(); } + Color get darkColor { + var number = 0.0; + for (var i = 0; i < length; i++) { + number += codeUnitAt(i); + } + number = (number % 10) * 25.5; + return HSLColor.fromAHSL(1, number, 1, 0.2).toColor(); + } + Color get lightColor { var number = 0.0; for (var i = 0; i < length; i++) { number += codeUnitAt(i); } number = (number % 10) * 25.5; - return HSLColor.fromAHSL(1, number, 1, 0.66).toColor(); + return HSLColor.fromAHSL(1, number, 1, 0.8).toColor(); } } diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart index 30535951..aab8ec7d 100644 --- a/lib/views/chat_list.dart +++ b/lib/views/chat_list.dart @@ -248,6 +248,7 @@ class _ChatListState extends State { searchController: searchController, hintText: L10n.of(context).searchForAChat, onChanged: (_) => setState(() => null), + suffix: Icon(Icons.search_outlined), ), ), floatingActionButton: