component updates
This commit is contained in:
parent
be7939ad7f
commit
0e7682c18f
|
|
@ -52,7 +52,9 @@ class _DatePickerButtonState extends State<DatePickerButton> {
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
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,
|
borderRadius: DesignConfig.lowBorderRadius,
|
||||||
border: Border.all(color: Theme.of(context).colorScheme.border),
|
border: Border.all(color: Theme.of(context).colorScheme.border),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,11 @@ class DidvanButton extends StatelessWidget {
|
||||||
height: 48,
|
height: 48,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: MaterialButton(
|
child: MaterialButton(
|
||||||
shape: const RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: DesignConfig.lowBorderRadius,
|
borderRadius: DesignConfig.lowBorderRadius,
|
||||||
|
side: style == ButtonStyleMode.flat
|
||||||
|
? BorderSide(color: foregroundColor)
|
||||||
|
: BorderSide.none,
|
||||||
),
|
),
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
|
|
@ -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<DidvanSwitch> {
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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<SearchField> createState() => _SearchFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchFieldState extends State<SearchField> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:didvan/config/design_config.dart';
|
import 'package:didvan/config/design_config.dart';
|
||||||
import 'package:didvan/config/theme_data.dart';
|
import 'package:didvan/config/theme_data.dart';
|
||||||
|
import 'package:didvan/services/network/request.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:skeleton_text/skeleton_text.dart';
|
import 'package:skeleton_text/skeleton_text.dart';
|
||||||
|
|
||||||
|
|
@ -20,6 +21,7 @@ class SkeletonImage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CachedNetworkImage(
|
return CachedNetworkImage(
|
||||||
|
httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'},
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue