mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
Fixed UI representation of server reorder page (#372)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:ui';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
@@ -22,6 +23,29 @@ class _ServerOrderPageState extends State<ServerOrderPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _proxyDecorator(Widget child, int index, Animation<double> animation) {
|
||||
return AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
final double animValue = Curves.easeInOut.transform(animation.value);
|
||||
final double elevation = lerpDouble(1, 6, animValue)!;
|
||||
final double scale = lerpDouble(1, 1.02, animValue)!;
|
||||
return Transform.scale(
|
||||
scale: scale,
|
||||
// Create a Card based on the color and the content of the dragged one
|
||||
// and set its elevation to the animated value.
|
||||
child: Card(
|
||||
elevation: elevation,
|
||||
// color: cards[index].color,
|
||||
// child: cards[index].child,
|
||||
child: _buildCardTile(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
// child: child,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
if (Pros.server.serverOrder.isEmpty) {
|
||||
return Center(child: Text(l10n.noServerAvailable));
|
||||
@@ -37,28 +61,36 @@ class _ServerOrderPageState extends State<ServerOrderPage> {
|
||||
}),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3),
|
||||
buildDefaultDragHandles: false,
|
||||
itemBuilder: (_, idx) => _buildItem(idx, Pros.server.serverOrder[idx]),
|
||||
itemBuilder: (_, idx) => _buildItem(idx),
|
||||
itemCount: Pros.server.serverOrder.length,
|
||||
proxyDecorator: _proxyDecorator,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItem(int index, String id) {
|
||||
Widget _buildItem(int index) {
|
||||
return ReorderableDelayedDragStartListener(
|
||||
key: ValueKey('$index'),
|
||||
index: index,
|
||||
child: CardX(child: _buildCardTile(index)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCardTile(int index) {
|
||||
final id = Pros.server.serverOrder[index];
|
||||
final spi = Pros.server.pick(id: id)?.spi;
|
||||
if (spi == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return ReorderableDelayedDragStartListener(
|
||||
key: ValueKey('$index'),
|
||||
index: index,
|
||||
child: CardX(
|
||||
child: ListTile(
|
||||
title: Text(spi.name),
|
||||
subtitle: Text(spi.id, style: UIs.textGrey),
|
||||
leading: CircleAvatar(
|
||||
child: Text(spi.name[0]),
|
||||
),
|
||||
trailing: const Icon(Icons.drag_handle),
|
||||
),
|
||||
|
||||
return ListTile(
|
||||
title: Text(spi.name),
|
||||
subtitle: Text(spi.id, style: UIs.textGrey),
|
||||
leading: CircleAvatar(
|
||||
child: Text(spi.name[0]),
|
||||
),
|
||||
trailing: ReorderableDragStartListener(
|
||||
index: index,
|
||||
child: const Icon(Icons.drag_handle),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user