FurryChat/lib/components/list_items/status_list_item.dart

84 lines
2.9 KiB
Dart
Raw Normal View History

2020-10-03 13:53:08 +00:00
import 'package:famedlysdk/famedlysdk.dart';
2020-10-06 19:59:36 +00:00
import 'package:furrychat/utils/user_status.dart';
import 'package:furrychat/views/status_view.dart';
2020-10-03 13:53:08 +00:00
import 'package:flutter/material.dart';
import '../avatar.dart';
import '../matrix.dart';
class StatusListItem extends StatelessWidget {
final UserStatus status;
const StatusListItem(this.status, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
final client = Matrix.of(context).client;
return FutureBuilder<Profile>(
future: client.getProfileFromUserId(status.userId),
builder: (context, snapshot) {
final profile =
2020-10-04 17:22:31 +00:00
snapshot.data ?? Profile(status.userId.localpart, null);
2020-10-03 13:53:08 +00:00
return InkWell(
borderRadius: BorderRadius.circular(8),
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => StatusView(
status: status,
avatarUrl: profile.avatarUrl,
displayname: profile.displayname,
),
),
),
child: Container(
width: 76,
child: Column(
children: <Widget>[
SizedBox(height: 10),
Container(
child: Stack(
children: [
Avatar(profile.avatarUrl, profile.displayname),
Positioned(
bottom: 0,
right: 0,
child: Container(
width: 10,
height: 10,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.green,
),
),
),
],
),
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: Theme.of(context).primaryColor,
),
borderRadius: BorderRadius.circular(80),
),
padding: EdgeInsets.all(2),
),
Padding(
padding:
const EdgeInsets.only(left: 6.0, top: 0.0, right: 6.0),
child: Text(
profile.displayname.trim().split(' ').first,
overflow: TextOverflow.clip,
maxLines: 1,
style: TextStyle(
color: Theme.of(context).textTheme.bodyText2.color,
fontSize: 13,
),
),
),
],
),
),
);
});
}
}