refactor: MVC archive
parent
ca70ec0240
commit
bff8a2629a
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/views/archive_view.dart';
|
||||||
|
import 'package:fluffychat/views/widgets/matrix.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Archive extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
ArchiveController createState() => ArchiveController();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ArchiveController extends State<Archive> {
|
||||||
|
List<Room> archive;
|
||||||
|
|
||||||
|
Future<List<Room>> getArchive(BuildContext context) async {
|
||||||
|
if (archive != null) return archive;
|
||||||
|
return await Matrix.of(context).client.archive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void forgetAction(int i) => setState(() => archive.removeAt(i));
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => ArchiveView(this);
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/*import 'package:fluffychat/controllers/archive_controller.dart';
|
||||||
|
import 'package:fluffychat/main.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'utils/test_client.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Test if the widget can be created', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(FluffyChatApp(
|
||||||
|
testWidget: Archive(),
|
||||||
|
testClient: await testClient(loggedIn: true),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*/
|
@ -0,0 +1,20 @@
|
|||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/utils/fluffy_client.dart';
|
||||||
|
|
||||||
|
Future<FluffyClient> testClient({
|
||||||
|
bool loggedIn = false,
|
||||||
|
String homeserver = 'https://fakeserver.notexisting',
|
||||||
|
String id = 'FluffyChat Widget Test',
|
||||||
|
}) async {
|
||||||
|
final client = FluffyClient(testMode: true);
|
||||||
|
if (homeserver != null) {
|
||||||
|
await client.checkHomeserver(homeserver);
|
||||||
|
}
|
||||||
|
if (loggedIn) {
|
||||||
|
await client.login(
|
||||||
|
identifier: AuthenticationUserIdentifier(user: '@alice:example.invalid'),
|
||||||
|
password: '1234',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return client;
|
||||||
|
}
|
Loading…
Reference in New Issue