From b281ffc0614e1618e37784c922f88740a84d41dd Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 16:30:02 +0200 Subject: [PATCH] unify spacing --- lib/dialogues/full_post_view.dart | 22 +++++++++++++--------- lib/dialogues/makepost.dart | 3 ++- lib/dialogues/profile_view.dart | 15 ++++++++++----- lib/dialogues/search.dart | 3 ++- lib/global.dart | 4 +++- lib/pages/notifications/notifications.dart | 2 ++ lib/pages/notifications/single_notif.dart | 6 ++++-- lib/pages/timeline/timeline.dart | 2 ++ lib/partials/post.dart | 9 ++++++--- lib/partials/thread.dart | 3 ++- lib/themes/themes.dart | 13 ++++++++++--- 11 files changed, 56 insertions(+), 26 deletions(-) diff --git a/lib/dialogues/full_post_view.dart b/lib/dialogues/full_post_view.dart index 1dc92eb..784a0d3 100644 --- a/lib/dialogues/full_post_view.dart +++ b/lib/dialogues/full_post_view.dart @@ -4,6 +4,7 @@ import 'package:loris/business_logic/network_tools/get_post_from_url.dart'; import 'package:loris/business_logic/posts/posts.dart'; import 'package:loris/business_logic/timeline/timeline.dart'; import 'package:loris/global.dart' as global; +import 'package:loris/themes/themes.dart' as themes; import '../partials/post.dart'; @@ -126,7 +127,7 @@ class _FullPostViewState extends State { ], ) : Padding( - padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + padding: themes.defaultInsideMargins, child: Wrap( alignment: WrapAlignment.spaceAround, crossAxisAlignment: WrapCrossAlignment.center, @@ -188,13 +189,16 @@ class _FullPostViewState extends State { maxWidth: global.getConstraints(context).maxWidth), width: global.getWidth(context), child: SingleChildScrollView( - child: SingleFullPostDisplay( - ancestors: ancestors, - descendants: descendants, - hidden: widget.hidden, - level: 0, - model: identities[activeIdentity]!.reblog ?? - identities[activeIdentity]!, + child: Padding( + padding: themes.defaultMargins, + child: SingleFullPostDisplay( + ancestors: ancestors, + descendants: descendants, + hidden: widget.hidden, + level: 0, + model: identities[activeIdentity]!.reblog ?? + identities[activeIdentity]!, + ), ), ), ) @@ -251,7 +255,7 @@ class SingleFullPostDisplay extends StatelessWidget { c.addAll(descendantsWidgets); return Container( padding: - EdgeInsets.fromLTRB(level == 0 ? 4 : 4, 0, level == 0 ? 4 : 0, 0), + EdgeInsets.fromLTRB(level == 0 ? 0 : 4, 0, level == 0 ? 0 : 4, 0), decoration: BoxDecoration( border: level == 0 ? const Border() diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index ba39586..9348235 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -12,6 +12,7 @@ import 'package:loris/global.dart' as global; import 'package:file_picker/file_picker.dart'; import 'package:mime/mime.dart'; import 'package:universal_io/io.dart' as io; +import 'package:loris/themes/themes.dart' as themes; class MakePost extends StatefulWidget { const MakePost({Key? key, this.inReplyTo}) : super(key: key); @@ -393,7 +394,7 @@ class _MakePostState extends State { return SimpleDialog( titlePadding: const EdgeInsets.all(0), alignment: Alignment.center, - contentPadding: const EdgeInsets.all(24), + contentPadding: themes.defaultMargins, title: Column( children: [ if (status != null) SelectableText(status!), diff --git a/lib/dialogues/profile_view.dart b/lib/dialogues/profile_view.dart index 32315e0..455fec5 100644 --- a/lib/dialogues/profile_view.dart +++ b/lib/dialogues/profile_view.dart @@ -10,6 +10,7 @@ import 'package:loris/partials/post.dart'; import 'package:loris/partials/post_text_renderer.dart'; import 'package:loris/global.dart' as global; import 'package:loris/partials/thread.dart'; +import 'package:loris/themes/themes.dart' as themes; class ProfileView extends StatefulWidget { const ProfileView({ @@ -210,7 +211,11 @@ class _ProfileViewState extends State { width: global.getWidth(context) + MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.height * 2 / 3, - child: ListView.builder( + child: ListView.separated( + separatorBuilder: (context, index) => const Divider( + color: Colors.transparent, + height: themes.defaultSeperatorHeight, + ), controller: _scrollController, itemCount: threads.length + 2, itemBuilder: (context, index) { @@ -218,7 +223,7 @@ class _ProfileViewState extends State { return profileViewDisplay; } else if (index > 0 && index <= threads.length) { return Padding( - padding: const EdgeInsets.all(8.0), + padding: themes.defaultMargins, child: Thread( model: threads[index - 1], constrained: false, @@ -352,7 +357,7 @@ class ProfileViewDisplay extends StatelessWidget { errorBuilder: (context, error, stackTrace) => const SizedBox.shrink(), ), Padding( - padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + padding: themes.defaultMargins, child: StatusIndicators( model: accountModel, relationship: relationshipModel, @@ -360,12 +365,12 @@ class ProfileViewDisplay extends StatelessWidget { ), d, Padding( - padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + padding: themes.defaultMargins, child: PostTextRenderer(input: accountModel.note), ), if (relationshipModel != null) Padding( - padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + padding: themes.defaultMargins, child: AccountInteractionButtons( account: accountModel, relationship: relationshipModel!, diff --git a/lib/dialogues/search.dart b/lib/dialogues/search.dart index d8fca7a..ff2640a 100644 --- a/lib/dialogues/search.dart +++ b/lib/dialogues/search.dart @@ -4,6 +4,7 @@ import 'package:loris/business_logic/account/account.dart'; import 'package:loris/business_logic/timeline/timeline.dart'; import 'package:loris/global.dart' as global; import 'package:loris/business_logic/search/search.dart' as logic; +import 'package:loris/themes/themes.dart' as themes; import '../partials/post.dart'; @@ -98,7 +99,7 @@ class _SearchDialogueState extends State { if (index < accountModels.length) { final model = accountModels[index]; return Padding( - padding: const EdgeInsets.all(8.0), + padding: themes.defaultMargins, child: Column( children: [ SelectableText(model.identity), diff --git a/lib/global.dart b/lib/global.dart index 0606e27..baaf77a 100644 --- a/lib/global.dart +++ b/lib/global.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:loris/business_logic/settings.dart'; +import 'themes/themes.dart' as themes; const String name = "loris"; const String version = "v0.4 'the posts update'"; @@ -24,7 +25,8 @@ const List bad = [ ]; double getWidth(context) { - return (MediaQuery.of(context).size.width * settings!.postWidth) - 24; + return (MediaQuery.of(context).size.width * settings!.postWidth) - + (themes.defaultSeperatorHeight * 2); } BoxConstraints getConstraints(context) { diff --git a/lib/pages/notifications/notifications.dart b/lib/pages/notifications/notifications.dart index 81af0c6..6dd55d7 100644 --- a/lib/pages/notifications/notifications.dart +++ b/lib/pages/notifications/notifications.dart @@ -7,6 +7,7 @@ import 'package:loris/business_logic/notifications/notifs.dart'; import 'package:loris/pages/notifications/single_notif.dart'; import 'package:loris/partials/loadingbox.dart'; import '../../business_logic/websocket.dart' as websocket; +import 'package:loris/themes/themes.dart' as themes; final notifStream = StreamController.broadcast(); @@ -133,6 +134,7 @@ class _NotificationsState extends State { addSemanticIndexes: true, itemBuilder: ((context, index) => notifs[index]), separatorBuilder: (context, index) => const Divider( + height: themes.defaultSeperatorHeight, color: Colors.transparent, ), itemCount: notifs.length), diff --git a/lib/pages/notifications/single_notif.dart b/lib/pages/notifications/single_notif.dart index 292ce37..6e0a352 100644 --- a/lib/pages/notifications/single_notif.dart +++ b/lib/pages/notifications/single_notif.dart @@ -3,6 +3,7 @@ import 'package:loris/business_logic/notifications/notifs.dart'; import 'package:loris/dialogues/profile_view.dart'; import 'package:loris/partials/post.dart'; import '../../global.dart' as global; +import 'package:loris/themes/themes.dart' as themes; class SingleNotif extends StatelessWidget { const SingleNotif({ @@ -17,19 +18,20 @@ class SingleNotif extends StatelessWidget { child: Container( width: global.getWidth(context), constraints: global.getConstraints(context), - padding: const EdgeInsets.all(24), + padding: themes.defaultInsideMargins, decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, border: Border.all( color: Theme.of(context).colorScheme.secondary, width: 2, ), - borderRadius: BorderRadius.circular(8), + borderRadius: const BorderRadius.all(themes.defaultRadius), ), child: Material( child: Column( children: [ InkWell( + borderRadius: const BorderRadius.all(themes.defaultRadius), onTap: () => showDialog( context: context, builder: (context) => ProfileView(model: model.account), diff --git a/lib/pages/timeline/timeline.dart b/lib/pages/timeline/timeline.dart index 1e97eb3..2f7442a 100644 --- a/lib/pages/timeline/timeline.dart +++ b/lib/pages/timeline/timeline.dart @@ -5,6 +5,7 @@ import 'package:loris/partials/thread.dart'; import '../../business_logic/timeline/timeline.dart' as tl; import '../../global.dart' as global; import 'package:loris/partials/loadingbox.dart'; +import 'package:loris/themes/themes.dart' as themes; class Timeline extends StatefulWidget { const Timeline({Key? key}) : super(key: key); @@ -212,6 +213,7 @@ class TimelineState extends State { separatorBuilder: (context, index) { return const Divider( color: Colors.transparent, + height: themes.defaultSeperatorHeight, ); }, itemCount: children.length, diff --git a/lib/partials/post.dart b/lib/partials/post.dart index ef285ed..4be7ce3 100644 --- a/lib/partials/post.dart +++ b/lib/partials/post.dart @@ -12,6 +12,7 @@ import 'package:loris/partials/post_text_renderer.dart'; import 'package:url_launcher/url_launcher_string.dart'; import '../business_logic/timeline/timeline.dart' as tl; import '../business_logic/interactions/interactions.dart' as interactions; +import 'package:loris/themes/themes.dart' as themes; class Post extends StatefulWidget { const Post({ @@ -36,6 +37,7 @@ class _PostState extends State { List c = []; c.addAll([ DisplayName(account: widget.model.account), + const SizedBox(height: 2), SizedBox( width: double.maxFinite, child: PostBody( @@ -87,6 +89,7 @@ class DisplayName extends StatelessWidget { usernameStyle = Theme.of(context).textTheme.displaySmall; } return InkWell( + borderRadius: const BorderRadius.all(themes.defaultRadius), onTap: !openInBrowser ? () { showDialog( @@ -169,7 +172,7 @@ class ProfilePic extends StatelessWidget { const double width = 64; if (url.isNotEmpty) { return ClipRRect( - borderRadius: BorderRadius.circular(8), + borderRadius: const BorderRadius.all(themes.defaultRadius), child: Image.network( fit: BoxFit.cover, url, @@ -227,13 +230,13 @@ class _PostBodyState extends State { @override Widget build(BuildContext context) { return InkWell( + borderRadius: const BorderRadius.all(themes.defaultRadius), onTap: () => showDialog( context: context, builder: (context) => FullPostView(originPostModel: widget.model), ), - child: Container( + child: SizedBox( width: double.infinity, - padding: const EdgeInsets.fromLTRB(0, 6, 0, 6), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/partials/thread.dart b/lib/partials/thread.dart index 3665a59..5c37318 100644 --- a/lib/partials/thread.dart +++ b/lib/partials/thread.dart @@ -3,6 +3,7 @@ import 'package:localization/localization.dart'; import 'package:loris/partials/post.dart'; import '../business_logic/timeline/timeline.dart' as logic; import '../global.dart' as global; +import 'package:loris/themes/themes.dart' as themes; class Thread extends StatefulWidget { const Thread({ @@ -111,7 +112,7 @@ class _ThreadState extends State { child: Material( borderRadius: const BorderRadius.all(Radius.circular(8)), child: Padding( - padding: const EdgeInsets.all(24), + padding: themes.defaultInsideMargins, child: Column( children: c, ), diff --git a/lib/themes/themes.dart b/lib/themes/themes.dart index 8228e8d..3d1967b 100644 --- a/lib/themes/themes.dart +++ b/lib/themes/themes.dart @@ -16,6 +16,9 @@ bool checkActive(Set states) { } const defaultRadius = Radius.circular(8); +const defaultSeperatorHeight = 4.0; +const defaultInsideMargins = EdgeInsets.all(18); +const defaultMargins = EdgeInsets.all(18); // color schemes to pick from can be added here // there is a class to create these @@ -210,14 +213,18 @@ ThemeData getTheme(CustomColors colors) { dialogTheme: DialogTheme( elevation: 0, backgroundColor: colors.colorScheme.surface, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(defaultRadius))), + shape: RoundedRectangleBorder( + side: BorderSide( + width: 2, + color: colors.colorScheme.secondary, + style: BorderStyle.solid), + borderRadius: const BorderRadius.all(defaultRadius))), selectedRowColor: colors.colorScheme.background, textSelectionTheme: TextSelectionThemeData(selectionColor: colors.hintColor), primaryIconTheme: const IconThemeData(size: 24), hoverColor: colors.hoverColor, - shadowColor: colors.colorScheme.surface, + shadowColor: Colors.transparent, focusColor: colors.hoverColor, indicatorColor: colors.hintColor, disabledColor: colors.hintColor,