mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Improve dark theme
This commit is contained in:
		@@ -71,3 +71,10 @@ class PreferencesHelper {
 | 
			
		||||
    return v == null ? alternative : v;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PreferencesHelper preferences() {
 | 
			
		||||
  if (PreferencesHelper._instance == null)
 | 
			
		||||
    throw Exception("Try to get preference before their initialization!");
 | 
			
		||||
 | 
			
		||||
  return PreferencesHelper._instance;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ class ComunicApplication extends StatelessWidget {
 | 
			
		||||
    return MaterialApp(
 | 
			
		||||
      debugShowCheckedModeBanner: false,
 | 
			
		||||
      home: ComunicApplicationHome(),
 | 
			
		||||
      theme: darkMode ? ThemeData.dark() : null,
 | 
			
		||||
      theme: darkMode ? ThemeData.dark() : ThemeData.light(),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import 'package:comunic/ui/widgets/account_image_widget.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/network_image_widget.dart';
 | 
			
		||||
import 'package:comunic/utils/date_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/ui_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Single comment tile
 | 
			
		||||
@@ -90,7 +91,7 @@ class CommentTile extends StatelessWidget {
 | 
			
		||||
          child: comment.hasContent
 | 
			
		||||
              ? Text(
 | 
			
		||||
                  comment.content,
 | 
			
		||||
                  style: TextStyle(color: Colors.black),
 | 
			
		||||
                  style: TextStyle(color: darkTheme() ? darkAccentColor : Colors.black),
 | 
			
		||||
                )
 | 
			
		||||
              : null,
 | 
			
		||||
        ),
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import 'package:comunic/ui/widgets/network_image_widget.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/text_rich_content_widget.dart';
 | 
			
		||||
import 'package:comunic/utils/date_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/ui_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Conversation message tile
 | 
			
		||||
@@ -201,12 +202,17 @@ class ConversationMessageTile extends StatelessWidget {
 | 
			
		||||
                              child: TextRichContentWidget(
 | 
			
		||||
                                message.message,
 | 
			
		||||
                                textAlign: TextAlign.justify,
 | 
			
		||||
                                style: TextStyle(color: Colors.black),
 | 
			
		||||
                                style: TextStyle(
 | 
			
		||||
                                    color: darkTheme()
 | 
			
		||||
                                        ? Colors.white
 | 
			
		||||
                                        : Colors.black),
 | 
			
		||||
                              ),
 | 
			
		||||
                              padding:
 | 
			
		||||
                                  EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
 | 
			
		||||
                              decoration: BoxDecoration(
 | 
			
		||||
                                color: Colors.black12,
 | 
			
		||||
                                color: darkTheme()
 | 
			
		||||
                                    ? Colors.white12
 | 
			
		||||
                                    : Colors.black12,
 | 
			
		||||
                                borderRadius: BorderRadius.circular(8.0),
 | 
			
		||||
                              ),
 | 
			
		||||
                            ),
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ import 'package:comunic/lists/users_list.dart';
 | 
			
		||||
import 'package:comunic/models/conversation.dart';
 | 
			
		||||
import 'package:comunic/utils/date_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/ui_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Single conversation tile
 | 
			
		||||
@@ -67,7 +68,9 @@ class ConversationTile extends StatelessWidget {
 | 
			
		||||
      // Leading icon
 | 
			
		||||
      leading: Icon(
 | 
			
		||||
        conversation.sawLastMessage ? Icons.check_circle : Icons.lens,
 | 
			
		||||
        color: conversation.sawLastMessage ? null : Colors.blue,
 | 
			
		||||
        color: conversation.sawLastMessage
 | 
			
		||||
            ? (darkTheme() ? darkAccentColor : null)
 | 
			
		||||
            : Colors.blue,
 | 
			
		||||
      ),
 | 
			
		||||
 | 
			
		||||
      // Conversation information
 | 
			
		||||
 
 | 
			
		||||
@@ -345,7 +345,7 @@ class _PostTileState extends State<PostTile> {
 | 
			
		||||
    comments.add(_buildCommentsForm());
 | 
			
		||||
 | 
			
		||||
    return Container(
 | 
			
		||||
      color: Colors.grey[300],
 | 
			
		||||
      color: darkTheme() ? Colors.black38 : Colors.grey[300],
 | 
			
		||||
      child: Padding(
 | 
			
		||||
        padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
 | 
			
		||||
        child: Column(
 | 
			
		||||
@@ -375,10 +375,15 @@ class _PostTileState extends State<PostTile> {
 | 
			
		||||
              controller: _commentController,
 | 
			
		||||
              onChanged: (s) => setState(() {}),
 | 
			
		||||
              onSubmitted: _canSubmitComment ? (s) => _submitComment() : null,
 | 
			
		||||
 | 
			
		||||
              style: TextStyle(
 | 
			
		||||
                color: darkTheme() ? Colors.white : null,
 | 
			
		||||
              ),
 | 
			
		||||
 | 
			
		||||
              decoration: InputDecoration(
 | 
			
		||||
                hintText: tr("New comment..."),
 | 
			
		||||
                hintStyle: TextStyle(color: Colors.grey, fontSize: 12),
 | 
			
		||||
                fillColor: Colors.white,
 | 
			
		||||
                fillColor: darkTheme() ? Colors.black38 : Colors.white,
 | 
			
		||||
                filled: true,
 | 
			
		||||
                border: OutlineInputBorder(
 | 
			
		||||
                    borderSide: BorderSide(width: 0.5, color: Colors.grey),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/ui_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Navigation bar widget
 | 
			
		||||
@@ -18,8 +19,8 @@ enum BarCallbackActions {
 | 
			
		||||
  ACTION_LOGOUT
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const _PrimaryColor = Colors.blue;
 | 
			
		||||
const _SecondaryColor = Colors.white;
 | 
			
		||||
Color _primaryColor() => darkTheme() ? Colors.black : Colors.blue;
 | 
			
		||||
Color _secondaryColor() => darkTheme() ? darkAccentColor : Colors.white;
 | 
			
		||||
 | 
			
		||||
/// Menu item information
 | 
			
		||||
class _MenuItem {
 | 
			
		||||
@@ -93,7 +94,7 @@ class ComunicAppBar extends StatelessWidget implements PreferredSizeWidget {
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Material(
 | 
			
		||||
      color: Colors.blue,
 | 
			
		||||
      color: darkTheme() ? Colors.black : Colors.blue,
 | 
			
		||||
      child: Row(
 | 
			
		||||
        crossAxisAlignment: CrossAxisAlignment.stretch,
 | 
			
		||||
        children: List.generate(
 | 
			
		||||
@@ -134,7 +135,7 @@ class _MenuItemWidget extends StatelessWidget {
 | 
			
		||||
 | 
			
		||||
    return Expanded(
 | 
			
		||||
      child: Material(
 | 
			
		||||
        color: isSelected ? _SecondaryColor : _PrimaryColor,
 | 
			
		||||
        color: isSelected ? _secondaryColor() : _primaryColor(),
 | 
			
		||||
        child: !item.isMenu
 | 
			
		||||
            ? InkWell(
 | 
			
		||||
                child: _buildIconContainer(),
 | 
			
		||||
@@ -151,7 +152,7 @@ class _MenuItemWidget extends StatelessWidget {
 | 
			
		||||
      children: <Widget>[
 | 
			
		||||
        IconTheme(
 | 
			
		||||
          data: IconThemeData(
 | 
			
		||||
              color: isSelected ? _PrimaryColor : _SecondaryColor),
 | 
			
		||||
              color: isSelected ? _primaryColor() : _secondaryColor()),
 | 
			
		||||
          child: item.icon,
 | 
			
		||||
        )
 | 
			
		||||
      ],
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
import 'package:cached_network_image/cached_network_image.dart';
 | 
			
		||||
import 'package:comunic/helpers/preferences_helper.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:html/parser.dart';
 | 
			
		||||
@@ -179,3 +180,9 @@ String htmlDecodeCharacters(String input) {
 | 
			
		||||
 | 
			
		||||
  return parse(input).documentElement.text;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const darkAccentColor = Colors.white70;
 | 
			
		||||
 | 
			
		||||
/// Check out whether dark theme is enabled or not
 | 
			
		||||
bool darkTheme() => preferences().getBool(PreferencesKeyList.ENABLE_DARK_THEME);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user