1
This commit is contained in:
@@ -9,51 +9,48 @@ class SuggestedTitle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var list = context.select<PlanDetailStore, List<String>>(
|
||||
(store) => store.planDetail.suggestionsList,
|
||||
);
|
||||
if (list.isEmpty) {
|
||||
return const SliverToBoxAdapter(
|
||||
child: SizedBox(),
|
||||
);
|
||||
}
|
||||
return SliverToBoxAdapter(
|
||||
child: TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 0, end: 1), // 从透明到完全显示
|
||||
duration: const Duration(milliseconds: 300),
|
||||
builder: (context, value, child) {
|
||||
return Opacity(
|
||||
opacity: value,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 20, bottom: 5),
|
||||
child: Opacity(
|
||||
opacity: 0.6,
|
||||
child: Row(
|
||||
spacing: 20,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 15,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
Text(
|
||||
"额外建议",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Container(
|
||||
width: 15,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
],
|
||||
return Consumer<PlanDetailStore>(
|
||||
builder: (context, store, _) {
|
||||
if (store.planDetail.suggestionsList.isEmpty) {
|
||||
return SizedBox();
|
||||
}
|
||||
return TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 0, end: 1), // 从透明到完全显示
|
||||
duration: const Duration(milliseconds: 300),
|
||||
builder: (context, value, child) {
|
||||
return Opacity(
|
||||
opacity: value,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 20, bottom: 5),
|
||||
child: Opacity(
|
||||
opacity: 0.6,
|
||||
child: Row(
|
||||
spacing: 20,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 15,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
Text(
|
||||
"额外建议",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Container(
|
||||
width: 15,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -67,13 +64,14 @@ class SuggestedList extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SuggestedListState extends State<SuggestedList> {
|
||||
final GlobalKey<SliverAnimatedListState> _listKey = GlobalKey<SliverAnimatedListState>();
|
||||
final GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();
|
||||
List<String> _suggestionsList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initListen();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _initListen());
|
||||
}
|
||||
|
||||
void _initListen() {
|
||||
@@ -82,7 +80,6 @@ class _SuggestedListState extends State<SuggestedList> {
|
||||
_suggestionsList = store.planDetail.suggestionsList;
|
||||
store.addListener(() {
|
||||
final newList = store.planDetail.suggestionsList;
|
||||
|
||||
// 找出新增的 item
|
||||
if (newList.length > _suggestionsList.length) {
|
||||
final addedItems = newList.sublist(_suggestionsList.length);
|
||||
@@ -107,8 +104,10 @@ class _SuggestedListState extends State<SuggestedList> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverAnimatedList(
|
||||
return AnimatedList(
|
||||
key: _listKey,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
initialItemCount: _suggestionsList.length,
|
||||
itemBuilder: (_, index, animation) {
|
||||
final curvedAnimation = CurvedAnimation(
|
||||
|
||||
Reference in New Issue
Block a user