Compare commits
No commits in common. "799c15321b1deac7443089792207f58e1ac7972b" and "ff52298d2adcfb86833f5f635f2aa5df491a1128" have entirely different histories.
799c15321b
...
ff52298d2a
30
README.md
30
README.md
|
@ -1,26 +1,16 @@
|
||||||
# Zenith
|
# zenith
|
||||||
|
|
||||||
A matrix client for Android.
|
A new Flutter project.
|
||||||
|
|
||||||
TODO: Add play store + f-droid store links.
|
## Getting Started
|
||||||
|
|
||||||
# Screenshots
|
This project is a starting point for a Flutter application.
|
||||||
|
|
||||||
TODO: Add screenshots.
|
A few resources to get you started if this is your first Flutter project:
|
||||||
|
|
||||||
# Features
|
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||||
|
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||||
|
|
||||||
TODO: Add feature list.
|
For help getting started with Flutter development, view the
|
||||||
|
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||||
# How to Build
|
samples, guidance on mobile development, and a full API reference.
|
||||||
|
|
||||||
First install dependencies:
|
|
||||||
```
|
|
||||||
flutter pub get
|
|
||||||
```
|
|
||||||
|
|
||||||
Then build the apk:
|
|
||||||
|
|
||||||
```
|
|
||||||
flutter build apk
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:matrix/matrix.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:zenith/zenith_client_provider.dart';
|
|
||||||
|
|
||||||
class ChatsPage extends StatefulWidget {
|
|
||||||
const ChatsPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChatsPage> createState() => _ChatsPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChatsPageState extends State<ChatsPage> {
|
|
||||||
final serverController = TextEditingController();
|
|
||||||
final usernameController = TextEditingController();
|
|
||||||
final passwordController = TextEditingController();
|
|
||||||
late Client client;
|
|
||||||
bool roomsLoading = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
client = Provider.of<ZenithClientProvider>(context, listen: false).client;
|
|
||||||
client.onRoomState.stream.listen((event) {
|
|
||||||
print(event.type);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendMessage() {}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
||||||
title: const Text("Zenith"),
|
|
||||||
),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Center(
|
|
||||||
child: roomsLoading
|
|
||||||
? const CircularProgressIndicator()
|
|
||||||
: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [Text("${client.rooms.length} Rooms.")],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: sendMessage,
|
|
||||||
tooltip: 'Send message',
|
|
||||||
child: const Icon(Icons.send),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:zenith/chats.dart';
|
|
||||||
import 'package:zenith/zenith_client_provider.dart';
|
|
||||||
|
|
||||||
class LoginPage extends StatefulWidget {
|
class LoginPage extends StatefulWidget {
|
||||||
const LoginPage({super.key});
|
const LoginPage({super.key});
|
||||||
|
@ -18,20 +14,24 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
final passwordController = TextEditingController();
|
final passwordController = TextEditingController();
|
||||||
|
|
||||||
void connectMatrix() async {
|
void connectMatrix() async {
|
||||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
debugPrint("Making the client...");
|
||||||
await provider.initialize(serverController.text, usernameController.text,
|
final client = Client("zenith");
|
||||||
passwordController.text);
|
client.onLoginStateChanged.stream.listen((event) {
|
||||||
|
debugPrint("LoginState=${event.toString()}");
|
||||||
|
});
|
||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
debugPrint("Checking the homeserver...");
|
||||||
prefs.setString("homeserver", serverController.text);
|
await client.checkHomeserver(Uri.parse(serverController.text));
|
||||||
prefs.setString("username", usernameController.text);
|
|
||||||
prefs.setString("password", passwordController.text);
|
|
||||||
|
|
||||||
if (!mounted) return;
|
debugPrint("Logging in...");
|
||||||
Navigator.pushAndRemoveUntil(
|
await client.login(LoginType.mLoginPassword,
|
||||||
context,
|
identifier: AuthenticationUserIdentifier(user: usernameController.text),
|
||||||
MaterialPageRoute(builder: (context) => const ChatsPage()),
|
password: passwordController.text);
|
||||||
(route) => false);
|
|
||||||
|
for (var room in client.rooms) {
|
||||||
|
debugPrint(
|
||||||
|
"Room ID: ${room.id}, Room Name: ${room.getLocalizedDisplayname()}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:zenith/chats.dart';
|
|
||||||
import 'package:zenith/login.dart';
|
import 'package:zenith/login.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:zenith/zenith_client_provider.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
@ -15,16 +10,13 @@ class MyApp extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ChangeNotifierProvider(
|
return MaterialApp(
|
||||||
create: (context) => ZenithClientProvider(),
|
title: 'Flutter Demo',
|
||||||
child: MaterialApp(
|
theme: ThemeData(
|
||||||
title: 'Zenith',
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
theme: ThemeData(
|
useMaterial3: true,
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
||||||
useMaterial3: true,
|
|
||||||
),
|
|
||||||
home: const MyHomePage(),
|
|
||||||
),
|
),
|
||||||
|
home: const MyHomePage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,36 +29,13 @@ class MyHomePage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
bool savedCreds = false;
|
|
||||||
|
|
||||||
void getCreds() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
final homeserver = prefs.getString("homeserver");
|
|
||||||
final username = prefs.getString("username");
|
|
||||||
final password = prefs.getString("password");
|
|
||||||
|
|
||||||
if (homeserver == null || username == null || password == null) return;
|
|
||||||
setState(() {
|
|
||||||
savedCreds = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!mounted) return;
|
|
||||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
|
||||||
await provider.initialize(homeserver, username, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
getCreds();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (!savedCreds) {
|
return const LoginPage();
|
||||||
return const LoginPage();
|
|
||||||
} else {
|
|
||||||
return const ChatsPage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:matrix/matrix.dart';
|
|
||||||
|
|
||||||
class ZenithClientProvider extends ChangeNotifier {
|
|
||||||
late Client _client;
|
|
||||||
|
|
||||||
Client get client => _client;
|
|
||||||
|
|
||||||
void setClient(Client newClient) {
|
|
||||||
_client = newClient;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> initialize(
|
|
||||||
String homeserver, String username, String password) async {
|
|
||||||
_client = Client("zenith");
|
|
||||||
print("Checking homeserver...");
|
|
||||||
await client.checkHomeserver(Uri.parse(homeserver));
|
|
||||||
print("Logging in...");
|
|
||||||
await client.login(LoginType.mLoginPassword,
|
|
||||||
identifier: AuthenticationUserIdentifier(user: username),
|
|
||||||
password: password);
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,8 +5,6 @@
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import shared_preferences_foundation
|
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
|
||||||
}
|
}
|
||||||
|
|
127
pubspec.lock
127
pubspec.lock
|
@ -137,14 +137,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
file:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file
|
|
||||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "7.0.0"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -179,11 +171,6 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_web_plugins:
|
|
||||||
dependency: transitive
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
hive:
|
hive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -328,30 +315,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.3"
|
version: "1.8.3"
|
||||||
path_provider_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path_provider_linux
|
|
||||||
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.1"
|
|
||||||
path_provider_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path_provider_platform_interface
|
|
||||||
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.1"
|
|
||||||
path_provider_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path_provider_windows
|
|
||||||
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.1"
|
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -360,22 +323,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.4.0"
|
version: "5.4.0"
|
||||||
platform:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: platform
|
|
||||||
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.1.3"
|
|
||||||
plugin_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: plugin_platform_interface
|
|
||||||
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.7"
|
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -408,62 +355,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.2"
|
version: "0.3.2"
|
||||||
shared_preferences:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: shared_preferences
|
|
||||||
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.2"
|
|
||||||
shared_preferences_android:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_android
|
|
||||||
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.1"
|
|
||||||
shared_preferences_foundation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_foundation
|
|
||||||
sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.4"
|
|
||||||
shared_preferences_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_linux
|
|
||||||
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.2"
|
|
||||||
shared_preferences_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_platform_interface
|
|
||||||
sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.1"
|
|
||||||
shared_preferences_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_web
|
|
||||||
sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.1"
|
|
||||||
shared_preferences_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: shared_preferences_windows
|
|
||||||
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.2"
|
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -581,22 +472,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.2"
|
version: "1.1.2"
|
||||||
win32:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: win32
|
|
||||||
sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "5.1.1"
|
|
||||||
xdg_directories:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: xdg_directories
|
|
||||||
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.3"
|
|
||||||
xml:
|
xml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -607,4 +482,4 @@ packages:
|
||||||
version: "6.3.0"
|
version: "6.3.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.1.5 <4.0.0"
|
dart: ">=3.1.5 <4.0.0"
|
||||||
flutter: ">=3.7.0"
|
flutter: ">=1.20.0"
|
||||||
|
|
|
@ -39,7 +39,6 @@ dependencies:
|
||||||
flutter_olm: ^1.4.1
|
flutter_olm: ^1.4.1
|
||||||
flutter_openssl_crypto: ^0.3.0
|
flutter_openssl_crypto: ^0.3.0
|
||||||
provider: ^6.1.1
|
provider: ^6.1.1
|
||||||
shared_preferences: ^2.2.2
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user