diff --git a/lib/widgets/date_picker_button.dart b/lib/widgets/date_picker_button.dart index 5a7366f..a2ac7f7 100644 --- a/lib/widgets/date_picker_button.dart +++ b/lib/widgets/date_picker_button.dart @@ -52,7 +52,9 @@ class _DatePickerButtonState extends State { child: Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.splash, + color: DesignConfig.brightness == Brightness.dark + ? Theme.of(context).colorScheme.splash + : Theme.of(context).colorScheme.surface, borderRadius: DesignConfig.lowBorderRadius, border: Border.all(color: Theme.of(context).colorScheme.border), ), diff --git a/lib/widgets/didvan/button.dart b/lib/widgets/didvan/button.dart index d85f01e..bed38e0 100644 --- a/lib/widgets/didvan/button.dart +++ b/lib/widgets/didvan/button.dart @@ -39,8 +39,11 @@ class DidvanButton extends StatelessWidget { height: 48, width: double.infinity, child: MaterialButton( - shape: const RoundedRectangleBorder( + shape: RoundedRectangleBorder( borderRadius: DesignConfig.lowBorderRadius, + side: style == ButtonStyleMode.flat + ? BorderSide(color: foregroundColor) + : BorderSide.none, ), color: backgroundColor, onPressed: () { diff --git a/lib/widgets/didvan/switch.dart b/lib/widgets/didvan/switch.dart new file mode 100644 index 0000000..d122ef4 --- /dev/null +++ b/lib/widgets/didvan/switch.dart @@ -0,0 +1,54 @@ +import 'package:didvan/pages/home/profile/widgets/menu_item.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class DidvanSwitch extends StatefulWidget { + final bool value; + final String title; + final IconData? icon; + final void Function(bool value) onChanged; + const DidvanSwitch({ + Key? key, + required this.value, + required this.title, + this.icon, + required this.onChanged, + }) : super(key: key); + + @override + _DidvanSwitchState createState() => _DidvanSwitchState(); +} + +class _DidvanSwitchState extends State { + bool _value = false; + + @override + void initState() { + _value = widget.value; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MenuItem( + title: widget.title, + onTap: () { + setState( + () => _value = !_value, + ); + widget.onChanged(_value); + }, + icon: widget.icon, + trailing: CupertinoSwitch( + activeColor: Theme.of(context).colorScheme.primary, + value: _value, + onChanged: (value) { + setState(() { + _value = value; + }); + widget.onChanged(value); + }, + ), + ); + } +} diff --git a/lib/widgets/search_field.dart b/lib/widgets/search_field.dart new file mode 100644 index 0000000..006bc3c --- /dev/null +++ b/lib/widgets/search_field.dart @@ -0,0 +1,105 @@ +import 'package:didvan/config/theme_data.dart'; +import 'package:didvan/constants/app_icons.dart'; +import 'package:didvan/widgets/didvan/icon_button.dart'; +import 'package:flutter/material.dart'; + +class SearchField extends StatefulWidget { + final String title; + final void Function(String value) onChanged; + final VoidCallback? onFilterButtonPressed; + + const SearchField({ + Key? key, + required this.title, + required this.onChanged, + this.onFilterButtonPressed, + }) : super(key: key); + + @override + State createState() => _SearchFieldState(); +} + +class _SearchFieldState extends State { + final FocusNode _focusNode = FocusNode(); + + @override + void initState() { + _focusNode.addListener(() { + setState(() {}); + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 40, + child: Row( + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + color: _fillColor(), + ), + child: TextField( + focusNode: _focusNode, + style: Theme.of(context).textTheme.bodyText1, + textAlignVertical: TextAlignVertical.center, + onChanged: widget.onChanged, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.search, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderRadius: const BorderRadius.all( + Radius.circular(4), + ), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + ), + prefixIcon: Icon( + DidvanIcons.search_regular, + color: Theme.of(context).colorScheme.text, + ), + prefixIconColor: Theme.of(context).colorScheme.inputText, + enabledBorder: OutlineInputBorder( + borderRadius: const BorderRadius.all( + Radius.circular(4), + ), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.border, + ), + ), + fillColor: Colors.red, + contentPadding: const EdgeInsets.only( + left: 12, + right: 12, + ), + border: InputBorder.none, + hintText: 'جستجو مطلب در ${widget.title}', + hintStyle: TextStyle( + color: Theme.of(context).colorScheme.disabledText), + ), + ), + ), + ), + if (widget.onFilterButtonPressed != null) const SizedBox(width: 8), + if (widget.onFilterButtonPressed != null) + DidvanIconButton( + onPressed: widget.onFilterButtonPressed!, + icon: DidvanIcons.filter_regular, + size: 32, + gestureSize: 32, + ), + ], + ), + ); + } + + Color _fillColor() { + if (_focusNode.hasFocus) { + return Theme.of(context).colorScheme.surface; + } + return Theme.of(context).colorScheme.surface; + } +} diff --git a/lib/widgets/skeletun_image.dart b/lib/widgets/skeletun_image.dart index ce77323..6699973 100644 --- a/lib/widgets/skeletun_image.dart +++ b/lib/widgets/skeletun_image.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:didvan/config/design_config.dart'; import 'package:didvan/config/theme_data.dart'; +import 'package:didvan/services/network/request.dart'; import 'package:flutter/material.dart'; import 'package:skeleton_text/skeleton_text.dart'; @@ -20,6 +21,7 @@ class SkeletonImage extends StatelessWidget { @override Widget build(BuildContext context) { return CachedNetworkImage( + httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'}, width: width, height: height, imageUrl: imageUrl,