mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Add references support
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
import 'package:comunic/utils/bbcode_parser.dart';
 | 
			
		||||
import 'package:comunic/utils/input_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/navigation_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:flutter_emoji/flutter_emoji.dart';
 | 
			
		||||
import 'package:url_launcher/url_launcher.dart';
 | 
			
		||||
@@ -32,17 +33,17 @@ class TextWidget extends StatelessWidget {
 | 
			
		||||
    if (this.parseBBcode)
 | 
			
		||||
      return BBCodeParsedWidget(
 | 
			
		||||
        text: content,
 | 
			
		||||
        parseCallback: (style, text) => _parseLinks(text, style),
 | 
			
		||||
        parseCallback: (style, text) => _parseLinks(context, text, style),
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
    // Just parse link
 | 
			
		||||
    return RichText(
 | 
			
		||||
      text: TextSpan(children: _parseLinks(content, style)),
 | 
			
		||||
      text: TextSpan(children: _parseLinks(context, content, style)),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Sub parse function
 | 
			
		||||
  List<InlineSpan> _parseLinks(String text, TextStyle style) {
 | 
			
		||||
  List<InlineSpan> _parseLinks(BuildContext context, String text, TextStyle style) {
 | 
			
		||||
    var buff = StringBuffer();
 | 
			
		||||
    final list = new List<InlineSpan>();
 | 
			
		||||
 | 
			
		||||
@@ -78,6 +79,25 @@ class TextWidget extends StatelessWidget {
 | 
			
		||||
        buff.write(" ");
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Check if it is a user reference
 | 
			
		||||
      else if(validateUserReference(word)) {
 | 
			
		||||
        changeWordType();
 | 
			
		||||
 | 
			
		||||
        list.add(
 | 
			
		||||
          WidgetSpan(
 | 
			
		||||
            child: InkWell(
 | 
			
		||||
              child: Text(
 | 
			
		||||
                word,
 | 
			
		||||
                style: style.copyWith(color: Colors.blueAccent),
 | 
			
		||||
              ),
 | 
			
		||||
              onTap: () => openVirtualDirectory(context, word),
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        buff.write(" ");
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Simple word
 | 
			
		||||
      else {
 | 
			
		||||
        buff.write(word);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user