opt.: Btn

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-07-28 20:26:08 +08:00
parent 8fd4cc1fe1
commit f9aadc6b0f
8 changed files with 78 additions and 73 deletions

View File

@@ -2,6 +2,6 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 1034;
static const int script = 54;
static const int build = 1038;
static const int script = 55;
}

View File

@@ -59,9 +59,9 @@ final class _PvePageState extends State<PvePage> {
listenable: _pve.err,
builder: (val) => val == null
? UIs.placeholder
: IconBtn(
icon: Icons.refresh,
onTap: () {
: Btn.icon(
icon: const Icon(Icons.refresh),
onTap: (_) {
_pve.err.value = null;
_pve.list();
_initRefreshTimer();
@@ -393,27 +393,26 @@ final class _PvePageState extends State<PvePage> {
}
Widget _buildCtrlBtns(PveCtrlIface item) {
const pad = EdgeInsets.symmetric(horizontal: 7, vertical: 5);
if (!item.available) {
return IconBtn(
icon: Icons.play_arrow,
color: Colors.grey,
onTap: () => _onCtrl(_pve.start, l10n.start, item));
return Btn.icon(
icon: const Icon(Icons.play_arrow, color: Colors.grey),
onTap: (_) => _onCtrl(_pve.start, l10n.start, item));
}
return Row(
children: [
IconBtn(
icon: Icons.stop,
color: Colors.grey,
onTap: () => _onCtrl(_pve.stop, l10n.stop, item)),
IconBtn(
icon: Icons.refresh,
color: Colors.grey,
onTap: () => _onCtrl(_pve.reboot, l10n.reboot, item)),
IconBtn(
icon: Icons.power_off,
color: Colors.grey,
onTap: () => _onCtrl(_pve.shutdown, l10n.shutdown, item),
),
Btn.icon(
icon: const Icon(Icons.stop, color: Colors.grey, size: 20),
padding: pad,
onTap: (_) => _onCtrl(_pve.stop, l10n.stop, item)),
Btn.icon(
icon: const Icon(Icons.refresh, color: Colors.grey, size: 20),
padding: pad,
onTap: (_) => _onCtrl(_pve.reboot, l10n.reboot, item)),
Btn.icon(
icon: const Icon(Icons.power_off, color: Colors.grey, size: 20),
padding: pad,
onTap: (_) => _onCtrl(_pve.shutdown, l10n.shutdown, item)),
],
);
}

View File

@@ -349,8 +349,8 @@ class _ServerPageState extends State<ServerPage>
List<Widget> _buildFlippedCard(Server srv) {
final children = [
IconTextBtn(
onPressed: () => _askFor(
Btn.column(
onTap: (_) => _askFor(
func: () async {
if (Stores.setting.showSuspendTip.fetch()) {
await context.showRoundDialog(
@@ -368,11 +368,11 @@ class _ServerPageState extends State<ServerPage>
typ: l10n.suspend,
name: srv.spi.name,
),
icon: Icons.stop,
icon: const Icon(Icons.stop),
text: l10n.suspend,
),
IconTextBtn(
onPressed: () => _askFor(
Btn.column(
onTap: (_) => _askFor(
func: () => srv.client?.execWithPwd(
ShellFunc.shutdown.exec,
context: context,
@@ -381,11 +381,11 @@ class _ServerPageState extends State<ServerPage>
typ: l10n.shutdown,
name: srv.spi.name,
),
icon: Icons.power_off,
icon: const Icon(Icons.power_off),
text: l10n.shutdown,
),
IconTextBtn(
onPressed: () => _askFor(
Btn.column(
onTap: (_) => _askFor(
func: () => srv.client?.execWithPwd(
ShellFunc.reboot.exec,
context: context,
@@ -394,12 +394,12 @@ class _ServerPageState extends State<ServerPage>
typ: l10n.reboot,
name: srv.spi.name,
),
icon: Icons.restart_alt,
icon: const Icon(Icons.restart_alt),
text: l10n.reboot,
),
IconTextBtn(
onPressed: () => AppRoutes.serverEdit(spi: srv.spi).go(context),
icon: Icons.edit,
Btn.column(
onTap: (_) => AppRoutes.serverEdit(spi: srv.spi).go(context),
icon: const Icon(Icons.edit),
text: l10n.edit,
)
];

View File

@@ -231,7 +231,7 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
builder: () {
return ListView.separated(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 11, vertical: 5),
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 5),
itemCount: names.length,
itemBuilder: (_, idx) => _buillItem(idx),
separatorBuilder: (_, __) => Padding(
@@ -270,32 +270,38 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
child = AnimatedContainer(
width: selected ? 90 : 50,
duration: Durations.medium3,
padding: selected ? const EdgeInsets.symmetric(horizontal: 7) : null,
curve: Curves.fastEaseInToSlowEaseOut,
child: switch (selected) {
true => Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(width: 55, child: text),
if (selected)
FadeIn(
child: IconBtn(
icon: MingCute.close_circle_fill,
color: color,
onTap: () => onClose(name),
child: Btn.icon(
icon: Icon(
MingCute.close_circle_fill,
color: color,
size: 17,
),
onTap: (_) => onClose(name),
),
),
const Spacer(),
SizedBox(width: 50, child: text),
],
),
false => Center(child: text),
false => Align(
alignment: Alignment.centerRight,
child: text,
),
},
).paddingOnly(left: 3, right: 3);
);
}
return InkWell(
borderRadius: BorderRadius.circular(13),
onTap: () => onTap(idx),
child: child,
).paddingSymmetric(horizontal: 13);
).paddingSymmetric(horizontal: 7);
}
}