From 534e31e63477c94a36da40fbbc0ff6176a2c2455 Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 4 Sep 2022 20:35:41 +0200 Subject: [PATCH] refactor profile view --- lib/pages/profile_view/profile_view.dart | 108 +++++++++++++---------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/lib/pages/profile_view/profile_view.dart b/lib/pages/profile_view/profile_view.dart index 19415c8..2b50885 100644 --- a/lib/pages/profile_view/profile_view.dart +++ b/lib/pages/profile_view/profile_view.dart @@ -17,57 +17,15 @@ class ProfileView extends StatefulWidget { } class _ProfileViewState extends State { - RelationshipModel? relationship; - - static const d = SizedBox( - height: 8, - ); - - void update() async { - final r = await getRelationship(widget.model.identity, widget.model.id); - setState(() { - relationship = r.values.first; - }); - } - - @override - void initState() { - super.initState(); - update(); - } - @override Widget build(BuildContext context) { - List c = [ - Image.network( - width: global.getWidth(context), - fit: BoxFit.fitWidth, - widget.model.header, - errorBuilder: (context, error, stackTrace) => const SizedBox.shrink(), - ), - StatusIndicators( - model: widget.model, - relationship: relationship, - ), - d, - DisplayName( - account: widget.model, - clickable: false, - ), - d, - PostTextRenderer(input: widget.model.note), - ]; return SimpleDialog( alignment: Alignment.center, contentPadding: const EdgeInsets.all(24), children: [ - Container( - constraints: global.getConstraints(context), - width: global.getWidth(context), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: c, - ), + DropdownButton(items: [], onChanged: null), + ProfileViewDisplay( + model: widget.model, ) ], ); @@ -132,3 +90,63 @@ class StatusIndicators extends StatelessWidget { ); } } + +class ProfileViewDisplay extends StatefulWidget { + const ProfileViewDisplay({super.key, required this.model}); + final AccountModel model; + + @override + State createState() => _ProfileViewDisplayState(); +} + +class _ProfileViewDisplayState extends State { + RelationshipModel? relationship; + + static const d = SizedBox( + height: 8, + ); + + void update() async { + final r = await getRelationship(widget.model.identity, widget.model.id); + setState(() { + relationship = r.values.first; + }); + } + + @override + void initState() { + super.initState(); + update(); + } + + @override + Widget build(BuildContext context) { + List c = [ + Image.network( + width: global.getWidth(context), + fit: BoxFit.fitWidth, + widget.model.header, + errorBuilder: (context, error, stackTrace) => const SizedBox.shrink(), + ), + StatusIndicators( + model: widget.model, + relationship: relationship, + ), + d, + DisplayName( + account: widget.model, + clickable: false, + ), + d, + PostTextRenderer(input: widget.model.note), + ]; + return Container( + constraints: global.getConstraints(context), + width: global.getWidth(context), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: c, + ), + ); + } +}