mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
rm dep. dropdownbtn
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 32 KiB |
@@ -10,8 +10,6 @@ import 'package:toolbox/view/widget/card_dialog.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
|
||||
void unawaited(Future<void> future) {}
|
||||
|
||||
bool isDarkMode(BuildContext context) =>
|
||||
Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
@@ -110,3 +108,19 @@ Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
||||
await Share.shareFiles(filePaths, text: 'ServerBox -> $text');
|
||||
return filePaths.isNotEmpty;
|
||||
}
|
||||
|
||||
Widget buildPopuopMenu(
|
||||
{required List<PopupMenuEntry> items,
|
||||
required Function(dynamic) onSelected}) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (_) => items,
|
||||
onSelected: onSelected,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(left: 7),
|
||||
child: Icon(
|
||||
Icons.more_vert,
|
||||
size: 23,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
@@ -152,49 +151,31 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
|
||||
Widget _buildMoreBtn(bool running, String containerId) {
|
||||
final item = running ? DockerMenuItems.stop : DockerMenuItems.start;
|
||||
return DropdownButtonHideUnderline(
|
||||
child: DropdownButton2(
|
||||
customButton: const Padding(
|
||||
padding: EdgeInsets.only(left: 7),
|
||||
child: Icon(
|
||||
Icons.more_vert,
|
||||
size: 17,
|
||||
),
|
||||
return buildPopuopMenu(
|
||||
items: [
|
||||
PopupMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
),
|
||||
customItemsHeight: 8,
|
||||
items: [
|
||||
DropdownMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
),
|
||||
DropdownMenuItem<DropdownBtnItem>(
|
||||
value: DockerMenuItems.rm,
|
||||
child: DockerMenuItems.rm.build,
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
final item = value as DropdownBtnItem;
|
||||
switch (item) {
|
||||
case DockerMenuItems.rm:
|
||||
_docker.delete(containerId);
|
||||
break;
|
||||
case DockerMenuItems.start:
|
||||
_docker.start(containerId);
|
||||
break;
|
||||
case DockerMenuItems.stop:
|
||||
_docker.stop(containerId);
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemHeight: 37,
|
||||
itemPadding: const EdgeInsets.only(left: 17, right: 17),
|
||||
dropdownWidth: 133,
|
||||
dropdownDecoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
PopupMenuItem<DropdownBtnItem>(
|
||||
value: DockerMenuItems.rm,
|
||||
child: DockerMenuItems.rm.build,
|
||||
),
|
||||
dropdownElevation: 8,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
final item = value as DropdownBtnItem;
|
||||
switch (item) {
|
||||
case DockerMenuItems.rm:
|
||||
_docker.delete(containerId);
|
||||
break;
|
||||
case DockerMenuItems.start:
|
||||
_docker.start(containerId);
|
||||
break;
|
||||
case DockerMenuItems.stop:
|
||||
_docker.stop(containerId);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:circle_chart/circle_chart.dart';
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -200,72 +199,42 @@ class _ServerPageState extends State<ServerPage>
|
||||
}
|
||||
|
||||
Widget _buildMoreBtn(ServerPrivateInfo spi) {
|
||||
return DropdownButtonHideUnderline(
|
||||
child: DropdownButton2(
|
||||
customButton: const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 1.7),
|
||||
child: Icon(
|
||||
Icons.more_vert,
|
||||
size: 17,
|
||||
return buildPopuopMenu(
|
||||
items: <PopupMenuEntry>[
|
||||
...ServerTabMenuItems.firstItems.map(
|
||||
(item) => PopupMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
),
|
||||
),
|
||||
customItemsIndexes: [ServerTabMenuItems.firstItems.length],
|
||||
customItemsHeight: 8,
|
||||
items: [
|
||||
...ServerTabMenuItems.firstItems.map(
|
||||
(item) => DropdownMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
),
|
||||
const PopupMenuDivider(height: 1),
|
||||
...ServerTabMenuItems.secondItems.map(
|
||||
(item) => PopupMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
),
|
||||
const DropdownMenuItem<Divider>(enabled: false, child: Divider()),
|
||||
...ServerTabMenuItems.secondItems.map(
|
||||
(item) => DropdownMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
final item = value as DropdownBtnItem;
|
||||
switch (item) {
|
||||
case ServerTabMenuItems.apt:
|
||||
AppRoute(AptManagePage(spi), 'apt manage page').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.sftp:
|
||||
AppRoute(SFTPPage(spi), 'SFTP').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.snippet:
|
||||
AppRoute(
|
||||
SnippetListPage(
|
||||
spi: spi,
|
||||
),
|
||||
'snippet list')
|
||||
.go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.edit:
|
||||
AppRoute(
|
||||
ServerEditPage(
|
||||
spi: spi,
|
||||
),
|
||||
'Edit server info page')
|
||||
.go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.docker:
|
||||
AppRoute(DockerManagePage(spi), 'Docker manage page').go(context);
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemHeight: 37,
|
||||
itemPadding: const EdgeInsets.only(left: 17, right: 17),
|
||||
dropdownWidth: 160,
|
||||
dropdownPadding: const EdgeInsets.symmetric(vertical: 7),
|
||||
dropdownDecoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
dropdownElevation: 8,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
final item = value as DropdownBtnItem;
|
||||
switch (item) {
|
||||
case ServerTabMenuItems.apt:
|
||||
AppRoute(AptManagePage(spi), 'apt manage').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.sftp:
|
||||
AppRoute(SFTPPage(spi), 'SFTP').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.snippet:
|
||||
AppRoute(SnippetListPage(spi: spi), 'snippet list').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.edit:
|
||||
AppRoute(ServerEditPage(spi: spi), 'Edit server info').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.docker:
|
||||
AppRoute(DockerManagePage(spi), 'Docker manage').go(context);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,13 +208,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.6"
|
||||
dropdown_button2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dropdown_button2
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.2"
|
||||
easy_isolate:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -51,7 +51,6 @@ dependencies:
|
||||
ref: main
|
||||
# path: ../circle_chart
|
||||
r_upgrade: ^0.3.6
|
||||
dropdown_button2: ^1.1.1
|
||||
flutter_advanced_drawer: ^1.3.0
|
||||
path_provider: ^2.0.9
|
||||
easy_isolate: ^1.3.0
|
||||
|
||||
Reference in New Issue
Block a user