mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: enable continue last session after logout (#3253)
This commit is contained in:
@ -238,14 +238,8 @@ class SignInAsGuestButton extends StatelessWidget {
|
|||||||
child: BlocBuilder<HistoricalUserBloc, HistoricalUserState>(
|
child: BlocBuilder<HistoricalUserBloc, HistoricalUserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final text = state.historicalUsers.isEmpty
|
final text = state.historicalUsers.isEmpty
|
||||||
? FlowyText.medium(
|
? LocaleKeys.signIn_loginAsGuestButtonText.tr()
|
||||||
LocaleKeys.signIn_loginAsGuestButtonText.tr(),
|
: LocaleKeys.signIn_continueAnonymousUser.tr();
|
||||||
textAlign: TextAlign.center,
|
|
||||||
)
|
|
||||||
: FlowyText.medium(
|
|
||||||
LocaleKeys.signIn_continueAnonymousUser.tr(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
|
|
||||||
final onTap = state.historicalUsers.isEmpty
|
final onTap = state.historicalUsers.isEmpty
|
||||||
? () {
|
? () {
|
||||||
@ -265,7 +259,10 @@ class SignInAsGuestButton extends StatelessWidget {
|
|||||||
child: FlowyButton(
|
child: FlowyButton(
|
||||||
isSelected: true,
|
isSelected: true,
|
||||||
disable: signInState.isSubmitting,
|
disable: signInState.isSubmitting,
|
||||||
text: text,
|
text: FlowyText.medium(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
radius: Corners.s6Border,
|
radius: Corners.s6Border,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
),
|
),
|
||||||
|
@ -4,6 +4,7 @@ import 'package:appflowy/startup/entry_point.dart';
|
|||||||
import 'package:appflowy/startup/launch_configuration.dart';
|
import 'package:appflowy/startup/launch_configuration.dart';
|
||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
import 'package:appflowy/user/application/auth/auth_service.dart';
|
import 'package:appflowy/user/application/auth/auth_service.dart';
|
||||||
|
import 'package:appflowy/user/application/historical_user_bloc.dart';
|
||||||
import 'package:appflowy/workspace/application/appearance.dart';
|
import 'package:appflowy/workspace/application/appearance.dart';
|
||||||
import 'package:appflowy/workspace/presentation/settings/widgets/settings_language_view.dart';
|
import 'package:appflowy/workspace/presentation/settings/widgets/settings_language_view.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
@ -19,7 +20,6 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
|
|||||||
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../generated/locale_keys.g.dart';
|
import '../../generated/locale_keys.g.dart';
|
||||||
@ -289,21 +289,52 @@ class GoButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FlowyTextButton(
|
return BlocProvider(
|
||||||
LocaleKeys.letsGoButtonText.tr(),
|
create: (context) => HistoricalUserBloc()
|
||||||
constraints: const BoxConstraints(
|
..add(
|
||||||
maxWidth: 340,
|
const HistoricalUserEvent.initial(),
|
||||||
maxHeight: 48,
|
),
|
||||||
|
child: BlocListener<HistoricalUserBloc, HistoricalUserState>(
|
||||||
|
listenWhen: (previous, current) =>
|
||||||
|
previous.openedHistoricalUser != current.openedHistoricalUser,
|
||||||
|
listener: (context, state) async {
|
||||||
|
await runAppFlowy();
|
||||||
|
},
|
||||||
|
child: BlocBuilder<HistoricalUserBloc, HistoricalUserState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
final text = state.historicalUsers.isEmpty
|
||||||
|
? LocaleKeys.letsGoButtonText.tr()
|
||||||
|
: LocaleKeys.signIn_continueAnonymousUser.tr();
|
||||||
|
|
||||||
|
final textWidget = FlowyText.medium(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
fontSize: 14,
|
||||||
|
);
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
width: 340,
|
||||||
|
height: 48,
|
||||||
|
child: FlowyButton(
|
||||||
|
isSelected: true,
|
||||||
|
text: textWidget,
|
||||||
|
radius: Corners.s6Border,
|
||||||
|
onTap: () {
|
||||||
|
if (state.historicalUsers.isNotEmpty) {
|
||||||
|
final bloc = context.read<HistoricalUserBloc>();
|
||||||
|
final historicalUser = state.historicalUsers.first;
|
||||||
|
bloc.add(
|
||||||
|
HistoricalUserEvent.openHistoricalUser(historicalUser),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
onPressed();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
radius: BorderRadius.circular(12),
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
fontSize: FontSizes.s14,
|
|
||||||
fontFamily: GoogleFonts.poppins(fontWeight: FontWeight.w500).fontFamily,
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14.0),
|
|
||||||
onPressed: onPressed,
|
|
||||||
fillColor: Theme.of(context).colorScheme.primary,
|
|
||||||
fontColor: Theme.of(context).colorScheme.onPrimary,
|
|
||||||
hoverColor: Theme.of(context).colorScheme.primaryContainer,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user