Commit dbc980a8 authored by Amir Mohammadi's avatar Amir Mohammadi 👦🏻
Browse files

add comment and fix the name

parent 0077ba08
......@@ -64,7 +64,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Text("Put it Down"),
onPressed: () {
setState(() {
richText = FindSympol(controller.text)
richText = ClickableText(controller.text)
.makeHashtagAndMention(hashtagAction, mentionAction);
});
},
......
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class FindSympol {
class ClickableText {
String _clearText;
String _hashtagSymbol = "#";
String _mentionSymbol = "@";
......@@ -9,10 +9,10 @@ class FindSympol {
var _mentionAction;
List<TextSpan> _output = List<TextSpan>();
FindSympol(String clearText) {
ClickableText(String clearText) {
this._clearText = clearText;
}
//it build List of TextSpan and Just Find and make Clickable Hashtag
List<TextSpan> makeJustHashtag(var hashtagAction) {
this._hashtagAction = hashtagAction;
List<int> _position = _getPositionOfSymbol(_hashtagSymbol);
......@@ -20,6 +20,7 @@ class FindSympol {
return _output;
}
//it build List of TextSpan and Just Find and make Clickable Mention
List<TextSpan> makeJustMention(var mentionAction) {
this._mentionAction = mentionAction;
List<int> _position = _getPositionOfSymbol(_mentionSymbol);
......@@ -27,6 +28,7 @@ class FindSympol {
return _output;
}
//it build List of TextSpan and Find both Hashtag And Mention and make Clickable them
List<TextSpan> makeHashtagAndMention(var hashtagAction, var mentionAction) {
this._mentionAction = mentionAction;
List<int> _position = _getPositionOfSymbols(_hashtagSymbol, _mentionSymbol);
......@@ -40,6 +42,7 @@ class FindSympol {
return _output;
}
//it find postion of both Hashtag and metion symbol
List<int> _getPositionOfSymbols(String hashtagSymbol, String mentionSymbol) {
List<int> _position = List<int>();
String uw =
......@@ -56,6 +59,7 @@ class FindSympol {
return _position;
}
//it find postion of input symbol
List<int> _getPositionOfSymbol(String inputSymbol) {
List<int> _position = List<int>();
String uw =
......@@ -72,6 +76,7 @@ class FindSympol {
return _position;
}
//make Richtext List for "makeJustHashtag" and "makeJustMention"
_makeRichText(_position, symbol, action) {
for (var i = 0; i + 1 < _position.length; i++) {
if (i % 2 == 0) {
......@@ -97,6 +102,7 @@ class FindSympol {
return _output;
}
//make Richtext List for "makeHashtagAndMention"
_makeRichTextForBothSymbol(
_position,
hashtagSymbol,
......@@ -134,6 +140,7 @@ class FindSympol {
return _output;
}
//chooseAction for each symbol
_chooseAction(String symbol, hashtagAction, mentionAction) {
if (symbol == _hashtagSymbol) {
return hashtagAction;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment