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