diff --git a/packages/design_system/lib/src/buttons/custom_text_button.dart b/packages/design_system/lib/src/buttons/custom_text_button.dart index 7288fc73..9ecb0732 100644 --- a/packages/design_system/lib/src/buttons/custom_text_button.dart +++ b/packages/design_system/lib/src/buttons/custom_text_button.dart @@ -1,28 +1,27 @@ import 'package:flutter/material.dart'; -class CustomTextButton extends StatelessWidget{ - - final onPressed; +class CustomTextButton extends StatelessWidget { + final VoidCallback onPressed; final String text; final double size; final FontWeight weight; final Color? color; - @override const CustomTextButton({ super.key, required this.onPressed, required this.text, this.size = 14, this.weight = FontWeight.normal, - this.color + this.color, }); @override Widget build(BuildContext context) { - return TextButton( - style: ButtonStyle(padding: WidgetStatePropertyAll(EdgeInsets.zero)), + style: const ButtonStyle( + padding: WidgetStatePropertyAll(EdgeInsets.zero), + ), onPressed: onPressed, child: Text( text, @@ -30,10 +29,10 @@ class CustomTextButton extends StatelessWidget{ fontSize: size, fontWeight: weight, letterSpacing: 0, - color: color?? Color(0xFF4B4B4B), - decoration: TextDecoration.underline + color: color ?? const Color(0xFF4B4B4B), + decoration: TextDecoration.underline, ), - ) + ), ); } -} \ No newline at end of file +} diff --git a/packages/design_system/lib/src/buttons/primary_button.dart b/packages/design_system/lib/src/buttons/primary_button.dart index b3d48880..38149989 100644 --- a/packages/design_system/lib/src/buttons/primary_button.dart +++ b/packages/design_system/lib/src/buttons/primary_button.dart @@ -1,9 +1,7 @@ -import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -class PrimaryButton extends StatelessWidget{ - final onPressed; +class PrimaryButton extends StatelessWidget { + final VoidCallback onPressed; final String text; final Color color; final double height; @@ -12,7 +10,8 @@ class PrimaryButton extends StatelessWidget{ final double radius; final double padding; - PrimaryButton({ + const PrimaryButton({ + super.key, required this.onPressed, required this.text, required this.color, @@ -25,30 +24,35 @@ class PrimaryButton extends StatelessWidget{ @override Widget build(BuildContext context) { - return FilledButton( style: ButtonStyle( backgroundColor: WidgetStatePropertyAll(color), - padding: WidgetStatePropertyAll(EdgeInsets.symmetric(horizontal: padding)), - shape: WidgetStatePropertyAll(RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(radius)), - )), + padding: WidgetStatePropertyAll( + EdgeInsets.symmetric(horizontal: padding), + ), + shape: WidgetStatePropertyAll( + RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(radius)), + ), + ), ), onPressed: onPressed, child: SizedBox( width: width, height: height, - child: Center(child: Text( - text, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: size, - fontWeight: FontWeight.w500, - letterSpacing: 0, - color: Colors.white//theme.getColorFor(ThemeCode.textSecondary) - ) - )) - ) + child: Center( + child: Text( + text, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: size, + fontWeight: FontWeight.w500, + letterSpacing: 0, + color: Colors.white, // theme.getColorFor(ThemeCode.textSecondary) + ), + ), + ), + ), ); } -} \ No newline at end of file +} diff --git a/packages/design_system/lib/src/buttons/secondary_button.dart b/packages/design_system/lib/src/buttons/secondary_button.dart index ce360713..8bb07c8b 100644 --- a/packages/design_system/lib/src/buttons/secondary_button.dart +++ b/packages/design_system/lib/src/buttons/secondary_button.dart @@ -1,10 +1,7 @@ -import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; class SecondaryButton extends StatelessWidget { - - final onPressed; + final VoidCallback onPressed; final String? text; final IconData? icon; final String? label; @@ -15,8 +12,8 @@ class SecondaryButton extends StatelessWidget { final double? width; final double? size; - @override - SecondaryButton({ + const SecondaryButton({ + super.key, required this.onPressed, this.text, this.icon, @@ -31,37 +28,43 @@ class SecondaryButton extends StatelessWidget { @override Widget build(BuildContext context) { - return OutlinedButton( style: ButtonStyle( - padding: WidgetStatePropertyAll(EdgeInsets.symmetric(horizontal: padding)), - shape: WidgetStatePropertyAll(RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(radius)), - side: BorderSide(color: Color(0xFF4B4B4B)) - )), + padding: WidgetStatePropertyAll( + EdgeInsets.symmetric(horizontal: padding), + ), + shape: WidgetStatePropertyAll( + RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(radius)), + side: BorderSide(color: Color(0xFF4B4B4B)), + ), + ), ), onPressed: onPressed, child: SizedBox( width: width, height: height, - child: Center(child: text!=null ? Text( - text!, - textAlign: TextAlign.center, - semanticsLabel: label, - style: TextStyle( - fontSize: size ?? 18, - fontWeight: FontWeight.w500, - letterSpacing: 0, - color: Color(0xFF4B4B4B) - ) - ) : Icon( - icon, - semanticLabel: label, - size: size ?? 24, - color: color ?? Color(0xFF4B4B4B) - )) - ) + child: Center( + child: text != null + ? Text( + text!, + textAlign: TextAlign.center, + semanticsLabel: label, + style: TextStyle( + fontSize: size ?? 18, + fontWeight: FontWeight.w500, + letterSpacing: 0, + color: Color(0xFF4B4B4B), + ), + ) + : Icon( + icon, + semanticLabel: label, + size: size ?? 24, + color: color ?? Color(0xFF4B4B4B), + ), + ), + ), ); } - -} \ No newline at end of file +} diff --git a/packages/design_system/lib/src/dropdowns/dropdown.dart b/packages/design_system/lib/src/dropdowns/dropdown.dart index 53324997..1c27311b 100644 --- a/packages/design_system/lib/src/dropdowns/dropdown.dart +++ b/packages/design_system/lib/src/dropdowns/dropdown.dart @@ -1,12 +1,10 @@ -import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -class CustomDropdown extends StatelessWidget{ +class CustomDropdown extends StatelessWidget { final List items; - final values; - final onChanged; - final value; + final List? values; + final ValueChanged onChanged; + final dynamic value; final String? hint; final String? label; final double radius; @@ -25,43 +23,54 @@ class CustomDropdown extends StatelessWidget{ this.radius = 12, this.width = double.infinity, this.height = 70, - this.color + this.color, }); @override Widget build(BuildContext context) { - return Column( spacing: 8, children: [ - if (label != null) Align( - alignment: Alignment.bottomLeft, - child: Text( - label!, - style: TextStyle(fontSize: 14, letterSpacing: 0), + if (label != null) + Align( + alignment: Alignment.bottomLeft, + child: Text( + label!, + style: const TextStyle(fontSize: 14, letterSpacing: 0), + ), ), - ), SizedBox( width: width, height: height, - child: Center(child: DropdownButtonFormField( - dropdownColor: Colors.white, - decoration: InputDecoration( - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(radius)), - borderSide: BorderSide(color: color??Color(0xFF4B4B4B)) - ) + child: Center( + child: DropdownButtonFormField( + dropdownColor: Colors.white, + decoration: InputDecoration( + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(radius)), + borderSide: BorderSide( + color: color ?? const Color(0xFF4B4B4B), + ), + ), + ), + initialValue: value, + onChanged: onChanged, + hint: hint != null ? Text(hint!) : null, + items: List>.generate(items.length, ( + int index, + ) { + final dynamic itemValue = values != null + ? values![index] + : index; + return DropdownMenuItem( + value: itemValue, + child: items[index], + ); + }), ), - //underline: Container(), - initialValue: value, - onChanged: onChanged, - hint: Text(hint??""), - items: List.generate(items.length, (int index){ - return DropdownMenuItem(value: (values!=null)?values[index]:index, child: items[index]); - }) - )), - ) + ), + ), ], - ) ; + ); } -} \ No newline at end of file +} diff --git a/packages/design_system/lib/src/inputs/textfields.dart b/packages/design_system/lib/src/inputs/textfields.dart index 40e36508..0b2eb6fc 100644 --- a/packages/design_system/lib/src/inputs/textfields.dart +++ b/packages/design_system/lib/src/inputs/textfields.dart @@ -1,10 +1,8 @@ -import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -class CustomTextField extends StatefulWidget{ - bool? showPassword; +class CustomTextField extends StatefulWidget { + final bool? showPassword; final bool numeric; final String hint; final String label; @@ -12,7 +10,7 @@ class CustomTextField extends StatefulWidget{ final ValueChanged? onChanged; final int? length; - CustomTextField({ + const CustomTextField({ super.key, this.showPassword, this.numeric = false, @@ -27,57 +25,65 @@ class CustomTextField extends StatefulWidget{ State createState() => CustomTextFieldState(); } -class CustomTextFieldState extends State{ +class CustomTextFieldState extends State { + late bool _showPassword; + @override + void initState() { + super.initState(); + _showPassword = widget.showPassword ?? true; + } @override Widget build(BuildContext context) { - return Column( spacing: 8, children: [ - ?widget.label == '' ? null : Align( - alignment: Alignment.bottomLeft, - child: Text( - widget.label, - style: TextStyle(fontSize: 14, letterSpacing: 0), - ) - ), + if (widget.label.isNotEmpty) + Align( + alignment: Alignment.bottomLeft, + child: Text( + widget.label, + style: const TextStyle(fontSize: 14, letterSpacing: 0), + ), + ), TextFormField( - keyboardType: widget.numeric? TextInputType.number : TextInputType.text, - obscureText: !(widget.showPassword ?? true), - enableSuggestions: widget.showPassword ?? true, - autocorrect: !(widget.showPassword ?? false), - style: TextStyle(color: Color(0xFF4B4B4B)), - inputFormatters: widget.numeric? [ - FilteringTextInputFormatter.digitsOnly - ] : [], + keyboardType: widget.numeric + ? TextInputType.number + : TextInputType.text, + obscureText: !_showPassword, + enableSuggestions: _showPassword, + autocorrect: !_showPassword, + style: const TextStyle(color: Color(0xFF4B4B4B)), + inputFormatters: widget.numeric + ? [FilteringTextInputFormatter.digitsOnly] + : const [], decoration: InputDecoration( counterText: "", hintText: widget.hint, - //labelText: widget.label, - //floatingLabelBehavior: FloatingLabelBehavior.always, - border: OutlineInputBorder( + border: const OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(12)), borderSide: BorderSide(color: Color(0xFF4B4B4B)), - gapPadding: 16 + gapPadding: 16, ), - suffixIcon: widget.showPassword!=null ? IconButton( - icon: Icon(widget.showPassword! - ? Icons.visibility_off - : Icons.visibility), - onPressed: () { - setState(() { - widget.showPassword = !widget.showPassword!; - }); - }, - ) : null, + suffixIcon: widget.showPassword != null + ? IconButton( + icon: Icon( + _showPassword ? Icons.visibility_off : Icons.visibility, + ), + onPressed: () { + setState(() { + _showPassword = !_showPassword; + }); + }, + ) + : null, ), minLines: widget.lines ?? 1, maxLines: widget.lines ?? 1, maxLength: widget.length, - onChanged: widget.onChanged ?? (_)=>{}, - ) + onChanged: widget.onChanged, + ), ], ); } -} \ No newline at end of file +} diff --git a/packages/design_system/lib/src/progress_bars/progress_bar.dart b/packages/design_system/lib/src/progress_bars/progress_bar.dart index e4434ec3..4ffa216c 100644 --- a/packages/design_system/lib/src/progress_bars/progress_bar.dart +++ b/packages/design_system/lib/src/progress_bars/progress_bar.dart @@ -2,7 +2,7 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -class ProgressBar extends ConsumerWidget{ +class ProgressBar extends ConsumerWidget { final double max; final double value; final double height; @@ -13,6 +13,7 @@ class ProgressBar extends ConsumerWidget{ final Color textColor; const ProgressBar({ + super.key, required this.max, required this.value, required this.height, @@ -20,21 +21,19 @@ class ProgressBar extends ConsumerWidget{ required this.textSecondarySize, required this.backgroundColor, required this.foregroundColor, - required this.textColor,} - ); + required this.textColor, + }); @override Widget build(BuildContext context, WidgetRef ref) { - - return - Stack( - children: [ - LinearProgressIndicator( + return Stack( + children: [ + LinearProgressIndicator( value: value / max, minHeight: height, borderRadius: BorderRadius.all(Radius.circular(24)), color: foregroundColor, - backgroundColor: backgroundColor + backgroundColor: backgroundColor, ), FractionallySizedBox( widthFactor: value / max, @@ -47,10 +46,10 @@ class ProgressBar extends ConsumerWidget{ secondarySize: textSecondarySize, color: textColor, ), - ) + ), ), ), - ] + ], ); } -} \ No newline at end of file +} diff --git a/packages/design_system/lib/src/snackbars/snackbar.dart b/packages/design_system/lib/src/snackbars/snackbar.dart index e4a2c9c1..7496663d 100644 --- a/packages/design_system/lib/src/snackbars/snackbar.dart +++ b/packages/design_system/lib/src/snackbars/snackbar.dart @@ -1,32 +1,20 @@ -import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -enum MessageType { - info, - error, - warning, - success -} +enum MessageType { info, error, warning, success } -class CustomSnackBar extends StatelessWidget{ +class CustomSnackBar extends StatelessWidget { final MessageType? type; final String message; - const CustomSnackBar({ - super.key, - this.type, - required this.message, - }); + const CustomSnackBar({super.key, this.type, required this.message}); @override SnackBar build(BuildContext context) { - late final Color foregroundColor; late final Color backgroundColor; late final IconData icon; - switch (type??MessageType.info){ + switch (type ?? MessageType.info) { case MessageType.info: backgroundColor = Color(0xFFE3EFFD); foregroundColor = Color(0xFF1F4ECF); @@ -50,15 +38,20 @@ class CustomSnackBar extends StatelessWidget{ backgroundColor: backgroundColor, shape: RoundedRectangleBorder( side: BorderSide(color: foregroundColor, width: 1), - borderRadius: BorderRadius.all(Radius.circular(10)) + borderRadius: BorderRadius.all(Radius.circular(10)), ), content: Row( spacing: 8, children: [ Icon(icon, color: foregroundColor), - Expanded(child: Text(message, style: TextStyle(color: Color(0xFF4B4B4B), fontSize: 14))) - ], - ), + Expanded( + child: Text( + message, + style: TextStyle(color: Color(0xFF4B4B4B), fontSize: 14), + ), + ), + ], + ), ); } -} \ No newline at end of file +}