You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
3.5 KiB

8 months ago
import 'package:flutter/material.dart';
import 'package:supplier_new/common/settings.dart';
8 months ago
1 month ago
class SearchOrderAppBar extends StatefulWidget implements PreferredSizeWidget {
8 months ago
final TextEditingController controller;
final VoidCallback onBack;
final VoidCallback onHelp;
1 month ago
final Function(String)? onSearch;
8 months ago
const SearchOrderAppBar({
super.key,
required this.controller,
required this.onBack,
required this.onHelp,
1 month ago
required this.onSearch,
8 months ago
});
1 month ago
@override
State<SearchOrderAppBar> createState() => _SearchOrderAppBarState();
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
class _SearchOrderAppBarState extends State<SearchOrderAppBar>{
late VoidCallback _listener;
@override
void initState(){
super.initState();
_listener = (){
if(!mounted) return;
setState((){});
};
widget.controller.addListener(_listener);
}
@override
void dispose(){
widget.controller.removeListener(_listener);
super.dispose();
}
8 months ago
@override
Widget build(BuildContext context) {
1 month ago
8 months ago
return AppBar(
1 month ago
8 months ago
backgroundColor: Colors.white,
1 month ago
scrolledUnderElevation: 0,
1 month ago
8 months ago
elevation: 0,
1 month ago
leading: GestureDetector(
1 month ago
onTap: widget.onBack,
child: Padding(
1 month ago
padding: const EdgeInsets.all(8.0),
1 month ago
child: Image.asset(
1 month ago
'images/backbutton_appbar.png',
1 month ago
height: 24,
1 month ago
width: 24,
1 month ago
fit: BoxFit.contain,
1 month ago
),
1 month ago
),
1 month ago
8 months ago
),
1 month ago
8 months ago
titleSpacing: 0,
1 month ago
8 months ago
title: Container(
1 month ago
8 months ago
height: 40,
1 month ago
8 months ago
decoration: BoxDecoration(
1 month ago
8 months ago
color: Colors.white,
1 month ago
borderRadius: BorderRadius.circular(22),
1 month ago
border: Border.all(color: const Color(0XFF939495)),
1 month ago
8 months ago
),
1 month ago
8 months ago
child: TextField(
1 month ago
controller: widget.controller,
onChanged: widget.onSearch,
decoration: InputDecoration(
1 month ago
8 months ago
hintText: "Search order",
1 month ago
hintStyle: fontTextStyle(
1 month ago
16,
1 month ago
const Color(0XFF646566),
1 month ago
FontWeight.w400,
1 month ago
),
1 month ago
prefixIcon: SizedBox(
1 month ago
height: 20,
1 month ago
width: 20,
1 month ago
child: Padding(
1 month ago
padding: const EdgeInsets.all(8.0),
1 month ago
child: Image.asset(
1 month ago
'images/search.png',
1 month ago
fit: BoxFit.contain,
1 month ago
),
1 month ago
),
1 month ago
),
1 month ago
/// ⭐ CLEAR BUTTON ADDED HERE
suffixIcon: widget.controller.text.isNotEmpty
? IconButton(
icon: const Icon(
Icons.close,
size:18,
color: Color(0XFF646566)
),
onPressed: (){
widget.controller.clear();
},
)
: null,
8 months ago
border: InputBorder.none,
1 month ago
contentPadding: const EdgeInsets.symmetric(vertical: 0),
1 month ago
8 months ago
),
1 month ago
style: fontTextStyle(
1 month ago
16,
1 month ago
const Color(0XFF2A2A2A),
1 month ago
FontWeight.w400,
1 month ago
),
1 month ago
8 months ago
),
1 month ago
8 months ago
),
1 month ago
actions: [
1 month ago
Padding(
1 month ago
padding: const EdgeInsets.all(8.0),
1 month ago
child: GestureDetector(
1 month ago
onTap: widget.onHelp,
child: Image.asset(
1 month ago
'images/help_appbar.png',
1 month ago
height: 24,
1 month ago
width: 24,
1 month ago
fit: BoxFit.contain,
1 month ago
),
1 month ago
),
1 month ago
),
1 month ago
8 months ago
],
1 month ago
8 months ago
);
1 month ago
8 months ago
}
1 month ago
}