2024-02-08 08:34:33 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2024-02-07 17:25:58 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-02-10 12:08:25 +00:00
|
|
|
import 'package:goatagent/screens/application.dart';
|
2024-02-08 08:34:33 +00:00
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
class DashboardScreen extends StatefulWidget {
|
2024-02-07 17:25:58 +00:00
|
|
|
const DashboardScreen({super.key});
|
|
|
|
|
2024-02-08 08:34:33 +00:00
|
|
|
@override
|
|
|
|
State<DashboardScreen> createState() => _DashboardScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _DashboardScreenState extends State<DashboardScreen> {
|
|
|
|
final client = http.Client();
|
|
|
|
final directoryEndpoint =
|
|
|
|
Uri.parse('https://id.smartsheep.studio/.well-known');
|
|
|
|
|
|
|
|
List<dynamic> directory = List.empty();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_pullDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _pullDirectory() async {
|
|
|
|
var response = await client.get(directoryEndpoint);
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
setState(() {
|
|
|
|
directory = jsonDecode(utf8.decode(response.bodyBytes))["directory"];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-07 17:25:58 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-02-08 08:34:33 +00:00
|
|
|
return Scaffold(
|
|
|
|
body: SafeArea(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, top: 30),
|
|
|
|
child: GridView.count(
|
|
|
|
crossAxisCount: 2,
|
|
|
|
children: directory.map((element) {
|
|
|
|
return Card(
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () async {
|
2024-02-10 12:08:25 +00:00
|
|
|
var link = element["link"];
|
2024-02-10 14:38:50 +00:00
|
|
|
Navigator.of(context, rootNavigator: true)
|
|
|
|
.push(MaterialPageRoute(
|
2024-02-10 12:08:25 +00:00
|
|
|
builder: (context) => ApplicationScreen(
|
|
|
|
link: Uri.parse(link),
|
|
|
|
title: element["name"],
|
2024-02-08 08:34:33 +00:00
|
|
|
),
|
|
|
|
));
|
|
|
|
},
|
|
|
|
splashColor: Colors.indigo.withAlpha(30),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(10),
|
2024-02-10 14:38:50 +00:00
|
|
|
child: Wrap(
|
|
|
|
spacing: 8.0,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 6, top: 2),
|
|
|
|
child: Card(
|
|
|
|
shape: const CircleBorder(),
|
|
|
|
elevation: 0,
|
|
|
|
color: Colors.indigo.withAlpha(70),
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(16),
|
|
|
|
child: Icon(Icons.apps),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: Text(element['name']),
|
2024-02-12 09:50:06 +00:00
|
|
|
subtitle: Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 2),
|
|
|
|
child: Text(element['description'], style: Theme.of(context).textTheme.bodySmall),
|
|
|
|
),
|
2024-02-10 14:38:50 +00:00
|
|
|
),
|
|
|
|
],
|
2024-02-08 08:34:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
),
|
|
|
|
),
|
2024-02-07 17:25:58 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2024-02-08 08:34:33 +00:00
|
|
|
}
|