Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small UI fixes #305

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 47 additions & 32 deletions lib/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ List<Widget> createCommonAppBarActions(BuildContext context) {
onPressed: () => pushNamedRoute(context, routeSearch, SearchArguments(0, focusInputOnOpen: true)),
),
IconButton(
icon: const Icon(Symbols.settings),
icon: const Icon(
Symbols.settings,
),
onPressed: () {
Navigator.pushNamed(context, routeSettings);
},
Expand Down Expand Up @@ -132,7 +134,13 @@ class _HomeScreenState extends State<_HomeScreen> {
var username = link.pathSegments[0];
var statusId = link.pathSegments[2];

pushNamedRoute(context, routeStatus, StatusScreenArguments(id: statusId, username: username,));
pushNamedRoute(
context,
routeStatus,
StatusScreenArguments(
id: statusId,
username: username,
));
return;
}

Expand Down Expand Up @@ -231,7 +239,8 @@ class _HomeScreenState extends State<_HomeScreen> {

switch (e.id) {
case 'feed':
return FeedScreen(key: _feedKey, scrollController: scrollController, id: '-1', name: L10n.current.feed);
return FeedScreen(
key: _feedKey, scrollController: scrollController, id: '-1', name: L10n.current.feed);
case 'subscriptions':
return SubscriptionsScreen();
case 'groups':
Expand Down Expand Up @@ -270,7 +279,8 @@ class ScaffoldWithBottomNavigation extends StatefulWidget {
final List<Widget> Function(ScrollController scrollController) builder;
final GlobalKey<FeedScreenState>? feedKey;

const ScaffoldWithBottomNavigation({Key? key, required this.pages, required this.initialPage, required this.builder, required this.feedKey})
const ScaffoldWithBottomNavigation(
{Key? key, required this.pages, required this.initialPage, required this.builder, required this.feedKey})
: super(key: key);

@override
Expand Down Expand Up @@ -349,8 +359,7 @@ class ScaffoldWithBottomNavigationState extends State<ScaffoldWithBottomNavigati
int idx = widget.pages.indexWhere((e) => e.id == 'subscriptions');
if (navigationAnimations) {
_pageController?.animateToPage(idx, curve: Curves.easeInOut, duration: const Duration(milliseconds: 100));
}
else {
} else {
_pageController?.jumpToPage(idx);
}
});
Expand All @@ -360,35 +369,41 @@ class ScaffoldWithBottomNavigationState extends State<ScaffoldWithBottomNavigati
controller: _pageController,
physics: const LessSensitiveScrollPhysics(),
onPageChanged: (page) => navigationAnimations
? Debouncer.debounce('page-change', const Duration(milliseconds: 200), () {
setState(() => _selectedIndex = page);
})
: setState(() => _selectedIndex = page),
? Debouncer.debounce('page-change', const Duration(milliseconds: 200), () {
setState(() => _selectedIndex = page);
})
: setState(() => _selectedIndex = page),
children: _children,
),
bottomNavigationBar: NavigationBar(
selectedIndex: _selectedIndex,
backgroundColor: Theme.of(context).brightness == Brightness.dark && themeTrueBlack ? Colors.black : null,
indicatorColor: Theme.of(context).brightness == Brightness.dark && themeTrueBlack ? Colors.black : null,
labelBehavior: showTabLabels
? NavigationDestinationLabelBehavior.alwaysShow
: NavigationDestinationLabelBehavior.alwaysHide,
height: PrefService.of(context).get(optionHomeShowTabLabels) ? 70 : 40,
destinations: [
..._pages.map((e) => NavigationDestination(icon: Icon(e.icon, size: 22), label: e.titleBuilder(context)))
],
onDestinationSelected: (int value) async {
if (_children[value] is FeedScreen && widget.feedKey != null && widget.feedKey!.currentState != null) {
await widget.feedKey!.currentState!.checkUpdateOrRefreshFeed();
}
if (navigationAnimations) {
_pageController?.animateToPage(value, duration: const Duration(milliseconds: 200), curve: Curves.linear);
}
else {
_pageController?.jumpToPage(value);
}
}
),
selectedIndex: _selectedIndex,
surfaceTintColor: Theme.of(context).brightness == Brightness.dark && themeTrueBlack ? Colors.black : null,
backgroundColor: Theme.of(context).brightness == Brightness.dark && themeTrueBlack ? Colors.black : null,
indicatorColor: Theme.of(context).brightness == Brightness.dark && themeTrueBlack ? Colors.black : null,
labelBehavior: showTabLabels
? NavigationDestinationLabelBehavior.alwaysShow
: NavigationDestinationLabelBehavior.alwaysHide,
height: PrefService.of(context).get(optionHomeShowTabLabels) ? 70 : 40,
destinations: [
..._pages.map((e) => NavigationDestination(
selectedIcon: Icon(
e.icon,
size: 22,
fill: 1,
),
icon: Icon(e.icon, size: 22),
label: e.titleBuilder(context)))
],
onDestinationSelected: (int value) async {
if (_children[value] is FeedScreen && widget.feedKey != null && widget.feedKey!.currentState != null) {
await widget.feedKey!.currentState!.checkUpdateOrRefreshFeed();
}
if (navigationAnimations) {
_pageController?.animateToPage(value, duration: const Duration(milliseconds: 200), curve: Curves.linear);
} else {
_pageController?.jumpToPage(value);
}
}),
);
}
}
88 changes: 44 additions & 44 deletions lib/tweet/tweet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
getNewEntity: (Hashtag hashtag) {
return TweetHashtag(
hashtag,
() => pushNamedRoute(context, routeSearch, SearchArguments(1, focusInputOnOpen: false, query: '#${hashtag.text}')));
() => pushNamedRoute(
context, routeSearch, SearchArguments(1, focusInputOnOpen: false, query: '#${hashtag.text}')));
});

entities = _populateEntities(
Expand Down Expand Up @@ -287,8 +288,7 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
if (urlEnt.url.expandedUrl == null || !_isTwitterUrl(urlEnt.url.expandedUrl!)) {
addPartContent = true;
}
}
else {
} else {
addPartContent = true;
}
if (addPartContent) {
Expand Down Expand Up @@ -331,14 +331,14 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
fill: fill,
),
color: color ?? Theme.of(context).colorScheme.primary,
iconSize: 20,
iconSize: 18,
onPressed: onPressed,
);
}

_createFooterTextButton(IconData icon, String label, [Color? color, Function()? onPressed]) {
return TextButton.icon(
icon: Icon(icon, size: 20, color: color),
icon: Icon(icon, size: 18, color: color),
onPressed: onPressed,
label: Text(label, style: TextStyle(color: color, fontSize: 14)),
);
Expand Down Expand Up @@ -419,7 +419,8 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
if (this.tweet.retweetedStatusWithCard != null) {
retweetBanner = _TweetTileLeading(
icon: Symbols.repeat,
onTap: () => pushNamedRoute(context, routeProfile, ProfileScreenArguments.fromScreenName(this.tweet.user!.screenName!)),
onTap: () =>
pushNamedRoute(context, routeProfile, ProfileScreenArguments.fromScreenName(this.tweet.user!.screenName!)),
children: [
TextSpan(
text: L10n.of(context)
Expand Down Expand Up @@ -473,43 +474,42 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi

if (isBirdwatchQuote) {
return Card(
child: Container(
// Fill the width so both RTL and LTR text are displayed correctly
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: Column(
children: [
_TweetTileLeading(icon: Symbols.group_rounded, children: [
TextSpan(
text: L10n.of(context).community_notes_title,
style: TextStyle(color: theme.textTheme.bodySmall!.color, fontSize: theme.textTheme.bodySmall!.fontSize, fontWeight: ui.FontWeight.bold),
)
]),
SizedBox(height: 8),
AutoDirection(
text: tweetText,
child: Text.rich(
TextSpan(children: [
..._displayParts.map((e) {
if (e.plainText != null) {
return TextSpan(text: e.plainText, style: TextStyle(fontSize: optionTweetFontSizeValue));
}
else {
return e.entity!;
}
})]),
)
),
]
)
)
);
child: Container(
// Fill the width so both RTL and LTR text are displayed correctly
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: Column(children: [
_TweetTileLeading(icon: Symbols.group_rounded, children: [
TextSpan(
text: L10n.of(context).community_notes_title,
style: TextStyle(
color: theme.textTheme.bodySmall!.color,
fontSize: theme.textTheme.bodySmall!.fontSize,
fontWeight: ui.FontWeight.bold),
)
]),
SizedBox(height: 8),
AutoDirection(
text: tweetText,
child: Text.rich(
TextSpan(children: [
..._displayParts.map((e) {
if (e.plainText != null) {
return TextSpan(text: e.plainText, style: TextStyle(fontSize: optionTweetFontSizeValue));
} else {
return e.entity!;
}
})
]),
)),
])));
}

var birdwatchQuoted = Container();
if (tweet.birdwatchQuotedStatus != null) {
birdwatchQuoted = Container(
decoration: BoxDecoration(border: Border.all(color: theme.primaryColor), borderRadius: BorderRadius.circular(8)),
decoration:
BoxDecoration(border: Border.all(color: theme.primaryColor), borderRadius: BorderRadius.circular(8)),
margin: const EdgeInsets.all(8),
child: TweetTile(
clickable: false,
Expand Down Expand Up @@ -602,9 +602,9 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
builder: (context, model, child) => RepaintBoundary(
key: _globalKey,
child: Card(
color: theme.brightness == Brightness.dark && prefs.get(optionThemeTrueBlack)
? Colors.black
: null,
color: theme.brightness == Brightness.dark && prefs.get(optionThemeTrueBlack) ? Colors.black : null,
surfaceTintColor:
theme.brightness == Brightness.dark && prefs.get(optionThemeTrueBlack) ? Colors.black : null,
child: Row(
children: [
retweetSidebar,
Expand Down Expand Up @@ -634,7 +634,8 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
if (currentUsername != null && tweet.user!.screenName!.endsWith(currentUsername!)) {
return;
}
pushNamedRoute(context, routeProfile, ProfileScreenArguments(tweet.user!.idStr, tweet.user!.screenName));
pushNamedRoute(context, routeProfile,
ProfileScreenArguments(tweet.user!.idStr, tweet.user!.screenName));
},
title: Row(
children: [
Expand Down Expand Up @@ -767,8 +768,7 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
await model.deleteSavedTweet(tweet.idStr!);
if (mounted) {
setState(() {});
}
else {
} else {
DataService().map['toggleRefreshFeed'] = true;
}
});
Expand Down
39 changes: 20 additions & 19 deletions lib/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class FollowButtonSelectGroupDialog extends StatefulWidget {
}

class _FollowButtonSelectGroupDialogState extends State<FollowButtonSelectGroupDialog> {

@override
Widget build(BuildContext context) {
var groupModel = context.read<GroupsModel>();
Expand All @@ -127,19 +126,16 @@ class _FollowButtonSelectGroupDialogState extends State<FollowButtonSelectGroupD
var color = Theme.of(context).brightness == Brightness.dark ? Colors.white70 : Colors.black54;

return MultiSelectDialog(
title: Row(
children: [
Text(L10n.of(context).select),
Spacer(),
IconButton(
title: Row(children: [
Text(L10n.of(context).select),
Spacer(),
IconButton(
icon: const Icon(Symbols.add),
onPressed: () async {
await openSubscriptionGroupDialog(context, null, '', defaultGroupIcon, preMembers: {widget.user.id});
Navigator.pop(context, 'reload');
}
),
]
),
}),
]),
searchHint: L10n.of(context).search,
confirmText: Text(L10n.of(context).ok),
cancelText: Text(L10n.of(context).cancel),
Expand Down Expand Up @@ -180,8 +176,11 @@ class FollowButton extends StatelessWidget {
var followed = state.any((element) => element.id == user.id);
var inFeed = followed ? state.any((element) => element.id == user.id && element.inFeed) : false;

var icon =
followed ? (inFeed ? Icon(Symbols.person_remove_rounded, color: color) : const Icon(Symbols.person_remove_rounded, color: Colors.red)) : Icon(Symbols.person_add_rounded, color: color);
var icon = followed
? (inFeed
? Icon(Symbols.person_remove_rounded, color: color)
: const Icon(Symbols.person_remove_rounded, color: Colors.red))
: Icon(Symbols.person_add_rounded, color: color);
var textSub = followed ? L10n.of(context).unsubscribe : L10n.of(context).subscribe;
var textFeed = followed ? (inFeed ? L10n.of(context).remove_from_feed : L10n.of(context).add_to_feed) : null;

Expand All @@ -202,12 +201,12 @@ class FollowButton extends StatelessWidget {
while (resp is String && resp == 'reload') {
var groups = await context.read<GroupsModel>().listGroupsForUser(user.id);
resp = await showDialog(
context: context,
builder: (_) => FollowButtonSelectGroupDialog(
user: user,
followed: followed,
groupsForUser: groups,
));
context: context,
builder: (_) => FollowButtonSelectGroupDialog(
user: user,
followed: followed,
groupsForUser: groups,
));
}
break;
case 'toggle_subscribe':
Expand Down Expand Up @@ -257,7 +256,9 @@ class UserWithExtra extends User {
..entities = json['entities'] == null ? null : UserEntities.fromJson(json['entities'] as Map<String, dynamic>)
..description = json['description'] as String?
..protected = json['protected'] as bool?
..verified = json['ext_is_blue_verified'] ?? json['verified'] as bool?
..verified = json['verified_type'] == "Business"
? true
: json['ext_is_blue_verified'] ?? json['verified'] ?? json['is_blue_verified'] as bool?
..status = json['status'] == null ? null : Tweet.fromJson(json['status'] as Map<String, dynamic>)
..followersCount = json['followers_count'] as int?
..friendsCount = json['friends_count'] as int?
Expand Down