2020-01-05 11:27:03 +00:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2020-10-06 19:59:36 +00:00
|
|
|
import 'package:furrychat/components/adaptive_page_layout.dart';
|
|
|
|
import 'package:furrychat/components/list_items/chat_list_item.dart';
|
|
|
|
import 'package:furrychat/components/matrix.dart';
|
2020-01-05 11:27:03 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2020-10-03 11:11:07 +00:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2020-01-05 11:27:03 +00:00
|
|
|
|
|
|
|
class Archive extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_ArchiveState createState() => _ArchiveState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ArchiveState 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AdaptivePageLayout(
|
|
|
|
firstScaffold: Scaffold(
|
|
|
|
appBar: AppBar(
|
2020-05-07 05:52:40 +00:00
|
|
|
title: Text(L10n.of(context).archive),
|
2020-01-05 11:27:03 +00:00
|
|
|
),
|
|
|
|
body: FutureBuilder<List<Room>>(
|
|
|
|
future: getArchive(context),
|
|
|
|
builder: (BuildContext context, snapshot) {
|
|
|
|
if (!snapshot.hasData) {
|
|
|
|
return Center(child: CircularProgressIndicator());
|
|
|
|
} else {
|
|
|
|
archive = snapshot.data;
|
|
|
|
return ListView.builder(
|
|
|
|
itemCount: archive.length,
|
|
|
|
itemBuilder: (BuildContext context, int i) => ChatListItem(
|
|
|
|
archive[i],
|
2020-02-16 08:22:56 +00:00
|
|
|
onForget: () => setState(() => archive.removeAt(i))),
|
2020-01-05 11:27:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
secondScaffold: Scaffold(
|
|
|
|
body: Center(
|
2020-05-13 13:58:59 +00:00
|
|
|
child: Image.asset('assets/logo.png', width: 100, height: 100),
|
2020-01-05 11:27:03 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
primaryPage: FocusPage.FIRST,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|