softplayer-web/lib/pages/catalog.dart

86 lines
2.6 KiB
Dart
Raw Normal View History

2024-03-26 16:17:04 +00:00
import 'package:flutter/material.dart';
2024-04-04 14:35:33 +00:00
import 'package:grpc/grpc_web.dart';
2024-03-27 21:07:53 +00:00
import 'package:softplayer_web/api/third_party/chartmuseum.dart';
import 'package:softplayer_web/components/catalog_card.dart';
2024-03-26 16:17:04 +00:00
import 'package:softplayer_web/components/menubar.dart';
2024-03-27 21:07:53 +00:00
import 'package:softplayer_web/models/catalog_entry.dart';
2024-03-26 16:17:04 +00:00
class CatalogPage extends StatefulWidget {
2024-04-04 14:35:33 +00:00
final GrpcWebClientChannel grpcChannel;
const CatalogPage({
super.key,
required this.grpcChannel,
});
2024-03-26 16:17:04 +00:00
final String title = "catalog";
@override
State<CatalogPage> createState() => _CatalogPage();
}
class _CatalogPage extends State<CatalogPage> {
2024-03-27 21:07:53 +00:00
late Future<List<HelmChart>> helmChart;
@override
void initState() {
super.initState();
helmChart = fetchCharts();
2024-03-26 16:17:04 +00:00
}
2024-03-27 21:07:53 +00:00
final List<CatalogEntry> catalog = [
CatalogEntry(
name: "openvpn",
description: "you know what I mean",
logoUrl:
"https://upload.wikimedia.org/wikipedia/commons/f/f5/OpenVPN_logo.svg"),
CatalogEntry(
name: "openvpn",
description: "you know what I mean",
logoUrl:
"https://upload.wikimedia.org/wikipedia/commons/f/f5/OpenVPN_logo.svg"),
];
2024-03-26 16:17:04 +00:00
@override
Widget build(BuildContext context) {
2024-03-27 21:07:53 +00:00
print(helmChart);
return SelectionArea(
child: Scaffold(
appBar: const MenuPanel(tab: TabName.catalog),
body: Container(
margin: const EdgeInsets.all(14),
child: Container(
child: Row(children: <Widget>[
const SizedBox(
width: 200,
child: Card(
child: Column(
children: <Widget>[Text("Filter")],
))),
Flexible(
child: Column(
children: <Widget>[
const TextField(
decoration: InputDecoration(
icon: Icon(Icons.search),
labelText: "Search",
),
autofocus: true,
),
CatalogCard(data: catalog),
FutureBuilder(
future: helmChart,
builder: (context, snapshot) {
print(snapshot);
if (snapshot.hasData) {
return Text(snapshot.data!.first.name);
} else if (snapshot.hasError) {
return SelectableText('${snapshot.error}');
}
return const CircularProgressIndicator();
}),
],
2024-03-26 16:17:04 +00:00
),
2024-03-27 21:07:53 +00:00
)
])),
2024-03-26 16:17:04 +00:00
),
2024-03-27 21:07:53 +00:00
));
2024-03-26 16:17:04 +00:00
}
}