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

Interactive Book Integration Phase 1 | GSoC 2021 #110

Merged
merged 47 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
313e772
Bringup Interactive Book UI Views.
manjotsidhu Jun 7, 2021
fe2031e
IbPageView: Implement Table of Contents UI.
manjotsidhu Jun 8, 2021
dc88b2b
IbPageView: Fading Floating Action Buttons for readability
manjotsidhu Jun 9, 2021
29618f5
IbPageView: Improve Floating Action Buttons.
manjotsidhu Jun 11, 2021
5bdcdfd
IbLandingView: Seperate Actions for Expandable tile Drawer
manjotsidhu Jun 11, 2021
b4d06a5
UI Tests: Fix Landing View Test due to recent changes
manjotsidhu Jun 12, 2021
d4701bd
GH Actions: Temporarily enable ib branch to run CI.
manjotsidhu Jun 12, 2021
db8c834
Models: Bringup Interactive Book Models.
manjotsidhu Jun 12, 2021
dc140e6
Services: Implement Interactive Book APIs
manjotsidhu Jun 13, 2021
a1e9e07
IbPageView: Use camelCasing for constructor variable.
manjotsidhu Jun 13, 2021
c3e4704
Tests: Fix IbApiTest typo.
manjotsidhu Jun 13, 2021
7cdae74
Models: Replace IbRawPage with IbChapter.
manjotsidhu Jun 13, 2021
27a6898
Ib: Models: Format code
manjotsidhu Jun 13, 2021
ed6a262
Services: Bringup Interactive Book Engine
manjotsidhu Jun 15, 2021
cb0a2f0
Implement Interactive Book ViewModels.
manjotsidhu Jun 16, 2021
60e4064
IbEngineService: Implement Navigation
manjotsidhu Jun 17, 2021
2ca4e28
IbEngineService: Implement Table of Contents parsing
manjotsidhu Jun 18, 2021
2c3fd0c
IbEngine: Include Table of Contents Filters.
manjotsidhu Jun 22, 2021
e6191f0
IbChapter: Use obj ref for prev, next attrs
manjotsidhu Jun 22, 2021
39c1d0c
Implement ViewModels to Interactive Book views.
manjotsidhu Jun 23, 2021
1d0c322
IbPageView: Format Code.
manjotsidhu Jun 25, 2021
78c4217
Interactive Book: Switch to flutter_markdown
manjotsidhu Jun 26, 2021
57179ee
IB: Bringup Simulator embeds extension using webview.
manjotsidhu Jun 27, 2021
52d2fa0
Switch to CV fork of flutter_markdown package
manjotsidhu Jun 28, 2021
e7d1cd8
Ib: Implement Chapter Contents for parent pages.
manjotsidhu Jun 28, 2021
fa5e854
Markdown: Fix h4 style.
manjotsidhu Jun 28, 2021
08efe82
Markdown: Set image root path as IB_BASE_URL.
manjotsidhu Jun 28, 2021
7f1ba0d
Ib: Ignore Parsing Pop Quizes
manjotsidhu Jun 29, 2021
60ff798
IbLiquidSyntax: Add support for images via liquid tags.
manjotsidhu Jun 29, 2021
1d5fe7d
IbEngine: Encode HTML characters using HtmlUnescape.
manjotsidhu Jun 29, 2021
bfc546d
IbPageView: Launch absolute links on external browser. #104
manjotsidhu Jul 4, 2021
a6c6d63
IbTheme: Independent of CVTheme.
manjotsidhu Jul 4, 2021
1de0db9
IbPageView: Use Scrollbar with ScrollView
manjotsidhu Jul 4, 2021
45ff247
IbPageView: Scrollbar: Disable always shown.
manjotsidhu Jul 4, 2021
ad6b3d9
Upgrade Packages
manjotsidhu Jul 5, 2021
2ccdad1
conf: update pod dependencies
Nitish145 Jul 6, 2021
0a4a2fd
conf: update pubspec.lock
Nitish145 Jul 6, 2021
2d43532
conf: update flutter SDK to support extensions
manjotsidhu Jul 6, 2021
e78340e
Services: Bringup hive database service.
manjotsidhu Jul 6, 2021
f652b82
Fix typos.
manjotsidhu Jul 6, 2021
b875812
DatabaseServiceTest: Fix test for MacOS.
manjotsidhu Jul 6, 2021
0a393ab
Ib: Cache getChapters API using Hive.
manjotsidhu Jul 13, 2021
d2c69a5
IbPageView: Reduce divider thickness.
manjotsidhu Jul 14, 2021
1af9117
IbLandingView: Highlight and expand selected chapter.
manjotsidhu Jul 14, 2021
9483557
IbLandingView: Fixes and Improvements
manjotsidhu Jul 14, 2021
5fed1ed
IbLandingView: properly init and dispose valueNotifier.
manjotsidhu Jul 15, 2021
fea7d6b
Ib: Bringup HTML Interactions!
manjotsidhu Jul 20, 2021
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
3 changes: 3 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
# Get flutter dependencies.
- run: flutter pub get

# Run build runner to generate dart files
- run: flutter packages pub run --no-sound-null-safety build_runner build --delete-conflicting-outputs

# Check for any formatting issues in the code.
- run: flutter format --set-exit-if-changed .

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- ib
pull_request:

jobs:
Expand All @@ -27,6 +28,9 @@ jobs:
# Get flutter dependencies.
- run: flutter pub get

# Run build runner to generate dart files
- run: flutter packages pub run --no-sound-null-safety build_runner build --delete-conflicting-outputs

# Check for any formatting issues in the code.
- run: flutter format --set-exit-if-changed .

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ A detailed guide for multiple platforms setup could be find [here](https://flutt
- `flutter pub get` to get all the dependencies.
- `flutter run`

### Generating Files using Build Runner

`flutter packages pub run --no-sound-null-safety build_runner build`

### Android OAuth Config

This project uses flutter version 1.20.2 and hence the support for compile time variables. To use compile time variables pass them in `--dart-defines` as `flutter run --dart-define=VAR_NAME=VAR_VALUE`. Supported `dart-defines` include :
Expand Down
58 changes: 29 additions & 29 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ PODS:
- AppAuth/ExternalUserAgent (= 1.4.0)
- AppAuth/Core (1.4.0)
- AppAuth/ExternalUserAgent (1.4.0)
- FBSDKCoreKit (9.1.0):
- FBSDKCoreKit/Basics (= 9.1.0)
- FBSDKCoreKit/Core (= 9.1.0)
- FBSDKCoreKit/Basics (9.1.0)
- FBSDKCoreKit/Core (9.1.0):
- FBSDKCoreKit/Basics
- FBSDKLoginKit (9.1.0):
- FBSDKLoginKit/Login (= 9.1.0)
- FBSDKLoginKit/Login (9.1.0):
- FBSDKCoreKit (~> 9.1.0)
- FBSDKCoreKit (11.0.1):
- FBSDKCoreKit/Core (= 11.0.1)
- FBSDKCoreKit/Core (11.0.1):
- FBSDKCoreKit_Basics (~> 11.0.1)
- FBSDKCoreKit_Basics (11.0.1):
- FBSDKCoreKit_Basics/Basics (= 11.0.1)
- FBSDKCoreKit_Basics/Basics (11.0.1)
- FBSDKLoginKit (11.0.1):
- FBSDKLoginKit/Login (= 11.0.1)
- FBSDKLoginKit/Login (11.0.1):
- FBSDKCoreKit (~> 11.0.1)
- FBSDKCoreKit_Basics (~> 11.0.1)
- Flutter (1.0.0)
- flutter_facebook_auth (2.0.0):
- FBSDKCoreKit (~> 9.1.0)
- FBSDKLoginKit (~> 9.1.0)
- FBSDKCoreKit (~> 11.0.0)
- FBSDKLoginKit (~> 11.0.0)
- Flutter
- flutter_keyboard_visibility (0.0.1):
- Flutter
- flutter_secure_storage (3.3.1):
- Flutter
- flutter_web_auth (0.2.4):
- flutter_web_auth (0.3.0):
- Flutter
- google_sign_in (0.0.1):
- Flutter
Expand All @@ -32,14 +34,10 @@ PODS:
- AppAuth (~> 1.2)
- GTMAppAuth (~> 1.0)
- GTMSessionFetcher/Core (~> 1.1)
- GTMAppAuth (1.1.0):
- GTMAppAuth (1.2.2):
- AppAuth/Core (~> 1.4)
- GTMSessionFetcher (~> 1.4)
- GTMSessionFetcher (1.5.0):
- GTMSessionFetcher/Full (= 1.5.0)
- GTMSessionFetcher/Core (1.5.0)
- GTMSessionFetcher/Full (1.5.0):
- GTMSessionFetcher/Core (= 1.5.0)
- GTMSessionFetcher/Core (~> 1.5)
- GTMSessionFetcher/Core (1.6.1)
- image_picker (0.0.1):
- Flutter
- share (0.0.1):
Expand Down Expand Up @@ -74,6 +72,7 @@ SPEC REPOS:
trunk:
- AppAuth
- FBSDKCoreKit
- FBSDKCoreKit_Basics
- FBSDKLoginKit
- GoogleSignIn
- GTMAppAuth
Expand Down Expand Up @@ -109,24 +108,25 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
FBSDKCoreKit: a00fe2efd780c195a5e09201bf51c56106245b40
FBSDKLoginKit: d98498c598ec09de657385a9349a1f21119b7f86
FBSDKCoreKit: 38c9e29a3f1436362acacff6486d3a28628c288f
FBSDKCoreKit_Basics: 06780a4a12e16596bde8406add02c6aa1bf38616
FBSDKLoginKit: 8243e04c590c38b85c69fcf09d1234514d2475c3
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_facebook_auth: 4b170c07b7fce791497093fcc3f134fb215f3f07
flutter_facebook_auth: abc044072738b7baa90d80583dabdb1211614f0d
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
flutter_web_auth: b7465086188ce4413d7e8b23622583784b9007a7
flutter_web_auth: ede89bf8107b021cf16e769756d267d84d24e88b
google_sign_in: 6bd214b9c154f881422f5fe27b66aaa7bbd580cc
GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213
GTMAppAuth: 197a8dabfea5d665224aa00d17f164fc2248dab9
GTMSessionFetcher: b3503b20a988c4e20cc189aa798fd18220133f52
image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09
GTMAppAuth: ad5c2b70b9a8689e1a04033c9369c4915bfcbe89
GTMSessionFetcher: 36689134877faeb055b27dfa4ccc9ceaa42e029e
image_picker: e06f7a68f000bd36f552c1847e33cda96ed31f1f
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e
wakelock: bfc7955c418d0db797614075aabbc58a39ab5107
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96
wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f
webview_flutter: 3603125dfd3bcbc9d8d418c3f80aeecf331c068b

PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa

Expand Down
2 changes: 2 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/AppAuth/AppAuth.framework",
"${BUILT_PRODUCTS_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework",
"${BUILT_PRODUCTS_DIR}/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics.framework",
"${BUILT_PRODUCTS_DIR}/FBSDKLoginKit/FBSDKLoginKit.framework",
"${BUILT_PRODUCTS_DIR}/GTMAppAuth/GTMAppAuth.framework",
"${BUILT_PRODUCTS_DIR}/GTMSessionFetcher/GTMSessionFetcher.framework",
Expand All @@ -302,6 +303,7 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AppAuth.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit_Basics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKLoginKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMAppAuth.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMSessionFetcher.framework",
Expand Down
10 changes: 10 additions & 0 deletions lib/config/environment_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ class EnvironmentConfig {
defaultValue: 'https://circuitverse.org/api/v1',
);

static const String IB_API_BASE_URL = String.fromEnvironment(
'IB_API_BASE_URL',
defaultValue: 'https://learn.circuitverse.org/_api/pages',
);

static const String IB_BASE_URL = String.fromEnvironment(
'IB_BASE_URL',
defaultValue: 'https://learn.circuitverse.org',
);

// GITHUB OAUTH ENV VARIABLES
static const String GITHUB_OAUTH_CLIENT_ID = String.fromEnvironment(
'GITHUB_OAUTH_CLIENT_ID',
Expand Down
2 changes: 2 additions & 0 deletions lib/cv_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

class CVTheme {
CVTheme._();

static Color textFieldLabelColor(context) {
return Theme.of(context).brightness == Brightness.dark
? Colors.grey[300]
Expand Down Expand Up @@ -70,6 +71,7 @@ class CVTheme {
static const Color bgCard = Color.fromRGBO(255, 255, 255, 0.9);
static const Color bgCardDark = Color.fromRGBO(97, 97, 97, 1);
static const Color htmlEditorBg = Color.fromRGBO(245, 245, 245, 1);

static const OutlineInputBorder primaryDarkOutlineBorder = OutlineInputBorder(
borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: CVTheme.primaryColorDark),
Expand Down
76 changes: 76 additions & 0 deletions lib/ib_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';

class IbTheme {
IbTheme._();

static ThemeData getThemeData(context) {
return Theme.of(context).copyWith(
primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith(
color: Colors.white,
),
accentColor: IbTheme.primaryColor,
primaryColor: IbTheme.primaryColor,
textTheme: Theme.of(context).textTheme.apply(
fontFamily: IbTheme.fontFamily,
bodyColor: IbTheme.textColor(context),
),
primaryTextTheme: Theme.of(context).primaryTextTheme.apply(
fontFamily: IbTheme.fontFamily,
bodyColor: Colors.white,
),
accentTextTheme: Theme.of(context).accentTextTheme.apply(
fontFamily: IbTheme.fontFamily,
),
);
}

static Color textFieldLabelColor(context) {
return Theme.of(context).brightness == Brightness.dark
? Colors.grey[300]
: Colors.grey[600];
}

static Color textColor(context) {
return Theme.of(context).brightness == Brightness.dark
? Colors.white
: IbTheme.bodyTextColor;
}

static Color primaryHeadingColor(context) {
return Theme.of(context).brightness == Brightness.dark
? Colors.white
: IbTheme.headingTextColor;
}

static Color boxBg(context) {
return Theme.of(context).brightness == Brightness.dark
? bgCardDark
: bgCard;
}

static Color boxShadow(context) {
return Theme.of(context).brightness == Brightness.dark ? bgCardDark : grey;
}

static Color highlightText(context) {
return Theme.of(context).brightness == Brightness.dark
? primaryColor
: primaryColorDark;
}

static Color getPrimaryColor(context) {
return Theme.of(context).brightness == Brightness.dark
? IbTheme.brightPrimaryColor
: IbTheme.primaryColor;
}

static const Color primaryColor = Color.fromRGBO(2, 110, 87, 1);
static const Color brightPrimaryColor = Color.fromRGBO(0, 232, 179, 1);
static const Color primaryColorDark = Color.fromRGBO(2, 110, 87, 0.5);
static const Color bodyTextColor = Color.fromRGBO(92, 89, 98, 1);
static const Color headingTextColor = Color.fromRGBO(39, 38, 43, 1);
static const String fontFamily = 'Roboto';
static const Color grey = Color.fromRGBO(150, 150, 150, 1);
static const Color bgCard = Color.fromRGBO(255, 255, 255, 0.9);
static const Color bgCardDark = Color.fromRGBO(97, 97, 97, 1);
}
19 changes: 19 additions & 0 deletions lib/locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import 'package:mobile_app/services/API/fcm_api.dart';
import 'package:mobile_app/services/API/grades_api.dart';
import 'package:mobile_app/services/API/group_members_api.dart';
import 'package:mobile_app/services/API/groups_api.dart';
import 'package:mobile_app/services/API/ib_api.dart';
import 'package:mobile_app/services/API/projects_api.dart';
import 'package:mobile_app/services/API/users_api.dart';
import 'package:mobile_app/services/API/country_institute_api.dart';
import 'package:mobile_app/services/database_service.dart';
import 'package:mobile_app/services/dialog_service.dart';
import 'package:mobile_app/services/API/contributors_api.dart';
import 'package:mobile_app/services/ib_engine_service.dart';
import 'package:mobile_app/services/local_storage_service.dart';
import 'package:mobile_app/viewmodels/authentication/auth_options_viewmodel.dart';
import 'package:mobile_app/viewmodels/authentication/forgot_password_viewmodel.dart';
Expand All @@ -24,6 +27,8 @@ import 'package:mobile_app/viewmodels/groups/my_groups_viewmodel.dart';
import 'package:mobile_app/viewmodels/groups/new_group_viewmodel.dart';
import 'package:mobile_app/viewmodels/groups/update_assignment_viewmodel.dart';
import 'package:mobile_app/viewmodels/home/home_viewmodel.dart';
import 'package:mobile_app/viewmodels/ib/ib_landing_viewmodel.dart';
import 'package:mobile_app/viewmodels/ib/ib_page_viewmodel.dart';
import 'package:mobile_app/viewmodels/profile/edit_profile_viewmodel.dart';
import 'package:mobile_app/viewmodels/profile/profile_viewmodel.dart';
import 'package:mobile_app/viewmodels/profile/user_favourites_viewmodel.dart';
Expand All @@ -37,10 +42,16 @@ import 'package:mobile_app/viewmodels/about/about_viewmodel.dart';
GetIt locator = GetIt.instance;

Future<void> setupLocator() async {
// Dialog Service
locator.registerLazySingleton(() => DialogService());

// Local Storage Service
var localStorageService = await LocalStorageService.getInstance();
locator.registerSingleton<LocalStorageService>(localStorageService);

// Database Service
locator.registerLazySingleton<DatabaseService>(() => DatabaseServiceImpl());

// API Services
locator.registerLazySingleton<ContributorsApi>(() => HttpContributorsApi());
locator.registerLazySingleton<UsersApi>(() => HttpUsersApi());
Expand All @@ -53,6 +64,10 @@ Future<void> setupLocator() async {
locator.registerLazySingleton<FCMApi>(() => HttpFCMApi());
locator.registerLazySingleton<CountryInstituteAPI>(
() => HttpCountryInstituteAPI());
locator.registerLazySingleton<IbApi>(() => HttpIbApi());

// Interactive Book Engine Service
locator.registerLazySingleton<IbEngineService>(() => IbEngineServiceImpl());

// Startup ViewModel
locator.registerFactory(() => StartUpViewModel());
Expand Down Expand Up @@ -89,4 +104,8 @@ Future<void> setupLocator() async {
locator.registerFactory(() => AddAssignmentViewModel());
locator.registerFactory(() => UpdateAssignmentViewModel());
locator.registerFactory(() => AssignmentDetailsViewModel());

// Interactive Book ViewModels
locator.registerFactory(() => IbLandingViewModel());
locator.registerFactory(() => IbPageViewModel());
}
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:get/get.dart';
import 'package:mobile_app/cv_theme.dart';
import 'package:mobile_app/locale/locales.dart';
import 'package:mobile_app/locator.dart';
import 'package:mobile_app/services/database_service.dart';
import 'package:mobile_app/utils/router.dart';
import 'package:theme_provider/theme_provider.dart';
import 'ui/views/startup_view.dart';
Expand All @@ -16,6 +17,9 @@ Future<void> main() async {
// Register all the models and services before the app starts
await setupLocator();

// Init Hive
await locator<DatabaseService>().init();

runApp(CircuitVerseMobile());
}

Expand Down
2 changes: 1 addition & 1 deletion lib/models/failure_model.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Failure {
class Failure implements Exception {
final String message;

Failure(this.message);
Expand Down
27 changes: 27 additions & 0 deletions lib/models/ib/ib_chapter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';

class IbChapter {
final String id;
final String value;
final String navOrder;
IbChapter prev;
IbChapter next;
final List<IbChapter> items;

IbChapter({
@required this.id,
@required this.value,
@required this.navOrder,
this.prev,
this.next,
this.items,
});

set prevPage(IbChapter prev) => this.prev = prev;
set nextPage(IbChapter next) => this.next = next;

@override
String toString() {
return '{id: $id, prev: ${prev?.id}, next: ${next?.id}';
}
}
17 changes: 17 additions & 0 deletions lib/models/ib/ib_content.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';

abstract class IbContent {
String content;

IbContent({@required this.content});
}

class IbTocItem extends IbContent {
final List<IbTocItem> items;

IbTocItem({@required String content, this.items}) : super(content: content);
}

class IbMd extends IbContent {
IbMd({@required String content}) : super(content: content);
}
Loading