Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class _MobileWorkspaceStartScreenState
final style = Theme.of(context);
final size = MediaQuery.of(context).size;
const double spacing = 16.0;
final hasWorkspaces = widget.workspaceState.workspaces.isNotEmpty;
final List<DropdownMenuEntry<WorkspacePB>> workspaceEntries =
<DropdownMenuEntry<WorkspacePB>>[];
for (final WorkspacePB workspace in widget.workspaceState.workspaces) {
Expand All @@ -48,7 +49,7 @@ class _MobileWorkspaceStartScreenState
);
}

// render the workspace dropdown menu if success, otherwise render error page
// render the workspace dropdown menu if success, otherwise render error page
final body = widget.workspaceState.successOrFailure.fold(
(_) {
return Padding(
Expand Down Expand Up @@ -106,21 +107,18 @@ class _MobileWorkspaceStartScreenState
style: ElevatedButton.styleFrom(
minimumSize: const Size(double.infinity, 56),
),
onPressed: () {
if (selectedWorkspace == null) {
// If user didn't choose any workspace, pop to the initial workspace(first workspace)
_popToWorkspace(
context,
widget.workspaceState.workspaces.first,
);
return;
}
// pop to the selected workspace
_popToWorkspace(
context,
selectedWorkspace!,
);
},
onPressed:
hasWorkspaces
? () {
final workspace =
selectedWorkspace ??
widget.workspaceState.workspaces.first;

// If user didn't choose any workspace, pop to the
// initial workspace(first workspace).
_popToWorkspace(context, workspace);
}
: null,
child: Text(LocaleKeys.signUp_getStartedText.tr()),
),
const VSpace(spacing),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:appflowy/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart';
import 'package:appflowy/workspace/application/workspace/prelude.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'test_material_app.dart';

void main() {
setUpAll(() async {
EasyLocalization.logger.enableLevels = [];
await EasyLocalization.ensureInitialized();
});

group('MobileWorkspaceStartScreen', () {
testWidgets('disables get started when workspaces are empty', (
tester,
) async {
await tester.pumpWidget(
WidgetTestApp(
child: MobileWorkspaceStartScreen(
workspaceState: WorkspaceState(
isLoading: false,
workspaces: const [],
successOrFailure: FlowyResult.success(null),
),
),
),
);

await tester.pumpAndSettle();

final button = tester.widget<ElevatedButton>(find.byType(ElevatedButton));
expect(button.onPressed, isNull);
});
});
}
Loading