mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Can change conversation color
This commit is contained in:
		@@ -1,9 +1,13 @@
 | 
			
		||||
import 'package:comunic/lists/users_list.dart';
 | 
			
		||||
import 'package:comunic/models/conversation.dart';
 | 
			
		||||
import 'package:comunic/models/user.dart';
 | 
			
		||||
import 'package:comunic/ui/dialogs/color_picker_dialog.dart';
 | 
			
		||||
import 'package:comunic/ui/tiles/simple_user_tile.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/pick_user_widget.dart';
 | 
			
		||||
import 'package:comunic/utils/color_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/dart_color.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/log_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Create / Update conversation screen
 | 
			
		||||
@@ -28,10 +32,24 @@ class UpdateConversationScreen extends StatefulWidget {
 | 
			
		||||
 | 
			
		||||
class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
  TextEditingController _nameController = TextEditingController();
 | 
			
		||||
  TextEditingController _colorController = TextEditingController();
 | 
			
		||||
  UsersList _members = UsersList();
 | 
			
		||||
  bool _followConversation = true;
 | 
			
		||||
  bool _canEveryoneAddMembers = true;
 | 
			
		||||
 | 
			
		||||
  String get _conversationColor => _colorController.text;
 | 
			
		||||
 | 
			
		||||
  Color get _color {
 | 
			
		||||
    if (_conversationColor == null || _conversationColor.isEmpty) return null;
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      return HexColor(_conversationColor);
 | 
			
		||||
    } catch (e, s) {
 | 
			
		||||
      logError(e, s);
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get isUpdating => widget.initialSettings != null;
 | 
			
		||||
 | 
			
		||||
  get isAdmin => !isUpdating || widget.initialSettings.isAdmin;
 | 
			
		||||
@@ -64,12 +82,27 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
            TextField(
 | 
			
		||||
              controller: _nameController,
 | 
			
		||||
              decoration: InputDecoration(
 | 
			
		||||
                labelText: tr("Conversation name (optionnal)"),
 | 
			
		||||
                labelText: tr("Conversation name (optional)"),
 | 
			
		||||
                alignLabelWithHint: true,
 | 
			
		||||
                enabled: isAdmin,
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
 | 
			
		||||
            // Conversation color
 | 
			
		||||
            TextField(
 | 
			
		||||
              controller: _colorController,
 | 
			
		||||
              onChanged: (s) => setState(() {}),
 | 
			
		||||
              decoration: InputDecoration(
 | 
			
		||||
                  labelText: tr("Conversation color (optional)"),
 | 
			
		||||
                  alignLabelWithHint: true,
 | 
			
		||||
                  enabled: isAdmin,
 | 
			
		||||
                  suffixIcon: IconButton(
 | 
			
		||||
                    icon: Icon(Icons.colorize),
 | 
			
		||||
                    color: _color,
 | 
			
		||||
                    onPressed: isAdmin ? _pickColor : null,
 | 
			
		||||
                  )),
 | 
			
		||||
            ),
 | 
			
		||||
 | 
			
		||||
            // Follow conversation ?
 | 
			
		||||
            Row(
 | 
			
		||||
              children: <Widget>[
 | 
			
		||||
@@ -149,6 +182,12 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void _pickColor() async {
 | 
			
		||||
    final color = await showColorPickerDialog(context, _color);
 | 
			
		||||
    setState(() =>
 | 
			
		||||
        _colorController.text = color == null ? "" : "#${colorToHex(color)}");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// An option of the members menu has been selected
 | 
			
		||||
  void _membersMenuItemSelected(User user, _MembersMenuChoices choice) {
 | 
			
		||||
    if (choice == null) return;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user