2020-01-05 12:27:03 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2021-04-12 18:33:43 +02:00
|
|
|
import 'package:fluffychat/controllers/archive_controller.dart';
|
2021-04-09 16:15:03 +02:00
|
|
|
import 'package:fluffychat/views/widgets/list_items/chat_list_item.dart';
|
2020-01-05 12:27:03 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-10-03 13:11:07 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2020-01-05 12:27:03 +01:00
|
|
|
|
2021-04-12 18:33:43 +02:00
|
|
|
class ArchiveView extends StatelessWidget {
|
|
|
|
final ArchiveController controller;
|
2020-01-05 12:27:03 +01:00
|
|
|
|
2021-04-12 18:33:43 +02:00
|
|
|
const ArchiveView(this.controller, {Key key}) : super(key: key);
|
2020-01-05 12:27:03 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-01-16 12:46:38 +01:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2021-01-16 14:24:52 +01:00
|
|
|
leading: BackButton(),
|
2021-01-16 12:46:38 +01:00
|
|
|
title: Text(L10n.of(context).archive),
|
2020-01-05 12:27:03 +01:00
|
|
|
),
|
2021-01-16 12:46:38 +01:00
|
|
|
body: FutureBuilder<List<Room>>(
|
2021-04-12 18:33:43 +02:00
|
|
|
future: controller.getArchive(context),
|
2021-01-16 12:46:38 +01:00
|
|
|
builder: (BuildContext context, snapshot) {
|
2021-04-12 18:33:43 +02:00
|
|
|
if (snapshot.hasError) {
|
|
|
|
return Center(
|
|
|
|
child: Text(
|
|
|
|
L10n.of(context).oopsSomethingWentWrong,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
));
|
|
|
|
}
|
2021-01-16 12:46:38 +01:00
|
|
|
if (!snapshot.hasData) {
|
|
|
|
return Center(child: CircularProgressIndicator());
|
|
|
|
} else {
|
2021-04-12 18:33:43 +02:00
|
|
|
controller.archive = snapshot.data;
|
2021-01-16 12:46:38 +01:00
|
|
|
return ListView.builder(
|
2021-04-12 18:33:43 +02:00
|
|
|
itemCount: controller.archive.length,
|
2021-01-16 12:46:38 +01:00
|
|
|
itemBuilder: (BuildContext context, int i) => ChatListItem(
|
2021-04-12 18:33:43 +02:00
|
|
|
controller.archive[i],
|
|
|
|
onForget: controller.forgetAction,
|
|
|
|
),
|
2021-01-16 12:46:38 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2020-01-05 12:27:03 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|