Skip to content

Commit

Permalink
praso WebView App Improvements commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nomanameer committed Nov 9, 2021
1 parent 4ba337f commit 2f35531
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}


android {
compileSdkVersion 31

Expand All @@ -56,6 +57,7 @@ android {
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
signingConfig signingConfigs.release
Expand Down
File renamed without changes
1 change: 1 addition & 0 deletions lib/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class _ErrorScreenState extends State<ErrorScreen> {
textAlign: TextAlign.center,
style: TextStyle(color: Color(0xFF5F6368,)),
),

],
),
GestureDetector(
Expand Down
64 changes: 44 additions & 20 deletions lib/web_view_redirect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,19 @@ class _WebViewPageState extends State<WebViewPage> {
);
}

void downloadFile({required String url}) async{
void downloadFile({required String url}) async {
print('.........started');

final taskId = await FlutterDownloader.enqueue(
saveInPublicStorage: true,
fileName: 'prasoInvoice_${DateTime.now().toString().replaceAll(' ', '').replaceAll(':', '').replaceAll('-', '').replaceAll('.', '')}',
fileName:
'prasoInvoice_${DateTime.now().toString().replaceAll(' ', '').replaceAll(':', '').replaceAll('-', '').replaceAll('.', '')}',
url: url,
savedDir: '/storage/emulated/0/',
showNotification: true, // show download progress in status bar (for Android)
openFileFromNotification: true, // click on notification to open downloaded file (for Android)
showNotification: true,
// show download progress in status bar (for Android)
openFileFromNotification:
true, // click on notification to open downloaded file (for Android)
);
final tasks = await FlutterDownloader.loadTasks();

Expand All @@ -99,15 +102,15 @@ class _WebViewPageState extends State<WebViewPage> {
prasoNotifyProvider = Provider.of(context, listen: false);
WebView.platform = SurfaceAndroidWebView();

IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader_send_port');
IsolateNameServer.registerPortWithName(
_port.sendPort, 'downloader_send_port');
_port.listen((dynamic data) {
String id = data[0];
DownloadTaskStatus status = data[1];
int progress = data[2];
print('id......$id...........progress....$progress.......status.....${status.value}');
setState((){

});
print(
'id......$id...........progress....$progress.......status.....${status.value}');
setState(() {});
});

FlutterDownloader.registerCallback(downloadCallback);
Expand All @@ -119,8 +122,10 @@ class _WebViewPageState extends State<WebViewPage> {
super.dispose();
}

static void downloadCallback(String id, DownloadTaskStatus status, int progress) {
final SendPort? send = IsolateNameServer.lookupPortByName('downloader_send_port');
static void downloadCallback(
String id, DownloadTaskStatus status, int progress) {
final SendPort? send =
IsolateNameServer.lookupPortByName('downloader_send_port');
send!.send([id, status, progress]);
}

Expand Down Expand Up @@ -176,10 +181,9 @@ class _WebViewPageState extends State<WebViewPage> {
prasoNotifyProvider!.url = url;
},
navigationDelegate: (navigation) async {

print(navigation.url);
return Future.value(NavigationDecision.navigate);
},
},
gestureNavigationEnabled: true,
),

Expand All @@ -194,7 +198,8 @@ class _WebViewPageState extends State<WebViewPage> {
height: 90,
color: Colors.white,
child: Selector<PrasoNotifyProvider, String>(
selector: (context, prasoNotifyProvider) => prasoNotifyProvider.url,
selector: (context, prasoNotifyProvider) =>
prasoNotifyProvider.url,
builder: (context, value, child) => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expand All @@ -215,23 +220,36 @@ class _WebViewPageState extends State<WebViewPage> {
prasoNotifyProvider.homeIcon,
builder: (context, value, child) =>
bottomNavigationBarItems(
imagePath: prasoNotifyProvider!.url.length == 'https://praso.com.br/'.length ? 'assets/images/home_select.png':'assets/images/home_icon.png',
imagePath: prasoNotifyProvider!
.url.length ==
'https://praso.com.br/'.length
? 'assets/images/home_select.png'
: 'assets/images/home_icon.png',
iconText: 'início',
color: prasoNotifyProvider!.homeIcon))),
color:
prasoNotifyProvider!.homeIcon))),

//category icon
GestureDetector(
onTap: () {
prasoNotifyProvider!.homeIcon = Colors.black;
prasoNotifyProvider!.categoryIcon = Colors.blue;
prasoNotifyProvider!.accountIcon = Colors.black;
_webViewController!.loadUrl('https://praso.com.br/collections/acucares');
// _webViewController!.loadUrl('https://www.google.com/');
_webViewController!.loadUrl(
'https://praso.com.br/collections/acucares');
},
child: Selector<PrasoNotifyProvider, Color>(
selector: (context, prasoNotifyProvider) =>
prasoNotifyProvider.categoryIcon,
builder: (context, value, child) =>
bottomNavigationBarItems(imagePath: prasoNotifyProvider!.url.length == 'https://praso.com.br/collections/acucares'.length ? 'assets/images/catagories_select.png': 'assets/images/categories_icon.png',
bottomNavigationBarItems(
imagePath: prasoNotifyProvider!
.url.length ==
'https://praso.com.br/collections/acucares'
.length
? 'assets/images/catagories_select.png'
: 'assets/images/categories_icon.png',
iconText: 'categorias',
color: prasoNotifyProvider!
.categoryIcon))),
Expand All @@ -243,14 +261,20 @@ class _WebViewPageState extends State<WebViewPage> {
prasoNotifyProvider!.categoryIcon =
Colors.black;
prasoNotifyProvider!.accountIcon = Colors.blue;
_webViewController!.loadUrl('https://praso.com.br/account/login?return_url=%2Faccount');
_webViewController!.loadUrl(
'https://praso.com.br/account/login?return_url=%2Faccount');
},
child: Selector<PrasoNotifyProvider, Color>(
selector: (context, prasoNotifyProvider) =>
prasoNotifyProvider.accountIcon,
builder: (context, value, child) =>
bottomNavigationBarItems(
imagePath: prasoNotifyProvider!.url.length == 'https://praso.com.br/account/login?return_url=%2Faccount'.length ? 'assets/images/contact_select.png' :'assets/images/contact_icon.png',
imagePath: prasoNotifyProvider!
.url.length ==
'https://praso.com.br/account/login?return_url=%2Faccount'
.length
? 'assets/images/contact_select.png'
: 'assets/images/contact.png',
iconText: 'conta',
color: prasoNotifyProvider!
.accountIcon))),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ flutter:
- assets/images/home_select.png
- assets/images/categories_icon.png
- assets/images/catagories_select.png
- assets/images/contact_icon.png
- assets/images/contact.png
- assets/images/contact_select.png

# - images/a_dot_ham.jpeg
Expand Down

0 comments on commit 2f35531

Please sign in to comment.