First commit

This commit is contained in:
2023-12-28 16:35:10 +13:00
commit ff52298d2a
129 changed files with 5178 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final serverController = TextEditingController();
final usernameController = TextEditingController();
final passwordController = TextEditingController();
void connectMatrix() async {
debugPrint("Making the client...");
final client = Client("zenith");
client.onLoginStateChanged.stream.listen((event) {
debugPrint("LoginState=${event.toString()}");
});
debugPrint("Checking the homeserver...");
await client.checkHomeserver(Uri.parse(serverController.text));
debugPrint("Logging in...");
await client.login(LoginType.mLoginPassword,
identifier: AuthenticationUserIdentifier(user: usernameController.text),
password: passwordController.text);
for (var room in client.rooms) {
debugPrint(
"Room ID: ${room.id}, Room Name: ${room.getLocalizedDisplayname()}");
}
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text("Login"),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
controller: serverController,
decoration: const InputDecoration(
labelText: 'Server', hintText: 'https://matrix.org'),
),
TextFormField(
controller: usernameController,
decoration: const InputDecoration(
labelText: 'Username', hintText: 'john'),
),
TextFormField(
controller: passwordController,
decoration: const InputDecoration(labelText: 'Password'),
obscureText: true,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: connectMatrix,
tooltip: 'Log in',
child: const Icon(Icons.login),
),
);
}
}
+41
View File
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:zenith/login.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return const LoginPage();
}
}