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

Add Onboarding Pages #35

Merged
merged 6 commits into from
Jul 19, 2023
Merged
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
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def keystoreProperties = new Properties()

android {
compileSdkVersion 33
ndkVersion '25.1.8937393'
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand Down
Binary file added assets/rive/balloon.riv
Binary file not shown.
Binary file added assets/rive/dark.riv
Binary file not shown.
Binary file added assets/rive/team-work.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rive/wod.riv
Binary file not shown.
63 changes: 57 additions & 6 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:integration_test/integration_test.dart';
import 'package:navbar_router/navbar_router.dart';
import 'package:vocabhub/main.dart' as app;
import 'package:vocabhub/navbar/navbar.dart';
import 'package:vocabhub/onboarding/onboarding.dart';
import 'package:vocabhub/pages/login.dart';

extension FindText on String {
Expand All @@ -30,12 +31,62 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized()
as IntegrationTestWidgetsFlutterBinding;
group('Test App should load', () {
group('Test App should load:', () {
testWidgets('New User should be onboarded', (WidgetTester tester) async {
await app.main();
// await binding.convertFlutterSurfaceToImage();
await Future.delayed(const Duration(seconds: 3));
await tester.pumpAndSettle();
expect((app.VocabApp).typeX(), findsOneWidget);
await tester.pumpAndSettle();
await Future.delayed(const Duration(seconds: 1));
expect((WelcomePage).typeX(), findsOneWidget);
// final title = "Welcome\nto\nVocabhub".textX();
// expect(title, findsOneWidget);
await tester.pumpAndSettle();
final takeATour = "Take a tour".textX();
expect(takeATour, findsOneWidget);
await tester.pumpAndSettle();
await tester.tap(takeATour);
await tester.pumpAndSettle();
expect((OnboardingPage).typeX(), findsOneWidget);
await tester.pumpAndSettle();
await Future.delayed(const Duration(seconds: 3));
final title1 = 'A Crowd Sourced platform'.textX();
expect(title1, findsOneWidget);
final list = List.generate(3, (index) => index).toList();
double offset = 400;
await for (final item in Stream.fromIterable(list)) {
await tester.timedDragFrom(
Offset(offset, 800), Offset(-offset, 800), Duration(milliseconds: 500));
await tester.pumpAndSettle();
offset += 400;
}
// await Future.delayed(const Duration(seconds: 1));
// final title2 = 'Word of the Day'.textX();
// expect(title2, findsOneWidget);
// await Future.delayed(const Duration(seconds: 1));
// await tester.dragFrom(Offset(400, 800), const Offset(-400, 800));
// // await tester.drag(pageView, const Offset(-400, 400));
// await tester.pumpAndSettle();
// final title3 = 'Explore curated words'.textX();
// expect(title3, findsOneWidget);
// await tester.dragFrom(Offset(400, 800), const Offset(-400, 800));
await tester.pumpAndSettle();
await Future.delayed(const Duration(seconds: 1));
final getStartedText = "Get Started".textX();
expect(getStartedText, findsOneWidget);
await tester.pumpAndSettle();
await tester.tap(getStartedText);
await tester.pumpAndSettle();
expect((AppSignIn).typeX(), findsOneWidget);
});

testWidgets('User should be able to login', (WidgetTester tester) async {
// runZonedGuarded(app.main, (error, stack) {
// });
app.main();
await binding.convertFlutterSurfaceToImage();
await app.main();
// await binding.convertFlutterSurfaceToImage();
await Future.delayed(const Duration(seconds: 3));
await tester.pumpAndSettle();
expect((app.VocabApp).typeX(), findsOneWidget);
Expand Down Expand Up @@ -81,8 +132,8 @@ void main() {
});

testWidgets("User stays loggedIn", (widgetTester) async {
app.main();
await binding.convertFlutterSurfaceToImage();
await app.main();
// await binding.convertFlutterSurfaceToImage();
await Future.delayed(const Duration(seconds: 3));
await widgetTester.pumpAndSettle();
expect((Dashboard).typeX(), findsOneWidget);
Expand All @@ -102,7 +153,7 @@ void main() {
});

testWidgets("Ensure all navbar widgets load", (widgetTester) async {
app.main();
await app.main();
await binding.convertFlutterSurfaceToImage();
final List<Widget> baseWidgets = [
Dashboard(),
Expand Down
15 changes: 15 additions & 0 deletions lib/controller/settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ class SettingsController extends ChangeNotifier {
ThemeMode get theme => _theme;
bool _ratedOnPlayStore = false;
DateTime _lastRatedDate = DateTime.now();
bool _isOnboarded = false;

bool get hasRatedOnPlaystore => _ratedOnPlayStore;

bool get isOnboarded => _isOnboarded;

bool get isDark => _theme == ThemeMode.dark;
Color _themeSeed = VocabTheme.colorSeeds[1];
String? version;
Expand All @@ -25,6 +28,11 @@ class SettingsController extends ChangeNotifier {

DateTime get lastRatedDate => _lastRatedDate;

Future<bool> getOnBoarded() async {
_isOnboarded = await _settingsService!.getOnboarded();
return _isOnboarded;
}

/// Returns the last rated sheet shown date
/// this time does not indicate the user has rated the app
/// it only indicates the last time the user was shown the rate sheet
Expand All @@ -33,6 +41,12 @@ class SettingsController extends ChangeNotifier {
return _lastRatedDate;
}

set onBoarded(bool value) {
_isOnboarded = value;
notifyListeners();
_settingsService!.setOnboarded(value);
}

set themeSeed(Color value) {
_themeSeed = value;
notifyListeners();
Expand Down Expand Up @@ -73,6 +87,7 @@ class SettingsController extends ChangeNotifier {
_themeSeed = await getThemeSeed();
_ratedOnPlayStore = getRatedOnPlaystore();
_lastRatedDate = await getLastRatedShown();
_isOnboarded = await getOnBoarded();
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
version = packageInfo.version;
notifyListeners();
Expand Down
10 changes: 10 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
// import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -50,6 +51,14 @@ Future<void> main() async {
));
}

class AppScrollBehavior extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
};
}

@pragma('vm:entry-point')
void notificationTapBackground(NotificationResponse notificationResponse) {
// ignore: avoid_print
Expand Down Expand Up @@ -143,6 +152,7 @@ class _VocabAppState extends ConsumerState<VocabApp> {
final colorScheme = ColorScheme.fromSeed(seedColor: settingsController.themeSeed);
return MaterialApp(
title: Constants.APP_TITLE,
scrollBehavior: AppScrollBehavior(),
navigatorObservers: [_observer],
debugShowCheckedModeBanner: !kDebugMode,
darkTheme: ThemeData.dark(
Expand Down
1 change: 0 additions & 1 deletion lib/navbar/dashboard/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ class DashboardDesktop extends StatelessWidget {
),
),
Container(
// height: SizeUtils.size.height * 0.95,
padding: EdgeInsets.symmetric(vertical: 16.0),
width: 400,
child: Column(
Expand Down
1 change: 1 addition & 0 deletions lib/navbar/profile/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class _SettingsPageMobileState extends ConsumerState<SettingsPageMobile> {
}),
hLine(),
settingTile('Logout', trailingIcon: Icons.logout, onTap: () async {
user.loggedIn = false;
authController.logout(context);
Navigate.pushAndPopAll(context, AppSignIn());
}),
Expand Down
4 changes: 3 additions & 1 deletion lib/navbar/search/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class _MobileViewState extends State<MobileView> {
wordsByAlphabet[index].add(element);
}
});
showToast('${words.length} Words fetched successfully');
if (NavbarNotifier.currentIndex == SEARCH_INDEX) {
showToast('${words.length} Words fetched successfully');
}
response.value = response.value.copyWith(
data: wordsByAlphabet,
state: RequestState.done,
Expand Down
Loading