make ip private for both footer and sidebar
This commit is contained in:
@@ -143,34 +143,30 @@ class _InfoProp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IPWidget extends StatefulWidget {
|
class IPWidget extends StatefulWidget {
|
||||||
final String text1;
|
final String text;
|
||||||
final String text2;
|
final TextStyle? style;
|
||||||
|
IPWidget(this.text, {this.style}) : super(key: UniqueKey());
|
||||||
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
|
@override
|
||||||
_IPWidgetState createState() => _IPWidgetState();
|
_IPWidgetState createState() => _IPWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IPWidgetState extends State<IPWidget> {
|
class _IPWidgetState extends State<IPWidget> {
|
||||||
bool isText1Visible = true;
|
bool isFullIPVisible = true;
|
||||||
|
|
||||||
void toggleVisibility() {
|
void toggleVisibility() {
|
||||||
setState(() {
|
setState(() {
|
||||||
isText1Visible = !isText1Visible;
|
isFullIPVisible = !isFullIPVisible;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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]}';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,8 +175,9 @@ class _IPWidgetState extends State<IPWidget> {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: toggleVisibility,
|
onTap: toggleVisibility,
|
||||||
child: Text(
|
child: Text(
|
||||||
isText1Visible ? widget.text1 : widget.text2,
|
isFullIPVisible ? _replaceMiddlePart(widget.text) : widget.text,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: widget.style,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:flutter_animate/flutter_animate.dart';
|
|||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hiddify/core/localization/translations.dart';
|
import 'package:hiddify/core/localization/translations.dart';
|
||||||
import 'package:hiddify/core/widget/skeleton_widget.dart';
|
import 'package:hiddify/core/widget/skeleton_widget.dart';
|
||||||
|
import 'package:hiddify/features/proxy/active/active_proxy_footer.dart';
|
||||||
import 'package:hiddify/features/proxy/active/active_proxy_notifier.dart';
|
import 'package:hiddify/features/proxy/active/active_proxy_notifier.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
|
||||||
@@ -30,11 +31,7 @@ class ActiveProxySideBarCard extends HookConsumerWidget {
|
|||||||
final asyncState = ref.watch(activeProxyNotifierProvider);
|
final asyncState = ref.watch(activeProxyNotifierProvider);
|
||||||
|
|
||||||
Widget propText(String txt) {
|
Widget propText(String txt) {
|
||||||
return Text(
|
return IPWidget(txt, style: theme.textTheme.bodySmall);
|
||||||
txt,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: theme.textTheme.bodySmall,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Theme(
|
return Theme(
|
||||||
|
|||||||
Reference in New Issue
Block a user