Merge branch 'main' of hiddify-github:hiddify/hiddify-next

This commit is contained in:
Hiddify
2024-03-08 14:20:42 +01:00
17 changed files with 2934 additions and 2800 deletions

View File

@@ -15,3 +15,5 @@ abstract class Constants {
static const cfWarpTermsOfService =
"https://www.cloudflare.com/application/terms/";
}
const kAnimationDuration = Duration(milliseconds: 250);

View File

@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:hiddify/core/model/constants.dart';
class AnimatedText extends Text {
const AnimatedText(
super.data, {
super.key,
super.style,
this.duration = kAnimationDuration,
this.size = true,
this.slide = true,
});
final Duration duration;
final bool size;
final bool slide;
@override
Widget build(BuildContext context) {
return AnimatedSwitcher(
duration: duration,
transitionBuilder: (child, animation) {
child = FadeTransition(
opacity: animation,
child: child,
);
if (size) {
child = SizeTransition(
axis: Axis.horizontal,
fixedCrossAxisSizeFactor: 1,
sizeFactor: Tween<double>(begin: 0.88, end: 1).animate(animation),
child: child,
);
}
if (slide) {
child = SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, -0.2),
end: Offset.zero,
).animate(animation),
child: child,
);
}
return child;
},
child: Text(
data!,
key: ValueKey<String>(data!),
style: style,
),
);
}
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter/widgets.dart';
extension SpacedWidgets on List<Widget> {
List<Widget> spaceBy({double? width, double? height}) => [
for (int i = 0; i < length; i++) ...[
if (i > 0) SizedBox(width: width, height: height),
this[i],
],
];
}