213 lines
6.5 KiB
Dart
213 lines
6.5 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:novyronst/root/lib_export.dart';
|
|
import 'package:novyronst/tools/widgets/extend_widget.dart';
|
|
import 'package:novyronst/tools/widgets/novy_com_widget.dart';
|
|
|
|
class HomeSearchView extends StatefulWidget {
|
|
const HomeSearchView({
|
|
super.key,
|
|
this.onlyTap = false,
|
|
this.onTap,
|
|
this.showLogo = true,
|
|
});
|
|
|
|
final bool onlyTap;
|
|
final Function()? onTap;
|
|
final bool showLogo;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _SearchViewState();
|
|
}
|
|
}
|
|
|
|
class _SearchViewState extends State<HomeSearchView> {
|
|
final _searchController = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: AppScreen.navBarHeight,
|
|
padding: EdgeInsets.only(
|
|
top: AppScreen.statusBarHeight,
|
|
left: 16,
|
|
right: 16,
|
|
bottom: 5,
|
|
),
|
|
child: SizedBox(
|
|
height: 36,
|
|
child: Row(
|
|
children: [
|
|
if (widget.showLogo) ...[
|
|
HelpImage.asset(ConstImage.homeTopLogo, width: 36),
|
|
const SizedBox(width: 16),
|
|
],
|
|
Expanded(
|
|
child: SizedBox(
|
|
height: 36,
|
|
child: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Positioned.fill(
|
|
child: HelpImage.asset(
|
|
ConstImage.searchBg,
|
|
height: 36,
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 11, right: 78),
|
|
child: Row(
|
|
children: [
|
|
const Icon(
|
|
Icons.search,
|
|
color: Colors.white,
|
|
size: 24,
|
|
),
|
|
|
|
Expanded(
|
|
child: widget.onlyTap
|
|
? NovyText(
|
|
'What are...... ',
|
|
fontSize: 13,
|
|
color: Colors.white.withAlpha(127),
|
|
)
|
|
: CupertinoTextField(
|
|
controller: _searchController,
|
|
// focusNode: widget.focusNode,
|
|
decoration: const BoxDecoration(),
|
|
placeholder: 'What are...... ',
|
|
placeholderStyle: TextStyle(
|
|
fontSize: 13,
|
|
color: Colors.white.withAlpha(127),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.white,
|
|
),
|
|
|
|
textInputAction: TextInputAction.search,
|
|
onEditingComplete: () {},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
child: HelpImage.asset(
|
|
ConstImage.homeSearch,
|
|
width: 78,
|
|
height: 36,
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
).addInkWell(onTap: widget.onlyTap ? widget.onTap : null);
|
|
}
|
|
}
|
|
|
|
/// 搜索页面的搜索框
|
|
class SeSearchView extends StatefulWidget {
|
|
const SeSearchView({
|
|
super.key,
|
|
this.onClickSearch,
|
|
required this.controller,
|
|
this.focusNode,
|
|
});
|
|
|
|
final Function(String)? onClickSearch;
|
|
final TextEditingController controller;
|
|
final FocusNode? focusNode;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _SeSearchViewState();
|
|
}
|
|
}
|
|
|
|
class _SeSearchViewState extends State<SeSearchView> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: 44,
|
|
padding: const EdgeInsets.only(top: 4, bottom: 4),
|
|
child: SizedBox(
|
|
height: 36,
|
|
child: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Positioned.fill(
|
|
child: HelpImage.asset(
|
|
ConstImage.searchBg,
|
|
height: 36,
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 11, right: 78),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.search, color: Colors.white, size: 24),
|
|
|
|
Expanded(
|
|
child: CupertinoTextField(
|
|
controller: widget.controller,
|
|
focusNode: widget.focusNode,
|
|
decoration: const BoxDecoration(),
|
|
placeholder: 'What are...... ',
|
|
placeholderStyle: TextStyle(
|
|
fontSize: 13,
|
|
color: Colors.white.withAlpha(127),
|
|
),
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
textInputAction: TextInputAction.search,
|
|
onEditingComplete: () {
|
|
if (widget.controller.text.trim().isNotEmpty) {
|
|
widget.onClickSearch?.call(widget.controller.text);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
child:
|
|
HelpImage.asset(
|
|
ConstImage.homeSearch,
|
|
width: 78,
|
|
height: 36,
|
|
fit: BoxFit.fill,
|
|
).addInkWell(
|
|
onTap: () {
|
|
if (widget.controller.text.trim().isNotEmpty) {
|
|
widget.onClickSearch?.call(widget.controller.text);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|