-
Notifications
You must be signed in to change notification settings - Fork 471
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
Conversation
WalkthroughThis 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 Changes
Uplevel your code reviews with Entelligence.AI ProEntelligence.AI ProIf 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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.
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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
+ }
} | ||
|
||
@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), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Summary by Entelligence.AI
Webview
widget that allows users to view web pages directly within the app, enhancing the user experience by providing seamless navigation to external links.