softplayer-web/lib/components/environment_card.dart

103 lines
3.1 KiB
Dart
Raw Normal View History

2024-04-29 10:42:16 +00:00
import 'package:flutter/material.dart';
2024-04-30 15:31:53 +00:00
import 'package:softplayer_web/api/grpc/environments.dart';
2024-05-03 11:10:06 +00:00
import 'package:softplayer_web/components/environment_preview.dart';
2024-05-02 17:09:44 +00:00
import 'package:softplayer_web/helpers/providers/common.dart';
2024-04-29 10:42:16 +00:00
2024-05-02 21:56:55 +00:00
class EnvirnomentCard extends StatefulWidget {
2024-04-30 15:31:53 +00:00
final EnvironmentLocalData env;
2024-04-29 10:42:16 +00:00
const EnvirnomentCard({
super.key,
2024-04-30 15:31:53 +00:00
required this.env,
2024-04-29 10:42:16 +00:00
});
2024-05-02 21:56:55 +00:00
@override
State<EnvirnomentCard> createState() => _EnvirnomentCardState();
}
class _EnvirnomentCardState extends State<EnvirnomentCard> {
late double elevation = 1.0;
2024-04-29 10:42:16 +00:00
@override
Widget build(BuildContext context) {
2024-05-02 21:56:55 +00:00
Provider provider = ProviderHelper().getProvider(widget.env.provider);
2024-05-02 17:09:44 +00:00
String serverType;
String serverLocation;
try {
2024-05-02 21:56:55 +00:00
serverType = ProviderHelper().getServerType(widget.env.serverType);
serverLocation = provider.getServerLocation(widget.env.serverLocation);
2024-05-02 17:09:44 +00:00
} catch (e) {
rethrow;
}
2024-05-02 21:56:55 +00:00
return Container(
margin: const EdgeInsets.all(8.0),
height: 10,
child: MouseRegion(
onExit: (event) {
setState(() {
elevation = 1.0;
});
},
onEnter: (event) {
setState(() {
elevation = 5.0;
});
},
child: Card(
elevation: elevation,
child: SelectionArea(
child: InkWell(
2024-05-03 11:10:06 +00:00
onLongPress: () => showMenu(
position: RelativeRect.fromSize(Rect.largest, Size.infinite),
2024-05-02 21:56:55 +00:00
context: context,
2024-05-03 11:10:06 +00:00
items: [
2024-05-22 11:03:44 +00:00
const PopupMenuItem(child: Text("test")),
const PopupMenuItem(child: Text("text")),
2024-05-03 11:10:06 +00:00
],
),
onTap: () => showDialog(
context: context,
builder: (context) => EnvirnomentPreiview(env: widget.env),
2024-05-02 21:56:55 +00:00
),
child: Column(
children: [
Text(widget.env.name),
const Divider(),
Table(
border: const TableBorder(
bottom: BorderSide.none,
left: BorderSide.none,
right: BorderSide.none,
top: BorderSide.none,
),
children: [
TableRow(children: [
const Text("Description"),
Text(widget.env.description),
]),
TableRow(children: [
const Text("Provider"),
Text(provider.getProviderName()),
]),
TableRow(children: [
const Text("Server Type"),
Text(serverType),
]),
TableRow(children: [
const Text("Location"),
Text(serverLocation),
]),
],
)
],
2024-04-30 15:31:53 +00:00
),
2024-05-02 21:56:55 +00:00
),
),
2024-04-30 15:31:53 +00:00
),
2024-04-29 10:42:16 +00:00
),
);
}
}