profile pics and usernames now visible
This commit is contained in:
parent
eed5290109
commit
652db6391e
|
@ -0,0 +1,11 @@
|
|||
class AccountModel {
|
||||
late String acct;
|
||||
late String displayName;
|
||||
late String avatar;
|
||||
|
||||
AccountModel.fromJson(Map<String, dynamic> json) {
|
||||
acct = json["acct"];
|
||||
displayName = json["display_name"];
|
||||
avatar = json["avatar"];
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:slothmu/business_logic/account/account.dart';
|
||||
import '../settings.dart' as settings;
|
||||
import '../../global.dart' as global;
|
||||
|
||||
|
@ -20,6 +21,7 @@ class PostModel implements Comparable {
|
|||
late String spoilerText;
|
||||
late bool favourited;
|
||||
late bool reblogged;
|
||||
late AccountModel account;
|
||||
|
||||
PostModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json["id"] as String;
|
||||
|
@ -32,6 +34,7 @@ class PostModel implements Comparable {
|
|||
spoilerText = json["spoiler_text"] as String;
|
||||
favourited = json["favourited"] as bool;
|
||||
reblogged = json["reblogged"] as bool;
|
||||
account = AccountModel.fromJson(json["account"]);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:slothmu/business_logic/account/account.dart';
|
||||
import '../business_logic/timeline/timeline.dart' as tl;
|
||||
|
||||
class Post extends StatefulWidget {
|
||||
|
@ -15,7 +16,7 @@ class _PostState extends State<Post> {
|
|||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
const DisplayName(),
|
||||
DisplayName(account: widget.model.account),
|
||||
PostBody(
|
||||
sensitive: widget.model.sensitive,
|
||||
content: widget.model.content,
|
||||
|
@ -29,27 +30,31 @@ class _PostState extends State<Post> {
|
|||
|
||||
class DisplayName extends StatelessWidget {
|
||||
const DisplayName({
|
||||
required this.account,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
final AccountModel account;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.face,
|
||||
size: 64,
|
||||
),
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: ProfilePic(
|
||||
url: account.avatar,
|
||||
)),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"first name display last name name",
|
||||
account.displayName,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
Text(
|
||||
"@alice_exampleuser@example.com",
|
||||
account.acct,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
|
@ -59,6 +64,27 @@ class DisplayName extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class ProfilePic extends StatelessWidget {
|
||||
const ProfilePic({required this.url, Key? key}) : super(key: key);
|
||||
final String url;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double width = 64;
|
||||
if (url.isNotEmpty) {
|
||||
return Image.network(
|
||||
url,
|
||||
width: 64,
|
||||
);
|
||||
} else {
|
||||
return const Icon(
|
||||
Icons.cruelty_free,
|
||||
size: width,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PostBody extends StatefulWidget {
|
||||
const PostBody({
|
||||
required this.sensitive,
|
||||
|
|
Loading…
Reference in New Issue