// ignore_for_file: must_be_immutable import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:flutter/material.dart'; class FikoYTButton extends StatelessWidget { const FikoYTButton({ super.key, required this.text, this.onPressed, this.onLongPress, this.route, this.tema, }); final FikoYTButtonTheme? tema; final dynamic text; final String? route; final VoidCallback? onPressed; final VoidCallback? onLongPress; @override Widget build(BuildContext context) { final theme = Theme.of(context).extension(); final textColor = tema?.textColor ?? theme?.textColor ?? Colors.white; final textShadow = tema?.textShadow ?? theme?.textShadow; final fontSize = tema?.fontSize ?? 16.0; final fontWeight = tema?.fontWeight ?? FontWeight.w600; final strokeWidth = tema?.textStrokeWidth ?? 0.8; // Daha ince stroke final strokeColor = tema?.textStrokeColor ?? textColor.withOpacity(0.5); // Daha açık stroke rengi return TextButton( onLongPress: onLongPress, onPressed: route == null ? onPressed : () { onPressed?.call(); context.vRouter.to(route!); }, style: TextButtonTheme.of(context).style?.copyWith( alignment: tema?.align ?? Alignment.centerLeft, backgroundColor: WidgetStateProperty.all(tema?.backgroundColor), shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: tema?.borderRadius ?? BorderRadius.circular(tema?.radius ?? 15.0), side: BorderSide(color: tema?.borderColor ?? Colors.transparent), ), ), textStyle: WidgetStateProperty.all( TextStyle( shadows: tema?.textShadow ?? Theme.of(context).extension()?.textShadow, color: tema?.textColor ?? Theme.of(context).extension()?.textColor, fontSize: tema?.fontSize, fontWeight: tema?.fontWeight, ), ), // elevation: (tema?.elevation ?? 0) > 0 ? WidgetStateProperty.all(tema?.elevation ?? 0.0):null, // shadowColor: (tema?.elevation ?? 0) > 0 ? WidgetStateProperty.all(Theme.of(context).extension()?.shadowColor ?? Colors.black):null, ), child: text is String ? Padding( padding: tema?.edgePadding ?? EdgeInsets.zero, child: Stack( alignment: tema?.align ?? Alignment.centerLeft, children: [ // Hafif stroke efekti (Çok koyu olmaması için azaltıldı) Text( text, textAlign: tema?.textAlign, style: TextStyle( fontSize: fontSize, fontWeight: fontWeight, foreground: Paint() ..style = PaintingStyle.stroke ..strokeWidth = strokeWidth ..color = strokeColor, ), ), // Ana metin Text( text, textAlign: tema?.textAlign, style: TextStyle( fontSize: fontSize, fontWeight: fontWeight, color: textColor, shadows: textShadow, ), ), ], ), ) : text, ); } } class FikoYTIconButton extends StatefulWidget { FikoYTIconButton({ super.key, required this.text, this.onPressed, this.onLongPress, this.route, this.tema, this.icon, // Yeni eklenen ikon parametresi this.iconWidget, // Yeni eklenen ikon parametresi }); FikoYTButtonTheme? tema; final dynamic text; final String? route; final IconData? icon; // İkon desteği eklendi final Widget? iconWidget; // İkon desteği eklendi final VoidCallback? onPressed; final VoidCallback? onLongPress; @override State createState() => _FikoYTIconButtonState(); } class _FikoYTIconButtonState extends State with WidgetsBindingObserver { FikoYTButtonTheme? ilkTema; @override void initState() { super.initState(); ilkTema = widget.tema; WidgetsBinding.instance.addObserver(this); } @override void didChangePlatformBrightness() { super.didChangePlatformBrightness(); setState(() {}); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } @override Widget build(BuildContext context) { return TextButton( onLongPress: widget.onLongPress, onPressed: widget.route == null ? widget.onPressed : () { if (widget.onPressed != null) widget.onPressed!(); context.vRouter.to(widget.route!); }, style: TextButtonTheme.of(context).style?.copyWith( backgroundColor: WidgetStateProperty.all( widget.tema?.backgroundColor, ), textStyle: WidgetStateProperty.all( TextStyle( shadows: widget.tema?.textShadow ?? Theme.of(context).extension()?.textShadow, color: widget.tema?.textColor ?? Theme.of(context).extension()?.textColor, fontSize: widget.tema?.fontSize, fontWeight: widget.tema?.fontWeight, ), ), shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: widget.tema?.borderRadius ?? BorderRadius.all(Radius.circular(widget.tema?.radius ?? 15.0)), side: BorderSide( color: widget.tema?.borderColor ?? Colors.transparent, ), ), ), elevation: WidgetStateProperty.all(widget.tema?.elevation ?? 0.0), ), child: widget.text is String ? Padding( padding: widget.tema?.edgePadding ?? EdgeInsets.zero, child: Row( mainAxisSize: MainAxisSize.min, children: [ if (widget.iconWidget != null) widget.iconWidget! else if (widget.icon != null) // Eğer ikon varsa önce ekleyelim Icon( widget.icon, color: widget.tema?.textColor ?? Theme.of(context).extension()?.tertiaryTextColor, size: widget.tema?.fontSize ?? 16.0, shadows: widget.tema?.textShadow ?? Theme.of(context).extension()?.textShadow, ) else if (widget.icon != null) const SizedBox(width: 2), // Metin ve ikon arasında boşluk bırak Stack( children: [ Text( widget.text, textAlign: widget.tema?.textAlign, style: TextStyle( shadows: widget.tema?.textShadow ?? Theme.of(context).extension()?.textShadow, fontSize: widget.tema?.fontSize, fontWeight: widget.tema?.fontWeight, foreground: Paint() ..style = PaintingStyle.stroke ..strokeWidth = widget.tema?.textStrokeWidth ?? 1.0 ..color = widget.tema?.textStrokeColor ?? Colors.transparent, ), ), Text( widget.text, textAlign: widget.tema?.textAlign, style: TextStyle( shadows: widget.tema?.textShadow ?? Theme.of(context).extension()?.textShadow, color: widget.tema?.textColor ?? Theme.of(context).extension()?.textColor, fontSize: widget.tema?.fontSize, fontWeight: widget.tema?.fontWeight, ), ), ], ), ], ), ) : widget.text, ); } } class AnimatedFikoYTButton1 extends StatelessWidget { const AnimatedFikoYTButton1({ super.key, required this.text, this.onPressed, this.onLongPress, this.tema, }); final dynamic text; final FikoYTButtonTheme? tema; final VoidCallback? onPressed; final VoidCallback? onLongPress; @override Widget build(BuildContext context) { final theme = Theme.of(context).extension(); final textColor = tema?.textColor ?? theme?.textColor ?? Colors.white; final textShadow = tema?.textShadow ?? theme?.textShadow; final fontSize = tema?.fontSize ?? 16.0; final fontWeight = tema?.fontWeight ?? FontWeight.w600; final strokeWidth = tema?.textStrokeWidth ?? 0.8; // Daha ince stroke final strokeColor = tema?.textStrokeColor ?? textColor.withOpacity(0.5); // Daha açık stroke rengi return TextButton( onLongPress: onLongPress, onPressed: onPressed, style: TextButtonTheme.of(context).style?.copyWith( backgroundColor: WidgetStateProperty.all(tema?.backgroundColor ?? Colors.transparent), shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: tema?.borderRadius ?? BorderRadius.circular(15.0), side: BorderSide(color: tema?.borderColor ?? Colors.transparent), ), ),elevation: WidgetStateProperty.all(tema?.elevation ?? 0.0), ), child: AnimatedSwitcher( duration: tema?.animationDuration ?? const Duration(milliseconds: 750), transitionBuilder: (Widget child, Animation animation) { return FadeTransition( opacity: animation, child: child, ); }, child: text is String ? Padding( key: ValueKey(text), padding: tema?.edgePadding ?? EdgeInsets.zero, child: Stack( alignment: Alignment.center, children: [ // Hafif stroke efekti (Çok koyu olmaması için azaltıldı) Text( text, textAlign: tema?.textAlign, style: TextStyle( fontSize: fontSize, fontWeight: fontWeight, foreground: Paint() ..style = PaintingStyle.stroke ..strokeWidth = strokeWidth ..color = strokeColor, ), ), // Ana metin Text( text, textAlign: tema?.textAlign, style: TextStyle( fontSize: fontSize, fontWeight: fontWeight, color: textColor, shadows: textShadow, ), ), ], ), ) : text, ), ); } } /// class AnimatedNumberFikoYTButton1 extends StatefulWidget { AnimatedNumberFikoYTButton1({ super.key, required this.text, this.textBuilder, this.onPressed, this.onLongPress, this.tema, }); double? text; dynamic Function(double? tweenValue)? textBuilder; FikoYTButtonTheme? tema; ///---> final VoidCallback? onPressed; final VoidCallback? onLongPress; @override State createState() => _AnimatedNumberFikoYTButton1State(); } class _AnimatedNumberFikoYTButton1State extends State with WidgetsBindingObserver { late double? _oldText; // Eski text değeri FikoYTButtonTheme? ilkTema; @override void initState() { super.initState(); ilkTema = widget.tema; // widget.tema = FikoButtonTheme.karistir(FikoTheme.of(context).fikoButonTema, ilkTema ?? FikoTheme.of(context).fikoButonTema); _oldText = widget.text; } @override void didUpdateWidget(covariant AnimatedNumberFikoYTButton1 oldWidget) { super.didUpdateWidget(oldWidget); // Eğer widget'ın text değeri değiştiyse, eski değeri sakla if (oldWidget.text != widget.text) { _oldText = oldWidget.text; } } @override void didChangePlatformBrightness() { super.didChangePlatformBrightness(); setState(() { // print(FikoTheme.of(context).koyuMod); // widget.tema = FikoButtonTheme.karistir(FikoTheme.of(context).fikoButonTema, ilkTema ?? FikoTheme.of(context).fikoButonTema); }); } @override Widget build(BuildContext context) { return TweenAnimationBuilder( tween: Tween( begin: _oldText ?? 0.0, // Başlangıç değeri end: widget.text ?? 0.0, ), // Bitiş değeri duration: widget.tema?.animationDuration ?? const Duration(milliseconds: 750), // Animasyon süresi builder: (context, value, child) { return FikoYTButton( // key: ValueKey("${toplamBrutEkUcretler$.value?.toPrecision(2) ?? 0.0} TL"), text: widget.textBuilder != null ? widget.textBuilder!((value.isNaN || value.isInfinite) ? 0.0 : value) : "${(value.isNaN || value.isInfinite) ? 0 : value.toPrecision(2).toStringAsFixed(2)}", onPressed: widget.onPressed, onLongPress: widget.onLongPress, tema: widget.tema, ); }, ); } }