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