72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import 'application.dart';
|
|
|
|
class DashboardScreen extends StatefulWidget {
|
|
const DashboardScreen({super.key});
|
|
|
|
@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"];
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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 {
|
|
await Navigator.of(context).push(MaterialPageRoute(
|
|
builder: (context) => AuthorizationScreen(
|
|
Uri.parse(element["link"]),
|
|
),
|
|
));
|
|
},
|
|
splashColor: Colors.indigo.withAlpha(30),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(10),
|
|
child: ListTile(
|
|
title: Text(element['name']),
|
|
subtitle: Text(element['description']),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|