diff --git a/news_app/.gitignore b/news_app/.gitignore new file mode 100644 index 0000000..ac4a906 --- /dev/null +++ b/news_app/.gitignore @@ -0,0 +1,72 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.packages +.pub-cache/ +.pub/ +/build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/news_app/.metadata b/news_app/.metadata new file mode 100644 index 0000000..0fc3312 --- /dev/null +++ b/news_app/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 2e540931f73593e35627592ca4f9a4ca3035ed31 + channel: stable + +project_type: app diff --git a/news_app/README.md b/news_app/README.md new file mode 100644 index 0000000..1f9a20b --- /dev/null +++ b/news_app/README.md @@ -0,0 +1,16 @@ +# news_app + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/news_app/assets/1.jpeg b/news_app/assets/1.jpeg new file mode 100644 index 0000000..5e6157e Binary files /dev/null and b/news_app/assets/1.jpeg differ diff --git a/news_app/assets/2.jpg b/news_app/assets/2.jpg new file mode 100644 index 0000000..2b0627c Binary files /dev/null and b/news_app/assets/2.jpg differ diff --git a/news_app/assets/3.jpeg b/news_app/assets/3.jpeg new file mode 100644 index 0000000..9dc59cf Binary files /dev/null and b/news_app/assets/3.jpeg differ diff --git a/news_app/lib/main.dart b/news_app/lib/main.dart new file mode 100644 index 0000000..9160869 --- /dev/null +++ b/news_app/lib/main.dart @@ -0,0 +1,273 @@ +import 'package:flutter/material.dart'; +import 'package:gradient_app_bar/gradient_app_bar.dart'; +import 'package:bubble_tab_indicator/bubble_tab_indicator.dart'; + +// Color 1 #5B44DA +// Color 2 #7B71F6 + +const pink = Color(0xFF5B44DA); +const lightPink = Color(0xFF7B71F6); +const posts = [ + { + 'userImage': 'assets/1.jpeg', + 'username': 'Adrian Schultz', + 'title': 'Cleaning And Organizing Your Computer', + 'description': + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus aliquam quam id facilisis tempor. Aenean quis gravida justo.', + 'id': 1, + 'time': '2 minutes ago', + 'bookmarked': true + }, + { + 'userImage': 'assets/2.jpg', + 'username': 'Mario Mitchell', + 'title': 'Choosing The Best Audio Player Software For Your Computer', + 'description': + 'Nunc sed cursus dolor, eu dictum ipsum. Aenean luctus consectetur eros nec tincidunt. Sed at velit finibus nisi pellentesque tempor.', + 'id': 2, + 'time': '1 hour ago', + 'bookmarked': false + }, + { + 'userImage': 'assets/3.jpeg', + 'username': 'Steve Mann', + 'title': 'Thousands Now Remove Adware Removal Who Never Thought They Could', + 'description': '', + 'id': 3, + 'time': '20 minutes ago', + 'bookmarked': false + } +]; + +void main() => runApp(MyApp()); + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'News app', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + debugShowCheckedModeBanner: false, + home: HomePage()); + } +} + +class HomePage extends StatefulWidget { + HomePage({Key key}) : super(key: key); + + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State + with SingleTickerProviderStateMixin { + TabController controller; + + @override + void initState() { + super.initState(); + controller = TabController(vsync: this, length: 4); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: PreferredSize( + preferredSize: Size(MediaQuery.of(context).size.width, 100.0), + child: Container( + decoration: BoxDecoration(boxShadow: [ + BoxShadow( + color: pink, + offset: Offset(0, 2.0), + blurRadius: 20.0, + ) + ]), + child: GradientAppBar( + title: Text("Home"), + backgroundColorStart: pink, + backgroundColorEnd: lightPink, + centerTitle: false, + elevation: 0.0, + actions: [ + IconButton( + icon: Icon(Icons.search), + onPressed: () {}, + ), + IconButton( + icon: Icon(Icons.notifications_none), + onPressed: () {}, + ) + ], + bottom: TabBar( + isScrollable: true, + controller: controller, + indicatorSize: TabBarIndicatorSize.tab, + indicator: new BubbleTabIndicator( + indicatorHeight: 25.0, + indicatorColor: Colors.white, + tabBarIndicatorSize: TabBarIndicatorSize.tab, + ), + labelColor: Colors.black, + unselectedLabelColor: Colors.white, + tabs: [ + Tab( + text: "For you", + ), + Tab( + text: "Trendings", + ), + Tab( + text: "Populars", + ), + Tab( + text: "Best publishers", + ), + ], + onTap: (int val) {}, + ), + ), + ), + ), + body: TabBarView( + controller: controller, + children: [ + MainPage(), + OtherTabPage( + title: "Trendings", + ), + OtherTabPage( + title: "Populars", + ), + OtherTabPage( + title: "Best publishers", + ) + ], + ), + ); + } +} + +class MainPage extends StatelessWidget { + const MainPage({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Expanded( + child: ListView.builder( + padding: EdgeInsets.only(top: 20.0, bottom: 20.0), + itemBuilder: (BuildContext context, int index) { + return Container( + width: MediaQuery.of(context).size.width - 40, + margin: EdgeInsets.symmetric(horizontal: 20, vertical: 5.0), + padding: EdgeInsets.all(10.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10.0), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + offset: Offset(0, 2.0), + blurRadius: 20.0, + ) + ]), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Row( + children: [ + CircleAvatar( + backgroundColor: Colors.black, + backgroundImage: + AssetImage(posts[index]['userImage']), + ), + SizedBox( + width: 15.0, + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + posts[index]['username'], + style: TextStyle( + fontSize: 18.0, + fontWeight: FontWeight.w400, + ), + ), + Text( + posts[index]['time'], + style: TextStyle(color: Colors.black54), + ), + ], + ) + ], + ), + ), + Icon( + Icons.bookmark, + size: 32.0, + color: Colors.blue, + ) + ], + ), + SizedBox( + height: 10.0, + ), + Text( + posts[index]['title'], + style: TextStyle( + fontSize: 22.0, fontWeight: FontWeight.w500), + ), + posts[index]['description'] == '' + ? Container( + width: 0, + height: 0, + ) + : Column( + children: [ + SizedBox( + height: 10.0, + ), + Text( + posts[index]['description'], + style: TextStyle(color: Colors.black54), + ) + ], + ) + ], + ), + ); + }, + itemCount: posts.length, + ), + ), + ], + ); + } +} + +class OtherTabPage extends StatelessWidget { + final String title; + const OtherTabPage({Key key, this.title}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + child: Center( + child: Text(title), + ), + ); + } +} diff --git a/news_app/pubspec.yaml b/news_app/pubspec.yaml new file mode 100644 index 0000000..3412eb0 --- /dev/null +++ b/news_app/pubspec.yaml @@ -0,0 +1,73 @@ +name: news_app +description: A new Flutter project. + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.1.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.2 + gradient_app_bar: ^0.0.1 + bubble_tab_indicator: "^0.1.4" + +dev_dependencies: + flutter_test: + sdk: flutter + + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + assets: + - assets/ + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/news_app/test/widget_test.dart b/news_app/test/widget_test.dart new file mode 100644 index 0000000..e69de29