-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Network Interceptor for noticeboard mobile (#35)
* Bump up IOS version to 12 , added network interceptor in list_notices screen * Added network interceptor to all reqd widgets * Add Pranav to contributors.md * Added root context to the stream so that it is always mounted * Fix flutter analyze, removed deprecated willpopscope * Added dynamic fetch when back online All changes are as follows: I have updated the web view flutter package to 4.7.0 and upgraded flutter version to 3.19 because reloading the webview requires a webview controller, also added another stream for this purpose * Added EOF in enums, removed build files
- Loading branch information
1 parent
acb2415
commit 1f5b5e4
Showing
23 changed files
with
230 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- [@Sparsh1212](https://github.com/Sparsh1212) | ||
- [@just-ary27](https://github.com/just-ary27) | ||
- [@kmrinal19](https://github.com/kmrinal19) | ||
- [@kmrinal19](https://github.com/kmrinal19) | ||
- [@pranavkonidena](https://github.com/pranavkonidena) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
noticeboard/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict/> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'dart:async'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:noticeboard/bloc/notice_detail_bloc.dart'; | ||
import 'package:noticeboard/enum/connectivity_status_enum.dart'; | ||
import 'package:noticeboard/enum/current_widget_enum.dart'; | ||
|
||
class ConnectivityStatusBloc { | ||
late BuildContext context; | ||
late CurrentWidget currentWidget; | ||
final _eventController = StreamController<ConnectivityStatus>.broadcast(); | ||
StreamSink<ConnectivityStatus> get eventSink => _eventController.sink; | ||
Stream<ConnectivityStatus> get _eventStream => _eventController.stream; | ||
ConnectivityStatus previousResult = ConnectivityStatus.connected; | ||
|
||
static final ConnectivityStatusBloc _connectivityStatusBloc = | ||
ConnectivityStatusBloc._(); | ||
|
||
final networkSnackBar = | ||
const SnackBar(content: Text("Please check your internet connection!")); | ||
final backOnlineSnackbar = const SnackBar(content: Text("Back online!")); | ||
|
||
factory ConnectivityStatusBloc() => _connectivityStatusBloc; | ||
final NoticeDetailBloc _noticeDetailBloc = NoticeDetailBloc(); | ||
|
||
ConnectivityStatusBloc._() { | ||
_eventStream.listen((connectivityEvent) { | ||
if (connectivityEvent == ConnectivityStatus.notConnected && | ||
previousResult == ConnectivityStatus.connected && | ||
context.mounted) { | ||
ScaffoldMessenger.of(context).showSnackBar(networkSnackBar); | ||
} else if (connectivityEvent == ConnectivityStatus.connected && | ||
previousResult == ConnectivityStatus.notConnected) { | ||
ScaffoldMessenger.of(context).showSnackBar(backOnlineSnackbar); | ||
if (currentWidget == CurrentWidget.noticeDetail) { | ||
// Add an event in the sink so that notice detail webview can be refetched | ||
_noticeDetailBloc.eventSink.add(CurrentWidget.noticeDetail); | ||
} else { | ||
// User is on list of notices , refetch them | ||
_noticeDetailBloc.eventSink.add(CurrentWidget.listNotices); | ||
} | ||
} | ||
previousResult = connectivityEvent; | ||
}); | ||
} | ||
|
||
void disposeStream() { | ||
_eventController.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:noticeboard/enum/current_widget_enum.dart'; | ||
|
||
class NoticeDetailBloc { | ||
final _eventController = StreamController<CurrentWidget>.broadcast(); | ||
StreamSink<CurrentWidget> get eventSink => _eventController.sink; | ||
Stream<CurrentWidget> get eventStream => _eventController.stream; | ||
static final NoticeDetailBloc _noticeDetailBloc = NoticeDetailBloc._(); | ||
factory NoticeDetailBloc() => _noticeDetailBloc; | ||
NoticeDetailBloc._(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
enum ConnectivityStatus{ | ||
connected , | ||
notConnected | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
enum CurrentWidget { | ||
listNotices, | ||
noticeDetail | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.