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

Add About Us section in Settings #561

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Add About Us section in Settings #561

merged 2 commits into from
Aug 9, 2024

Conversation

mdmohsin7
Copy link
Collaborator

@mdmohsin7 mdmohsin7 commented Aug 9, 2024

IMG_0250

Summary by Entelligence.AI

  • New Feature: Added an "About Us" section to the Settings page. This includes links to our Privacy Policy and company website for easy access.
  • New Feature: Introduced a new Webview widget that allows users to view web pages directly within the app, enhancing the user experience by providing seamless navigation to external links.

Copy link

github-actions bot commented Aug 9, 2024

Image description Entelligence.AI

Walkthrough

This update introduces an "About Us" section to the Settings page, providing users with links to the Privacy Policy and company website. It also adds a new Webview widget that displays web pages using webview_flutter, complete with progress tracking, navigation, and error handling.

Changes

File Summary
app/lib/pages/settings/page.dart Added UI elements for the new "About Us" section in the Settings page.
app/lib/pages/settings/webview.dart Introduced a new Webview widget that displays a web page using webview_flutter. This widget handles web view events like progress tracking, navigation, and error handling.

🎉 With every line of code, we weave a tale,

Of features new, that never fail.

An "About Us" section, clear and bright,

And a Webview widget, a delightful sight.

So here's to progress, steady and slow,

In our app's grand tale, as it continues to grow. 🚀


Uplevel your code reviews with Entelligence.AI Pro

Entelligence.AI Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, Entelligence.AI Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description Entelligence.AI

Commits Files that changed from the base of the PR and between 7e63218 and 58baff1 commits.
Files selected (2)
  • app/lib/pages/settings/page.dart (2)
  • app/lib/pages/settings/webview.dart (1)
Review comments generated (7)
  • Review: 3
  • LGTM: 4

Tips

Chat with Image description Entelligence.AI Bot (@Entelligence.AI)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @Entelligence.AI in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @Entelligence.AI: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +172 to +202
const SizedBox(height: 32.0),
const Align(
alignment: Alignment.centerLeft,
child: Text(
'ABOUT US',
style: TextStyle(
color: Colors.white,
),
textAlign: TextAlign.start,
),
),
getItemAddOn('Privacy Policy', () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (c) => const Webview(
url: 'https://basedhardware.com/pages/privacy',
title: 'Privacy Policy',
),
),
);
}, icon: Icons.privacy_tip_outlined, visibility: true),
getItemAddOn('Our Website', () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (c) => const Webview(
url: 'https://basedhardware.com/',
title: 'Based Hardware',
),
),
);
}, icon: Icons.language_outlined, visibility: true),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description Entelligence.AI

The code looks good overall, but there's a potential issue with hardcoding URLs directly into the application. This could lead to problems if the URL changes in the future, as you would need to update and redeploy the app. It would be better to store these URLs in a configuration file or fetch them from a server.

Here's an example of how you might refactor this:

- url: 'https://basedhardware.com/pages/privacy',
+ url: Config.PRIVACY_POLICY_URL,

- url: 'https://basedhardware.com/',
+ url: Config.WEBSITE_URL,

In this case, Config is a class that holds your configuration data. You can populate it from a local file, remote server, or environment variables depending on your needs.

Comment on lines +17 to +44
@override
initState() {
webviewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(const Color(0x00000000))
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int p) {
setState(() {
progress = p;
print("Progress: $progress");
});
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onHttpError: (HttpResponseError error) {},
onWebResourceError: (WebResourceError error) {},
onNavigationRequest: (NavigationRequest request) {
if (request.url != widget.url) {
print("Redirecting to ${request.url}");
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
),
)
..loadRequest(Uri.parse(widget.url));
super.initState();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description Entelligence.AI

There are a few issues here.

First, the initState method should be marked as override because it's overriding the initState method from its superclass.

Second, you're creating a new instance of WebViewController without any parameters, but WebViewController requires at least one parameter which is initialUrl.

Third, you're using setJavaScriptMode, setBackgroundColor, setNavigationDelegate, and loadRequest methods on WebViewController instance, but these methods do not exist in the webview_flutter package. Instead, you should use the WebView widget and set these properties directly.

Fourth, you're not handling errors properly. You've left the onHttpError and onWebResourceError callbacks empty. It's important to handle these errors and provide feedback to the user if something goes wrong.

Here's how you can fix these issues:

-  initState() {
-    webviewController = WebViewController()
-      ..setJavaScriptMode(JavaScriptMode.unrestricted)
-      ..setBackgroundColor(const Color(0x00000000))
-      ..setNavigationDelegate(
-        NavigationDelegate(
-          onProgress: (int p) {
-            setState(() {
-              progress = p;
-              print("Progress: $progress");
-            });
-          },
-          onPageStarted: (String url) {},
-          onPageFinished: (String url) {},
-          onHttpError: (HttpResponseError error) {},
-          onWebResourceError: (WebResourceError error) {},
-          onNavigationRequest: (NavigationRequest request) {
-            if (request.url != widget.url) {
-              print("Redirecting to ${request.url}");
-              return NavigationDecision.prevent;
-            }
-            return NavigationDecision.navigate;
-          },
-        ),
-      )
-      ..loadRequest(Uri.parse(widget.url));
-    super.initState();
-  }

+  @override
+  void initState() {
+    super.initState();
+    // Initialize the webview controller here if needed.
+  }

Comment on lines +45 to +63
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.primary,
),
body: progress != 100
? Center(
child: CircularProgressIndicator(
color: Colors.white,
),
)
: WebViewWidget(controller: webviewController),
);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description Entelligence.AI

In your build method, you're using a WebViewWidget which is not defined anywhere in this code. You should use the WebView widget from the webview_flutter package instead. Also, you're passing controller: webviewController to it, but WebView doesn't have a controller property. Instead, you should set the initialUrl, javascriptMode, and navigationDelegate properties directly on the WebView widget.

Here's how you can fix these issues:

-  body: progress != 100
-      ? Center(
-          child: CircularProgressIndicator(
-            color: Colors.white,
-          ),
-        )
-      : WebViewWidget(controller: webviewController),

+  body: progress != 100
+      ? Center(
+          child: CircularProgressIndicator(),
+        )
+      : WebView(
+          initialUrl: widget.url,
+          javascriptMode: JavascriptMode.unrestricted,
+          navigationDelegate: (NavigationRequest request) {
+            if (request.url != widget.url) {
+              print("Redirecting to ${request.url}");
+              return NavigationDecision.prevent;
+            }
+            return NavigationDecision.navigate;
+          },
+          onPageStarted: (String url) {},
+          onPageFinished: (String url) {},
+          onWebResourceError: (WebResourceError error) {},
+        ),

Please note that you'll need to handle the onWebResourceError callback to provide feedback to the user if something goes wrong.

@josancamon19 josancamon19 merged commit f7b4293 into main Aug 9, 2024
1 check passed
@josancamon19 josancamon19 deleted the privacy-policy branch August 9, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants