home_page.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:canteen/pages/food_list_page.dart';
  2. import 'package:canteen/views/campus_listview.dart';
  3. import 'package:flutter/material.dart';
  4. /// Description: 主页
  5. /// Time : 07/25/2022 Monday
  6. /// Author : liuyuqi.gov@msn.cn
  7. class HomePage extends StatefulWidget {
  8. const HomePage({Key? key}) : super(key: key);
  9. @override
  10. State<HomePage> createState() => HomePageState();
  11. }
  12. class HomePageState extends State<HomePage> {
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. /// 标题栏
  17. appBar: AppBar(
  18. title: const Text("食堂菜谱"),
  19. leading: Builder(
  20. builder: (context) {
  21. ///返回按钮
  22. return IconButton(
  23. icon: const Icon(Icons.arrow_back, color: Colors.white),
  24. onPressed: () {
  25. Navigator.pop(context);
  26. },
  27. );
  28. },
  29. ),
  30. ),
  31. body: Container(
  32. color: Colors.white,
  33. child: Column(
  34. children: [
  35. /// 输入框栏
  36. Row(children: [
  37. Expanded(
  38. child: Container(
  39. margin: const EdgeInsets.fromLTRB(15, 10, 15, 10),
  40. padding: const EdgeInsets.fromLTRB(15, 0, 0, 0),
  41. child: TextField(
  42. decoration: InputDecoration(
  43. hintText: "请输入查询内容",
  44. prefixIcon: Row(children: [
  45. Icon(Icons.search,
  46. color: Theme.of(context).primaryColor),
  47. Icon(Icons.keyboard_arrow_down,
  48. color: Theme.of(context).primaryColor)
  49. ]),
  50. border: InputBorder.none),
  51. focusNode: () {
  52. var focusNode = FocusNode();
  53. focusNode.addListener(() {
  54. if (focusNode.hasFocus) {
  55. focusNode.unfocus();
  56. //跳转至搜索页面
  57. // Navigator.push(context, route);
  58. }
  59. });
  60. return focusNode;
  61. }(),
  62. ),
  63. decoration: const BoxDecoration(
  64. color: Color(0xFFF0F0F0),
  65. borderRadius: BorderRadius.all(Radius.circular(1e18)),
  66. ),
  67. )),
  68. IconButton(
  69. icon: Icon(Icons.star_border,
  70. color: Theme.of(context).primaryColor),
  71. onPressed: () {
  72. //此处应当跳转至收藏页面
  73. Navigator.of(context)
  74. .push(MaterialPageRoute(builder: (context) {
  75. return FoodListPage();
  76. }));
  77. },
  78. )
  79. ]),
  80. CampusListView()
  81. ],
  82. ),
  83. ),
  84. );
  85. }
  86. }