Skip to content

Commit

Permalink
Improved the article canonical
Browse files Browse the repository at this point in the history
Added more usefull links such as socials and offical websites
  • Loading branch information
anilkaraniya committed Mar 14, 2024
1 parent bdf24e1 commit ddfdebd
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 29 deletions.
4 changes: 4 additions & 0 deletions bakliwal_news/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

#custom
/lib/firebase_options.dart
/lib/repository/dev_api_key.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.bakliwal_news
package com.anil.bakliwal_news

import io.flutter.embedding.android.FlutterActivity

Expand Down
4 changes: 3 additions & 1 deletion bakliwal_news/lib/providers/news/public_articles.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: unnecessary_null_comparison, use_build_context_synchronously, avoid_print
import 'dart:convert';

import 'package:bakliwal_news/repository/dev_api_key.dart';
import 'package:flutter/widgets.dart';
import 'package:http/http.dart' as http;

Expand Down Expand Up @@ -117,7 +118,8 @@ class PublicArticles with ChangeNotifier {
String apiEndpoint, int page, int perPage, String tag) async {
var header = {
'Content-type': 'application/json',
'api-key': '<YOUR_API_KEY_HERE>'
// Out sourced the api key into the new file (Ignored in the git commands) to avoid any missuse.
'api-key': devApiKey,
};
print(Uri.parse(
'$apiEndpoint?page=$page&per_page=$perPage${apiPath != 'articles/latest' ? '&tag=$tag' : ''}'));
Expand Down
4 changes: 1 addition & 3 deletions bakliwal_news/lib/screens/primary_screen/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
if (userInformation.twitter != null)
IconButton(
onPressed: () async {
var url =
'https://twitter.com/${userInformation.twitter!.trim()}/';
var url = 'https://x.com/${userInformation.twitter!.trim()}';

if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(
Uri.parse(url),
mode: LaunchMode.externalApplication,
);
} else {
throw 'There was a problem to open the url: $url';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:intl/intl.dart';
import 'package:html/parser.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

import 'package:bakliwal_news/style/shimmers_effect.dart';

import 'package:bakliwal_news/models/public_article_model.dart';
import 'package:bakliwal_news/widget/view/article_discription_appbar.dart';
import 'package:bakliwal_news/style/style_declaration.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:bakliwal_news/widget/view/article_discription_appbar.dart';

// ignore: must_be_immutable
class PublicArticleCanonical extends StatefulWidget {
Expand Down Expand Up @@ -93,6 +93,32 @@ class MainDescriptionContent extends StatelessWidget {
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
data: newsArticle.description!,
imageBuilder: (uri, _, __) {
return ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
uri.toString(),
frameBuilder:
(context, child, frame, wasSynchronouslyLoaded) {
return child;
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return CustomShimmerEffect.rectangular(
height: 150,
);
}
},
errorBuilder: (context, error, stackTrace) {
return Image.network(
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Image_not_available.png/800px-Image_not_available.png",
);
},
),
);
},
onTapLink: (s1, s2, s3) async {
var url = s2;

Expand Down
65 changes: 62 additions & 3 deletions bakliwal_news/lib/widget/view/article_discription_appbar.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bakliwal_news/custome_icons_icons.dart';
import 'package:bakliwal_news/models/public_article_model.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
Expand All @@ -6,6 +7,7 @@ import 'package:bakliwal_news/models/screen_enums.dart';
import 'package:bakliwal_news/widget/view/common_article_popmenue.dart';
import 'package:bakliwal_news/style/style_declaration.dart';
import 'package:bakliwal_news/models/user_article.dart';
import 'package:url_launcher/url_launcher.dart';

class ArticleDiscriptionAppBar extends StatelessWidget {
final UserArticle? userArticle;
Expand All @@ -31,11 +33,21 @@ class ArticleDiscriptionAppBar extends StatelessWidget {
screenName: ScreenType.articleDiscription,
)
: Container(),
publicArticle == null
? const SizedBox(
width: 10,
userArticle == null
? InkWell(
onTap: () async {
await launchUrl(Uri.parse(publicArticle!.url!));
},
child: const Icon(
Icons.link,
color: AppColors.secondary,
size: 40,
),
)
: Container(),
const SizedBox(
width: 10,
),
InkWell(
onTap: () => Navigator.of(context).pop(),
child: const Icon(
Expand Down Expand Up @@ -132,6 +144,53 @@ class ArticleDiscriptionAppBar extends StatelessWidget {
color: Colors.blueGrey[200],
),
),
publicArticle != null
? const SizedBox(
height: 2,
)
: Container(),
publicArticle != null
? Row(
children: [
publicArticle!.user.twitterUsername != null
? InkWell(
onTap: () async {
launchUrl(
Uri.parse(
"https://x.com/${publicArticle!.user.twitterUsername!}",
),
);
},
child: const Icon(
CustomeIcons.twitter,
color: AppColors.textColor,
),
)
: Container(),
publicArticle!.user.twitterUsername != null
? const SizedBox(
width: 10,
)
: Container(),
publicArticle!.user.githubUsername != null ||
publicArticle!.user.githubUsername!.isNotEmpty
? InkWell(
onTap: () async {
launchUrl(
Uri.parse(
"https://github.com/${publicArticle!.user.githubUsername!}",
),
);
},
child: const Icon(
CustomeIcons.mark_github,
color: AppColors.textColor,
),
)
: Container(),
],
)
: Container(),
],
),
),
Expand Down
114 changes: 101 additions & 13 deletions bakliwal_news/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.24"
ansicolor:
dependency: transitive
description:
name: ansicolor
sha256: "8bf17a8ff6ea17499e40a2d2542c2f481cd7615760c6d34065cb22bfd22e6880"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
archive:
dependency: transitive
description:
name: archive
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
url: "https://pub.dev"
source: hosted
version: "3.4.10"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -49,6 +65,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
url: "https://pub.dev"
source: hosted
version: "2.0.3"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
url: "https://pub.dev"
source: hosted
version: "0.4.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -89,6 +121,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
cross_file:
dependency: transitive
description:
Expand Down Expand Up @@ -121,14 +161,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.6"
dio:
dependency: "direct main"
description:
name: dio
sha256: "49af28382aefc53562459104f64d16b9dfd1e8ef68c862d5af436cc8356ce5a8"
url: "https://pub.dev"
source: hosted
version: "5.4.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -358,6 +390,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea"
url: "https://pub.dev"
source: hosted
version: "0.13.1"
flutter_lints:
dependency: "direct dev"
description:
Expand All @@ -374,6 +414,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.21"
flutter_native_splash:
dependency: "direct main"
description:
name: flutter_native_splash
sha256: "558f10070f03ee71f850a78f7136ab239a67636a294a44a06b6b7345178edb1e"
url: "https://pub.dev"
source: hosted
version: "2.3.10"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand Down Expand Up @@ -448,6 +496,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
image:
dependency: transitive
description:
name: image
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
url: "https://pub.dev"
source: hosted
version: "4.1.7"
image_picker:
dependency: "direct main"
description:
Expand Down Expand Up @@ -528,6 +584,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.7"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
url: "https://pub.dev"
source: hosted
version: "4.8.1"
leak_tracker:
dependency: transitive
description:
Expand Down Expand Up @@ -716,10 +780,10 @@ packages:
dependency: transitive
description:
name: petitparser
sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
url: "https://pub.dev"
source: hosted
version: "5.4.0"
version: "6.0.2"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -768,6 +832,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.10.1+2"
pointycastle:
dependency: transitive
description:
name: pointycastle
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
url: "https://pub.dev"
source: hosted
version: "3.7.4"
profanity_filter:
dependency: "direct main"
description:
Expand Down Expand Up @@ -877,6 +949,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
universal_io:
dependency: transitive
description:
name: universal_io
sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
url_launcher:
dependency: "direct main"
description:
Expand Down Expand Up @@ -990,13 +1070,21 @@ packages:
source: hosted
version: "1.0.4"
xml:
dependency: "direct main"
dependency: transitive
description:
name: xml
sha256: "80d494c09849dc3f899d227a78c30c5b949b985ededf884cb3f3bcd39f4b447a"
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
url: "https://pub.dev"
source: hosted
version: "6.5.0"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "5.4.1"
version: "3.1.2"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.2"
Loading

0 comments on commit ddfdebd

Please sign in to comment.