Commit 10a07f78 authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬

Fixed Home Navbar integration completely

- Fixed : Navbar x Carousel sync
- Added Documentation
parent ce808319
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+5\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-08-26 17:00:48.008588","version":"1.22.0-2.0.pre.18"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+5\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-09-01 02:30:16.307969","version":"1.21.0-10.0.pre.193"}
\ No newline at end of file
......@@ -5,9 +5,22 @@ import 'package:logair_application/ui/routes/home.dart';
/// This controller class is integrated to the [HomeView] to enable out of scope control of select Widgets therein.
class HomeController {
/// The page that the controllers were previously pointing toward.
int _previousPage;
/// The page that the controllers are now pointing toward.
int _currentPage;
/// Whether the navbar triggered the action, to avoid livelock generated by [CircularBottomNavigationController] listening to [_navigationController.value].
bool _triggerOriginNavbar;
factory HomeController() => _singleton;
HomeController._internal();
HomeController._internal() {
this._currentPage = 0;
this._previousPage = 0;
this._triggerOriginNavbar = true;
}
static final HomeController _singleton = new HomeController._internal();
......@@ -21,17 +34,41 @@ class HomeController {
set carouselController(PageController carouselController) => this._pageController = carouselController;
/// Sets the [CircularBottomNavigationController] for the [CircularBottomNavigation]
set navigationController(CircularBottomNavigationController navController) => this._navigationController = navController;
/// Force the [CarouselSlider] to navigate to another page.
void gotoPage(int page) {
if (this._pageController != null)
this._pageController.jumpToPage(page);
set navigationController(CircularBottomNavigationController navController) {
this._navigationController = navController;
}
/// Forces the [CircularBottomNavigation] to the correct position.
void navbarToPage(int page) {
set navbar(int page) {
this._currentPage = page;
// Set to false to mitigate livelock.
this._triggerOriginNavbar = false;
// Guard
if (this._navigationController != null)
this._navigationController.value = (page + 1) % 3;
this._navigationController.value = (this._currentPage + 1) % 3;
this._previousPage = this._currentPage;
// Set to true once risk of livelock passed.
this._triggerOriginNavbar = true;
}
/// Forces the [PageController] to the correct position.
set page(int page) {
// Guard + Supplementary guard against livelock.
if (this._pageController != null && this._triggerOriginNavbar) {
// Navbar has pages in order [2, 0, 1] of the carousel.
this._currentPage = (page - 1) % 3;
// Make the carousel controller move forward (jump to +1 would limit UI because of lackluster cyclical handling).
if ((this._currentPage == 0 && this._previousPage == 2) || (this._currentPage == 1 && this._previousPage == 0) || (this._currentPage == 2 && this._previousPage == 1))
this._pageController.nextPage(duration: Duration(milliseconds: 200), curve: Curves.linear);
// Make the carousel controller move backward (jump to +1 would limit UI because of lackluster cyclical handling).
else if ((this._currentPage == 2 && this._previousPage == 0) || (this._currentPage == 0 && this._previousPage == 1) || (this._currentPage == 1 && this._previousPage == 2))
this._pageController.previousPage(duration: Duration(milliseconds: 200), curve: Curves.linear);
this._previousPage = this._currentPage;
}
}
}
\ No newline at end of file
......@@ -67,6 +67,7 @@ class _GraphState extends State<Graph> {
padding: EdgeInsets.only(top: 10, right: 10),
child: LineChart(
LineChartData(
clipToBorder: true,
lineTouchData: LineTouchData(
touchCallback: (lineTouchResponse) => { },
handleBuiltInTouches: true,
......
......@@ -54,9 +54,12 @@ class HomeView extends StatelessWidget {
height: sizingInfo.unnotchedHeight() * 33/40,
autoPlay: false,
enlargeCenterPage: false,
enableInfiniteScroll: true,
viewportFraction: 1.0,
scrollPhysics: AlwaysScrollableScrollPhysics(),
initialPage: 0,
onPageChanged: (int newPage) => HomeController().navbarToPage(newPage),
// Force the navbar to adapt to the newly scrolled page.
onPageChanged: (int newPage) => HomeController().navbar = newPage,
items: [
DataWidget(),
SocialWidget(),
......@@ -84,7 +87,8 @@ class HomeView extends StatelessWidget {
new TabItem(Icons.contacts, 'Social', Colors.yellow, labelStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
],
controller: _navigationController,
selectedCallback: (selected) => HomeController().gotoPage(selected),
// Force the carousel to adapt to the newly selected page.
selectedCallback: (pos) => HomeController().page = pos,
animationDuration: Duration(milliseconds: 250),
),
],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment