make ip anonymous
This commit is contained in:
@@ -92,10 +92,7 @@ class _InfoProp extends StatelessWidget {
|
|||||||
required IconData icon,
|
required IconData icon,
|
||||||
required String text,
|
required String text,
|
||||||
}) : icon = Icon(icon),
|
}) : icon = Icon(icon),
|
||||||
child = Text(
|
child = IPWidget(text),
|
||||||
text,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
_InfoProp.flag({
|
_InfoProp.flag({
|
||||||
@@ -107,10 +104,7 @@ class _InfoProp extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(2),
|
padding: const EdgeInsets.all(2),
|
||||||
child: CircleFlag(countryCode),
|
child: CircleFlag(countryCode),
|
||||||
),
|
),
|
||||||
child = Text(
|
child = IPWidget(text),
|
||||||
text,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
_InfoProp.loading({
|
_InfoProp.loading({
|
||||||
@@ -147,3 +141,47 @@ class _InfoProp extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class IPWidget extends StatefulWidget {
|
||||||
|
final String text1;
|
||||||
|
final String text2;
|
||||||
|
|
||||||
|
IPWidget(String text)
|
||||||
|
: text1 = _replaceMiddlePart(text),
|
||||||
|
text2 = text,
|
||||||
|
super(key: UniqueKey());
|
||||||
|
static String _replaceMiddlePart(String ip) {
|
||||||
|
RegExp regex = RegExp(
|
||||||
|
r'^([\da-f]+([:.]))([\da-f:.]*)([:.][\da-f]+)$',
|
||||||
|
caseSensitive: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
return ip.replaceAllMapped(regex, (match) {
|
||||||
|
return '${match[1]} ░ ${match[2]} ░ ${match[4]}';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
_IPWidgetState createState() => _IPWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _IPWidgetState extends State<IPWidget> {
|
||||||
|
bool isText1Visible = true;
|
||||||
|
|
||||||
|
void toggleVisibility() {
|
||||||
|
setState(() {
|
||||||
|
isText1Visible = !isText1Visible;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: toggleVisibility,
|
||||||
|
child: Text(
|
||||||
|
isText1Visible ? widget.text1 : widget.text2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user