opt.: popupmenu

This commit is contained in:
lollipopkit
2023-05-09 22:04:45 +08:00
parent b4f3fce64a
commit c1d1af8c01
15 changed files with 145 additions and 211 deletions

View File

@@ -25,16 +25,19 @@ extension ColorX on Color {
});
}
MaterialColor get materialColor => MaterialColor(value, {
50: withOpacity(0.05),
100: withOpacity(0.1),
200: withOpacity(0.2),
300: withOpacity(0.3),
400: withOpacity(0.4),
500: withOpacity(0.5),
600: withOpacity(0.6),
700: withOpacity(0.7),
800: withOpacity(0.8),
900: withOpacity(0.9),
});
MaterialColor get materialColor => MaterialColor(
value,
{
50: withOpacity(0.05),
100: withOpacity(0.1),
200: withOpacity(0.2),
300: withOpacity(0.3),
400: withOpacity(0.4),
500: withOpacity(0.5),
600: withOpacity(0.6),
700: withOpacity(0.7),
800: withOpacity(0.8),
900: withOpacity(0.9),
},
);
}

View File

@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/extension/navigator.dart';
import 'package:toolbox/data/res/ui.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../data/model/server/snippet.dart';
@@ -97,21 +96,6 @@ void setTransparentNavigationBar(BuildContext context) {
}
}
Widget buildPopuopMenu<T>({
required List<PopupMenuEntry<T>> items,
required void Function(T) onSelected,
Widget child = popMenuChild,
EdgeInsetsGeometry? padding,
}) {
return PopupMenuButton<T>(
itemBuilder: (_) => items,
onSelected: onSelected,
padding: padding ?? EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
child: child,
);
}
String tabTitleName(BuildContext context, int i) {
final s = S.of(context)!;
switch (i) {
@@ -120,7 +104,7 @@ String tabTitleName(BuildContext context, int i) {
case 1:
return s.convert;
case 2:
return s.ping;
return 'Ping';
default:
return '';
}
@@ -165,7 +149,7 @@ void showSnippetDialog(
var snippet = provider.snippets.first;
showRoundDialog(
context: context,
title: Text(s.chooseDestination),
title: Text(s.choose),
child: Picker(
items: provider.snippets.map((e) => Text(e.name)).toList(),
onSelected: (idx) => snippet = provider.snippets[idx],