|
|
|
|
|
|
|
|
|
|
|
import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; |
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
import 'package:farm_tpf/utils/const_string.dart'; |
|
|
import 'package:farm_tpf/utils/const_string.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _PlotActionScreenState extends State<PlotActionScreen> { |
|
|
class _PlotActionScreenState extends State<PlotActionScreen> { |
|
|
List<ActionType> actions = new List<ActionType>(); |
|
|
List<ActionType> actions = new List<ActionType>(); |
|
|
|
|
|
ScrollController _scrollController; |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
void initState() { |
|
|
void initState() { |
|
|
super.initState(); |
|
|
super.initState(); |
|
|
actions.add(ActionType(plot_action_nursery, null, null)); |
|
|
|
|
|
|
|
|
_scrollController = ScrollController()..addListener(() => setState(() {})); |
|
|
|
|
|
_initActionButtons(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_initActionButtons() { |
|
|
|
|
|
actions.add(ActionType(plot_action_nursery, null, PlotListScreen())); |
|
|
actions.add(ActionType(plot_action_plant, null, null)); |
|
|
actions.add(ActionType(plot_action_plant, null, null)); |
|
|
actions.add(ActionType(plot_action_crop_status, null, null)); |
|
|
actions.add(ActionType(plot_action_crop_status, null, null)); |
|
|
actions.add(ActionType(plot_action_environment_update, null, null)); |
|
|
actions.add(ActionType(plot_action_environment_update, null, null)); |
|
|
|
|
|
|
|
|
actions.add(ActionType(plot_action_finish, null, null)); |
|
|
actions.add(ActionType(plot_action_finish, null, null)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _createShrimpUpdate(ActionType actionType) { |
|
|
|
|
|
|
|
|
Widget _createActionButtons(ActionType actionType) { |
|
|
return GestureDetector( |
|
|
return GestureDetector( |
|
|
onTap: () { |
|
|
onTap: () { |
|
|
Navigator.of(context).push( |
|
|
Navigator.of(context).push( |
|
|
|
|
|
|
|
|
textAlign: TextAlign.center, |
|
|
textAlign: TextAlign.center, |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontWeight: FontWeight.w400, |
|
|
fontWeight: FontWeight.w400, |
|
|
fontSize: 16, |
|
|
|
|
|
|
|
|
fontSize: 13, |
|
|
color: COLOR_CONST.BLACK2, |
|
|
color: COLOR_CONST.BLACK2, |
|
|
), |
|
|
), |
|
|
)), |
|
|
)), |
|
|
|
|
|
|
|
|
)); |
|
|
)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool _showTitle(BuildContext context) { |
|
|
|
|
|
var kExpandedHeight = MediaQuery.of(context).size.width * 1.125 + 32; |
|
|
|
|
|
return _scrollController.hasClients && |
|
|
|
|
|
_scrollController.offset > kExpandedHeight - kToolbarHeight; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
return Scaffold( |
|
|
|
|
|
body: GridView.count( |
|
|
|
|
|
crossAxisCount: 2, |
|
|
|
|
|
childAspectRatio: 16 / 6, |
|
|
|
|
|
children: actions.map( |
|
|
|
|
|
(item) { |
|
|
|
|
|
return _createShrimpUpdate(item); |
|
|
|
|
|
}, |
|
|
|
|
|
).toList()), |
|
|
|
|
|
|
|
|
return NestedScrollView( |
|
|
|
|
|
controller: _scrollController, |
|
|
|
|
|
headerSliverBuilder: (context, innerBoxScrolled) => [ |
|
|
|
|
|
SliverAppBar( |
|
|
|
|
|
floating: false, |
|
|
|
|
|
pinned: true, |
|
|
|
|
|
backgroundColor: Colors.white, |
|
|
|
|
|
leading: Container(), |
|
|
|
|
|
title: _showTitle(context) ? Text(plot_detail_title) : null, |
|
|
|
|
|
//Height flexibleSpace : WidthScreen /2 * 6/16 * 6(row) + 8(space) *4 |
|
|
|
|
|
expandedHeight: MediaQuery.of(context).size.width * 1.125 + 32, |
|
|
|
|
|
flexibleSpace: _showTitle(context) |
|
|
|
|
|
? null |
|
|
|
|
|
: FlexibleSpaceBar( |
|
|
|
|
|
centerTitle: true, |
|
|
|
|
|
title: GridView.count( |
|
|
|
|
|
shrinkWrap: true, |
|
|
|
|
|
crossAxisCount: 2, |
|
|
|
|
|
childAspectRatio: 16 / 6, |
|
|
|
|
|
children: actions.map( |
|
|
|
|
|
(item) { |
|
|
|
|
|
return _createActionButtons(item); |
|
|
|
|
|
}, |
|
|
|
|
|
).toList()), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
SliverList( |
|
|
|
|
|
delegate: SliverChildListDelegate([ |
|
|
|
|
|
Container( |
|
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
|
child: _showTitle(context) |
|
|
|
|
|
? Text("") |
|
|
|
|
|
: Text( |
|
|
|
|
|
plot_detail_title, |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 20, fontWeight: FontWeight.normal), |
|
|
|
|
|
)) |
|
|
|
|
|
])) |
|
|
|
|
|
], |
|
|
|
|
|
body: RefreshIndicator( |
|
|
|
|
|
backgroundColor: Colors.white, |
|
|
|
|
|
onRefresh: () async {}, |
|
|
|
|
|
child: ListView.builder( |
|
|
|
|
|
itemBuilder: (context, index) => ListTile(title: Text("Text $index")), |
|
|
|
|
|
itemCount: 20, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |