161 lines
4.9 KiB
Dart
161 lines
4.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.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,
|
|
});
|
|
|
|
final bool onlyTap;
|
|
final Function()? onTap;
|
|
|
|
@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: [
|
|
HelpImage.asset(ConstImage.homeTopLogo, width: 36),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Stack(
|
|
children: [
|
|
HelpImage.asset(ConstImage.searchBg, height: 36, fit: BoxFit.fill),
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 11),
|
|
child: Row(
|
|
children: [
|
|
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: BoxDecoration(),
|
|
placeholder: 'What are...... ',
|
|
placeholderStyle: TextStyle(
|
|
fontSize: 13,
|
|
color: Colors.white.withAlpha(127),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.white,
|
|
),
|
|
|
|
textInputAction: TextInputAction.search,
|
|
onEditingComplete: () {
|
|
|
|
},
|
|
),),
|
|
|
|
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,
|
|
});
|
|
|
|
final Function(String)? onClickSearch;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _SeSearchViewState();
|
|
}
|
|
}
|
|
|
|
class _SeSearchViewState extends State<SeSearchView> {
|
|
|
|
final _searchController = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: 44,
|
|
padding: EdgeInsets.only(top: 4, bottom: 4),
|
|
child: Stack(
|
|
children: [
|
|
HelpImage.asset(ConstImage.searchBg, height: 36, fit: BoxFit.fill),
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 11),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.search, color: Colors.white, size: 24),
|
|
|
|
Expanded(child: CupertinoTextField(
|
|
controller: _searchController,
|
|
// focusNode: widget.focusNode,
|
|
decoration: 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 (_searchController.text.trim().isNotEmpty) {
|
|
widget.onClickSearch?.call(_searchController.text);
|
|
}
|
|
},
|
|
),),
|
|
|
|
HelpImage.asset(ConstImage.homeSearch,
|
|
width: 78, height: 36, fit: BoxFit.fill
|
|
).addInkWell(onTap: () {
|
|
if (_searchController.text.trim().isNotEmpty) {
|
|
widget.onClickSearch?.call(_searchController.text);
|
|
}
|
|
})
|
|
|
|
],
|
|
),
|
|
)
|
|
],
|
|
)
|
|
);
|
|
}
|
|
} |