Glass
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
|
||||
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
double op1 = 0;
|
||||
double op2 = 0;
|
||||
double op3 = 0;
|
||||
Widget CustomBody({required Widget child,required BuildContext context, required Function() onAnimEnd, List<BottomNavBarItem>? bottomNav}) {
|
||||
Widget CustomBody(
|
||||
{required Widget child,
|
||||
required BuildContext context,
|
||||
required Function() onAnimEnd,
|
||||
List<BottomNavBarItem>? bottomNav}) {
|
||||
Duration opDuration = const Duration(milliseconds: 1500);
|
||||
var random = new Random();
|
||||
|
||||
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
@@ -35,7 +37,7 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
shape: BoxShape.circle,
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.blue.withOpacity(0.3 + (op1/3)),
|
||||
Colors.blue.withOpacity(0.3 + (op1 / 3)),
|
||||
Colors.blue.withOpacity(op1),
|
||||
Colors.deepPurpleAccent.withOpacity(op1)
|
||||
],
|
||||
@@ -43,8 +45,8 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
child:
|
||||
Container(height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -55,8 +57,9 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
// setState(() {
|
||||
op2 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op2); onAnimEnd();
|
||||
op2 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op2);
|
||||
onAnimEnd();
|
||||
|
||||
// });
|
||||
},
|
||||
@@ -74,8 +77,8 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
child:
|
||||
Container(height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -86,8 +89,9 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
duration: opDuration,
|
||||
onEnd: () {
|
||||
// setState(() {
|
||||
op3 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op3); onAnimEnd();
|
||||
op3 = (random.nextDouble() / 2) + 0.5;
|
||||
log(op3);
|
||||
onAnimEnd();
|
||||
|
||||
// });
|
||||
},
|
||||
@@ -105,46 +109,56 @@ Widget CustomBody({required Widget child,required BuildContext context, required
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 200, sigmaY: 200),
|
||||
child: Container(
|
||||
height: 200, width: 200, color: Colors.transparent),
|
||||
child:
|
||||
Container(height: 200, width: 200, color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
(bottomNav != null) ? Positioned(
|
||||
bottom: 20,
|
||||
right: screenWidth * 0.15,
|
||||
child: Container(
|
||||
width: screenWidth * 0.7,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26, offset: Offset.fromDirection(1, 2))
|
||||
]),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: bottomNav,
|
||||
)),
|
||||
) : Container(),
|
||||
AnimatedContainer(duration: opDuration,child: child)
|
||||
Container(
|
||||
margin: const EdgeInsets.fromLTRB(0,0,0,50),
|
||||
child: AnimatedContainer(duration: opDuration, child: child),
|
||||
),
|
||||
(bottomNav != null)
|
||||
? Positioned(
|
||||
bottom: 20,
|
||||
right: screenWidth * 0.15,
|
||||
child: Container(
|
||||
width: screenWidth * 0.7,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.white.withOpacity(0.12),
|
||||
Colors.white.withOpacity(0.05)
|
||||
]
|
||||
),
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset.fromDirection(1, 2))
|
||||
]),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: bottomNav,
|
||||
)),
|
||||
)
|
||||
: Container(),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Widget NeonButton(
|
||||
{required void Function() onPressed,
|
||||
required String text,
|
||||
double width = 250,
|
||||
double height = 50,
|
||||
double fontSize = 20,
|
||||
List<Color>? colors,
|
||||
Widget? trailing,
|
||||
Widget? heading}) {
|
||||
if(colors == null){
|
||||
required String text,
|
||||
double width = 250,
|
||||
double height = 50,
|
||||
double fontSize = 20,
|
||||
List<Color>? colors,
|
||||
Widget? trailing,
|
||||
Widget? heading}) {
|
||||
if (colors == null) {
|
||||
colors = [Colors.blue, Colors.deepPurple];
|
||||
}
|
||||
return Padding(
|
||||
@@ -191,8 +205,65 @@ Widget NeonButton(
|
||||
);
|
||||
}
|
||||
|
||||
Widget GlassButton({Color color = Colors.white,double height = 30,required Function() onTap, required Widget child, required double width}){
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(width: width,height: height, decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
gradient: LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomCenter, colors: [color.withOpacity(0.3), color.withOpacity(0.1)]),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset.fromDirection(1, 2))
|
||||
],
|
||||
),
|
||||
child: Align(alignment: Alignment.center,child: child),),
|
||||
);
|
||||
}
|
||||
|
||||
Widget GlassCard({bool highlighted = false,required Widget child}) {
|
||||
return Container(
|
||||
// padding: EdgeInsets.all(30),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.white.withOpacity(highlighted ? 0.4 : 0.12),
|
||||
Colors.white.withOpacity(highlighted? 0.15:0.05),
|
||||
]),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset.fromDirection(1, 2))
|
||||
],
|
||||
|
||||
),
|
||||
child: child);
|
||||
}
|
||||
|
||||
Widget GlassProgressBar({double height = 10, required double width, required double value}){
|
||||
return Stack(
|
||||
children: [
|
||||
Container(width: width,height: height,decoration: BoxDecoration(
|
||||
gradient: LinearGradient(begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Colors.white.withOpacity(0.3), Colors.white.withOpacity(0.1)]),borderRadius: BorderRadius.circular(10)
|
||||
),),
|
||||
Container(width: width * value ,height: height,decoration: BoxDecoration(
|
||||
gradient: LinearGradient(begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Colors.white.withOpacity(0.6), Colors.white.withOpacity(0.4)]),borderRadius: BorderRadius.circular(10)
|
||||
),)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class BottomNavBarItem extends StatelessWidget {
|
||||
BottomNavBarItem({required this.active,required IconData this.icon, String? this.text, required Function() this.onPressed,});
|
||||
BottomNavBarItem({
|
||||
required this.active,
|
||||
required IconData this.icon,
|
||||
String? this.text,
|
||||
required Function() this.onPressed,
|
||||
});
|
||||
IconData icon;
|
||||
String? text;
|
||||
Function() onPressed;
|
||||
@@ -201,7 +272,7 @@ class BottomNavBarItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return InkWell(
|
||||
onTap: (){
|
||||
onTap: () {
|
||||
onPressed();
|
||||
},
|
||||
child: Container(
|
||||
@@ -210,8 +281,12 @@ class BottomNavBarItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedSize(duration: const Duration(milliseconds: 300),child: Icon(icon,size:active ? 45 : 25, color: active ? Colors.deepPurpleAccent : Colors.blue)),
|
||||
(text!=null) ? Text(text!) : Container()
|
||||
AnimatedSize(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: Icon(icon,
|
||||
size: active ? 45 : 25,
|
||||
color: active ? Colors.blueAccent : Colors.white.withOpacity(0.8))),
|
||||
(text != null) ? Text(text!) : Container()
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -220,11 +295,12 @@ class BottomNavBarItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
class GradientText extends StatelessWidget {
|
||||
const GradientText(
|
||||
{super.key, required this.text,
|
||||
required this.gradient,
|
||||
this.style,
|
||||
});
|
||||
const GradientText({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.gradient,
|
||||
this.style,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
@@ -240,4 +316,4 @@ class GradientText extends StatelessWidget {
|
||||
child: Text(text, style: style),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user