mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-29 11:59:00 +00:00

* chore: update client-api rev * chore: update collab rev id * feat: add sign_in_request and import shared entity * feat: added to userworkspace from af_workspace * chore: add script to update the client-api rev id * chore: update client-api rev * feat: add workspaces api * feat: added check user * chore: config * chore: update client_api version * chore: ws connect * chore: ws connect * chore: update crate versions * chore: rename event * chore: update client-appi * chore: set appflowy cloud env * chore: add env template * chore: update env name * docs: update docs * fix: check_user * feat: impl sign_in_with_url * feat: add file storage placeholders * chore: update client-api * chore: disable test * feat: impl workspace add and remove * chore: sign up test * feat: select cover image on upload (#3488) * fix: close popover after item selection in settings view (#3362) * fix: close popover after item selection in settings view * fix: add missing await before closing popover * fix: find popover container by context instead of passing controllers around * fix: add requested changes * feat: close text direction settings popups after selection * fix: clean up * fix: restore theme value dropdown as StatefulWidget * feat: openai and stabilityai integration (#3439) * chore: create trait * test: add tests * chore: remove log * chore: disable log * chore: checklist ux flow redesign (#3418) * chore: ux flow redesign * chore: remove unused imports * fix: allow creation of tasks of the same name * chore: apply code suggestions from Mathias * fix: add padding below field title text field (#3440) * Fixed Issue no #3426 * Reversed the pubspec.lock mistaken update * FIXED PADDING * Fixed Padding issue on calender field edit popup * chore: rename package name (#3501) * fix: right icon size sam as left one (#3494) * feat: enable removing user icon (#3487) * feat: enable removing user icon * fix: generate to true * fix: review comments * fix: more review comments * fix: integration test and final changes * fix: made cursor grab and background color when hovering on Appearance Options Buttons (#3498) * chore: calendar UI polish (#3484) * chore: update calendar theming * feat: add event popup editor * chore: new event button redesign and add card shadows * chore: unscheduled events button * chore: event title text field * fix: focus node double dispose * chore: show popover when create new event * test: integrate some tests for integration testing purposes * fix: some fixes and more integration tests * chore: add more space between font item and font menu * feat: add reset font button in toolbar * feat: only show text direction toolbar item when RTL is enabled * fix: unable to change RTL of heading block * test: add integration test for ltr/rtl mode * chore: update inlang project settings (#3441) * feat: using script to update the collab source. (#3508) * chore: add script * chore: update script * chore: update bytes version * chore: submit lock file * chore: update test * chore: update test * chore: bump version * chore: update * ci: fix * ci: fix * chore: update commit id * chore: update commit id * chore: update commit id * fix: is cloud enable --------- Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg> Co-authored-by: Mathias Mogensen <42929161+Xazin@users.noreply.github.com> Co-authored-by: Vincenzo De Petris <37916223+vincendep@users.noreply.github.com> Co-authored-by: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Co-authored-by: Aryan More <61151896+aryan-more@users.noreply.github.com> Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io> Co-authored-by: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Co-authored-by: Nitin-Poojary <70025277+Nitin-Poojary@users.noreply.github.com> Co-authored-by: Jannes Blobel <72493222+jannesblobel@users.noreply.github.com>
167 lines
5.8 KiB
Dart
167 lines
5.8 KiB
Dart
import 'package:appflowy/env/env.dart';
|
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
|
import 'package:appflowy/startup/startup.dart';
|
|
import 'package:appflowy/user/application/auth/auth_service.dart';
|
|
import 'package:appflowy/user/application/splash_bloc.dart';
|
|
import 'package:appflowy/user/domain/auth_state.dart';
|
|
import 'package:appflowy/user/presentation/helpers/helpers.dart';
|
|
import 'package:appflowy/user/presentation/router.dart';
|
|
import 'package:appflowy/user/presentation/screens/screens.dart';
|
|
import 'package:appflowy/util/platform_extension.dart';
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
|
import 'package:appflowy_backend/log.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
// [[diagram: splash screen]]
|
|
// ┌────────────────┐1.get user ┌──────────┐ ┌────────────┐ 2.send UserEventCheckUser
|
|
// │ SplashScreen │──────────▶│SplashBloc│────▶│ISplashUser │─────┐
|
|
// └────────────────┘ └──────────┘ └────────────┘ │
|
|
// │
|
|
// ▼
|
|
// ┌───────────┐ ┌─────────────┐ ┌────────┐
|
|
// │HomeScreen │◀───────────│BlocListener │◀────────────────│RustSDK │
|
|
// └───────────┘ └─────────────┘ └────────┘
|
|
// 4. Show HomeScreen or SignIn 3.return AuthState
|
|
class SplashScreen extends StatelessWidget {
|
|
/// Root Page of the app.
|
|
const SplashScreen({
|
|
super.key,
|
|
required this.autoRegister,
|
|
});
|
|
|
|
final bool autoRegister;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!autoRegister) {
|
|
return _buildChild(context);
|
|
} else {
|
|
return FutureBuilder<void>(
|
|
future: _registerIfNeeded(),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState != ConnectionState.done) {
|
|
return Container();
|
|
}
|
|
return _buildChild(context);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
BlocProvider<SplashBloc> _buildChild(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) =>
|
|
getIt<SplashBloc>()..add(const SplashEvent.getUser()),
|
|
child: Scaffold(
|
|
body: BlocListener<SplashBloc, SplashState>(
|
|
listener: (context, state) {
|
|
state.auth.map(
|
|
authenticated: (r) => _handleAuthenticated(context, r),
|
|
unauthenticated: (r) => _handleUnauthenticated(context, r),
|
|
initial: (r) => {},
|
|
);
|
|
},
|
|
child: const Body(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Handles the authentication flow once a user is authenticated.
|
|
Future<void> _handleAuthenticated(
|
|
BuildContext context,
|
|
Authenticated authenticated,
|
|
) async {
|
|
final userProfile = authenticated.userProfile;
|
|
|
|
/// After a user is authenticated, this function checks if encryption is required.
|
|
final result = await UserEventCheckEncryptionSign().send();
|
|
result.fold(
|
|
(check) async {
|
|
/// If encryption is needed, the user is navigated to the encryption screen.
|
|
/// Otherwise, it fetches the current workspace for the user and navigates them
|
|
if (check.isNeedSecret) {
|
|
getIt<AuthRouter>().pushEncryptionScreen(context, userProfile);
|
|
} else {
|
|
final result = await FolderEventGetCurrentWorkspace().send();
|
|
result.fold(
|
|
(workspaceSetting) {
|
|
// After login, replace Splash screen by corresponding home screen
|
|
getIt<SplashRouter>().goHomeScreen(
|
|
context,
|
|
);
|
|
},
|
|
(error) => handleOpenWorkspaceError(context, error),
|
|
);
|
|
}
|
|
},
|
|
(err) {
|
|
Log.error(err);
|
|
},
|
|
);
|
|
}
|
|
|
|
void _handleUnauthenticated(BuildContext context, Unauthenticated result) {
|
|
Log.trace(
|
|
'_handleUnauthenticated -> cloud is enabled: $isCloudEnabled',
|
|
);
|
|
// replace Splash screen as root page
|
|
if (isCloudEnabled) {
|
|
context.go(SignInScreen.routeName);
|
|
} else {
|
|
// if the env is not configured, we will skip to the 'skip login screen'.
|
|
context.go(SkipLogInScreen.routeName);
|
|
}
|
|
}
|
|
|
|
Future<void> _registerIfNeeded() async {
|
|
final result = await UserEventGetUserProfile().send();
|
|
if (!result.isLeft()) {
|
|
await getIt<AuthService>().signUpAsGuest();
|
|
}
|
|
}
|
|
}
|
|
|
|
class Body extends StatelessWidget {
|
|
const Body({super.key});
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
alignment: Alignment.center,
|
|
child: PlatformExtension.isMobile
|
|
? const FlowySvg(
|
|
FlowySvgs.flowy_logo_xl,
|
|
blendMode: null,
|
|
)
|
|
: const _DesktopSplashBody(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _DesktopSplashBody extends StatelessWidget {
|
|
const _DesktopSplashBody();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
return SingleChildScrollView(
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Image(
|
|
fit: BoxFit.cover,
|
|
width: size.width,
|
|
height: size.height,
|
|
image: const AssetImage(
|
|
'assets/images/appflowy_launch_splash.jpg',
|
|
),
|
|
),
|
|
const CircularProgressIndicator.adaptive(),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|