softplayer-web/lib/components/environment_card.dart

103 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:softplayer_web/api/grpc/environments.dart';
import 'package:softplayer_web/components/environment_preview.dart';
import 'package:softplayer_web/helpers/providers/common.dart';
class EnvirnomentCard extends StatefulWidget {
final EnvironmentLocalData env;
const EnvirnomentCard({
super.key,
required this.env,
});
@override
State<EnvirnomentCard> createState() => _EnvirnomentCardState();
}
class _EnvirnomentCardState extends State<EnvirnomentCard> {
late double elevation = 1.0;
@override
Widget build(BuildContext context) {
Provider provider = ProviderHelper().getProvider(widget.env.provider);
String serverType;
String serverLocation;
try {
serverType = ProviderHelper().getServerType(widget.env.serverType);
serverLocation = provider.getServerLocation(widget.env.serverLocation);
} catch (e) {
rethrow;
}
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(
onLongPress: () => showMenu(
position: RelativeRect.fromSize(Rect.largest, Size.infinite),
context: context,
items: [
const PopupMenuItem(child: Text("test")),
const PopupMenuItem(child: Text("text")),
],
),
onTap: () => showDialog(
context: context,
builder: (context) => EnvirnomentPreiview(env: widget.env),
),
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),
]),
],
)
],
),
),
),
),
),
);
}
}