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

Account page and management improvements #1354

Merged
merged 11 commits into from
May 16, 2024
6 changes: 3 additions & 3 deletions lib/account/pages/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ class _AccountPageState extends State<AccountPage> with AutomaticKeepAliveClient
listeners: [
BlocListener<AuthBloc, AuthState>(
listener: (context, state) {
if (!state.reload) return;
if (state.isLoggedIn && !state.reload) return;
setState(() => authState = state);
},
),
BlocListener<AccountBloc, AccountState>(
listener: (context, state) {
if (!state.reload) return;
if (authState.isLoggedIn && !state.reload) return;
setState(() => accountState = state);
},
),
],
child: (authState.isLoggedIn && accountState.status == AccountStatus.success && accountState.personView != null)
child: (authState.isLoggedIn)
? UserPage(
userId: accountState.personView!.person.id,
isAccountUser: true,
Expand Down
112 changes: 78 additions & 34 deletions lib/account/pages/login_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand Down Expand Up @@ -187,47 +186,92 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
firstChild: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RichText(
text: TextSpan(
style: theme.textTheme.bodySmall?.copyWith(color: Colors.blue),
text: AppLocalizations.of(context)!.gettingStarted,
recognizer: TapGestureRecognizer()
..onTap = () {
handleLink(context, url: 'https://join-lemmy.org/');
},
OutlinedButton(
onPressed: () {
handleLink(context, url: 'https://join-lemmy.org/');
},
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.only(left: 10, right: 16),
backgroundColor: theme.colorScheme.surface,
textStyle: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onPrimary,
),
),
child: Row(
children: [
Icon(
Icons.insert_link_rounded,
color: theme.textTheme.bodySmall?.color,
),
const SizedBox(
width: 8,
),
Text(
AppLocalizations.of(context)!.gettingStarted,
style: theme.textTheme.bodySmall,
),
],
),
),
],
),
secondChild: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(width: 5),
RichText(
text: TextSpan(
style: theme.textTheme.bodySmall?.copyWith(color: Colors.blue),
text: AppLocalizations.of(context)!.openInstance,
recognizer: TapGestureRecognizer()
..onTap = () {
handleLink(context, url: 'https://${_instanceTextEditingController.text}');
},
OutlinedButton(
onPressed: () {
handleLink(context, url: 'https://${_instanceTextEditingController.text}');
},
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.only(left: 10, right: 16),
backgroundColor: theme.colorScheme.surface,
textStyle: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onPrimary,
),
),
child: Row(
children: [
Icon(
Icons.insert_link_rounded,
color: theme.textTheme.bodySmall?.color,
),
const SizedBox(
width: 8,
),
Text(
AppLocalizations.of(context)!.openInstance,
style: theme.textTheme.bodySmall,
),
],
),
),
if (!widget.anonymous) ...[
const SizedBox(width: 10),
Text(
'|',
style: theme.textTheme.bodySmall,
),
const SizedBox(width: 10),
RichText(
text: TextSpan(
style: theme.textTheme.bodySmall?.copyWith(color: Colors.blue),
text: AppLocalizations.of(context)!.createAccount,
recognizer: TapGestureRecognizer()
..onTap = () {
handleLink(context, url: 'https://${_instanceTextEditingController.text}/signup');
},
const SizedBox(width: 12),
OutlinedButton(
onPressed: () {
handleLink(context, url: 'https://${_instanceTextEditingController.text}/signup');
},
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.only(left: 10, right: 16),
backgroundColor: theme.colorScheme.surface,
textStyle: theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onPrimary,
),
),
child: Row(
children: [
Icon(
Icons.insert_link_rounded,
color: theme.textTheme.bodySmall?.color,
),
const SizedBox(
width: 8,
),
Text(
AppLocalizations.of(context)!.createAccount,
style: theme.textTheme.bodySmall,
),
],
),
),
],
Expand Down Expand Up @@ -274,7 +318,7 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
hideOnError: true,
),
if (!widget.anonymous) ...[
const SizedBox(height: 35.0),
const SizedBox(height: 32.0),
AutofillGroup(
child: Column(
children: <Widget>[
Expand Down Expand Up @@ -344,7 +388,6 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
enableSuggestions: false,
),
],
const SizedBox(height: 12.0),
const SizedBox(height: 32.0),
ElevatedButton(
style: ElevatedButton.styleFrom(
Expand All @@ -362,6 +405,7 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
child: Text(widget.anonymous ? AppLocalizations.of(context)!.add : AppLocalizations.of(context)!.login,
style: theme.textTheme.titleMedium?.copyWith(color: !isLoading && fieldsFilledIn ? theme.colorScheme.onPrimary : theme.colorScheme.primary)),
),
const SizedBox(height: 12.0),
TextButton(
style: ElevatedButton.styleFrom(minimumSize: const Size.fromHeight(60)),
onPressed: !isLoading ? () => widget.popRegister() : null,
Expand Down
2 changes: 1 addition & 1 deletion lib/account/widgets/profile_modal_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class _ProfileSelectState extends State<ProfileSelect> {
),
],
),
trailing: !widget.quickSelectMode && (accounts!.length > 1 || anonymousInstances?.isNotEmpty == true)
trailing: !widget.quickSelectMode
? (currentAccountId == accounts![index].account.id)
? IconButton(
icon: loggingOutId == accounts![index].account.id
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,10 @@
"@thickness": {
"description": "Describes a thickness (e.g., divider)"
},
"thisAccount": "This Account",
"@thisAccount": {
"description": "Referring to the currently active account in account settings"
},
"thunderHasBeenUpdated": "Thunder updated to {version}!",
"@thunderHasBeenUpdated": {
"description": "Heading for changelog when Thunder has been updated"
Expand Down
30 changes: 12 additions & 18 deletions lib/user/pages/user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ class _UserPageState extends State<UserPage> {
appBar: AppBar(
scrolledUnderElevation: 0,
leading: widget.isAccountUser
? IconButton(
onPressed: () => showProfileModalSheet(context, showLogoutDialog: true),
icon: Icon(
Icons.logout,
semanticLabel: AppLocalizations.of(context)!.logOut,
? Padding(
padding: const EdgeInsets.fromLTRB(0.0, 4.0, 4.0, 4.0),
child: IconButton(
onPressed: () => showProfileModalSheet(context),
icon: Icon(
Icons.people_alt_rounded,
semanticLabel: AppLocalizations.of(context)!.profiles,
),
tooltip: AppLocalizations.of(context)!.profiles,
),
tooltip: AppLocalizations.of(context)!.logOut,
)
: null,
actions: [
Expand Down Expand Up @@ -118,18 +121,6 @@ class _UserPageState extends State<UserPage> {
tooltip: AppLocalizations.of(context)!.accountSettings,
),
),
if (widget.isAccountUser)
Padding(
padding: const EdgeInsets.fromLTRB(0.0, 4.0, 4.0, 4.0),
child: IconButton(
onPressed: () => showProfileModalSheet(context),
icon: Icon(
Icons.people_alt_rounded,
semanticLabel: AppLocalizations.of(context)!.profiles,
),
tooltip: AppLocalizations.of(context)!.profiles,
),
),
],
),
body: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
Expand All @@ -149,6 +140,9 @@ class _UserPageState extends State<UserPage> {
case UserStatus.refreshing:
case UserStatus.success:
case UserStatus.failedToBlock:
if (state.personView == null) {
return const Center(child: CircularProgressIndicator());
}
return UserPageSuccess(
userId: widget.userId,
isAccountUser: widget.isAccountUser,
Expand Down
Loading
Loading