Skip to content

Commit

Permalink
minor adjustments to profile selector
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiangsu committed Jun 24, 2023
1 parent 61255d6 commit b7e10eb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
- Added initial inbox feature to see your replies, mentions, and private messages
- Added about page with links to lemmy and github repository

### Changed
- Adjusted size of create comment bottom modal, and enabled text selection within the modal for the parent's comment
- Slight improvements to account/profile selection to show which profile is currently active

### Fixed
- Potentially fixed issue where scrolling behaviour is weird when creating a new post or comment
- Fixed issue where usernames/passwords containing leading or trailing spaces may fail to login - contribution from @MrAntonS

## 0.2.1+5 - 2023-06-22
### Added
Expand Down
35 changes: 24 additions & 11 deletions lib/account/widgets/profile_modal_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class ProfileSelect extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
String? currentAccountId = context.read<ThunderBloc>().state.preferences?.getString('active_profile_id');

return FutureBuilder(
future: fetchAccounts(),
builder: (context, snapshot) {
Expand All @@ -77,24 +79,35 @@ class ProfileSelect extends StatelessWidget {
);
} else {
return ListTile(
leading: const Icon(Icons.person),
title: Text(snapshot.data![index].username ?? 'N/A'),
leading: Icon(
Icons.person,
color: currentAccountId == snapshot.data![index].id ? Colors.amber : null,
),
title: Text(
snapshot.data![index].username ?? 'N/A',
style: theme.textTheme.titleMedium?.copyWith(),
),
subtitle: Text(snapshot.data![index].instance?.replaceAll('https://', '') ?? 'N/A'),
onTap: (currentAccountId == snapshot.data![index].id)
? null
: () {
context.read<AuthBloc>().add(SwitchAccount(accountId: snapshot.data![index].id));
context.pop();
},
trailing: IconButton(
icon: const Icon(
Icons.delete,
semanticLabel: 'Remove Account',
),
onPressed: () {
context.read<AuthBloc>().add(RemoveAccount(accountId: snapshot.data![index].id));
context.pop();
}),
trailing: (currentAccountId == snapshot.data![index].id)
? const InputChip(
label: Text('Active'),
visualDensity: VisualDensity.compact,
)
: IconButton(
icon: const Icon(
Icons.delete,
semanticLabel: 'Remove Account',
),
onPressed: () {
context.read<AuthBloc>().add(RemoveAccount(accountId: snapshot.data![index].id));
context.pop();
}),
);
}
},
Expand Down
18 changes: 16 additions & 2 deletions lib/inbox/pages/inbox_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/inbox/bloc/inbox_bloc.dart';

import 'package:thunder/inbox/widgets/inbox_mentions_view.dart';
Expand Down Expand Up @@ -58,7 +59,10 @@ class _InboxPageState extends State<InboxPage> {
title: AutoSizeText('Inbox', style: theme.textTheme.titleLarge),
actions: [
IconButton(
icon: const Icon(Icons.refresh_rounded),
icon: const Icon(
Icons.refresh_rounded,
semanticLabel: 'Refresh',
),
onPressed: () {
context.read<InboxBloc>().add(const GetInboxEvent());
},
Expand Down Expand Up @@ -94,11 +98,21 @@ class _InboxPageState extends State<InboxPage> {
children: [
const SizedBox(height: 10),
BlocBuilder<InboxBloc, InboxState>(builder: (context, InboxState state) {
if (context.read<AuthBloc>().state.isLoggedIn == false) {
return const Text('Log in to see your inbox');
}

switch (state.status) {
case InboxStatus.initial:
case InboxStatus.loading:
case InboxStatus.refreshing:
return const CircularProgressIndicator();
return const Center(
child: SizedBox(
width: 40,
height: 40,
child: CircularProgressIndicator(),
),
);
case InboxStatus.success:
if (_inboxType == InboxType.mentions) return const InboxMentionsView();
if (_inboxType == InboxType.messages) return const InboxPrivateMessagesView();
Expand Down

0 comments on commit b7e10eb

Please sign in to comment.