Skip to content

Commit

Permalink
Deprecation: Replaced the deprecated methods of url_launcher (#196)
Browse files Browse the repository at this point in the history
* replacing the deprecated methods

* formatted the about view file
  • Loading branch information
superiorsd10 authored Dec 10, 2023
1 parent 224d5e2 commit b884342
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
13 changes: 7 additions & 6 deletions lib/app/modules/about/controller/about_controller.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import 'package:get/get.dart';
import 'package:ultimate_alarm_clock/app/modules/about/views/about_view.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';

class AboutController extends GetxController {
final RxBool isAboutExpanded = true.obs;

static const String ccExtractorUrl = "https://ccextractor.org/";
static const String githubUrl = "https://github.com/CCExtractor/ultimate_alarm_clock";
static const String ccExtractorUrl = 'https://ccextractor.org/';
static const String githubUrl =
'https://github.com/CCExtractor/ultimate_alarm_clock';

Future<bool> launchUrl(Uri uri) async {
if (await canLaunch(uri.toString())) {
return await launch(uri.toString());
if (await canLaunchUrlString(uri.toString())) {
return await launchUrlString(uri.toString());
} else {
return false;
}
Expand All @@ -23,4 +24,4 @@ class AboutController extends GetxController {
void navigateToAboutView() {
Get.to(() => AboutView());
}
}
}
59 changes: 33 additions & 26 deletions lib/app/modules/about/views/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ class AboutView extends GetView<AboutController> {
final AboutController aboutController = Get.find<AboutController>();
ThemeController themeController = Get.find<ThemeController>();


@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('About',style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
fontWeight: FontWeight.w500,
),),
title: Text(
'About',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
fontWeight: FontWeight.w500,
),
),
elevation: 0,
centerTitle: true,
leading: IconButton(
Expand All @@ -43,39 +45,41 @@ class AboutView extends GetView<AboutController> {
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: SizedBox.fromSize(
size: Size.fromRadius(48),
size: const Size.fromRadius(48),
child: Image.asset('assets/images/ic_launcher-playstore.png'),
),
),
SizedBox(height: 10),
Text(
const SizedBox(height: 10),
const Text(
'Ultimate Alarm Clock',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 10),
Text(
const SizedBox(height: 10),
const Text(
'Version: 1.0.0',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 10),
const SizedBox(height: 10),
Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text(
'This project aims to build a non-conventional alarm clock with smart features such as auto-dismissal based on phone activity, weather, and more!',
padding: const EdgeInsets.symmetric(horizontal: 20),
child: const Text(
'This project aims to build a non-conventional alarm clock'
' with smart features such as auto-dismissal based on'
' phone activity, weather, and more!',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.grey,
),
),
),
SizedBox(height: 20),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expand All @@ -93,16 +97,17 @@ class AboutView extends GetView<AboutController> {
if (!await aboutController
.launchUrl(Uri.parse(AboutController.githubUrl))) {
throw Exception(
'Could not launch ${AboutController.githubUrl}');
'Could not launch ${AboutController.githubUrl}',
);
}
},
icon: SvgPicture.asset(
"assets/images/github.svg",
'assets/images/github.svg',
width: 30,
height: 30,
),
label: Text(
"GitHub",
label: const Text(
'GitHub',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
Expand All @@ -123,18 +128,20 @@ class AboutView extends GetView<AboutController> {
),
onPressed: () async {
if (!await aboutController.launchUrl(
Uri.parse(AboutController.ccExtractorUrl))) {
Uri.parse(AboutController.ccExtractorUrl),
)) {
throw Exception(
'Could not launch ${AboutController.ccExtractorUrl}');
'Could not launch ${AboutController.ccExtractorUrl}',
);
}
},
icon: SvgPicture.asset(
"assets/images/link.svg",
'assets/images/link.svg',
width: 30,
height: 30,
),
label: Text(
"CCExtractor",
label: const Text(
'CCExtractor',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
Expand Down

0 comments on commit b884342

Please sign in to comment.