Skip to content

Commit

Permalink
Interactive Book Integration Phase 1 | GSoC 2021 (#110)
Browse files Browse the repository at this point in the history
* Bringup Interactive Book UI Views.

* Moved common drawer tile to components as CVDrawerTile.
* Added a IbTheme class for custom styles.
* Bringup "Hardcoded" IbLandingView and it's UI Test.
* Bringup "Hardcoded" IbPageView and it's UI Test.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Implement Table of Contents UI.

* Uses Function Callback to run the function in IbPageView when TOC button is pressed in AppBar (present in
IbLandingView)
* Intentially added Future.delayed() when callback function is recieved, as in our hardcoded scenerio,
setState() is called even before the Widget fully builds. This will be not required when data is coming from
ViewModel via async methods.
* Table of Contents uses Bottom Modal Sheets with Scroll Controller.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Fading Floating Action Buttons for readability

* Floating Action Buttons now fades in if we scroll down and accordingly fades out if we scroll up.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Improve Floating Action Buttons.

* Made Button size smaller.
* Color Scheme follows white as bg color and primary color as Icon's color.
* Restore elevation to default (6.0) to show drop shadow.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbLandingView: Seperate Actions for Expandable tile Drawer

The current Interactive Book has pages for Parent pages like "Binary Algebra". Currently, mobile-app has the
expandable tile which will be just expanding and showing sub-pages. We want to have seperate actions for arrow
and text such that the text will open it's "Parent Page" and arrows/whitespace will expand to show child pages.

* Uses Gesture Detector to incorporate different action for Text.
* Produces no UI differences and works as expected.

ref: https://stackoverflow.com/a/61573993
Signed-off-by: Manjot Sidhu <[email protected]>

* UI Tests: Fix Landing View Test due to recent changes

* Future.delayed() introduced in callback function causes Timer to throw errors.
ref: https://stackoverflow.com/q/56600290

* Incorporate Floating Action Buttons changes to fix test.

Signed-off-by: Manjot Sidhu <[email protected]>

* GH Actions: Temporarily enable ib branch to run CI.

* I almost forgot to run Tests after doing changes.
* Should be reverted before merging back to master.

Signed-off-by: Manjot Sidhu <[email protected]>

* Models: Bringup Interactive Book Models.

Signed-off-by: Manjot Sidhu <[email protected]>

* Services: Implement Interactive Book APIs

* API for fetching Raw Page Data and Fetching Pages list
* We are not serializing and returning  modal for fetching pages list since directory modals are redundant and
we only want to use them for recursively reading pages from directories, which will be handled by our Interactive Book Engine Service.
* For Raw Page Data, our response is serialized in `IbRawPageData` model.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Use camelCasing for constructor variable.

Signed-off-by: Manjot Sidhu <[email protected]>

* Tests: Fix IbApiTest typo.

Signed-off-by: Manjot Sidhu <[email protected]>

* Models: Replace IbRawPage with IbChapter.

* In-order to build Navigation and Drawer List Items, we realized that IbRawPage is just too overkill for the
requirement. We just need title and ids to build Navigation and Drawer Lists. Also, since data is not getting
serialized directly from API, IbEngineService is expected to create models from this RAW JSON. Moreover, this
IbRawPage is already included in IbRawPageData which will fetched for every page content.

* From now onwards, IbChapter[] will be received from the IbEngineService and will be used just for Book
Structure and Navigation.

* IbChapter includes previous page id, next page id because IbRawPageData won't have this. The only way to get
prev and next is finding them while preparing Navigation and structure. Accordingly, IbPageView should also
require prev and next from the IbLandingView to show Previous and Next buttons action.

Signed-off-by: Manjot Sidhu <[email protected]>

* Ib: Models: Format code

Signed-off-by: Manjot Sidhu <[email protected]>

* Services: Bringup Interactive Book Engine

* Implemented getChapters() and getPageData().
* IbChapter now includes navOrder since it was needed to sort the navigation pages.
* IbChapters that includes prev, and next for FABs and navigation are not implemented yet.
* getPageData() supports basic Mardkdown parsing like #,##,###,--- and { tags } as done in POC: #44
* Table of Contents is yet to be implemented while fetching getPageData()

Testing -
* IbEngineService Tests are running well which uses mocked real-time data.
* IbChapters since due to nested paging, was expected to take time. I ran a quick real-time test of it on
mobile-app to see the performance, it takes approx 1-2 secs on a normal broadband. Also, according to the
plans, ViewModel will be able to cache the data for the whole session.

Signed-off-by: Manjot Sidhu <[email protected]>

* Implement Interactive Book ViewModels.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbEngineService: Implement Navigation
* Navigation includes previous and next buttons are not included in the APIs responses, so we have
to manually build using the list of chapters.
* The logic involves flattening the nested list and assigning prev and next in IbChapter

Signed-off-by: Manjot Sidhu <[email protected]>

* IbEngineService: Implement Table of Contents parsing

* The strategy is to parse using html package and recursively parse the lists.
* The list data will be stored in IbTocItem as part of IbContent.
* Added a new test case for a regular page (Contributing Guidelines) which uses almost every kind of
content, it will be helpful in future testing as well as to test Table of Contents.
* Since the data was too long, data is stored in JSON for clean and untouched response.
* Logic computes the numbers and alphabetes while parsing and prepends to the content.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbEngine: Include Table of Contents Filters.

* Table of Contents has it's title and list text which is not required in mobile-app as it's now in
bottom sheet.
* These filters will simply won't add them to Content models.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbChapter: Use obj ref for prev, next attrs

Signed-off-by: Manjot Sidhu <[email protected]>

* Implement ViewModels to Interactive Book views.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Format Code.

Signed-off-by: Manjot Sidhu <[email protected]>

* Interactive Book: Switch to flutter_markdown

* We found out that flutter_markdown which is maintained by flutter team, is already supporting GitHub
flavoured Markdown, therefore we replaced our parser with flutter_markdown.
* Creates almost no UI changes.
* Already supports inline markdown syntaxes (not HTML inline syntaxes which is TODO)
* Supports img and anchor links (needs to be reworked with respect to local and absolute URLs)
* Added Custom Syntaxes and Builders for our purposes.
* API Utils: Now supports UTF-8 Decoder as well. It was noticed that API Raw Page Data was not UTF-8
decoded.

Signed-off-by: Manjot Sidhu <[email protected]>

* IB: Bringup Simulator embeds extension using webview.

* flutter_markdown has some issues because of which we are using our own fork of the same.
(manjotsidhu/packages@29bb87f)
* We have updated flutter_markdown from 0.5.2 -> 0.6.2.
* flutter_html needed update because of Sub6Resources/flutter_html#500.
* flutter_html updated from 1.0.2 -> 1.3.0, which depends on flutter_svg, flutter_svg updated from 0.19.3
-> 0.20.0-nullsafety.3

Signed-off-by: Manjot Sidhu <[email protected]>

* Switch to CV fork of flutter_markdown package

Signed-off-by: Manjot Sidhu <[email protected]>

* Ib: Implement Chapter Contents for parent pages.

* Added support for Liquid syntax parsing.
* Chapter Contents is parsed from HTML content and then passed via PageData.

Signed-off-by: Manjot Sidhu <[email protected]>

* Markdown: Fix h4 style.

Signed-off-by: Manjot Sidhu <[email protected]>

* Markdown: Set image root path as IB_BASE_URL.

* There are 3 types of img tags used in Interactive Book:

  Type 1: Markdown Image: `![alternate text](https://img-link/file.png)`
  Type 2: Liquid Syntax Image (Recommended in Guidelines): `{% include image.html
url="https://img-link/file.png" description="alternate text" %}`
  Type 3: HTML Image Tag: `<img src="https://img-link/file.png" />` (Not supported)

* This will not fix *every* image tag in interactive book but it does fix type 1 Images.
* Type 3 Images will be converted to Type 2 and Type 2 implementation is a TODO.

Signed-off-by: Manjot Sidhu <[email protected]>

* Ib: Ignore Parsing Pop Quizes

* Ideally, we should not parse pop quizes using markdown.
* We will have a special widget that will build Pop Quizes.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbLiquidSyntax: Add support for images via liquid tags.

* Still this is not a full working solution since Flutter's Image.network is not capable of handling
SVG.
* We will need to override and add our custom Image Builder that will use flutter_svg package.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbEngine: Encode HTML characters using HtmlUnescape.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Launch absolute links on external browser. #104

Signed-off-by: Manjot Sidhu <[email protected]>

* IbTheme: Independent of CVTheme.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Use Scrollbar with ScrollView

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Scrollbar: Disable always shown.

Signed-off-by: Manjot Sidhu <[email protected]>

* Upgrade Packages

* Get.snackbar now accepts message and title mandatory.
* Http package now accepts Uri instead of String.
* Manual Testing is highly recommended.

Signed-off-by: Manjot Sidhu <[email protected]>

* conf: update pod dependencies

* conf: update pubspec.lock

* conf: update flutter SDK to support extensions

* Ref:
https://stackoverflow.com/questions/61779848/flutter-extension-methods-not-working-it-says-undefined-class-and-requires-t

Signed-off-by: Manjot Sidhu <[email protected]>

* Services: Bringup hive database service.

Signed-off-by: Manjot Sidhu <[email protected]>

* Fix typos.

Signed-off-by: Manjot Sidhu <[email protected]>

* DatabaseServiceTest: Fix test for MacOS.

Signed-off-by: Manjot Sidhu <[email protected]>

* Ib: Cache getChapters API using Hive.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbPageView: Reduce divider thickness.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbLandingView: Highlight and expand selected chapter.

Signed-off-by: Manjot Sidhu <[email protected]>

* IbLandingView: Fixes and Improvements

Signed-off-by: Manjot Sidhu <[email protected]>

* IbLandingView: properly init and dispose valueNotifier.

Signed-off-by: Manjot Sidhu <[email protected]>

* Ib: Bringup HTML Interactions!

Signed-off-by: Manjot Sidhu <[email protected]>

Co-authored-by: Nitish Aggarwal <[email protected]>
  • Loading branch information
manjotsidhu and Nitish145 authored Jul 20, 2021
1 parent 66d41c3 commit a07a8b4
Show file tree
Hide file tree
Showing 66 changed files with 5,754 additions and 226 deletions.
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

0 comments on commit a07a8b4

Please sign in to comment.