From 45649ca352c8ca653cebed23ee5ccb950723f217 Mon Sep 17 00:00:00 2001 From: MohammadTaha Basiri Date: Tue, 11 Jan 2022 15:56:35 +0330 Subject: [PATCH] structuring --- .../profile/edit_profile/widgets/switch.dart | 54 ------------ .../home/radar/widgets/search_field.dart | 83 ------------------- 2 files changed, 137 deletions(-) delete mode 100644 lib/pages/home/profile/edit_profile/widgets/switch.dart delete mode 100644 lib/pages/home/radar/widgets/search_field.dart diff --git a/lib/pages/home/profile/edit_profile/widgets/switch.dart b/lib/pages/home/profile/edit_profile/widgets/switch.dart deleted file mode 100644 index d122ef4..0000000 --- a/lib/pages/home/profile/edit_profile/widgets/switch.dart +++ /dev/null @@ -1,54 +0,0 @@ -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/pages/home/radar/widgets/search_field.dart b/lib/pages/home/radar/widgets/search_field.dart deleted file mode 100644 index 719a3f2..0000000 --- a/lib/pages/home/radar/widgets/search_field.dart +++ /dev/null @@ -1,83 +0,0 @@ -import 'package:didvan/config/theme_data.dart'; -import 'package:didvan/constants/app_icons.dart'; -import 'package:flutter/material.dart'; - -class SearchField extends StatefulWidget { - final String title; - final void Function(String value) onChanged; - - const SearchField({Key? key, required this.title, required this.onChanged}) - : 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 Container( - height: 40, - 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), - ), - ), - ); - } - - Color _fillColor() { - if (_focusNode.hasFocus) { - return Theme.of(context).colorScheme.surface; - } - return Theme.of(context).colorScheme.surface; - } -}