Add description
This commit is contained in:
parent
77be6102f6
commit
3972d14de3
85
CHANGELOG.md
85
CHANGELOG.md
|
@ -1,84 +1,3 @@
|
||||||
# fluffyfluttermatrix
|
## [0.0.1] - 09 June 2019
|
||||||
|
|
||||||
Dead simple Flutter widget to use Matrix.org in your Flutter app.
|
Initial commit.
|
||||||
|
|
||||||
## How to use this
|
|
||||||
|
|
||||||
1. Use the Matrix widget as root for your widget tree:
|
|
||||||
|
|
||||||
```dart
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:fluffyfluttermatrix/fluffyfluttermatrix.dart';
|
|
||||||
|
|
||||||
void main() => runApp(MyApp());
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return FluffyMatrix(
|
|
||||||
child: MaterialApp(
|
|
||||||
title: 'Welcome to Flutter'
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Access the MatrixState object by calling Matrix.of with your current BuildContext:
|
|
||||||
|
|
||||||
```dart
|
|
||||||
Client matrix = Matrix.of(context);
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Connect to a Matrix Homeserver and listen to the streams:
|
|
||||||
|
|
||||||
```dart
|
|
||||||
matrix.homeserver = "https://yourhomeserveraddress";
|
|
||||||
|
|
||||||
matrix.onLoginStateChanged.stream.listen((bool loginState){
|
|
||||||
print("LoginState: ${loginState.toString()}");
|
|
||||||
});
|
|
||||||
|
|
||||||
matrix.onEvent.stream.listen((EventUpdate eventUpdate){
|
|
||||||
print("New event update!");
|
|
||||||
});
|
|
||||||
|
|
||||||
matrix.onRoomUpdate.stream.listen((RoomUpdate eventUpdate){
|
|
||||||
print("New room update!");
|
|
||||||
});
|
|
||||||
|
|
||||||
final loginResp = await matrix.jsonRequest(
|
|
||||||
type: "POST",
|
|
||||||
action: "/client/r0/login",
|
|
||||||
data: {
|
|
||||||
"type": "m.login.password",
|
|
||||||
"user": _usernameController.text,
|
|
||||||
"password": _passwordController.text,
|
|
||||||
"initial_device_display_name": "Fluffy Matrix Client"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
matrix.connect(
|
|
||||||
newToken: loginResp["token"],
|
|
||||||
newUserID: loginResp["user_id"],
|
|
||||||
newHomeserver: matrix.homeserver,
|
|
||||||
newDeviceName: "Fluffy Matrix Client",
|
|
||||||
newDeviceID: loginResp["device_id"],
|
|
||||||
newMatrixVersions: ["r0.4.0"],
|
|
||||||
newLazyLoadMembers: false
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Send a message to a Room:
|
|
||||||
|
|
||||||
```dart
|
|
||||||
final resp = await jsonRequest(
|
|
||||||
type: "PUT",
|
|
||||||
action: "/r0/rooms/!fjd823j:example.com/send/m.room.message/$txnId",
|
|
||||||
data: {
|
|
||||||
"msgtype": "m.text",
|
|
||||||
"body": "hello"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
```
|
|
25
CONTRIBUTING.md
Normal file
25
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Contributing code to famedly talk
|
||||||
|
|
||||||
|
Everyone is welcome to contribute code to matrix-js-sdk, provided that they are willing to license their contributions under the same license as the project itself.
|
||||||
|
Please follow these rules when contributing code to famedly talk:
|
||||||
|
|
||||||
|
## Merge Requests:
|
||||||
|
- Never ever just push something directly to the master branch!
|
||||||
|
- Create a new branch or fork this project and send a Merge Request.
|
||||||
|
- Only Merge Requests with a working CI can be merged.
|
||||||
|
- Only Merge Requests with at least one code reviewer can be merged.
|
||||||
|
- Merge Requests may be refused if they don't follow the rules below.
|
||||||
|
|
||||||
|
## File structure:
|
||||||
|
- Every file must be named by the class and must be capitalized in the beginning.
|
||||||
|
- Directories need to be lowercase.
|
||||||
|
|
||||||
|
## Code style:
|
||||||
|
- We recommend to use Android Studio for coding. We are using the Android Studio auto styling with ctrl+alt+shift+L.
|
||||||
|
|
||||||
|
## Code quality:
|
||||||
|
- Don't repeat yourself! Use local variables, functions, classes.
|
||||||
|
- Don't mix UI and business logic in the same enivornment.
|
||||||
|
- Write tests for new classes, functions and widgets.
|
||||||
|
- Keep it simple stupid: https://en.wikipedia.org/wiki/KISS_principle
|
||||||
|
- Describe all of your classes, methods and attributes using **dartdoc** comments. Read this for more informations: https://dart.dev/guides/language/effective-dart/documentation
|
82
README.md
82
README.md
|
@ -1,14 +1,78 @@
|
||||||
# famedlysdk
|
# famedlysdk
|
||||||
|
|
||||||
A new Flutter package.
|
Matrix SDK for the famedly talk app written in dart.
|
||||||
|
|
||||||
## Getting Started
|
## How to use this
|
||||||
|
|
||||||
This project is a starting point for a Dart
|
1. Import the sdk
|
||||||
[package](https://flutter.dev/developing-packages/),
|
|
||||||
a library module containing code that can be shared easily across
|
|
||||||
multiple Flutter or Dart projects.
|
|
||||||
|
|
||||||
For help getting started with Flutter, view our
|
```yaml
|
||||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
fluffyfluttermatrix:
|
||||||
samples, guidance on mobile development, and a full API reference.
|
git:
|
||||||
|
url: https://gitlab.com/famedly/famedlysdk.git
|
||||||
|
ref: 77be6102f6cbb2e01adc28f9caa3aa583f914235
|
||||||
|
```
|
||||||
|
|
||||||
|
```dart
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Access the MatrixState object by calling Matrix.of with your current BuildContext:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
Client matrix = Client("famedly talk");
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Connect to a Matrix Homeserver and listen to the streams:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
matrix.homeserver = "https://yourhomeserveraddress";
|
||||||
|
|
||||||
|
matrix.onLoginStateChanged.stream.listen((bool loginState){
|
||||||
|
print("LoginState: ${loginState.toString()}");
|
||||||
|
});
|
||||||
|
|
||||||
|
matrix.onEvent.stream.listen((EventUpdate eventUpdate){
|
||||||
|
print("New event update!");
|
||||||
|
});
|
||||||
|
|
||||||
|
matrix.onRoomUpdate.stream.listen((RoomUpdate eventUpdate){
|
||||||
|
print("New room update!");
|
||||||
|
});
|
||||||
|
|
||||||
|
final loginResp = await matrix.jsonRequest(
|
||||||
|
type: "POST",
|
||||||
|
action: "/client/r0/login",
|
||||||
|
data: {
|
||||||
|
"type": "m.login.password",
|
||||||
|
"user": _usernameController.text,
|
||||||
|
"password": _passwordController.text,
|
||||||
|
"initial_device_display_name": "Fluffy Matrix Client"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
matrix.connect(
|
||||||
|
newToken: loginResp["token"],
|
||||||
|
newUserID: loginResp["user_id"],
|
||||||
|
newHomeserver: matrix.homeserver,
|
||||||
|
newDeviceName: "Fluffy Matrix Client",
|
||||||
|
newDeviceID: loginResp["device_id"],
|
||||||
|
newMatrixVersions: ["r0.4.0"],
|
||||||
|
newLazyLoadMembers: false
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Send a message to a Room:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
final resp = await jsonRequest(
|
||||||
|
type: "PUT",
|
||||||
|
action: "/r0/rooms/!fjd823j:example.com/send/m.room.message/$txnId",
|
||||||
|
data: {
|
||||||
|
"msgtype": "m.text",
|
||||||
|
"body": "hello"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
Loading…
Reference in a new issue