mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Add counter on comment form
This commit is contained in:
		@@ -325,15 +325,8 @@ class _ConversationScreenState extends State<ConversationScreen> {
 | 
				
			|||||||
              maxLengthEnforced: true,
 | 
					              maxLengthEnforced: true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              // Show max length only when there is some text already typed
 | 
					              // Show max length only when there is some text already typed
 | 
				
			||||||
              buildCounter: (
 | 
					              buildCounter: smartInputCounterWidgetBuilder,
 | 
				
			||||||
                BuildContext context, {
 | 
					
 | 
				
			||||||
                @required int currentLength,
 | 
					 | 
				
			||||||
                @required int maxLength,
 | 
					 | 
				
			||||||
                @required bool isFocused,
 | 
					 | 
				
			||||||
              }) =>
 | 
					 | 
				
			||||||
                  currentLength > 0
 | 
					 | 
				
			||||||
                      ? Text("$currentLength/$maxLength")
 | 
					 | 
				
			||||||
                      : Container(),
 | 
					 | 
				
			||||||
              enabled: !_isSendingMessage,
 | 
					              enabled: !_isSendingMessage,
 | 
				
			||||||
              controller: _textEditingController,
 | 
					              controller: _textEditingController,
 | 
				
			||||||
              onChanged: _updatedText,
 | 
					              onChanged: _updatedText,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -250,27 +250,33 @@ class _PostTileState extends State<PostTile> {
 | 
				
			|||||||
          // Comment input
 | 
					          // Comment input
 | 
				
			||||||
          Expanded(
 | 
					          Expanded(
 | 
				
			||||||
            child: TextField(
 | 
					            child: TextField(
 | 
				
			||||||
 | 
					              // Comment max size
 | 
				
			||||||
 | 
					              maxLength: 255,
 | 
				
			||||||
 | 
					              maxLines: null,
 | 
				
			||||||
 | 
					              buildCounter: smartInputCounterWidgetBuilder,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              controller: _commentController,
 | 
					              controller: _commentController,
 | 
				
			||||||
              onChanged: (s) => setState(() {}),
 | 
					              onChanged: (s) => setState(() {}),
 | 
				
			||||||
              onSubmitted: _canSubmitComment ? (s) => _submitComment() : null,
 | 
					              onSubmitted: _canSubmitComment ? (s) => _submitComment() : 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: 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),
 | 
				
			||||||
                      borderRadius: BorderRadius.only(
 | 
					                    borderRadius: BorderRadius.only(
 | 
				
			||||||
                        topLeft: Radius.circular(3),
 | 
					                      topLeft: Radius.circular(3),
 | 
				
			||||||
                        bottomLeft: Radius.circular(3),
 | 
					                      bottomLeft: Radius.circular(3),
 | 
				
			||||||
                      ),
 | 
					                    ),
 | 
				
			||||||
                      gapPadding: 1),
 | 
					                    gapPadding: 1),
 | 
				
			||||||
                  contentPadding: EdgeInsets.only(
 | 
					                contentPadding: EdgeInsets.only(
 | 
				
			||||||
                    left: 10,
 | 
					                  left: 10,
 | 
				
			||||||
                    right: 10,
 | 
					                  right: 10,
 | 
				
			||||||
                    bottom: 5,
 | 
					                  bottom: 5,
 | 
				
			||||||
                    top: 5,
 | 
					                  top: 5,
 | 
				
			||||||
                  )),
 | 
					                ),
 | 
				
			||||||
 | 
					              ),
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -153,3 +153,13 @@ Future<bool> showConfirmDialog({
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return result != null && result;
 | 
					  return result != null && result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Smart [InputCounterWidgetBuilder] that show text limit only when some
 | 
				
			||||||
 | 
					/// text has already been entered by the user
 | 
				
			||||||
 | 
					Widget smartInputCounterWidgetBuilder(
 | 
				
			||||||
 | 
					  BuildContext context, {
 | 
				
			||||||
 | 
					  @required int currentLength,
 | 
				
			||||||
 | 
					  @required int maxLength,
 | 
				
			||||||
 | 
					  @required bool isFocused,
 | 
				
			||||||
 | 
					}) =>
 | 
				
			||||||
 | 
					    currentLength > 0 ? Text("$currentLength/$maxLength") : Container();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user