From ad6fdd75722d2c7fe6cfc6b76d6451d1d58df7ef Mon Sep 17 00:00:00 2001 From: Kalash Saini Date: Thu, 16 Jun 2022 20:16:57 +0530 Subject: [PATCH] Improve UI and Added feature to see Image when clicked --- android/app/src/main/AndroidManifest.xml | 1 + assets/images/unavailable-image.jpg | Bin 0 -> 17340 bytes lib/HomeScreen.dart | 9 +-- lib/Screens/newsList.dart | 93 +++++++++++++---------- lib/Screens/showImage.dart | 16 ++++ lib/Screens/waitingScreen.dart | 3 +- lib/animation/animation.dart | 28 +++++++ lib/main.dart | 7 +- pubspec.lock | 7 ++ pubspec.yaml | 3 + 10 files changed, 115 insertions(+), 52 deletions(-) create mode 100644 assets/images/unavailable-image.jpg create mode 100644 lib/Screens/showImage.dart create mode 100644 lib/animation/animation.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0cf57a2..b3d807d 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -31,4 +31,5 @@ android:name="flutterEmbedding" android:value="2" /> + diff --git a/assets/images/unavailable-image.jpg b/assets/images/unavailable-image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e72557f210bc794d0b6cefb6cb46e8c35d73b5d8 GIT binary patch literal 17340 zcmeHu1ymf_ns9Z~xVyW1a1HM67Tkh61W0fR4vo88fS^Hx6I>G937U`q2^L7uB{TD8 z=FOYDo!vcW|9{V!52??sZ{6y;Rrhw`b{)V_kdc=GKwto{y!!!e_W?{PPYZh=00cmQ z?@ZwK6F?_!>1=KVSa#oWKrjF<1O^TX6##Hx0f6B?00`LwfMnb4G7t)Y{yKnv1DIdo z7jrNObSJ(0`&IB)k=tGX69KFTLjeQA1i+Xe7);RZE8z28IbfLY&hIMt8Q>9M;SeD( zcaeVM{UXA+EAkG&Fz~QH%V1$3Z~zz&#KTKrijQ$m3=2oCwi^?h3qFvN8kdjzE)WO= zfxw|6z(e2>@0@_ZFc1I}3zm`tdsUuVAmjD!)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7)is@~DUSyxQ9?xQZ^;bfu4R zJ8a2tHbW&7R)4pH`L#0<@yAPL1=CF**E0ekL zfuCSUQN^751)Qq0sd!YB+G2b)pUkAv6Tok$VGYDiw~$prQ}1s zgPKVZ2KH(T@?`upJ$s9#SDMssxKG2RQ4p%|Dd+WOU~IFHVs>(ucgvm3GnF?l)YqQ$ z1sF*txgwMIxnX0(7m;o%ek^zs{;3tdqV#r>f>Z84sBCEo$qwT?WIV=mH4R@!px6_vj5tdvvyv z*ju_6XD^`fr_s>h(A;gSkWoh4UxTjkqclBoOg&z%wwl?8$8wdLs`m~hxH^{f z`jTi-$xF1)2W0pkp?gfzx7t&dy=80KtJ8>#L|A9RSe3S;R^@l6-b}-J!iFCKsN{&j zg3`?DU3qn~M|kTasg7hRMaNk?Ogo4s$1Q6y( { - - var controller = PageController(initialPage: 1); + late PageController controller; String url = "https://newsapi.org/v2/top-headlines?country=in&category=science&apiKey=ff7aefdd16e6480faf2817f36e2daa5e"; @@ -35,9 +34,9 @@ class _HomeScreenState extends State { } @override - void initState() { super.initState(); + controller = PageController(initialPage: 1); fetchNews(); } @@ -53,10 +52,6 @@ class _HomeScreenState extends State { WebView(), ], ), - // floatingActionButton: FloatingActionButton( - // onPressed: ()=> fetchNews(), - // child: Icon(Icons.search), - // ), ), ); } diff --git a/lib/Screens/newsList.dart b/lib/Screens/newsList.dart index 3b02357..f1421cd 100644 --- a/lib/Screens/newsList.dart +++ b/lib/Screens/newsList.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import './showImage.dart'; +import '../animation/animation.dart'; + class NewsList extends StatelessWidget { - var jsonData; NewsList(this.jsonData); @@ -19,50 +21,57 @@ class NewsList extends StatelessWidget { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( - height: MediaQuery.of(context).size.height / 3, - color: Colors.amber, - // child: Image( - // fit: BoxFit.fill, - // image: AssetImage('assets/images/img.png') - // image: NetworkImage, - // ), - child: Image.network("${jsonData["articles"][index]["urlToImage"]}", fit: BoxFit.fill,), + InkWell( + // onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context)=> ShowImage("${jsonData["articles"][index]["urlToImage"]}"))), + onTap: () => + Navigator.push(context, SizeTransition3(ShowImage("${jsonData["articles"][index]["urlToImage"]}"))), + child: SizedBox( + height: MediaQuery.of(context).size.height / 3, + child: (jsonData["articles"][index]["urlToImage"] != null) + ? Image.network( + "${jsonData["articles"][index]["urlToImage"]}", + fit: BoxFit.fill, + ) + : const Image(image: AssetImage('assets/images/unavailable-image.jpg')) + ), ), Expanded( - child: Container( - padding: EdgeInsets.all(15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - jsonData["articles"][index]["title"], - style: TextStyle(fontSize: 25), - textAlign: TextAlign.justify), - const SizedBox(height: 10), - Text( - (jsonData["articles"][index]["content"] != null) ?jsonData["articles"][index]["content"] :"", - style: TextStyle( - color: Colors.grey[600], fontSize: 17), - textAlign: TextAlign.justify, - ), - SizedBox(height: 15), - Text( - 'Published at: ${dateFormatter.format( DateTime.parse(jsonData["articles"][index]["publishedAt"]))} ${timeFormatter.format( DateTime.parse(jsonData["articles"][index]["publishedAt"]))}', - style: TextStyle(color: Colors.grey, fontSize: 16), - textAlign: TextAlign.justify, - ), - SizedBox(height: 20,), - Text( - 'swipe left for more info.', - style: TextStyle(color: Colors.grey, fontSize: 14), - textAlign: TextAlign.justify, - ), - ], + child: Container( + padding: EdgeInsets.all(15), + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(18)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + jsonData["articles"][index]["title"], + style: TextStyle(fontSize: 25), + textAlign: TextAlign.justify), + const SizedBox(height: 10), + Text( + (jsonData["articles"][index]["content"] != null) + ? jsonData["articles"][index]["content"] + : "", + style: TextStyle(color: Colors.grey[600], fontSize: 17), + textAlign: TextAlign.justify, + ), + SizedBox(height: 15), + Text( + 'Published at: ${dateFormatter.format(DateTime.parse(jsonData["articles"][index]["publishedAt"]))} ${timeFormatter.format(DateTime.parse(jsonData["articles"][index]["publishedAt"]))}', + style: TextStyle(color: Colors.grey, fontSize: 16), + textAlign: TextAlign.justify, + ), + SizedBox( + height: 20, + ), + Text( + 'swipe left for more info.', + style: TextStyle(color: Colors.grey, fontSize: 14), + textAlign: TextAlign.justify, ), - )) + ], + ), + )) ], ); }); diff --git a/lib/Screens/showImage.dart b/lib/Screens/showImage.dart new file mode 100644 index 0000000..f3c648b --- /dev/null +++ b/lib/Screens/showImage.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class ShowImage extends StatelessWidget { + String url; + ShowImage(this.url); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, + body: (url != "null") + ?Center(child: Image.network(url)) + :Center(child: Text("Image Unavailable !",style: TextStyle(color: Colors.white),)), + ); + } +} \ No newline at end of file diff --git a/lib/Screens/waitingScreen.dart b/lib/Screens/waitingScreen.dart index 5cac5a9..354f904 100644 --- a/lib/Screens/waitingScreen.dart +++ b/lib/Screens/waitingScreen.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class WaitingScreen extends StatefulWidget { const WaitingScreen({Key? key}) : super(key: key); @@ -16,7 +17,7 @@ class _WaitingScreenState extends State { Icon(Icons.cloud_outlined,size: 150,), Icon(Icons.arrow_downward_rounded,size: 65,), SizedBox(height: 15), - Icon(Icons.mobile_friendly_rounded,size: 130,), + Icon(FontAwesomeIcons.mobileScreen,size: 115,), SizedBox(height: 50,), Text('Loading Shorts...',style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),), SizedBox(height: 40,), diff --git a/lib/animation/animation.dart b/lib/animation/animation.dart new file mode 100644 index 0000000..babfd92 --- /dev/null +++ b/lib/animation/animation.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +class SizeTransition3 extends PageRouteBuilder { + final Widget page; + + SizeTransition3(this.page) + : super( + pageBuilder: (context, animation, anotherAnimation) => page, + transitionDuration: Duration(milliseconds: 1000), + reverseTransitionDuration: Duration(milliseconds: 200), + transitionsBuilder: (context, animation, anotherAnimation, child) { + animation = CurvedAnimation( + curve: Curves.fastLinearToSlowEaseIn, + parent: animation, + reverseCurve: Curves.fastOutSlowIn); + return Align( + alignment: Alignment.center, + child: SizeTransition( + axis: Axis.horizontal, + sizeFactor: animation, + child: page, + axisAlignment: 0, + ), + ); + }, + ); + +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index e8c738c..dc20415 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,11 +3,14 @@ import 'package:flutter/material.dart'; import './HomeScreen.dart'; void main() { - runApp(MaterialApp( + runApp( + MaterialApp( + debugShowCheckedModeBanner: false, title: 'Flutter Demo', themeMode: ThemeMode.system, theme: ThemeData.light(), darkTheme: ThemeData.dark(), home: HomeScreen(), - )); + ) + ); } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 441efe8..38ac8d7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -74,6 +74,13 @@ packages: description: flutter source: sdk version: "0.0.0" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "10.1.0" http: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 1c5f872..577a257 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: cupertino_icons: ^1.0.2 http: ^0.13.4 intl: ^0.17.0 + font_awesome_flutter: ^10.1.0 dev_dependencies: flutter_test: @@ -62,6 +63,8 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/img.png + - assets/images/unavailable-image.jpg + # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see