|
|
|
@ -15,6 +15,7 @@ import 'package:flushbar/flushbar.dart';
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:universal_html/prefer_universal/html.dart' as html;
|
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
@ -43,12 +44,8 @@ class Matrix extends StatefulWidget {
|
|
|
|
|
MatrixState createState() => MatrixState();
|
|
|
|
|
|
|
|
|
|
/// Returns the (nearest) Client instance of your application.
|
|
|
|
|
static MatrixState of(BuildContext context) {
|
|
|
|
|
var newState =
|
|
|
|
|
(context.dependOnInheritedWidgetOfExactType<_InheritedMatrix>()).data;
|
|
|
|
|
newState.context = FirebaseController.context = context;
|
|
|
|
|
return newState;
|
|
|
|
|
}
|
|
|
|
|
static MatrixState of(BuildContext context) =>
|
|
|
|
|
Provider.of<MatrixState>(context, listen: false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MatrixState extends State<Matrix> {
|
|
|
|
@ -57,8 +54,6 @@ class MatrixState extends State<Matrix> {
|
|
|
|
|
@override
|
|
|
|
|
BuildContext context;
|
|
|
|
|
|
|
|
|
|
static const String userStatusesType = 'chat.fluffy.user_statuses';
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> get shareContent => _shareContent;
|
|
|
|
|
set shareContent(Map<String, dynamic> content) {
|
|
|
|
|
_shareContent = content;
|
|
|
|
@ -438,26 +433,9 @@ class MatrixState extends State<Matrix> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return _InheritedMatrix(
|
|
|
|
|
data: this,
|
|
|
|
|
return Provider(
|
|
|
|
|
create: (_) => this,
|
|
|
|
|
child: widget.child,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InheritedMatrix extends InheritedWidget {
|
|
|
|
|
final MatrixState data;
|
|
|
|
|
|
|
|
|
|
_InheritedMatrix({Key key, this.data, Widget child})
|
|
|
|
|
: super(key: key, child: child);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool updateShouldNotify(_InheritedMatrix old) {
|
|
|
|
|
var update = old.data.client.accessToken != data.client.accessToken ||
|
|
|
|
|
old.data.client.userID != data.client.userID ||
|
|
|
|
|
old.data.client.deviceID != data.client.deviceID ||
|
|
|
|
|
old.data.client.deviceName != data.client.deviceName ||
|
|
|
|
|
old.data.client.homeserver != data.client.homeserver;
|
|
|
|
|
return update;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|