repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutter_news
mirrored_repositories/flutter_news/lib/view_article.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutternews/main.dart'; import 'package:share/share.dart'; import 'package:url_launcher/url_launcher.dart'; import 'models/article.dart'; class ViewArticle extends StatefulWidget { Article article; ViewArticle(this.article); @override _ViewArticleState createState() => _ViewArticleState(article); } class _ViewArticleState extends State<ViewArticle> { Article article; _ViewArticleState(this.article); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Icon( Icons.arrow_back_ios, color: Colors.white, ), onPressed: () { Navigator.of(context).pop(); }, ), title: Text( article.title, style: myAppTheme.textTheme.caption.copyWith(color: Colors.white), ), ), body: ListView( padding: EdgeInsets.all(15), children: <Widget>[ //Image Hero( tag: article.mediaUrl != null && article.mediaUrl != "" ? article.mediaUrl : article.link, child: Image.network( article.mediaUrl != null && article.mediaUrl != "" ? article.mediaUrl : "https://cdn0.iconfinder.com/data/icons/simplicity/512/news_article_blog-512.png", fit: BoxFit.fitWidth, ), ), //Title Hero( tag: article.title, child: Padding( padding: const EdgeInsets.all(8.0), child: Text( article.title, style: myAppTheme.textTheme.headline1, ), ), ), //Icons Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ //Date Padding( padding: const EdgeInsets.all(12), child: Text( article.pubDate, style: myAppTheme.textTheme.bodyText1.copyWith(color: Colors.grey), ), ), //Open Article IconButton( icon: Icon( Icons.open_in_new, color: Colors.grey, ), onPressed: () async { //Open _launchURL(article.link); }, ), //Share IconButton( icon: Icon( Icons.share, color: Colors.grey, ), onPressed: () async { //Share Share.share(article.link); }, ) ], ), //Description Padding( padding: const EdgeInsets.all(8.0), child: Text( article.description, style: myAppTheme.textTheme.bodyText1.copyWith(color: Colors.grey), ), ), ], )); } _launchURL(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }
0
mirrored_repositories/flutter_news
mirrored_repositories/flutter_news/lib/homepage.dart
import 'dart:io'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutternews/main.dart'; import 'package:flutternews/services/news.dart'; import 'package:flutternews/settings.dart'; import 'package:flutternews/view_article.dart'; import 'package:flutternews/widgets/dialogboxes.dart'; import 'package:path_provider/path_provider.dart'; import 'models/article.dart'; class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { //Keys final scaffoldKey = GlobalKey<ScaffoldState>(); @override Widget build(BuildContext context) { double size = MediaQuery.of(context).size.width < MediaQuery.of(context).size.height ? MediaQuery.of(context).size.width : MediaQuery.of(context).size.height; return Scaffold( key: scaffoldKey, appBar: AppBar( title: Text( "Today's Top Headlines", style: myAppTheme.textTheme.caption.copyWith(color: Colors.white), ), actions: <Widget>[ IconButton( icon: Icon( Icons.refresh, color: Colors.white, ), onPressed: () async { showSnackBar(scaffoldKey: scaffoldKey, text: "Refreshing..."); //Reload await getNews(); }, ) ], ), drawer: Drawer( child: ListView( padding: EdgeInsets.zero, children: <Widget>[ DrawerHeader( child: Text("Flutter News App", style: myAppTheme.textTheme.caption), decoration: BoxDecoration( color: Colors.black12, ), ), ListTile( leading: Icon(Icons.settings, size: 25), title: Text("Settings", style: myAppTheme.textTheme.bodyText1), trailing: Icon(Icons.arrow_right, size: 25), onTap: () { //Close the drawer. Navigator.pop(context); //Open Settings Navigator.push( context, MaterialPageRoute(builder: (context) => Settings()), ); }, ), ], ), ), body: FutureBuilder( builder: (BuildContext context, AsyncSnapshot snapshot) { //When Loading if (snapshot == null || snapshot.hasData == false) { return Center( child: Column( children: <Widget>[ //Flare Animation Container( width: size * 0.8, height: size * 0.8, child: FlareActor( "assets/animations/NewsMedia.flr", alignment: Alignment.center, ), ), Text( "Please wait, Loading...", style: myAppTheme.textTheme.caption, ) ], ), ); //No Results } else if (snapshot.data.length == 0 || snapshot.data == null) { return Center( child: Column( children: <Widget>[ Image.asset( "assets/animations/no_connection.gif", fit: BoxFit.fitWidth, ), Text( "No news found...\nAre you sure you're connected?", style: myAppTheme.textTheme.caption, ) ], ), ); //Results } else { return getNewsListView(snapshot.data); } }, future: getNews(), ), ); } //Returns the ListView containing the News ListView getNewsListView(List<Article> news) { showNewsFetchDateTime(); return ListView.builder( itemCount: news.length, itemBuilder: (BuildContext context, int index) { if (news[index] == null) return Container(); return ListTile( leading: Hero( tag: news[index].mediaUrl != null && news[index].mediaUrl != "" ? news[index].mediaUrl : news[index].link, child: Image.network( news[index].mediaUrl != null && news[index].mediaUrl != "" ? news[index].mediaUrl : "https://cdn0.iconfinder.com/data/icons/simplicity/512/news_article_blog-512.png", height: 240, width: 80, ), ), //Title title: Hero( tag: news[index].title, child: Text( news[index].title, style: myAppTheme.textTheme.caption, ), ), onTap: () { //Open This News Navigator.push( context, MaterialPageRoute(builder: (context) => ViewArticle(news[index])), ); }, ); }); } Future<void> showNewsFetchDateTime() async { final Directory directory = await getApplicationDocumentsDirectory(); final File file = File('${directory.path}/news.xml'); showSnackBar(scaffoldKey: scaffoldKey, text: "Last fetched: " + file.lastModifiedSync().toString()); } }
0
mirrored_repositories/flutter_news
mirrored_repositories/flutter_news/lib/settings.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutternews/main.dart'; import 'package:share/share.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; import 'models/article.dart'; class Settings extends StatefulWidget { @override _SettingsState createState() => _SettingsState(); } class _SettingsState extends State<Settings> { //Saved settings SharedPreferences prefs; bool blBackgroundLoad = false, blDailyNotification = false; TimeOfDay todNotification; @override void initState() { loadSavedData(); super.initState(); } //Load the saved settings data loadSavedData() async { prefs = await SharedPreferences.getInstance(); //Get the background load setting setState(() { //Get background load blBackgroundLoad = prefs.getBool("background load") ?? false; //Get background notification blDailyNotification = prefs.getBool("daily notification") ?? false; //Get background notification time String strNotification = prefs.getString("daily notification time") ?? null; if (strNotification != null && strNotification != "") { strNotification = strNotification.replaceAll("TimeOfDay(", "").replaceAll(")", ""); todNotification = TimeOfDay(hour: int.parse(strNotification.split(":")[0]), minute: int.parse(strNotification.split(":")[1])); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Icon( Icons.arrow_back_ios, color: Colors.white, ), onPressed: () { Navigator.of(context).pop(); }, ), title: Text( "Settings", style: myAppTheme.textTheme.caption.copyWith(color: Colors.white), ), ), body: ListView( padding: EdgeInsets.all(10), children: <Widget>[ //Background fetch ListTile( title: Text("Background news update", style: myAppTheme.textTheme.bodyText1), subtitle: Text("Fetches news data in the background when the phone is on charge.", style: myAppTheme.textTheme.bodyText2), trailing: Switch( value: blBackgroundLoad, onChanged: (val) { setState(() { blBackgroundLoad = val; prefs.setBool("background load", blBackgroundLoad); }); }), ), //Daily reminder ListTile( title: Text("Daily reminder notification", style: myAppTheme.textTheme.bodyText1), subtitle: Text("Daily news reminder notifications", style: myAppTheme.textTheme.bodyText2), trailing: Switch( value: blDailyNotification, onChanged: (val) async { setState(() { blDailyNotification = val; prefs.setBool("daily notification", blDailyNotification); }); if (val == false) { flutterLocalNotificationsPlugin.cancelAll(); } else if (todNotification != null) { setDailyNotifications(); } }), ), //Daily reminder time blDailyNotification ? ListTile( title: Text("Daily reminder notification time", style: myAppTheme.textTheme.bodyText1), subtitle: Text( "Choose time to receive daily news notification\n" + (todNotification == null ? "(not set)" : todNotification.toString()), style: myAppTheme.textTheme.bodyText2), trailing: Icon( Icons.arrow_forward_ios, color: Colors.black, ), onTap: () async { //Set the Daily reminder time if (todNotification == null) todNotification = TimeOfDay(hour: 0, minute: 0); todNotification = await showTimePicker( context: context, initialTime: TimeOfDay.fromDateTime(DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, todNotification.hour, todNotification.minute) ?? DateTime.now()), ); if (blDailyNotification != null) prefs.setString("daily notification time", todNotification.toString()); setDailyNotifications(); setState(() {}); }, ) : Container() ], )); } setDailyNotifications() async { //Cancel all the previous notifications flutterLocalNotificationsPlugin.cancelAll(); //Set the time of schedules notifications var time = Time(todNotification.hour, todNotification.minute, 0); //Schedule Notifications var androidPlatformChannelSpecifics = AndroidNotificationDetails( 'repeatDailyAtTime channel id', 'repeatDailyAtTime channel name', 'repeatDailyAtTime description'); var iOSPlatformChannelSpecifics = IOSNotificationDetails(); var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.showDailyAtTime( 0, "Today's News", "Tap to see today's headlines", time, platformChannelSpecifics); } }
0
mirrored_repositories/flutter_news
mirrored_repositories/flutter_news/lib/main.dart
import 'dart:io'; import 'package:background_fetch/background_fetch.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutternews/services/news.dart'; import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'homepage.dart'; import 'themes/maintheme.dart'; //Theme Data ThemeData myAppTheme; //Saved settings SharedPreferences prefs; //Daily Notifications FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); void main() { runApp(MyApp()); //Setup the local daily notifications setupNotifications(); initPlatformState(); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { //Load the Theme myAppTheme = getMainThemeWithBrightness(context, Brightness.light); return MaterialApp( title: 'Flutter News App', theme: myAppTheme, home: MyHomePage(), ); } } setupNotifications() async { // initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project var initializationSettingsAndroid = AndroidInitializationSettings('app_icon'); var initializationSettingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: onDidReceiveLocalNotification); var initializationSettings = InitializationSettings(initializationSettingsAndroid, initializationSettingsIOS); await flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: onSelectNotification); } Future onSelectNotification(String payload) async { if (payload != null) { debugPrint('notification payload: ' + payload); } //Complete process //For out use case, nothing needed } Future onDidReceiveLocalNotification(int id, String title, String body, String payload) async { //Complete process //For out use case, nothing needed } // Platform messages are asynchronous, so we initialize in an async method. Future<void> initPlatformState() async { // Configure BackgroundFetch. BackgroundFetch.configure( BackgroundFetchConfig( minimumFetchInterval: 5, stopOnTerminate: false, enableHeadless: false, requiresBatteryNotLow: false, requiresCharging: true, requiresStorageNotLow: false, requiresDeviceIdle: false, requiredNetworkType: NetworkType.ANY), executeBackgroundTask) .then((int status) { print('[BackgroundFetch] configure success: $status'); }).catchError((e) { print('[BackgroundFetch] configure ERROR: $e'); }); //Schedule the background task BackgroundFetch.scheduleTask(TaskConfig(taskId: "com.praharsh.flutternews", delay: 60000)); } Future executeBackgroundTask(String taskId) async { //Get the background fetch setting SharedPreferences prefs = await SharedPreferences.getInstance(); bool blBackgroundLoad = prefs.getBool("background load") ?? false; if (blBackgroundLoad) { //Check if the last updated day way today final Directory directory = await getApplicationDocumentsDirectory(); final File file = File('${directory.path}/news.xml'); final today = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); final fileDate = DateTime(file.lastModifiedSync().year, file.lastModifiedSync().month, file.lastModifiedSync().day); if (fileDate.isBefore(today)) { await fetchNews(); //Send a push notification var androidPlatformChannelSpecifics = AndroidNotificationDetails( 'your channel id', 'your channel name', 'your channel description', importance: Importance.Max, priority: Priority.High, ticker: 'ticker'); var iOSPlatformChannelSpecifics = IOSNotificationDetails(); var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin .show(0, "News Loaded", "Tap here to read the latest headlines", platformChannelSpecifics, payload: 'item x'); //End this background process BackgroundFetch.finish(taskId); } else { //End this background process BackgroundFetch.finish(taskId); } } else { //End this background process BackgroundFetch.finish(taskId); } }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/widgets/decoration.dart
import 'package:flutter/material.dart'; //This Package contains the widgets for all the decoration used in the app //Get the Gradient Decoration BoxDecoration gradientDecoration() { return BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, stops: [0.5, 1], colors: [ Colors.orangeAccent, Colors.white, ], )); }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/widgets/dialogboxes.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; //Show Toast Message void showSnackBar({@required scaffoldKey, String text, String buttonText, VoidCallback onPressed}) { try { scaffoldKey.currentState.showSnackBar( SnackBar( content: Text(text), action: SnackBarAction(label: buttonText, onPressed: onPressed), ), ); } catch (e) { scaffoldKey.currentState.showSnackBar( SnackBar(content: Text(text)), ); } } // Return Alert Dialog Box void showAlertDialog(BuildContext context, String title, String body) { // flutter defined function showDialog( context: context, builder: (BuildContext context) { // return object of type Dialog return AlertDialog( title: new Text(title), content: new Text(body), actions: <Widget>[ // usually buttons at the bottom of the dialog new FlatButton( child: new Text("Close"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } //Show loading pop up void showLoading(BuildContext context) { showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return Dialog( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(30.0), topRight: Radius.circular(30.0), bottomLeft: Radius.circular(30.0), bottomRight: Radius.circular(30.0), )), child: Padding( padding: const EdgeInsets.all(15), child: new Row( mainAxisSize: MainAxisSize.min, children: [ new CircularProgressIndicator(), Padding( padding: const EdgeInsets.all(10), child: new Text("Loading, please wait..."), ), ], ), ), ); }, ); }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/widgets/form.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import '../main.dart'; //This Package contains the widgets for all the Form related widgets typedef CallBackString(String val); TextFormField getTextFormField( {@required BuildContext context, @required TextEditingController controller, @required String strHintText, @required String strLabelText, Icon icon, TextInputType keyboardType, CallBackString validator, CallBackString onChanged, CallBackString onFieldSubmitted, Color textColor = Colors.black}) { return TextFormField( controller: controller, decoration: InputDecoration( focusColor: textColor, fillColor: textColor, hoverColor: textColor, hintText: strHintText, hintStyle: TextStyle( fontSize: (!kIsWeb) ? MediaQuery.of(context).size.width * 0.04 : MediaQuery.of(context).size.width * 0.03, color: textColor), labelText: strLabelText, labelStyle: TextStyle( fontSize: (!kIsWeb) ? MediaQuery.of(context).size.width * 0.04 : MediaQuery.of(context).size.width * 0.03, color: textColor), border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide(color: myAppTheme.accentColor, width: 8)), suffixIcon: icon, ), keyboardType: keyboardType == null ? TextInputType.phone : keyboardType, style: TextStyle( fontSize: (!kIsWeb) ? MediaQuery.of(context).size.width * 0.04 : MediaQuery.of(context).size.width * 0.03, color: textColor), cursorColor: textColor, validator: (val) => validator(val), onChanged: (val) => onChanged(val), onFieldSubmitted: (val) => onFieldSubmitted(val)); } TextFormField getTextFormFieldPassword({ @required BuildContext context, @required TextEditingController controller, @required String strHintText, @required String strLabelText, Icon icon, TextInputType keyboardType, CallBackString validator, CallBackString onChanged, }) { return TextFormField( controller: controller, maxLines: 1, decoration: new InputDecoration( hintText: strHintText, hintStyle: TextStyle( fontSize: (!kIsWeb) ? MediaQuery.of(context).size.width * 0.04 : MediaQuery.of(context).size.width * 0.03, color: Colors.black), labelText: strLabelText, labelStyle: TextStyle( fontSize: (!kIsWeb) ? MediaQuery.of(context).size.width * 0.04 : MediaQuery.of(context).size.width * 0.03, color: Colors.black), border: new OutlineInputBorder( borderRadius: new BorderRadius.circular(8), borderSide: new BorderSide(color: Color.fromARGB(255, 51, 72, 84), width: 10)), icon: icon, ), keyboardType: keyboardType == null ? TextInputType.phone : keyboardType, obscureText: true, style: TextStyle( fontSize: (!kIsWeb) ? MediaQuery.of(context).size.width * 0.06 : MediaQuery.of(context).size.width * 0.03, ), validator: (val) => validator(val), onChanged: (val) => onChanged(val)); }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/widgets/buttons.dart
import 'package:flutter/material.dart'; import '../main.dart'; //This Package contains the widgets for all the buttons used in the app //This Returns the Primary Raised button with Icon RaisedButton primaryRaisedIconButton( {@required BuildContext context, @required String text, @required Icon icon, double textSize, Color color, Color highlightColor, Color splashColor, Color textColor, VoidCallback onPressed}) { return RaisedButton.icon( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0), bottomLeft: Radius.circular(10.0), bottomRight: Radius.circular(10.0)), side: BorderSide(color: Color.fromARGB(255, 51, 72, 84))), color: color == null ? Color.fromARGB(255, 51, 72, 84) : color, disabledColor: Colors.grey, highlightColor: highlightColor == null ? Color.fromARGB(255, 51, 72, 84) : highlightColor, splashColor: splashColor == null ? Colors.white : splashColor, icon: icon, label: Text(text, style: getTextStyle(context, textSize, textColor)), onPressed: () => onPressed()); } //This Returns the Primary Raised button RaisedButton primaryRaisedButton( {@required BuildContext context, @required String text, double textSize, Color color, Color highlightColor, Color splashColor, Color textColor, VoidCallback onPressed}) { return RaisedButton( shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8))), padding: EdgeInsets.fromLTRB(5, 10, 5, 10), color: color == null ? Color.fromARGB(255, 51, 72, 84) : color, disabledColor: Color.fromARGB(255, 51, 72, 84), highlightColor: highlightColor == null ? Color.fromARGB(255, 51, 72, 84) : highlightColor, splashColor: splashColor == null ? Colors.white : splashColor, child: Text(text, style: getTextStyle(context, textSize, textColor)), onPressed: () => onPressed()); } //Get the TextStyle from the given params TextStyle getTextStyle(_context, _textSize, _textColor) { TextStyle _textStyle; //Defining size if (_textSize == null) _textSize = MediaQuery.of(_context).size.width * 0.04; //Defining textColor if (_textColor == null) { _textStyle = TextStyle( fontSize: _textSize, ); } else { _textStyle = TextStyle( fontSize: _textSize, color: _textColor, ); } return _textStyle; }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/widgets/shapes.dart
import 'package:flutter/material.dart'; //This Package contains the widgets for all the shapes used in the app //Get the Rounded shape for cards RoundedRectangleBorder roundedShape() { return RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0), bottomRight: Radius.circular(15.0), )); }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/models/article.dart
//Definition of the article class class Article { String title, description, link, pubDate, mediaUrl; Article(this.title, this.description, this.link, this.pubDate, {this.mediaUrl}); }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/themes/maintheme.dart
import 'package:flutter/material.dart'; //This file contains the main theme settings //Return the ThemeData with Brightness ThemeData getMainThemeWithBrightness(BuildContext context, Brightness appBrightness) { double size = 300; try { size = MediaQuery.of(context).size.width < MediaQuery.of(context).size.height ? MediaQuery.of(context).size.width : MediaQuery.of(context).size.height; } catch (e) { size = 300; } return ThemeData( primaryColor: Colors.blue, accentColor: Colors.black, primarySwatch: Colors.blue, fontFamily: 'Poppins', appBarTheme: AppBarTheme(color: Color.fromARGB(255, 3, 4, 6), iconTheme: IconThemeData(color: Colors.white)), disabledColor: Color.fromARGB(255, 178, 191, 202), iconTheme: IconThemeData( color: appBrightness == Brightness.light ? Color.fromARGB(255, 51, 72, 84) : Color.fromARGB(255, 178, 191, 202), opacity: 1.0, size: size * 0.06), // Define the default TextTheme. Use this to specify the default // text styling for headlines, titles, bodies of text, and more. // Define the default TextTheme. Use this to specify the default // text styling for headlines, titles, bodies of text, and more. textTheme: TextTheme( headline1: TextStyle( fontSize: size * 0.075, fontFamily: 'Poppins', fontWeight: FontWeight.bold, color: appBrightness == Brightness.light ? Colors.black : Colors.white), headline2: TextStyle( fontSize: size * 0.07, fontFamily: 'Poppins', fontWeight: FontWeight.bold, color: appBrightness == Brightness.light ? Colors.black : Colors.white), subtitle1: TextStyle( fontSize: size * 0.06, fontFamily: 'Poppins', fontWeight: FontWeight.bold, color: appBrightness == Brightness.light ? Colors.black : Colors.white), subtitle2: TextStyle( fontSize: size * 0.055, fontFamily: 'Poppins', fontWeight: FontWeight.bold, color: appBrightness == Brightness.light ? Colors.black : Colors.white), caption: TextStyle( fontSize: size * 0.05, fontFamily: 'Poppins', fontWeight: FontWeight.w500, color: appBrightness == Brightness.light ? Colors.black : Colors.white), bodyText1: TextStyle( fontSize: size * 0.05, fontFamily: "Poppins", color: appBrightness == Brightness.light ? Colors.black : Colors.white), bodyText2: TextStyle( fontSize: size * 0.040, fontFamily: "Poppins", color: appBrightness == Brightness.light ? Colors.black : Colors.white), ), primaryTextTheme: appBrightness == Brightness.light ? Theme.of(context).primaryTextTheme.apply(bodyColor: Colors.black) : Theme.of(context).primaryTextTheme.apply(bodyColor: Colors.white), brightness: appBrightness, ); }
0
mirrored_repositories/flutter_news/lib
mirrored_repositories/flutter_news/lib/services/news.dart
import 'dart:io'; import 'package:flutternews/models/article.dart'; import 'package:path_provider/path_provider.dart'; import 'package:xml/xml.dart' as xml; import 'package:http/http.dart' as http; //Fetches and returns the news Future<List<Article>> getNews() async { if (await fetchNews() == false) { //Could not fetch the news from the internet. //Has to be a connection issue return null; } else { List lstNews = await readNews(); return lstNews; } } //Fetches the XML file from the endpoint and saves it Future<bool> fetchNews() async { final response = await http.get("https://news.yahoo.com/rss/"); if (response.statusCode == 200) { write(response.body); return true; } else { return false; } } Future<bool> write(String text) async { bool blRet = true; final Directory directory = await getApplicationDocumentsDirectory(); final File file = File('${directory.path}/news.xml'); await file.writeAsString(text); return blRet; } //Reads the XML file from the Storage Future<List<Article>> readNews() async { //Get the saved XML file from the storage final Directory directory = await getApplicationDocumentsDirectory(); final File file = File('${directory.path}/news.xml'); //Parse the XML String strNews = await file.readAsString(); xml.XmlDocument xmlDoc = xml.parse(strNews); return xmlDoc.findAllElements("item").map((e) { // print( // e.findElements("title").first.text, // ); try { Article article = Article( e.findElements("title").first.text, strGetDescriptionFromHTML(e.findElements("description").first.text), e.findElements("link").first.text, e.findElements("pubDate").first.text, ); String strMedia = e.findElements("media:content").toString(); if (strGetURLFromMedia(strMedia) != "") article.mediaUrl = strGetURLFromMedia(strMedia); return article; } catch (e) { return null; } }).toList(); } String strGetURLFromMedia(String strMedia) { if (strMedia == null || strMedia == "") return ""; try { return strMedia.substring(strMedia.lastIndexOf("url=") + 5, strMedia.lastIndexOf(".jpg") + 4); } catch (e) { return ""; } } String strGetDescriptionFromHTML(String strDescription) { if (strDescription == null || strDescription == "") return ""; try { return strDescription.substring( strDescription.lastIndexOf("alt=") + 5, strDescription.lastIndexOf('" border="0"')); } catch (e) { return ""; } }
0
mirrored_repositories/digital_clock
mirrored_repositories/digital_clock/lib/digital_clock.dart
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_clock_helper/model.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:intl/intl.dart'; enum _Element { background, text, } final _lightTheme = { _Element.background: Colors.white, _Element.text: Colors.black, }; final _darkTheme = { _Element.background: Colors.black, _Element.text: Colors.white, }; /// A basic digital clock. /// /// You can do better than this! class DigitalClock extends StatefulWidget { const DigitalClock(this.model); final ClockModel model; @override _DigitalClockState createState() => _DigitalClockState(); } class _DigitalClockState extends State<DigitalClock> { DateTime _dateTime = DateTime.now(); Timer _timer; @override void initState() { super.initState(); widget.model.addListener(_updateModel); _updateTime(); _updateModel(); } @override void didUpdateWidget(DigitalClock oldWidget) { super.didUpdateWidget(oldWidget); if (widget.model != oldWidget.model) { oldWidget.model.removeListener(_updateModel); widget.model.addListener(_updateModel); } } @override void dispose() { _timer?.cancel(); widget.model.removeListener(_updateModel); widget.model.dispose(); super.dispose(); } void _updateModel() { setState(() { // Cause the clock to rebuild when the model changes. }); } void _updateTime() { setState(() { _dateTime = DateTime.now(); _timer = Timer( Duration(seconds: 1) - Duration(milliseconds: _dateTime.millisecond), _updateTime, ); }); } String weatherIcon() { if (widget.model.weatherString == "sunny") { return 'images/sun.png'; } else if (widget.model.weatherString == "windy") { return 'images/wind.png'; } else if (widget.model.weatherString == "cloudy") { return 'images/cloud.png'; } else if (widget.model.weatherString == "rainy") { return 'images/rain.png'; } else if (widget.model.weatherString == "foggy") { return 'images/fog.png'; } else if (widget.model.weatherString == "snowy") { return 'images/snow.png'; } else { return 'images/thunderstorm.png'; } } String setBackground() { if (widget.model.weatherString == "sunny") { if (Theme.of(context).brightness == Brightness.light) { return 'images/sunnyLight.gif'; } else { return 'images/sunnyDark.gif'; } } if (widget.model.weatherString == "windy") { if (Theme.of(context).brightness == Brightness.light) { return 'images/windyLight.gif'; } else { return 'images/windyDark.gif'; } } if (widget.model.weatherString == "cloudy") { if (Theme.of(context).brightness == Brightness.light) { return 'images/cloudyLight.gif'; } else { return 'images/cloudyDark.gif'; } } if (widget.model.weatherString == "rainy") { if (Theme.of(context).brightness == Brightness.light) { return 'images/rainyLight.gif'; } else { return 'images/rainyDark.gif'; } } if (widget.model.weatherString == "foggy") { if (Theme.of(context).brightness == Brightness.light) { return 'images/foggyLight.gif'; } else { return 'images/foggyDark.gif'; } } if (widget.model.weatherString == "snowy") { if (Theme.of(context).brightness == Brightness.light) { return 'images/snowyLight.gif'; } else { return 'images/snowyDark.gif'; } } else { if (Theme.of(context).brightness == Brightness.light) { return 'images/thunderLight.gif'; } else { return 'images/thunderDark.gif'; } } } @override Widget build(BuildContext context) { final colors = Theme.of(context).brightness == Brightness.light ? _lightTheme : _darkTheme; final setBackgroundcolor = setBackground(); final imageAsset = weatherIcon(); final location = widget.model.location.toString(); final tempeature = widget.model.temperatureString; final weekDay = DateFormat('EEEE').format(_dateTime); final hour = DateFormat(widget.model.is24HourFormat ? 'HH' : 'hh').format(_dateTime); final minute = DateFormat('mm').format(_dateTime); final second = DateFormat('ss').format(_dateTime); final date = DateFormat('MMM d y').format(_dateTime); final fontSize = MediaQuery.of(context).size.width / 7.5; final offset = -fontSize / 20; final defaultStyle = TextStyle( color: colors[_Element.text], fontSize: fontSize, ); return DecoratedBox( decoration: BoxDecoration( image: DecorationImage( image: AssetImage('$setBackgroundcolor'), fit: BoxFit.cover), ), child: Container( alignment: AlignmentDirectional.bottomStart, child: Container( padding: EdgeInsets.all(25.0), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Padding( padding: EdgeInsets.fromLTRB(0, 0, 10.0, 0), child: Image( image: AssetImage('$imageAsset'), ), ), Text( '$tempeature', style: GoogleFonts.blackOpsOne(), ), ], ), Text( '$location', style: GoogleFonts.blackOpsOne(), ) ], ), Row( children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Row( children: <Widget>[ Text( '$weekDay , $date', style: GoogleFonts.blackOpsOne(), ) ], ), DefaultTextStyle( style: defaultStyle, child: Row( children: <Widget>[ Text( '$hour: $minute: $second', style: GoogleFonts.blackOpsOne(), ), ], ), ) ], ) ], ), // Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, // children: <Widget>[ // Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: <Widget>[ // Padding( // padding: EdgeInsets.fromLTRB(0, 0, 10.0, 0), // child: Image( // image: AssetImage('$imageAsset'), // ), // ), // Text( // '$tempeature', // style: GoogleFonts.blackOpsOne(), // ), // ], // ), // Text( // '$location', // style: GoogleFonts.blackOpsOne(), // ) // ], // ) ], ), )), ); } }
0
mirrored_repositories/digital_clock
mirrored_repositories/digital_clock/lib/main.dart
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:io'; import 'package:flutter_clock_helper/customizer.dart'; import 'package:flutter_clock_helper/model.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'digital_clock.dart'; void main() { // A temporary measure until Platform supports web and TargetPlatform supports // macOS. if (!kIsWeb && Platform.isMacOS) { // TODO(gspencergoog): Update this when TargetPlatform includes macOS. // https://github.com/flutter/flutter/issues/31366 // See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override. debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; } // This creates a clock that enables you to customize it. // // The [ClockCustomizer] takes in a [ClockBuilder] that consists of: // - A clock widget (in this case, [DigitalClock]) // - A model (provided to you by [ClockModel]) // For more information, see the flutter_clock_helper package. // // Your job is to edit [DigitalClock], or replace it with your // own clock widget. (Look in digital_clock.dart for more details!) runApp(ClockCustomizer((ClockModel model) => DigitalClock(model))); }
0
mirrored_repositories/Instagram
mirrored_repositories/Instagram/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Generated App', theme: new ThemeData( primarySwatch: Colors.blue, primaryColor: const Color(0xFF2196f3), accentColor: const Color(0xFF2196f3), canvasColor: const Color(0xFFfafafa), ), home: new MyHomePage(), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key}) : super(key: key); @override _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text('Instagram'), ), body: new Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Icon( Icons.settings, color: const Color(0xFF130101), size: 30.0), new Text( "gupta_prayant", style: new TextStyle(fontSize:17.0, color: const Color(0xFF000000), fontWeight: FontWeight.w900, fontFamily: "Roboto"), ), new Icon( Icons.person_add, color: const Color(0xFF000000), size: 30.0) ] ), new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Image.network( 'https://drive.google.com/file/d/1gPW37ieonn_A4sXvc_N6qxX2ofpJ7rtz/view?usp=sharing', fit:BoxFit.fitHeight, width: 90.0, height: 90.0, ), new Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Text( "gupta_prayant", style: new TextStyle(fontSize:21.0, color: const Color(0xFF090909), fontWeight: FontWeight.w500, fontFamily: "Roboto"), ), new Text( "Edit Profile", style: new TextStyle(fontSize:17.0, color: const Color(0xFF000000), fontWeight: FontWeight.w900, fontFamily: "Roboto"), ) ] ) ] ), new Text( " Prayant Gupta", style: new TextStyle(fontSize:17.0, color: const Color(0xFF000000), fontWeight: FontWeight.w900, fontFamily: "Roboto"), ), new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Text( "17", style: new TextStyle(fontSize:17.0, color: const Color(0xFF000000), fontWeight: FontWeight.w900, fontFamily: "Roboto"), ), new Text( "Posts", style: new TextStyle(fontSize:14.0, color: const Color(0xFF000000), fontWeight: FontWeight.w400, fontFamily: "Roboto"), ) ] ), new Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Text( "205", style: new TextStyle(fontSize:17.0, color: const Color(0xFF000000), fontWeight: FontWeight.w900, fontFamily: "Roboto"), ), new Text( "Following", style: new TextStyle(fontSize:14.0, color: const Color(0xFF000000), fontWeight: FontWeight.w400, fontFamily: "Roboto"), ) ] ), new Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Text( "205", style: new TextStyle(fontSize:17.0, color: const Color(0xFF000000), fontWeight: FontWeight.w900, fontFamily: "Roboto"), ), new Text( "Followers", style: new TextStyle(fontSize:14.0, color: const Color(0xFF000000), fontWeight: FontWeight.w400, fontFamily: "Roboto"), ) ] ) ] ), new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Icon( Icons.grid_on, color: const Color(0xFF076dd2), size: 30.0), new Icon( Icons.view_day, color: const Color(0xFFbdbdbd), size: 30.0), new Icon( Icons.turned_in_not, color: const Color(0xFFa8a4a4), size: 30.0), new Icon( Icons.local_offer, color: const Color(0xFFa69d9d), size: 30.0) ] ) ] ), ); } }
0
mirrored_repositories/Instagram
mirrored_repositories/Instagram/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pavlova/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/floor_task
mirrored_repositories/floor_task/lib/main.dart
import 'package:floor_start/database/task_dao.dart'; import 'package:floor_start/screen/list_page.dart'; import 'package:flutter/material.dart'; import 'package:floor_start/database/database.dart'; Future<void> main() async { final database = await $FloorTaskDatabase .databaseBuilder('flutter_database.db') .build(); final dao = database.taskDao; runApp(MyApp(dao)); } class MyApp extends StatelessWidget { final TaskDao dao; const MyApp(this.dao); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: ThemeData( brightness: Brightness.dark, primaryColor: Colors.deepPurple, accentColor: Colors.orange, errorColor: Colors.redAccent[100]), home: ListPage(title: 'Task with Floor',dao: dao), ); } }
0
mirrored_repositories/floor_task/lib
mirrored_repositories/floor_task/lib/database/database.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'database.dart'; // ************************************************************************** // FloorGenerator // ************************************************************************** class $FloorTaskDatabase { /// Creates a database builder for a persistent database. /// Once a database is built, you should keep a reference to it and re-use it. static _$TaskDatabaseBuilder databaseBuilder(String name) => _$TaskDatabaseBuilder(name); /// Creates a database builder for an in memory database. /// Information stored in an in memory database disappears when the process is killed. /// Once a database is built, you should keep a reference to it and re-use it. static _$TaskDatabaseBuilder inMemoryDatabaseBuilder() => _$TaskDatabaseBuilder(null); } class _$TaskDatabaseBuilder { _$TaskDatabaseBuilder(this.name); final String name; final List<Migration> _migrations = []; /// Adds migrations to the builder. _$TaskDatabaseBuilder addMigrations(List<Migration> migrations) { _migrations.addAll(migrations); return this; } /// Creates the database and initializes it. Future<TaskDatabase> build() async { final database = _$TaskDatabase(); database.database = await database.open(name ?? ':memory:', _migrations); return database; } } class _$TaskDatabase extends TaskDatabase { _$TaskDatabase([StreamController<String> listener]) { changeListener = listener ?? StreamController<String>.broadcast(); } TaskDao _taskDaoInstance; Future<sqflite.Database> open(String name, List<Migration> migrations) async { final path = join(await sqflite.getDatabasesPath(), name); return sqflite.openDatabase( path, version: 1, onConfigure: (database) async { await database.execute('PRAGMA foreign_keys = ON'); }, onUpgrade: (database, startVersion, endVersion) async { MigrationAdapter.runMigrations( database, startVersion, endVersion, migrations); }, onCreate: (database, _) async { await database.execute( 'CREATE TABLE IF NOT EXISTS `Task` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT, `createdTime` INTEGER)'); }, ); } @override TaskDao get taskDao { return _taskDaoInstance ??= _$TaskDao(database, changeListener); } } class _$TaskDao extends TaskDao { _$TaskDao(this.database, this.changeListener) : _queryAdapter = QueryAdapter(database, changeListener), _taskInsertionAdapter = InsertionAdapter( database, 'Task', (Task item) => <String, dynamic>{ 'id': item.id, 'title': item.title, 'createdTime': item.createdTime }, changeListener), _taskUpdateAdapter = UpdateAdapter( database, 'Task', 'id', (Task item) => <String, dynamic>{ 'id': item.id, 'title': item.title, 'createdTime': item.createdTime }, changeListener), _taskDeletionAdapter = DeletionAdapter( database, 'Task', 'id', (Task item) => <String, dynamic>{ 'id': item.id, 'title': item.title, 'createdTime': item.createdTime }, changeListener); final sqflite.DatabaseExecutor database; final StreamController<String> changeListener; final QueryAdapter _queryAdapter; final _taskMapper = (Map<String, dynamic> row) => Task(row['id'] as int, row['title'] as String, row['createdTime'] as int); final InsertionAdapter<Task> _taskInsertionAdapter; final UpdateAdapter<Task> _taskUpdateAdapter; final DeletionAdapter<Task> _taskDeletionAdapter; @override Future<Task> findTaskById(int id) async { return _queryAdapter.query('SELECT * FROM task WHERE id = ?', arguments: <dynamic>[id], mapper: _taskMapper); } @override Future<List<Task>> findAllTasks() async { return _queryAdapter.queryList('SELECT * FROM task', mapper: _taskMapper); } @override Stream<List<Task>> findAllTasksAsStream() { return _queryAdapter.queryListStream('SELECT * FROM task', tableName: 'Task', mapper: _taskMapper); } @override Future<void> deleteAllTask() async { await _queryAdapter.queryNoReturn('DELETE FROM task'); } @override Future<void> insertTask(Task task) async { await _taskInsertionAdapter.insert(task, sqflite.ConflictAlgorithm.abort); } @override Future<void> updateTask(Task task) async { await _taskUpdateAdapter.update(task, sqflite.ConflictAlgorithm.abort); } @override Future<void> deleteTask(Task task) async { await _taskDeletionAdapter.delete(task); } }
0
mirrored_repositories/floor_task/lib
mirrored_repositories/floor_task/lib/database/task_dao.dart
import 'package:floor/floor.dart'; import 'package:floor_start/model/task.dart'; @dao abstract class TaskDao { @Query('SELECT * FROM task WHERE id = :id') Future<Task> findTaskById(int id); @Query('SELECT * FROM task') Future<List<Task>> findAllTasks(); @Query('SELECT * FROM task') Stream<List<Task>> findAllTasksAsStream(); @insert Future<void> insertTask(Task task); @update Future<void> updateTask(Task task); @delete Future<void> deleteTask(Task task); @Query('DELETE FROM task') Future<void> deleteAllTask(); }
0
mirrored_repositories/floor_task/lib
mirrored_repositories/floor_task/lib/database/database.dart
import 'dart:async'; import 'package:floor/floor.dart'; import 'package:floor_start/database/task_dao.dart'; import 'package:floor_start/model/task.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart' as sqflite; part 'database.g.dart'; @Database(version : 1, entities : [Task]) abstract class TaskDatabase extends FloorDatabase { TaskDao get taskDao; }
0
mirrored_repositories/floor_task/lib
mirrored_repositories/floor_task/lib/model/task.dart
import 'package:floor/floor.dart'; @entity class Task { @PrimaryKey(autoGenerate: true) final int id; String title; final int createdTime; Task(this.id, this.title,this.createdTime); @override bool operator ==(Object other) => identical(this, other) || other is Task && runtimeType == other.runtimeType && id == other.id && title == other.title; @override int get hashCode => id.hashCode ^ title.hashCode; @override String toString() => 'Task {id : $id, title : $title,created at : $createdTime}'; }
0
mirrored_repositories/floor_task/lib
mirrored_repositories/floor_task/lib/screen/list_page.dart
import 'package:floor_start/database/task_dao.dart'; import 'package:floor_start/model/task.dart'; import 'package:floor_start/screen/text_input_dialog.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; class ListPage extends StatelessWidget { final String title; final TaskDao dao; ListPage({ Key key, @required this.title, @required this.dao, }) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(title), ), floatingActionButton: FloatingActionButton( child: new Icon(Icons.add), onPressed: () => displayDialog(context: context, dao: dao, update: false), ), body: Column( children: <Widget>[ Expanded( child: StreamBuilder<List<Task>>( stream: dao.findAllTasksAsStream(), builder: (_, snapshot) { if (!snapshot.hasData) return Container(); final tasks = snapshot.data; return ListView.builder( itemCount: tasks.length, itemBuilder: (_, index) { return ListCell( task: tasks[index], dao: dao, ); }, ); }, ), ), ], ), ); } } _formatDate(int at) { return DateFormat.yMd() .add_jm() .format(DateTime.fromMillisecondsSinceEpoch(at)); } class ListCell extends StatelessWidget { const ListCell({ Key key, @required this.task, @required this.dao, }) : super(key: key); final Task task; final TaskDao dao; _onLongPressUpdate(BuildContext context, TaskDao dao, bool update, Task task) { displayDialog(context: context, dao: dao, update: update, task: task); } @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 4.0), child: Card( elevation: 2.0, child: ListTile( onLongPress: () => _onLongPressUpdate(context, dao, true, task), title: Text( task.title, style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.white), ), subtitle: Text( 'created at ${_formatDate(task.createdTime)}', style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w400), ), trailing: IconButton( onPressed: () async { await dao.deleteTask(task); Scaffold.of(context).showSnackBar( SnackBar(content: Text('task ${task.title} is removed')), ); }, icon: Icon( Icons.remove_circle, color: Colors.orange, ), )), ), ); } }
0
mirrored_repositories/floor_task/lib
mirrored_repositories/floor_task/lib/screen/text_input_dialog.dart
import 'package:floor_start/database/task_dao.dart'; import 'package:floor_start/model/task.dart'; import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; displayDialog( {@required BuildContext context, @required TaskDao dao, bool update, Task task}) async { final TextEditingController textEditingController = TextEditingController(); return showDialog( context: context, builder: (context) { return AlertDialog( title: Text( update ? 'Update task' : 'Add a task' ), content: TextField( controller: textEditingController, decoration: InputDecoration( hintText: update ? task.title : "enter a title"), ), actions: <Widget>[ FlatButton( child: Text('CANCEL'), onPressed: () { Navigator.of(context).pop(); }, ), FlatButton( child: Text(update ? 'UPDATE' : 'OK'), onPressed: () async { final message = textEditingController.text; if (update) { task.title = message; await dao.updateTask(task); } else { final task = Task( null, message, DateTime.now().millisecondsSinceEpoch); await dao.insertTask(task); } textEditingController.clear(); Navigator.of(context).pop(); }, ), ], ); }); }
0
mirrored_repositories/mashmart_demo
mirrored_repositories/mashmart_demo/lib/main.dart
import 'package:flutter/material.dart'; import 'package:mashmart/views/account/welcome_screen.dart'; import 'package:mashmart/views/homepage.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: Colors.teal.shade700, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: WelcomeScreen(), ); } }
0
mirrored_repositories/mashmart_demo/lib
mirrored_repositories/mashmart_demo/lib/views/homepage.dart
import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:get/get.dart'; import 'package:mashmart/controllers/product_controller.dart'; class HomePage extends StatelessWidget { final GlobalKey<ScaffoldState> _key = GlobalKey<ScaffoldState>(); final ProductController productController = Get.put(ProductController()); final ScrollController scrollController = new ScrollController(); @override Widget build(BuildContext context) { return Scaffold( key: _key, drawer: Drawer(), appBar: AppBar( title: Image.asset( 'assets/images/mashmart_logo_h.png', height: 60, width: 180, ), centerTitle: true, elevation: 0.0, backgroundColor: Colors.grey.shade50, leading: IconButton( icon: Icon(Icons.menu_rounded), color: Colors.black87, onPressed: () { print("Drawer Menu Clicked"); _key.currentState.openDrawer(); }, ), actions: <Widget>[ Stack( children: [ IconButton( icon: Icon( Icons.shopping_cart, size: 30, color: Colors.black87, ), onPressed: () { print("Cart Clicked"); }), Positioned( top: 20, right: 4, child: Container( height: 21, width: 21, padding: EdgeInsets.all(4), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.teal.shade700), child: Center( child: Text( "0", style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: Colors.white), ), ), ), ), ], ), Stack( children: [ IconButton( icon: Icon( Icons.notifications_rounded, size: 30, color: Colors.black87, ), onPressed: () { print("Notifications Clicked"); }), Positioned( top: 20, right: 4, child: Container( height: 21, width: 21, padding: EdgeInsets.all(4), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.teal.shade700), child: Center( child: Text( "0", style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: Colors.white), ), ), ), ), ], ), ], ), body: Column( children: [ Padding( padding: const EdgeInsets.all(16), child: Row( children: [ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ TextFormField( decoration: InputDecoration( hintText: "Search for markets or products", prefixIcon: Icon(Icons.search_rounded), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), )), onTap: () { print("Search Box Tapped"); }, ), ], ), ), ], ), ), Padding( padding: const EdgeInsets.all(16), child: Row( children: [ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Products", style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87), ), Row( children: [ IconButton( icon: Icon( Icons.list_rounded, color: Colors.black87, ), onPressed: () { print("List Clicked"); }), IconButton( icon: Icon( Icons.grid_view, color: Colors.black, ), onPressed: () { print("Grid Clicked"); }), ], ) ], ), ], ), ), ], ), ), Expanded( child: Obx(() { if (productController.isLoading.value) return Center(child: CircularProgressIndicator()); else print("Total Products = " + productController.products.length.toString()); return StaggeredGridView.countBuilder( crossAxisCount: 2, itemCount: productController.products.length, crossAxisSpacing: 12, mainAxisSpacing: 12, itemBuilder: (context, index) { return Card( elevation: 2, child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( height: 200, width: double.infinity, clipBehavior: Clip.antiAlias, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), ), child: Image.network( productController.products[index].image, fit: BoxFit.cover, ), ), Positioned( right: 5, top: 5, child: CircleAvatar( backgroundColor: Colors.teal.shade700, child: IconButton( icon: Icon( Icons.shopping_cart, size: 22, color: Colors.white, ), onPressed: () { print("Add to Cart Clicked"); }), )), ], ), SizedBox(height: 8), Text( productController.products[index].name, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, color: Colors.black87), overflow: TextOverflow.ellipsis, ), SizedBox(height: 8), Text( productController.products[index].price, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14, color: Colors.black54), overflow: TextOverflow.ellipsis, ), ], )), ); }, staggeredTileBuilder: (index) => StaggeredTile.fit(1), ); }), ) ], ), ); } }
0
mirrored_repositories/mashmart_demo/lib/views
mirrored_repositories/mashmart_demo/lib/views/account/welcome_screen.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mashmart/views/account/signup.dart'; import 'package:mashmart/views/homepage.dart'; class WelcomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { final signInButton = Material( borderRadius: BorderRadius.circular(12.0), color: Colors.teal.shade700, child: MaterialButton( minWidth: 150, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: () { print("SignIn"); Navigator.of(context).push(MaterialPageRoute(builder: (_) { return HomePage(); })); }, child: Text("Sign In", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat', fontSize: 20.0) .copyWith(color: Colors.white, fontWeight: FontWeight.bold)), ), ); final signUpButton = Material( borderRadius: BorderRadius.circular(12.0), color: Colors.grey.shade800, child: MaterialButton( minWidth: 150, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: () { print("SignUp"); Navigator.of(context).push(MaterialPageRoute(builder: (_) { return SignUpScreen(); })); }, child: Text("Sign Up", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat', fontSize: 20.0) .copyWith(color: Colors.white, fontWeight: FontWeight.bold)), ), ); return Scaffold( body: SafeArea( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Container( margin: EdgeInsets.all(20), alignment: Alignment.bottomCenter, child: Text("Welcome to Mashmart", style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, )), ), Image.asset('assets/images/account_welcome_screen.png'), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/mashmart_logo_h.png', height: 60, width: 180, ), ], ), SizedBox(height: 30), signInButton, SizedBox(height: 10), signUpButton, ], ), ), ), ); } }
0
mirrored_repositories/mashmart_demo/lib/views
mirrored_repositories/mashmart_demo/lib/views/account/signup.dart
import 'package:flutter/material.dart'; class SignUpScreen extends StatelessWidget { @override Widget build(BuildContext context) { // SignEmail final signUpEmailButton = Material( elevation: 5, borderRadius: BorderRadius.circular(12.0), color: Colors.blueGrey.shade800, child: MaterialButton( minWidth: 150, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: () { print("Email"); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Image.asset( 'assets/icon_custom/icon_email_127px.png', height: 20, width: 20, ), SizedBox(width: 8), Text("Email", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat', fontSize: 18.0) .copyWith( color: Colors.white, fontWeight: FontWeight.bold)), ], ), ), ); // SignGoogle final signUpGoogleButton = Material( elevation: 5, borderRadius: BorderRadius.circular(12.0), color: Colors.red.shade600, child: MaterialButton( minWidth: 150, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: () { print("Google"); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Image.asset( 'assets/icon_custom/icon_google_127px.png', height: 20, width: 20, ), SizedBox(width: 8), Text("Google", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat', fontSize: 18.0) .copyWith( color: Colors.white, fontWeight: FontWeight.bold)), ], ), ), ); // SignFacebook final signUpFacebookButton = Material( borderRadius: BorderRadius.circular(12.0), color: Colors.blue.shade700, child: MaterialButton( minWidth: 150, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: () { print("Facebook"); /*Navigator.of(context).push(MaterialPageRoute(builder: (_) { return SignUpScreen(); }));*/ }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Image.asset( 'assets/icon_custom/icon_facebook_127px.png', height: 20, width: 20, ), SizedBox(width: 8), Text("Facebook", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat', fontSize: 18.0) .copyWith( color: Colors.white, fontWeight: FontWeight.bold)), ], ), ), ); // SignTwitter final signUpTwitterButton = Material( borderRadius: BorderRadius.circular(12.0), color: Colors.blue, child: MaterialButton( minWidth: 150, padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), onPressed: () { print("Twitter"); }, child: Row( mainAxisSize: MainAxisSize.min, children: [ Image.asset( 'assets/icon_custom/icon_twitter_squared_127px.png', height: 20, width: 20, ), SizedBox(width: 8), Text("Twitter", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Montserrat', fontSize: 18.0) .copyWith( color: Colors.white, fontWeight: FontWeight.bold)), ], ), ), ); return Scaffold( body: SafeArea( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(20), child: Text("Sign Up", style: TextStyle( fontSize: 32, fontWeight: FontWeight.bold, )), ), Image.asset( 'assets/images/mashmart_logo_h.png', height: 60, width: 180, ), ], ), SizedBox(height: 5), Image.asset('assets/images/account_signup_screen.png', height: 300, width: 320,), SizedBox(height: 30), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ signUpEmailButton, SizedBox(width: 10), signUpGoogleButton, ], ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ signUpFacebookButton, SizedBox(width: 10), signUpTwitterButton, ], ) ], ), ), ), ); } }
0
mirrored_repositories/mashmart_demo/lib/views
mirrored_repositories/mashmart_demo/lib/views/products/product_tile.dart
import 'package:flutter/material.dart'; import 'package:mashmart/models/product_model.dart'; class ProductTile extends StatelessWidget { final Product product; const ProductTile(this.product); @override Widget build(BuildContext context) { return Card( elevation: 2, ); } }
0
mirrored_repositories/mashmart_demo/lib
mirrored_repositories/mashmart_demo/lib/controllers/product_controller.dart
import 'package:get/state_manager.dart'; import 'package:mashmart/models/product_model.dart'; import 'package:mashmart/services/api_service.dart'; class ProductController extends GetxController { var isLoading = true.obs; //Rx<Data> productList = Data().obs; List<Data> products; @override void onInit() { fetchProducts(); super.onInit(); } void fetchProducts() async { try{ isLoading(true); products = await ApiService.fetchProducts(); if(products != null){ } } finally { isLoading(false); } } }
0
mirrored_repositories/mashmart_demo/lib
mirrored_repositories/mashmart_demo/lib/models/product_model.dart
class Product { int code; Meta meta; List<Data> data; Product({this.code, this.meta, this.data}); Product.fromJson(Map<String, dynamic> json) { code = json['code']; meta = json['meta'] != null ? new Meta.fromJson(json['meta']) : null; if (json['data'] != null) { data = new List<Data>(); json['data'].forEach((v) { data.add(new Data.fromJson(v)); }); } } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['code'] = this.code; if (this.meta != null) { data['meta'] = this.meta.toJson(); } if (this.data != null) { data['data'] = this.data.map((v) => v.toJson()).toList(); } return data; } } class Meta { Pagination pagination; Meta({this.pagination}); Meta.fromJson(Map<String, dynamic> json) { pagination = json['pagination'] != null ? new Pagination.fromJson(json['pagination']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); if (this.pagination != null) { data['pagination'] = this.pagination.toJson(); } return data; } } class Pagination { int total; int pages; int page; int limit; Pagination({this.total, this.pages, this.page, this.limit}); Pagination.fromJson(Map<String, dynamic> json) { total = json['total']; pages = json['pages']; page = json['page']; limit = json['limit']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['total'] = this.total; data['pages'] = this.pages; data['page'] = this.page; data['limit'] = this.limit; return data; } } class Data { int id; String name; String description; String image; String price; String discountAmount; bool status; List<Categories> categories; Data( {this.id, this.name, this.description, this.image, this.price, this.discountAmount, this.status, this.categories}); Data.fromJson(Map<String, dynamic> json) { id = json['id']; name = json['name']; description = json['description']; image = json['image']; price = json['price']; discountAmount = json['discount_amount']; status = json['status']; if (json['categories'] != null) { categories = new List<Categories>(); json['categories'].forEach((v) { categories.add(new Categories.fromJson(v)); }); } } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['name'] = this.name; data['description'] = this.description; data['image'] = this.image; data['price'] = this.price; data['discount_amount'] = this.discountAmount; data['status'] = this.status; if (this.categories != null) { data['categories'] = this.categories.map((v) => v.toJson()).toList(); } return data; } } class Categories { int id; String name; Categories({this.id, this.name}); Categories.fromJson(Map<String, dynamic> json) { id = json['id']; name = json['name']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['name'] = this.name; return data; } }
0
mirrored_repositories/mashmart_demo/lib
mirrored_repositories/mashmart_demo/lib/Helper/label_icon_cart_counter.dart
class LabelIconCartCounter{ }
0
mirrored_repositories/mashmart_demo/lib
mirrored_repositories/mashmart_demo/lib/Helper/label_icon_notifications_counter.dart
class LabelIconNotificationCounter{ }
0
mirrored_repositories/mashmart_demo/lib
mirrored_repositories/mashmart_demo/lib/services/api_service.dart
import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; import 'package:http/io_client.dart'; import 'package:mashmart/models/product_model.dart'; class ApiService { static var client = http.Client(); static Future<List<Data>> fetchProducts ()async { var url = 'https://www.gorest.co.in/public-api/products'; print(url); var response = await client.get(url); final ioc = new HttpClient(); final http = new IOClient(ioc); var res = await http.get(url); if (res.statusCode == 200) { //print(res.body); List<Data> product = Product.fromJson(jsonDecode(res.body)).data; print(product); return product; } else { throw "Can't get subjects."; } } }
0
mirrored_repositories/mashmart_demo
mirrored_repositories/mashmart_demo/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mashmart/main.dart'; import 'package:mashmart/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI/lib/main.dart
import 'package:ScreensUI/Screens/SignUpScreen.dart'; import 'package:flutter/material.dart'; import 'Screens/LogInScreen.dart'; void main() { runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return MaterialApp( title: "LogIn Screen", debugShowCheckedModeBanner: false, home: SignIn() );//Place SignUp function here to Observe SignUp Screen. } }
0
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI/lib
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI/lib/Screens/LogInScreen.dart
import 'package:flutter/material.dart'; class SignIn extends StatefulWidget { @override _SignInState createState() => _SignInState(); } class _SignInState extends State<SignIn> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffe8ebed), body: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height - 70, //For moving according to the screen when the keyboard popsup. alignment: Alignment.bottomCenter, child: Container( padding: EdgeInsets.all(30), child: Column( mainAxisSize: MainAxisSize.min, children: [ Stack( children: <Widget>[ Container( height: 180, width: 600, child: ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.asset("assets/images/friendship.png"), ), ), ], ), SizedBox(height: 60), // From here the login Credentials start. Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color(0xffe1e2e3), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 5, blurRadius: 7, offset: Offset(0, 3), ), ]), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.symmetric( horizontal: 10, vertical: 3), child: Text( "Login", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w800), )), SizedBox(height: 5), Container( padding: EdgeInsets.symmetric( horizontal: 2, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20))), child: TextFormField( decoration: InputDecoration( hintText: "Email", border: InputBorder.none, prefixIcon: Icon( Icons.email, color: Colors.grey, ), ), ), ), SizedBox(height: 15), Container( padding: EdgeInsets.symmetric( horizontal: 2, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20))), child: TextFormField( obscureText: true, decoration: InputDecoration( hintText: "Password", border: InputBorder.none, prefixIcon: Icon(Icons.vpn_key, color: Colors.grey), ), ), ), ]), ), SizedBox( height: 25, ), Container( alignment: Alignment.centerRight, child: Container( child: Text( "Forgot Password?", style: TextStyle( color: Colors.deepPurpleAccent, fontWeight: FontWeight.w500), )), ), SizedBox(height: 25), //From here the signin buttons will occur. Row( mainAxisAlignment: MainAxisAlignment.center, children: [ RaisedButton( elevation: 3, padding: EdgeInsets.symmetric( vertical: 15, horizontal: 50), onPressed: () {}, color: Colors .deepPurpleAccent, //Not bad=>Color(0xff1d56b8), child: Text( "Sign In", style: TextStyle( fontSize: 20, color: Colors.white, fontWeight: FontWeight.w700), ), shape: RoundedRectangleBorder( side: BorderSide(color: Colors.white70), borderRadius: BorderRadius.all(Radius.circular(30)), )), SizedBox(width: 10), GestureDetector( //Signin with google button. onTap: () { //I changed it from raised button to container and then added gesture control to add an image of google. }, child: Container( padding: EdgeInsets.symmetric( horizontal: 10, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20)), boxShadow: [ BoxShadow( //Created this shadow for looking elevated. //For creating like a card. color: Colors.black12, offset: Offset(0.0, 18.0), // This offset is for making the the lenght of the shadow and also the brightness of the black color try seeing it by changing its values. blurRadius: 15.0), BoxShadow( color: Colors.black12, offset: Offset(0.0, -04.0), blurRadius: 10.0), ]), child: Row( mainAxisAlignment: MainAxisAlignment .center, // I had added main axis allignment to be center to make to be at the center. children: [ Text( "Sign In With", style: TextStyle( fontSize: 16, color: Colors.deepPurpleAccent, fontWeight: FontWeight.w700), ), Image.asset( "assets/images/google.png", height: 40, ) ], )), ), ], ), SizedBox(height: 30), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Don't have an account?"), SizedBox(width: 10), GestureDetector( onTap: () {}, child: Container( child: Text("Register now", style: TextStyle( fontWeight: FontWeight.w700, color: Colors.deepPurpleAccent)), ), ) ]), ], )), ), ), ); } }
0
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI/lib
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI/lib/Screens/SignUpScreen.dart
import 'package:flutter/material.dart'; class SignUp extends StatefulWidget { @override _SignUpState createState() => _SignUpState(); } class _SignUpState extends State<SignUp> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffe8ebed), body: SingleChildScrollView( //we are adding this so that we can scroll when KeyBoard PopsUp. child: Container( height: MediaQuery.of(context) .size .height, // If you get any blur that is outoff the screen then try to decrease or increase this negative value.This is mainly bcz it adjusts as per the phone size. alignment: Alignment.topCenter, child: Container( padding: EdgeInsets.all(30), child: Column( mainAxisSize: MainAxisSize.min, children: [ Form( child: Column( children: [ Stack( //I added stack so that i can position it anywhere i want with the coordinates like left ,right,bottom. children: <Widget>[ Positioned( child: ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.asset( "assets/images/talking.png", ), ), ), ], ), //The Username,Email,Password Input fields. SizedBox(height: 20), Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color(0xffe1e2e3), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 5, blurRadius: 7, offset: Offset(0, 3), ), ]), child: Column( children: [ Container( padding: EdgeInsets.symmetric( horizontal: 20, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20))), child: TextFormField( decoration: InputDecoration( hintText: "Username", border: InputBorder.none), ), ), SizedBox(height: 10), Container( padding: EdgeInsets.symmetric( horizontal: 20, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20))), child: TextFormField( decoration: InputDecoration( hintText: "Email", border: InputBorder.none), ), ), SizedBox(height: 10), Container( padding: EdgeInsets.symmetric( horizontal: 20, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20))), child: TextFormField( obscureText: true, decoration: InputDecoration( hintText: "Password", border: InputBorder.none), ), ), ], ), ) ], ), ), SizedBox(height: 30), //Raised Buttons of sigup will appear. Row( mainAxisAlignment: MainAxisAlignment.center, children: [ RaisedButton( elevation: 13, padding: EdgeInsets.symmetric( vertical: 15, horizontal: 55), onPressed: () {}, color: Colors.deepPurpleAccent, child: Text( "Sign Up", style: TextStyle( fontSize: 16, color: Colors.white, fontWeight: FontWeight.w700), ), shape: RoundedRectangleBorder( side: BorderSide(color: Colors.white70), borderRadius: BorderRadius.all(Radius.circular(20)))), SizedBox(width: 5), InkWell( //We can use the GestureDetector as well. onTap: () {}, child: Container( padding: EdgeInsets.symmetric( horizontal: 10, vertical: 5), decoration: BoxDecoration( color: Color(0xfff5f8fd), borderRadius: BorderRadius.all(Radius.circular(20)), boxShadow: [ //For creating like a card. BoxShadow( color: Colors.black12, offset: Offset(0.0, 18.0), blurRadius: 15.0), BoxShadow( color: Colors.black12, offset: Offset(0.0, -04.0), blurRadius: 10.0), ]), child: Row( children: [ Text( "Sign Up With", style: TextStyle( fontSize: 16, color: Colors.deepPurpleAccent, fontWeight: FontWeight.w700), ), Image.asset( "assets/images/google.png", height: 40, ) ], )), ) ], ), SizedBox(height: 25), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Already have an account?"), SizedBox(width: 10), InkWell( onTap: () {}, child: Container( child: Text("Sign In", style: TextStyle( fontWeight: FontWeight.w900, color: Colors.deepPurpleAccent, fontSize: 18)), ), ) ]), ], )), ), ), ); } }
0
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI
mirrored_repositories/Flutter-SignIn-and-SignUp-UI/Flutter UI/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:ScreensUI/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/amalskuy
mirrored_repositories/amalskuy/lib/constants.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; const kbackgroundColor = Color(0xffEEF1F6); const kprimaryColor = Color(0xFF4285F6); Color Tint = const Color(0xFFb1ceff); Color dimGrey = const Color(0xff5C5C5C); Color medGrey = const Color(0xffB0B0B0); Color lightGrey = const Color(0xffEAEAEA); Color whitishGrey = const Color(0xffF2F2F2); Color blueDark = const Color(0xff0042b1);
0
mirrored_repositories/amalskuy
mirrored_repositories/amalskuy/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: return macos; case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions web = FirebaseOptions( apiKey: 'AIzaSyDXVrZ6Xy60K8VUfUd0DKWsH95nKpO2Rno', appId: '1:569144975210:web:dbe4982fc95a84e131cf13', messagingSenderId: '569144975210', projectId: 'authamalskuy', authDomain: 'authamalskuy.firebaseapp.com', storageBucket: 'authamalskuy.appspot.com', ); static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyATHkassDLnKP-MqrQKFGyDRK3FWNif8W8', appId: '1:569144975210:android:d99415158590014231cf13', messagingSenderId: '569144975210', projectId: 'authamalskuy', storageBucket: 'authamalskuy.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyA-nDSYjYlXyyZeXEI98aZQTL0zQiAcMdg', appId: '1:569144975210:ios:444ea91e1981c66631cf13', messagingSenderId: '569144975210', projectId: 'authamalskuy', storageBucket: 'authamalskuy.appspot.com', iosClientId: '569144975210-8t28gmrk44dom3adqqgshuasum88k850.apps.googleusercontent.com', iosBundleId: 'com.example.amalskuy', ); static const FirebaseOptions macos = FirebaseOptions( apiKey: 'AIzaSyA-nDSYjYlXyyZeXEI98aZQTL0zQiAcMdg', appId: '1:569144975210:ios:d1c6a1b157347d4431cf13', messagingSenderId: '569144975210', projectId: 'authamalskuy', storageBucket: 'authamalskuy.appspot.com', iosClientId: '569144975210-i573sf4uefsbfkoea8h628tp2c0t8usq.apps.googleusercontent.com', iosBundleId: 'com.example.amalskuy.RunnerTests', ); }
0
mirrored_repositories/amalskuy
mirrored_repositories/amalskuy/lib/main.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:amalskuy/constants.dart'; import 'package:amalskuy/screens/onboarding_screen.dart'; import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Amalskuy', debugShowCheckedModeBanner: false, theme: ThemeData( fontFamily: "DMSans", colorScheme: ColorScheme.fromSeed(seedColor: kprimaryColor), scaffoldBackgroundColor: kbackgroundColor, useMaterial3: true, ), home: const OnboardingScreen(), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/widgets/card_widget.dart
import 'package:faker/faker.dart'; import 'package:flutter/material.dart'; import '../constants.dart'; class TeacherCard extends StatelessWidget { const TeacherCard({ Key? key, required this.faker, }) : super(key: key); final Faker faker; @override Widget build(BuildContext context) { return Container( width: double.infinity, height: 111, padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 10), margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 22), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all(color: blueDark.withOpacity(0.12), width: 1), color: Colors.white), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(15), child: Image.network( faker.image.image(random: true, keywords: ["person"]), width: 75, height: 75, fit: BoxFit.cover, )), const SizedBox( width: 16, ), const Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( "Contoh Judul Amal atau Donasi", style: TextStyle(fontSize: 12, color: kprimaryColor, fontWeight: FontWeight.w800), ), Flexible( flex: 1, child: FittedBox( fit: BoxFit.scaleDown, child: Text( "Rp. 6.200.2500 Terkumpul", style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.bold), maxLines: 1, ), ), ), Flexible( flex: 1, child: FittedBox( fit: BoxFit.scaleDown, child: Text( "100+ Orang Baik Telah Berdonasi • 1 Minggu", style: TextStyle( fontSize: 10, color: Color(0xff91919F), fontWeight: FontWeight.normal), maxLines: 1, ), ), ), ], )) ], ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/pages/home_page.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; class HomePage extends StatelessWidget { HomePage({super.key}); final user = FirebaseAuth.instance.currentUser!; void signUserOut() { FirebaseAuth.instance.signOut(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( actions: [ IconButton( onPressed: signUserOut, icon: Icon(Icons.logout), ) ], ), body: Center(child: Text("Logged IN as :"+ user.email!)), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/pages/login_or_registerPage.dart
import 'package:flutter/material.dart'; import 'package:amalskuy/pages/login_page.dart'; import 'package:amalskuy/pages/register_page.dart'; class LoginOrRegisterPage extends StatefulWidget { const LoginOrRegisterPage({super.key}); @override State<LoginOrRegisterPage> createState() => LoginOrRegisterPageState(); } class LoginOrRegisterPageState extends State<LoginOrRegisterPage> { //initially show login Page bool showLoginPage = true; // toggle between login and register page void togglePages() { setState(() { showLoginPage = !showLoginPage; }); } @override Widget build(BuildContext context) { if (showLoginPage) { return LoginPage( onTap: togglePages, ); } else { return RegisterPage( onTap: togglePages, ); } } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/pages/register_page.dart
import 'package:amalskuy/constants.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:amalskuy/components/my_textfield.dart'; import 'package:amalskuy/components/my_button.dart'; import 'package:amalskuy/components/square_tile.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import '../services/auth_service.dart'; class RegisterPage extends StatefulWidget { final Function()? onTap; RegisterPage({super.key, required this.onTap}); @override State<RegisterPage> createState() => _RegisterPageState(); } class _RegisterPageState extends State<RegisterPage> { final usernameController = TextEditingController(); final emailController = TextEditingController(); final passwordController = TextEditingController(); final confirmPasswordController = TextEditingController(); void signUserUp() async { // show loading circle showDialog( context: context, builder: (context) { return const Center( child: CircularProgressIndicator(), ); }, ); try { // check if both password and confirm pasword is same if (passwordController.text == confirmPasswordController.text) { UserCredential userCredential = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: emailController.text, password: passwordController.text, ); //pop the loading circle Navigator.pop(context); } else { //show error password dont match genericErrorMessage("Password tidak sesuai"); } } on FirebaseAuthException catch (e) { //pop the loading circle Navigator.pop(context); genericErrorMessage(e.code); } } void genericErrorMessage(String message) { showDialog( context: context, builder: (context) { return AlertDialog( title: Text(message), actions: [ TextButton( onPressed: () { Navigator.pop(context); }, child: const Text('OK'), ), ], ); }, ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, resizeToAvoidBottomInset: true, body: SafeArea( child: SingleChildScrollView( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox(height: 70), //login const Padding( padding: EdgeInsets.only(left: 24), child: Row( children: [ Text("Daftar", style: TextStyle( color: Colors.black, fontFamily: "DMSans", fontWeight: FontWeight.w800, fontSize: 40, ), ), ], ), ), const SizedBox(height: 10), Padding( padding: const EdgeInsets.only(left: 25), child: Row( children: [ Text( 'Isi formulir pendaftaran dibawah ini\ndengan informasi terkait data diri anda lalu\nmari memulai perjalanan bersama kita.', style: TextStyle( color: Colors.grey[700], fontFamily: "DMSans", fontWeight: FontWeight.w400, fontSize: 15, ), ), ], ), ), const SizedBox(height: 25), //username MyTextField( controller: emailController, hintText: 'Email', obscureText: false, ), const SizedBox(height: 15), //password MyTextField( controller: passwordController, hintText: 'Password', obscureText: true, ), const SizedBox(height: 15), MyTextField( controller: confirmPasswordController, hintText: 'Konfirmasi Password', obscureText: true, ), const SizedBox(height: 25), //sign in button MyButton( onTap: signUserUp, text: 'Daftar', ), const SizedBox(height: 20), // continue with Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Row( children: [ Expanded( child: Divider( thickness: 0.5, color: Colors.grey.shade400, ), ), Padding( padding: const EdgeInsets.only(left: 8, right: 8), child: Text( 'atau', style: TextStyle(color: Colors.grey.shade600, fontWeight: FontWeight.w400), ), ), Expanded( child: Divider( thickness: 0.5, color: Colors.grey.shade400, ), ), ], ), ), const SizedBox(height: 30), //google Row( mainAxisAlignment: MainAxisAlignment.center, children: [ //google buttom SquareTile( onTap: () => AuthService().signInWithGoogle(), imagePath: "assets/images/googlelogo.png", height: 30, ), ], ), const SizedBox( height: 50, ), // not a memeber ? register now Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Sudah memiliki akun? ', style: TextStyle(color: Colors.grey[600], fontSize: 12, fontWeight: FontWeight.w600), ), GestureDetector( onTap: widget.onTap, child: const Text( 'Masuk', style: TextStyle( color: kprimaryColor, fontWeight: FontWeight.w600, fontSize: 14), ), ), ], ) ], ), ), ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/pages/auth_page.dart
import 'package:amalskuy/screens/myhome_page.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:amalskuy/pages/login_page.dart'; import 'login_or_registerPage.dart'; class AuthPage extends StatelessWidget { const AuthPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: StreamBuilder<User?>( stream: FirebaseAuth.instance.authStateChanges(), builder: (context, snapshot) { // user logged in if(snapshot.hasData){ return const MyHomePage(); } //user not logged in else{ return const LoginOrRegisterPage(); } }, ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/pages/login_page.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:amalskuy/components/my_button.dart'; import 'package:amalskuy/components/my_textfield.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:amalskuy/components/square_tile.dart'; import 'package:amalskuy/services/auth_service.dart'; import 'package:amalskuy/constants.dart'; class LoginPage extends StatefulWidget { final Function()? onTap; LoginPage({super.key, required this.onTap}); @override State<LoginPage> createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { final emailController = TextEditingController(); final passwordController = TextEditingController(); void signUserIn() async { // show loading circle showDialog( context: context, builder: (context) { return const Center( child: CircularProgressIndicator(), ); }); try { await FirebaseAuth.instance.signInWithEmailAndPassword( email: emailController.text, password: passwordController.text, ); //pop the loading circle Navigator.pop(context); } on FirebaseAuthException catch (e) { //pop the loading circle Navigator.pop(context); genericErrorMessage(e.code); } } void genericErrorMessage(String message) { showDialog( context: context, builder: (context) { return AlertDialog( title: Text(message), actions: [ TextButton( onPressed: () { Navigator.pop(context); }, child: const Text('OK'), ), ], ); }, ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, resizeToAvoidBottomInset: true, body: SafeArea( child: SingleChildScrollView( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox(height: 100), //login const Padding( padding: EdgeInsets.only(left: 24), child: Row( children: [ Text("Masuk", style: TextStyle( color: Colors.black, fontFamily: "DMSans", fontWeight: FontWeight.w800, fontSize: 40, ), ), ], ), ), const SizedBox(height: 10), Padding( padding: const EdgeInsets.only(left: 25), child: Row( children: [ Text( 'Masukkan data diri anda, berupa email \ndan kata sandi untuk masuk ke AmalSkuy!', style: TextStyle( color: Colors.grey[700], fontFamily: "DMSans", fontWeight: FontWeight.w400, fontSize: 15, ), ), ], ), ), const SizedBox(height: 25), //username MyTextField( controller: emailController, hintText: 'Username atau email', obscureText: false, ), const SizedBox(height: 15), //password MyTextField( controller: passwordController, hintText: 'Password', obscureText: true, ), const SizedBox(height: 25), //sign in button MyButton( onTap: signUserIn, text: 'Masuk', ), const SizedBox(height: 20), //forgot passowrd Padding( padding: const EdgeInsets.all(5.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Lupa Password Kamu? ', style: TextStyle( color: Colors.grey.shade600, fontSize: 12, fontWeight: FontWeight.w600), ), const Text( 'Reset Password via Email.', style: TextStyle( color: kprimaryColor, fontSize: 12, fontWeight: FontWeight.w600, ), ) ], ), ), const SizedBox( height: 10, ), // continue with Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Row( children: [ Expanded( child: Divider( thickness: 0.5, color: Colors.grey.shade400, ), ), Padding( padding: const EdgeInsets.only(left: 8, right: 8,), child: Text( 'atau', style: TextStyle(color: Colors.grey.shade600, fontWeight: FontWeight.w400), ), ), Expanded( child: Divider( thickness: 0.5, color: Colors.grey.shade400, ), ), ], ), ), const SizedBox(height: 30), //google Row( mainAxisAlignment: MainAxisAlignment.center, children: [ //google buttom SquareTile( onTap: () => AuthService().signInWithGoogle(), imagePath: "assets/images/googlelogo.png", height: 30, ), ], ), const SizedBox( height: 50, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Belum punya akun? ', style: TextStyle(color: Colors.grey[600], fontSize: 12, fontWeight: FontWeight.w600), ), GestureDetector( onTap: widget.onTap, child: const Text( 'Daftar Skuy', style: TextStyle( color: kprimaryColor, fontWeight: FontWeight.w600, fontSize: 14), ), ), ], ) ], ), ), ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/components/square_tile.dart
import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; class SquareTile extends StatelessWidget { final String imagePath; final double height; final Function()? onTap; const SquareTile({ super.key, required this.imagePath, required this.height, required this.onTap, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: onTap, child: Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( border: Border.all(color: Colors.white), borderRadius: BorderRadius.circular(20), color: Colors.white, boxShadow:[ BoxShadow( blurRadius: 40, spreadRadius: 0.1, offset: Offset(0.1,0.1), color: Colors.grey.withOpacity(0.4), ) ] ), child: Image.asset( imagePath, height: height, ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/components/my_button.dart
import 'package:amalskuy/constants.dart'; import 'package:flutter/material.dart'; class MyButton extends StatelessWidget { final Function()? onTap; final String text; const MyButton({ super.key, required this.onTap, required this.text, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: onTap, child: Container( padding: const EdgeInsets.all(22), margin: const EdgeInsets.symmetric(horizontal: 25), decoration: BoxDecoration( color: kprimaryColor, borderRadius: BorderRadius.circular(8), ), child: Center( child: Text( text, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/components/my_textfield.dart
import 'package:flutter/material.dart'; class MyTextField extends StatelessWidget { final controller; final String hintText; final bool obscureText; const MyTextField({ super.key, required this.controller, required this.hintText, required this.obscureText, }); @override Widget build(BuildContext context) { return SizedBox( height: 55, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: TextField( controller: controller, obscureText: obscureText, decoration: InputDecoration( enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8.0), borderSide: BorderSide(color: Colors.grey.shade400), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8.0), borderSide: BorderSide(color: Colors.grey.shade600), ), filled: true, fillColor: Colors.white, hintText: hintText, hintStyle: TextStyle(color: Colors.grey.shade500, fontWeight: FontWeight.w200, fontSize: 15), ), ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/services/auth_service.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:google_sign_in/google_sign_in.dart'; class AuthService { //Google sign in signInWithGoogle() async { //begin interactive sign in process final GoogleSignInAccount? gUser = await GoogleSignIn().signIn(); //obtain auth details from request final GoogleSignInAuthentication gAuth = await gUser!.authentication; //create new credentials for user final credential = GoogleAuthProvider.credential( accessToken: gAuth.accessToken, idToken: gAuth.idToken, ); //sign in! return await FirebaseAuth.instance.signInWithCredential(credential); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/profile_screen.dart
import 'package:faker/faker.dart'; import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:amalskuy/constants.dart'; class ProfileScreen extends StatefulWidget { const ProfileScreen({Key? key}) : super(key: key); @override _ProfileScreenState createState() => _ProfileScreenState(); } class _ProfileScreenState extends State<ProfileScreen> { final user = FirebaseAuth.instance.currentUser!; final _emailController = TextEditingController(); final _passwordController = TextEditingController(); String getUsernameFromEmail(String email) { final splitEmail = email.split('@'); return splitEmail[0]; } void signUserOut() { FirebaseAuth.instance.signOut(); } void removeUser() async { try { await user?.delete(); // If the user account was deleted successfully, sign out the user. FirebaseAuth.instance.signOut(); // Show a success message or navigate to another screen. ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Akun berhasil dihapus')), ); } catch (e) { // If there was an error deleting the user account, show an error message. ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Terjadi kesalahan: $e')), ); } } void updatePassword() async { try { await user.updatePassword(_passwordController.text.trim()); // If the email was updated successfully, show a success message. ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Password berhasil diperbarui')), ); } on FirebaseAuthException catch (e) { // If there was an error updating the email, show an error message. ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Terjadi kesalahan: $e')), ); } } @override Widget build(BuildContext context) { final username = getUsernameFromEmail(user.email!); return SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(top: 40, left: 16, right: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const Center( child: Text("Profile", style: TextStyle( fontSize: 28, fontWeight: FontWeight.w800, ),), ), const SizedBox(height: 30,), Container( height: 100, padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: Colors.blue[200], shape: BoxShape.circle, image: DecorationImage( image: NetworkImage(faker.image.image(keywords: ['person']),)) ), child: Text( username.substring(1, 1).toUpperCase(), style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, ), ), ), const SizedBox(height: 16), Center( child: Text( username, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, ), ), ), Center(child: Text(user.email!, style: const TextStyle( fontWeight: FontWeight.w400, color: kprimaryColor, ),)), const SizedBox( height: 90, ), TextField( controller: _passwordController, decoration: InputDecoration( labelText: 'Password Baru', border: OutlineInputBorder( ), ), ), SizedBox( height: 20, ), ElevatedButton( onPressed: updatePassword, child: const Text("Update Password"), ), ElevatedButton( onPressed: removeUser, child: const Text("Hapus Akun"), ), ElevatedButton( onPressed: signUserOut, child: const Text("LogOut"), ), ], ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/onboarding_screen.dart
import 'package:flutter/material.dart'; import 'package:amalskuy/screens/size_config.dart'; import 'package:amalskuy/screens/onboarding_contents.dart'; import 'package:amalskuy/pages/auth_page.dart'; class OnboardingScreen extends StatefulWidget { const OnboardingScreen({Key? key}) : super(key: key); @override State<OnboardingScreen> createState() => _OnboardingScreenState(); } class _OnboardingScreenState extends State<OnboardingScreen> { late PageController _controller; @override void initState() { _controller = PageController(); super.initState(); } int _currentPage = 0; List colors = const [ Colors.white, Colors.white, Colors.white, ]; AnimatedContainer _buildDots({ int? index, }) { return AnimatedContainer( duration: const Duration(milliseconds: 200), decoration: const BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(50), ), color: Color(0xFF4285F6), ), margin: const EdgeInsets.only(right: 5), height: 10, curve: Curves.easeIn, width: _currentPage == index ? 20 : 10, ); } @override Widget build(BuildContext context) { SizeConfig().init(context); double width = SizeConfig.screenW!; double height = SizeConfig.screenH!; return Scaffold( backgroundColor: colors[_currentPage], body: SafeArea( child: Column( children: [ Expanded( flex: 3, child: PageView.builder( physics: const BouncingScrollPhysics(), controller: _controller, onPageChanged: (value) => setState(() => _currentPage = value), itemCount: contents.length, itemBuilder: (context, i) { return Padding( padding: const EdgeInsets.all(40.0), child: Column( children: [ Image.asset( contents[i].image, height: SizeConfig.blockV! * 35, ), SizedBox( height: (height >= 840) ? 60 : 30, ), Text( contents[i].title, textAlign: TextAlign.center, style: TextStyle( color: const Color(0xFF4285F6), fontFamily: "DMSans", fontWeight: FontWeight.w800, fontSize: (width <= 550) ? 30 : 35, ), ), const SizedBox(height: 15), Text( contents[i].desc, style: TextStyle( fontFamily: "DMSans", fontWeight: FontWeight.w400, fontSize: (width <= 550) ? 17 : 25, ), textAlign: TextAlign.center, ) ], ), ); }, ), ), Expanded( flex: 1, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate( contents.length, (int index) => _buildDots( index: index, ), ), ), _currentPage + 1 == contents.length ? Padding( padding: const EdgeInsets.only(top: 30, bottom: 0, left: 30, right: 30), child: ElevatedButton( onPressed: _navigateToSignUpScreen, style: ElevatedButton.styleFrom( backgroundColor: const Color(0xFF4285F6), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50), ), padding: (width <= 550) ? const EdgeInsets.symmetric( horizontal: 100, vertical: 20) : EdgeInsets.symmetric( horizontal: width * 0.2, vertical: 25), textStyle: TextStyle(fontSize: (width <= 550) ? 13 : 17), ), child: const Text("Skuy", style: TextStyle( color: Colors.white, fontFamily: "DMSans", fontWeight: FontWeight.w600, ),), ), ) : Padding( padding: const EdgeInsets.only(top: 30, bottom: 0, left: 30, right: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ TextButton( onPressed: () { _controller.jumpToPage(2); }, style: TextButton.styleFrom( elevation: 0, textStyle: TextStyle( fontWeight: FontWeight.w600, fontSize: (width <= 550) ? 13 : 17, ), ), child: const Text( "Lewati", style: TextStyle( color: Color(0xFF4285F6), fontFamily: "DMSans", fontWeight: FontWeight.w600), ), ), ElevatedButton( onPressed: () { _controller.nextPage( duration: const Duration(milliseconds: 200), curve: Curves.easeIn, ); }, style: ElevatedButton.styleFrom( backgroundColor: const Color(0xFF4285F6), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50), ), elevation: 0, padding: (width <= 550) ? const EdgeInsets.symmetric( horizontal: 30, vertical: 20) : const EdgeInsets.symmetric( horizontal: 30, vertical: 25), textStyle: TextStyle( fontSize: (width <= 550) ? 13 : 17), ), child: const Text("Selanjutnya", style: TextStyle( color: Colors.white, fontFamily: "DMSans", fontWeight: FontWeight.w600 ),), ), ], ), ), const Padding( padding: EdgeInsets.only(top: 0, bottom: 25), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text('Powered by Respect Team', style: TextStyle( color: Colors.grey, fontFamily: "DMSans", fontWeight: FontWeight.w400, fontSize: 13, ),)], ),), ], ), ), ], ), ), ); } void _navigateToSignUpScreen() { Navigator.push( context, MaterialPageRoute(builder: (context) => AuthPage()), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/onboarding_contents.dart
class OnboardingContents { final String title; final String image; final String desc; OnboardingContents({ required this.title, required this.image, required this.desc, }); } List<OnboardingContents> contents = [ OnboardingContents( title: "Satukan Tangan, Demi Kebaikan", image: "assets/images/onboardart1.png", desc: "Bersama untuk meraih kebaikan, bergandeng tangan untuk membantu satu sama lain.", ), OnboardingContents( title: "Satukan Donasi, Raih Solidaritas", image: "assets/images/onboardart2.png", desc: "Tabung amal jariyah kamu, dan salurkan kepada mereka yang lebih membutuhkan bersama AmalSkuy", ), OnboardingContents( title: "", image: "assets/images/barengamalskuy.png", desc: "", ), ];
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/myhome_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:amalskuy/constants.dart'; import 'package:amalskuy/screens/index_screen.dart'; import 'package:amalskuy/screens/search_screen.dart'; import 'package:amalskuy/screens/profile_screen.dart'; class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { final List<Widget> _screens = const [ IndexScreen(), SearchScreen(), ProfileScreen(), ]; int _index = 0; @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, extendBody: true, backgroundColor: const Color(0xffF4FAFB), body: _screens[_index], floatingActionButton: SizedBox( width: 58, height: 58, child: FloatingActionButton( onPressed: () { setState(() { _index = 1; }); }, backgroundColor: _index == 1 ? kprimaryColor : Tint, child: SvgPicture.asset( "assets/hand.svg", color: Colors.white, height: 30, )), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: SizedBox( height: 60, child: BottomAppBar( notchMargin: 15, color: Colors.white, shape: const CircularNotchedRectangle(), child: Row( children: [ Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ IconButton( onPressed: () { setState(() { _index = 0; }); }, icon: SvgPicture.asset( "assets/icons/home.svg", color: _index == 0 ? kprimaryColor : Tint, )), ], )), const SizedBox( width: 73, ), Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ IconButton( onPressed: () { setState(() { _index = 2; }); }, icon: SvgPicture.asset( "assets/icons/profile.svg", color: _index == 2 ? kprimaryColor : Tint, )) ], )), ], ), ), ), ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/size_config.dart
import 'package:flutter/material.dart'; class SizeConfig { static MediaQueryData? _mediaQueryData; static double? screenW; static double? screenH; static double? blockH; static double? blockV; void init(BuildContext context) { _mediaQueryData = MediaQuery.of(context); screenW = _mediaQueryData!.size.width; screenH = _mediaQueryData!.size.height; blockH = screenW! / 100; blockV = screenH! / 100; } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/search_screen.dart
import 'package:faker/faker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:amalskuy/constants.dart'; import '../widgets/card_widget.dart'; class SearchScreen extends StatefulWidget { const SearchScreen({Key? key}) : super(key: key); @override State<SearchScreen> createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { Faker faker = Faker(); String selectedGender = "Terbaru"; List<String> subjects = [ "Kesehatan", "Balita", "Sedekah", "Sosial", "Bencana", "Peduli lingkungan", "Tidak Mampu", "Pendidikan", "Infrastruktur", ]; List<String> selectedSubjects = []; bool search = false; @override Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; return SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 20), child: Column( children: [ Center( child: SizedBox( width: size.width * 0.9, child: TextFormField( cursorColor: kprimaryColor, enableSuggestions: true, textAlign: TextAlign.start, decoration: InputDecoration( filled: true, alignLabelWithHint: true, fillColor: const Color(0xffDCEBEA), hintStyle: TextStyle(fontSize: 15, color: blueDark), prefixIcon: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: SvgPicture.asset( "assets/icons/search.svg", color: blueDark, ), ), suffixIcon: GestureDetector( onTap: () { showModalBottomSheet( context: context, backgroundColor: Colors.white, enableDrag: true, isScrollControlled: true, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(15), topRight: Radius.circular(15))), builder: (_) => StatefulBuilder( builder: (context, setState) => SingleChildScrollView( padding: const EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: Text( "Filter Pencarian", style: TextStyle( fontSize: 17, color: blueDark, fontWeight: FontWeight.bold), ), ), const SizedBox( height: 20, ), Text( "Urutkan", style: TextStyle( fontSize: 16, color: blueDark, fontWeight: FontWeight.w500), ), Padding( padding: const EdgeInsets.symmetric( vertical: 16), child: Wrap( spacing: 6, runSpacing: 12, runAlignment: WrapAlignment.start, alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, children: [ IntrinsicWidth( child: GestureDetector( onTap: () { setState( () { selectedGender = "Terbaru"; }, ); }, child: Container( height: 30, padding: const EdgeInsets .symmetric( horizontal: 32), decoration: BoxDecoration( color: "Terbaru" == selectedGender ? kprimaryColor : Tint, borderRadius: BorderRadius .circular(15)), alignment: Alignment.center, child: Text( "Terbaru", style: TextStyle( color: "Terbaru" == selectedGender ? Colors.white : Colors.black, fontWeight: FontWeight.w500), )), ), ), IntrinsicWidth( child: GestureDetector( onTap: () { setState( () { selectedGender = "Trending"; }, ); }, child: Container( height: 30, padding: const EdgeInsets .symmetric( horizontal: 32), decoration: BoxDecoration( color: "Trending" == selectedGender ? kprimaryColor : Tint, borderRadius: BorderRadius .circular(15)), alignment: Alignment.center, child: Text( "Trending", style: TextStyle( color: "Trending" == selectedGender ? Colors.white : Colors.black, fontWeight: FontWeight.w500), )), ), ), IntrinsicWidth( child: GestureDetector( onTap: () { setState( () { selectedGender = "Akan Berakhir"; }, ); }, child: Container( height: 30, padding: const EdgeInsets .symmetric( horizontal: 32), decoration: BoxDecoration( color: "Akan Berakhir" == selectedGender ? kprimaryColor : Tint, borderRadius: BorderRadius .circular(15)), alignment: Alignment.center, child: Text( "Akan Berakhir", style: TextStyle( color: "Akan Berakhir" == selectedGender ? Colors.white : Colors.black, fontWeight: FontWeight.w500), )), ), ), ], ), ), const SizedBox( height: 16, ), Container( width: double.infinity, height: 50, margin: const EdgeInsets.symmetric( vertical: 7), child: ElevatedButton( onPressed: () {}, child: const Text( "Terapkan Filter", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, fontSize: 17), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all( kprimaryColor), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular( 8.0), ))), ), ), Container( width: double.infinity, height: 50, margin: const EdgeInsets.symmetric( vertical: 7), child: ElevatedButton( onPressed: () {}, child: Text( "Hapus Semua", style: TextStyle( color: kprimaryColor, fontWeight: FontWeight.w500, fontSize: 17), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all( Colors.white), overlayColor: MaterialStateProperty.all( kprimaryColor .withOpacity(0.2)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular( 4.0), side: BorderSide( color: kprimaryColor)))), ), ) ], ), ), )); }, child: Image.asset( "assets/search.png", ), ), hintText: "Cari Amal atau Donasi", prefixIconConstraints: const BoxConstraints(maxHeight: 17, maxWidth: 50), isDense: true, contentPadding: const EdgeInsets.symmetric(vertical: 0, horizontal: 0), prefixStyle: TextStyle(color: whitishGrey), border: const OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(8)), borderSide: BorderSide.none)), ), ), ), search ? ListView.builder( shrinkWrap: true, primary: false, itemCount: 15, itemBuilder: (context, index) => TeacherCard(faker: faker), ) : Column( children: [ Container( padding: EdgeInsets.symmetric( vertical: 16, horizontal: size.width * 0.075), alignment: Alignment.centerLeft, child: Text( "Kategori", style: TextStyle( color: blueDark, fontSize: 16, fontWeight: FontWeight.w500), ), ), Wrap( spacing: 6, runSpacing: 12, runAlignment: WrapAlignment.start, alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, children: List.generate( subjects.length, (index) => IntrinsicWidth( child: GestureDetector( onTap: () { setState(() { if (selectedSubjects .contains(subjects[index])) { selectedSubjects.remove(subjects[index]); } else { selectedSubjects.add(subjects[index]); } }); }, child: Container( height: 30, padding: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( color: selectedSubjects.contains(subjects[index]) ? kprimaryColor : Tint, borderRadius: BorderRadius.circular(15)), alignment: Alignment.center, child: Text( subjects[index], style: TextStyle( color: selectedSubjects .contains(subjects[index]) ? Colors.white : Colors.black, fontWeight: FontWeight.w500), ), ), ), ), ), ), const SizedBox( height: 16, ), Container( padding: EdgeInsets.symmetric( vertical: 16, horizontal: size.width * 0.075), alignment: Alignment.centerLeft, ), const SizedBox( height: 60, ), Container( width: size.width * 0.9, height: 50, margin: const EdgeInsets.symmetric(vertical: 7), child: ElevatedButton( onPressed: () { setState(() { search = true; }); }, child: const Text( "Cari Sekarang", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, fontSize: 17), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all(kprimaryColor), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ))), ), ), Container( width: size.width * 0.9, height: 50, margin: const EdgeInsets.symmetric(vertical: 7), child: ElevatedButton( onPressed: () { setState(() { selectedSubjects.clear(); selectedGender = "Terbaru"; }); }, child: Text( "Hapus Semua", style: TextStyle( color: kprimaryColor, fontWeight: FontWeight.w500, fontSize: 17), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.white), overlayColor: MaterialStateProperty.all( kprimaryColor.withOpacity(0.2)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), side: BorderSide(color: kprimaryColor)))), ), ) ], ) ], ), ); } }
0
mirrored_repositories/amalskuy/lib
mirrored_repositories/amalskuy/lib/screens/index_screen.dart
import 'dart:math'; import 'package:faker/faker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:line_icons/line_icons.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; import 'package:amalskuy/constants.dart'; import 'package:firebase_auth/firebase_auth.dart'; import '../widgets/card_widget.dart'; class IndexScreen extends StatefulWidget { const IndexScreen({Key? key}) : super(key: key); @override State<IndexScreen> createState() => _IndexScreenState(); } class _IndexScreenState extends State<IndexScreen> { Faker faker = Faker(); final PageController _pageController = PageController(viewportFraction: 0.9); int selectedPrice = 4; final user = FirebaseAuth.instance.currentUser!; String getUsernameFromEmail(String email) { final splitEmail = email.split('@'); return splitEmail[0]; } String selectedGender = "Male"; int limit = 2; // recomended tutor min @override Widget build(BuildContext context) { final username = getUsernameFromEmail(user.email!); Size size = MediaQuery.of(context).size; return SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 20,), Container( height: 50, padding: const EdgeInsets.symmetric(horizontal: 22), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ CircleAvatar( radius: 25, backgroundImage: NetworkImage( faker.image.image(keywords: ['person']), ), ), const SizedBox( width: 10, ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: FittedBox( fit: BoxFit.scaleDown, alignment: Alignment.center, child: Text( username, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: kprimaryColor), ), ), ), const Flexible( child: FittedBox( fit: BoxFit.scaleDown, alignment: Alignment.center, child: Text( "Selamat Datang di AmalSkuy", style: TextStyle(fontSize: 16, color: Colors.black, fontWeight: FontWeight.w600), ), ), ), ], ), ], ), ), const SizedBox( height: 10, ), Container( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), alignment: Alignment.centerLeft, child: const Text( "Yuk Mulai Beramal!", style: TextStyle( color: Colors.black, fontSize: 29, fontWeight: FontWeight.w600), ), ), SizedBox( width: size.width * 0.9, child: TextFormField( cursorColor: dimGrey, enableSuggestions: true, textAlign: TextAlign.start, decoration: InputDecoration( filled: true, alignLabelWithHint: true, fillColor: whitishGrey, hintStyle: TextStyle(fontSize: 15, color: dimGrey), prefixIcon: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: SvgPicture.asset( "assets/icons/search.svg", color: kprimaryColor, ), ), suffixIcon: GestureDetector( onTap: () { showModalBottomSheet( context: context, backgroundColor: Colors.white, enableDrag: true, isScrollControlled: true, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(15), topRight: Radius.circular(15))), builder: (_) => StatefulBuilder( builder: (context, setState) => SingleChildScrollView( padding: const EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: Text( "Filter Pencarian", style: TextStyle( fontSize: 17, color: blueDark, fontWeight: FontWeight.bold), ), ), const SizedBox( height: 20, ), Text( "Urutkan", style: TextStyle( fontSize: 16, color: blueDark, fontWeight: FontWeight.w500), ), Padding( padding: const EdgeInsets.symmetric( vertical: 16), child: Wrap( spacing: 6, runSpacing: 12, runAlignment: WrapAlignment.start, alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, children: [ IntrinsicWidth( child: GestureDetector( onTap: () { setState( () { selectedGender = "Terbaru"; }, ); }, child: Container( height: 30, padding: const EdgeInsets .symmetric( horizontal: 32), decoration: BoxDecoration( color: "Terbaru" == selectedGender ? kprimaryColor : Tint, borderRadius: BorderRadius .circular(15)), alignment: Alignment.center, child: Text( "Terbaru", style: TextStyle( color: "Terbaru" == selectedGender ? Colors.white : Colors.black, fontWeight: FontWeight.w500), )), ), ), IntrinsicWidth( child: GestureDetector( onTap: () { setState( () { selectedGender = "Trending"; }, ); }, child: Container( height: 30, padding: const EdgeInsets .symmetric( horizontal: 32), decoration: BoxDecoration( color: "Trending" == selectedGender ? kprimaryColor : Tint, borderRadius: BorderRadius .circular(15)), alignment: Alignment.center, child: Text( "Trending", style: TextStyle( color: "Trending" == selectedGender ? Colors.white : Colors.black, fontWeight: FontWeight.w500), )), ), ), IntrinsicWidth( child: GestureDetector( onTap: () { setState( () { selectedGender = "Akan Berakhir"; }, ); }, child: Container( height: 30, padding: const EdgeInsets .symmetric( horizontal: 32), decoration: BoxDecoration( color: "Akan Berakhir" == selectedGender ? kprimaryColor : Tint, borderRadius: BorderRadius .circular(15)), alignment: Alignment.center, child: Text( "Akan Berakhir", style: TextStyle( color: "Akan Berakhir" == selectedGender ? Colors.white : Colors.black, fontWeight: FontWeight.w500), )), ), ), ], ), ), const SizedBox( height: 16, ), Container( width: double.infinity, height: 50, margin: const EdgeInsets.symmetric( vertical: 7), child: ElevatedButton( onPressed: () {}, child: const Text( "Terapkan Filter", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, fontSize: 17), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all( kprimaryColor), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ))), ), ), Container( width: double.infinity, height: 50, margin: const EdgeInsets.symmetric( vertical: 7), child: ElevatedButton( onPressed: () {}, child: const Text( "Hapus Semua", style: TextStyle( color: kprimaryColor, fontWeight: FontWeight.w500, fontSize: 17), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all( Colors.white), overlayColor: MaterialStateProperty.all( kprimaryColor.withOpacity( 0.2)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular( 4.0), side: const BorderSide( color: kprimaryColor)))), ), ) ], ), ), )); }, child: Image.asset( "assets/search.png", ), ), hintText: "Cari Amal atau Donasi", prefixIconConstraints: const BoxConstraints(maxHeight: 17, maxWidth: 50), isDense: true, contentPadding: const EdgeInsets.symmetric(vertical: 0, horizontal: 0), prefixStyle: TextStyle(color: whitishGrey), border: const OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(8)), borderSide: BorderSide.none)), ), ), SizedBox( height: 200, child: PageView.builder( controller: _pageController, padEnds: true, itemCount: 3, physics: const BouncingScrollPhysics(), itemBuilder: (_, __) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: Image.asset( "assets/card" + (__ + 1).toString() + ".png", ), ); }, ), ), SmoothPageIndicator( controller: _pageController, count: 3, effect: ExpandingDotsEffect( dotHeight: 6, dotWidth: 6, dotColor: Tint, activeDotColor: kprimaryColor), ), Padding( padding: const EdgeInsets.only(top: 6, left: 30, right: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Flexible( child: FittedBox( child: Text( "Informasi Amal Terbaru", style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w800), ), )), Flexible( child: FittedBox( child: TextButton( onPressed: () { if (limit == 2) { setState(() { limit = 50; }); } else { setState(() { limit = 2; }); } }, style: ButtonStyle( padding: MaterialStateProperty.all(EdgeInsets.zero), ), child: Text( limit == 2 ? "Lihat Semua" : "Perkecil", style: GoogleFonts.manrope( color: kprimaryColor, fontSize: 12, fontWeight: FontWeight.bold, ), ), ), )) ], ), ), ListView.builder( shrinkWrap: true, primary: false, itemCount: min(limit, 12), itemBuilder: (context, index) => TeacherCard(faker: faker), ) ], ), ); } }
0
mirrored_repositories/amalskuy
mirrored_repositories/amalskuy/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:amalskuy/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/marvelopedia-flutter-app
mirrored_repositories/marvelopedia-flutter-app/lib/main.dart
import 'package:flutter/material.dart'; import 'package:marvelopedia_flutter_app/screens/login.dart'; const PrimaryColorDark = const Color(0x4DFFFFFF); void main() => runApp(MaterialApp( home: Login(), theme: new ThemeData( brightness: Brightness.light, primaryColor: Colors.red[600], fontFamily: 'Marvel', appBarTheme: AppBarTheme(color: Colors.red[600]), accentColor: Colors.white, backgroundColor: Colors.black, tabBarTheme: TabBarTheme( labelColor: Colors.red[600], unselectedLabelColor: Colors.grey[500]), ), darkTheme: ThemeData( brightness: Brightness.dark, fontFamily: 'Marvel', accentColor: Colors.white, backgroundColor: Colors.grey[500], appBarTheme: AppBarTheme(color: PrimaryColorDark), tabBarTheme: TabBarTheme( labelColor: Colors.white, unselectedLabelColor: Colors.grey[500]), ), ));
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/model/hero-model.dart
class ComicViewModel { int id; String name; String description; String image; ComicViewModel({this.id, this.name, this.description, this.image}); }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/model/comic-model.dart
class ComicViewModel { int id; String title; String description; double price; String image; ComicViewModel({this.id, this.title, this.description, this.price, this.image}); }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/api/comic-api.dart
import 'package:http/http.dart' as http; import 'package:crypto/crypto.dart' as crypto; import 'dart:convert'; import 'package:convert/convert.dart'; String description = ''; String comicImageUrl = ''; double price = 0; String searchComic = ''; int offset = 0; String apikey = "f0f9dbea302f60ec236962eadd11af09"; generateMd5(String data) { var content = new Utf8Encoder().convert(data); var md5 = crypto.md5; var digest = md5.convert(content); return hex.encode(digest.bytes); } Future<bool> getComic(int id) async { http.Response response; int timestamp = new DateTime.now().millisecondsSinceEpoch; String temp = "${timestamp}c6d627c0a8fb80a61752e031dd30a4d4d2fafffef0f9dbea302f60ec236962eadd11af09"; String hash = generateMd5(temp); String url = "https://gateway.marvel.com:443/v1/public/comics/$id?ts=$timestamp&apikey=$apikey&hash=$hash"; response = await http.get(url).catchError((error) { return false; }); description = json.decode(response.body)["data"]["results"][0]["description"]; String path = json.decode(response.body)["data"]["results"][0]["thumbnail"]["path"]; String ext = json.decode(response.body)["data"]["results"][0]["thumbnail"] ["extension"]; comicImageUrl = '$path.$ext'; price = json.decode(response.body)["data"]["results"][0]["price"]; return true; } Future<Map> getComics() async { http.Response response; int timestamp = new DateTime.now().millisecondsSinceEpoch; String temp = "${timestamp}c6d627c0a8fb80a61752e031dd30a4d4d2fafffef0f9dbea302f60ec236962eadd11af09"; String hash = generateMd5(temp); int limit = 20; if (searchComic == "") { response = await http.get( "https://gateway.marvel.com:443/v1/public/comics?ts=$timestamp&orderBy=title&offset=$offset&apikey=$apikey&limit=$limit&hash=$hash"); } else { response = await http.get( "https://gateway.marvel.com:443/v1/public/comics?ts=$timestamp&orderBy=title&titleStartsWith=$searchComic&apikey=$apikey&limit=$limit&hash=$hash"); } return json.decode(response.body); } /* Widget _shimmer() { return GridView.builder( padding: EdgeInsets.all(10), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 10.0, mainAxisSpacing: 10), itemCount: 10, itemBuilder: (context, index) { //gesture detector serve para deixar a imagem clicavel return GestureDetector( child: Shimmer.fromColors( child: Container( height: 700.0, width: 500.0, color: Colors.white, ), baseColor: Colors.grey[400], highlightColor: Colors.white, ), ); }); } */
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/api/super-hero-api.dart
import 'dart:convert'; import 'package:crypto/crypto.dart' as crypto; import 'package:convert/convert.dart'; import 'package:http/http.dart' as http; String searchSuperHero = ''; String apikey = "f0f9dbea302f60ec236962eadd11af09"; int _offset = 0; int limit = 20; String heroImageUrl = ''; String nameHero = ''; String descriptionHero = ''; Future<Map> getHeroes() async { http.Response response; int timestamp = new DateTime.now().millisecondsSinceEpoch; String temp = "${timestamp}c6d627c0a8fb80a61752e031dd30a4d4d2fafffef0f9dbea302f60ec236962eadd11af09"; String hash = generateMd5(temp); if (searchSuperHero == "") { try { response = await http.get( "https://gateway.marvel.com:443/v1/public/characters?ts=$timestamp&orderBy=name&offset=$_offset&apikey=$apikey&limit=$limit&hash=$hash"); } catch (e) { print(e); } } else { response = await http.get( "https://gateway.marvel.com:443/v1/public/characters?ts=$timestamp&orderBy=name&nameStartsWith=$searchSuperHero&apikey=$apikey&limit=$limit&hash=$hash"); } return json.decode(response.body); } generateMd5(String data) { var content = new Utf8Encoder().convert(data); var md5 = crypto.md5; var digest = md5.convert(content); return hex.encode(digest.bytes); } Future<bool> getHero(int id) async { http.Response response; int timestamp = new DateTime.now().millisecondsSinceEpoch; String temp = "${timestamp}c6d627c0a8fb80a61752e031dd30a4d4d2fafffef0f9dbea302f60ec236962eadd11af09"; String hash = generateMd5(temp); String url = "https://gateway.marvel.com:443/v1/public/characters/$id?ts=$timestamp&apikey=$apikey&hash=$hash"; response = await http.get(url).catchError((error) { return false; }); descriptionHero = json.decode(response.body)["data"]["results"][0]["description"]; String path = json.decode(response.body)["data"]["results"][0]["thumbnail"]["path"]; String ext = json.decode(response.body)["data"]["results"][0]["thumbnail"] ["extension"]; heroImageUrl = '$path.$ext'; print(json.decode(response.body)["data"]["results"]); return true; }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/register.dart
import 'package:flutter/material.dart'; class Register extends StatefulWidget { @override _RegisterState createState() => _RegisterState(); } class _RegisterState extends State<Register> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Cadastro") ), body: Container(), ); } }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/profile.dart
import 'package:flutter/material.dart'; import 'package:marvelopedia_flutter_app/screens/sign_in.dart'; import 'login.dart'; class Profile extends StatefulWidget { @override _ProfileState createState() => _ProfileState(); } class _ProfileState extends State<Profile> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Perfil"), ), body: Center( child: Column( mainAxisSize: MainAxisSize.max, children: <Widget>[ avatarOrIcon(), SizedBox(height: 40), Text( '$name', style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold), ), Text( '$email', style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold), ), SizedBox(height: 40), RaisedButton( onPressed: () { signOutGoogle(); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute(builder: (context) { return Login(); }), ModalRoute.withName('/')); }, color: Colors.red[600], child: Padding( padding: const EdgeInsets.all(8.0), child: Text( 'Deslogar', style: TextStyle(fontSize: 25, color: Colors.white), ), ), elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(40)), ) ], ), )); } }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/super-hero.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:marvelopedia_flutter_app/api/super-hero-api.dart'; import 'package:marvelopedia_flutter_app/screens/sign_in.dart'; class SuperHero extends StatefulWidget { final int id; final String name; SuperHero({Key key, @required this.id, @required this.name}) : super(key: key); @override _SuperHeroState createState() => _SuperHeroState(this.id, this.name); } class _SuperHeroState extends State<SuperHero> { final int id; final String name; _SuperHeroState(this.id, this.name); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, title: Text(this.name), leading: new IconButton( icon: new Icon(Icons.arrow_back), onPressed: () => Navigator.of(context).pop(), ), actions: <Widget>[ FlatButton( onPressed: () {}, child: Container( height: 40, width: 40, child: avatarOrIcon(), )) ], ), body: SingleChildScrollView( child: Container( child: FutureBuilder( future: getHero(id), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: case ConnectionState.none: return Align( alignment: Alignment.center, child: Container( width: 100, height: 100, alignment: Alignment.center, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.red[600]), strokeWidth: 5.0, ), ), ); case ConnectionState.active: case ConnectionState.done: default: if (snapshot.hasError) { return Container( child: Text("Erro ao carregar os dados!"), ); } else { return Padding( padding: EdgeInsets.all(20), child: Align( alignment: Alignment.center, child: Column( children: <Widget>[ Padding( padding: EdgeInsets.fromLTRB(0, 0, 0, 15), child: CachedNetworkImage( imageUrl: heroImageUrl, fit: BoxFit.fill, height: 300, )), Text('$name', style: TextStyle( fontSize: 25, )), Text('$descriptionHero', style: TextStyle( fontSize: 20, )), ], ))); } } }), ))); } }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/comic.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:marvelopedia_flutter_app/api/comic-api.dart'; import 'package:marvelopedia_flutter_app/screens/sign_in.dart'; import 'package:toast/toast.dart'; class Comic extends StatefulWidget { final int id; final String title; Comic({Key key, @required this.id, @required this.title}) : super(key: key); @override _ComicState createState() => _ComicState(this.id, this.title); } class _ComicState extends State<Comic> { String title; int id; _ComicState(this.id, this.title); @override void initState() { super.initState(); getComic(id); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, title: Text('$title'), leading: new IconButton( icon: new Icon(Icons.arrow_back), onPressed: () => Navigator.of(context).pop(), ), elevation: 0.0, actions: <Widget>[ FlatButton( onPressed: () {}, child: Container( width: 40, height: 40, child: avatarOrIcon(), ), ) ], ), body: SingleChildScrollView( child: Expanded( child: FutureBuilder( future: getComic(id), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: case ConnectionState.none: return Align( alignment: Alignment.center, child: Container( width: 100, height: 100, alignment: Alignment.center, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.red[600]), strokeWidth: 5.0, ), ), ); case ConnectionState.active: case ConnectionState.done: default: if (snapshot.hasError) { errorToast(); return Container( child: Text("Erro ao carregar os dados!"), ); } else { return Padding( padding: EdgeInsets.all(20), child: Align( alignment: Alignment.center, child: Column( children: <Widget>[ CachedNetworkImage( imageUrl: comicImageUrl, fit: BoxFit.fill, height: 300, ), Padding( padding: EdgeInsets.fromLTRB(0, 10, 0, 10), child: Text('$title', style: TextStyle( fontSize: 20, ))), priceNotNull(), descriptionNotNull(), ], ))); } } }), ))); } Widget priceNotNull() { if (price != null) return Text( 'Preço: $price', style: TextStyle(fontSize: 15), ); return Container(); } Widget descriptionNotNull() { if (description != null) return Text('$description', style: TextStyle( fontSize: 20, )); return Container(); } void errorToast() { Toast.show("Erro ao carregar os dados. Verifique sua conexão com internet.", context, duration: 2, gravity: Toast.BOTTOM); } }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/comics.dart
import 'package:flutter/material.dart'; import 'package:marvelopedia_flutter_app/api/comic-api.dart'; import 'package:marvelopedia_flutter_app/screens/profile.dart'; import 'package:marvelopedia_flutter_app/screens/sign_in.dart'; import 'comic.dart'; import 'package:cached_network_image/cached_network_image.dart'; class Comics extends StatefulWidget { @override _ComicsState createState() => _ComicsState(); } class _ComicsState extends State<Comics> { @override void initState() { super.initState(); getComics(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Quadrinhos"), automaticallyImplyLeading: false, actions: <Widget>[ FlatButton( onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => Profile()), ); }, child: Container( width: 40, height: 40, child: avatarOrIcon(), ), ) ], ), body: Column( children: <Widget>[ Container( child: Padding( padding: EdgeInsets.fromLTRB(10, 10, 10, 10), child: TextField( onChanged: (text) { setState(() { searchComic = text; }); }, style: TextStyle( fontSize: 18, ), textAlign: TextAlign.center, decoration: InputDecoration( suffixIcon: Icon( Icons.search, size: 28.0, ), border: OutlineInputBorder(), labelText: "Pesquise um quadrinho", ), ), ), ), Expanded( child: FutureBuilder( future: getComics(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: case ConnectionState.none: return Container( width: 100, height: 130, alignment: Alignment.center, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.red[600]), strokeWidth: 5.0, ), ); case ConnectionState.active: case ConnectionState.done: default: if (snapshot.hasError) { return Container( child: Text("Erro ao carregar os dados!"), ); } else { if(snapshot.data["data"]["results"].length > 0) return _createComicTable(context, snapshot); return Padding( padding: EdgeInsets.all(10), child: Align( alignment: Alignment.center, child: Column( children: <Widget>[ Text( 'Não foram encontrados quadrinhos com essa pesquisa. =( ', style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold, color: Colors.red[500], ), ) ], ) , ) ); } } }), ), ], )); } Widget _createComicTable(BuildContext context, AsyncSnapshot snapshot) { return GridView.builder( padding: EdgeInsets.all(10), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 5, mainAxisSpacing: 5), itemCount: snapshot.data["data"]["results"].length, itemBuilder: (context, index) { return GestureDetector( onTap: () { int id = snapshot.data["data"]["results"][index]["id"]; String title = snapshot.data["data"]["results"][index]["title"]; Navigator.push( context, MaterialPageRoute( builder: (context) => Comic(id: id, title: title)), ); }, child: CachedNetworkImage( imageUrl: '${snapshot.data["data"]["results"][index]["thumbnail"]["path"]}/portrait_xlarge.${snapshot.data["data"]["results"][index]["thumbnail"]["extension"]}', fit: BoxFit.fill, ), ); }); } }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/sign_in.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; final FirebaseAuth _auth = FirebaseAuth.instance; final GoogleSignIn googleSignIn = GoogleSignIn(); String name; String email; String imageUrl; Future<String> signInWithGoogle() async { final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn(); final GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication; final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleSignInAuthentication.accessToken, idToken: googleSignInAuthentication.idToken, ); final AuthResult authResult = await _auth.signInWithCredential(credential); final FirebaseUser user = authResult.user; /* final FirebaseUser user = await _auth.signInWithCredential(credential); */ assert(!user.isAnonymous); assert(await user.getIdToken() != null); final FirebaseUser currentUser = await _auth.currentUser(); assert(user.uid == currentUser.uid); assert(user.email != null); assert(user.displayName != null); assert(user.photoUrl != null); name = user.displayName; email = user.email; imageUrl = user.photoUrl; /* if (name.contains(" ")) { name = name.substring(0, name.indexOf(" ")); } */ return 'signInWithGoogle succeeded: $user'; } void signOutGoogle() async { name = ''; email = ''; imageUrl = ''; await googleSignIn.signOut(); print("User Sign Out"); } Widget avatarOrIcon() { if ((imageUrl != null) || (imageUrl == "")) { return CircleAvatar( backgroundImage: NetworkImage( imageUrl, ), radius: 60, backgroundColor: Colors.transparent, ); } return Icon(Icons.person, color: Colors.white); }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/tabs.dart
import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:marvelopedia_flutter_app/screens/comics.dart'; import 'heroes.dart'; class Tabs extends StatefulWidget { @override _TabsState createState() => _TabsState(); } class _TabsState extends State<Tabs> { @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: _scaffold(), ); } } Widget _scaffold() { return Scaffold( body: TabBarView( children: [ new Container( child: Comics(), ), new Container( child: Heroes(), ), ], ), bottomNavigationBar: Container( child: new TabBar( tabs: [ Tab( icon: new Icon(FontAwesomeIcons.bookOpen), ), Tab( icon: new FaIcon(FontAwesomeIcons.mask), ) ], unselectedLabelColor: Colors.grey, indicatorSize: TabBarIndicatorSize.label, indicatorPadding: EdgeInsets.all(5.0), indicatorColor: Colors.black, ), ), ); }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/heroes.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:marvelopedia_flutter_app/api/super-hero-api.dart'; import 'package:marvelopedia_flutter_app/screens/profile.dart'; import 'package:marvelopedia_flutter_app/screens/sign_in.dart'; import 'package:toast/toast.dart'; import 'super-hero.dart'; class Heroes extends StatefulWidget { @override _HeroesState createState() => _HeroesState(); } class _HeroesState extends State<Heroes> { @override void initState() { super.initState(); getHeroes().then((map) { print(map); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Heróis"), automaticallyImplyLeading: false, actions: <Widget>[ FlatButton( onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => Profile()), ); }, child: Container( width: 40, height: 40, child: avatarOrIcon(), ), ) ], ), body: Column( children: <Widget>[ Container( height: 70, child: Padding( padding: EdgeInsets.fromLTRB(10, 10, 10, 10), child: TextField( onChanged: (text) { setState(() { searchSuperHero = text; getHeroes(); }); }, style: TextStyle( fontSize: 18, ), textAlign: TextAlign.center, decoration: InputDecoration( suffixIcon: Icon( Icons.search, size: 28.0, ), border: OutlineInputBorder(), labelText: "Pesquise um heróis", ), ), ), ), Expanded( child: FutureBuilder( future: getHeroes(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: case ConnectionState.none: return Container( width: 100, height: 100, alignment: Alignment.center, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.red[600]), strokeWidth: 5.0, ), ); case ConnectionState.active: case ConnectionState.done: default: if (snapshot.hasError) { errorToast(); return Container( child: Text("Erro ao carregar os dados!"), ); } else { if (snapshot.data['data']['results'].length > 0) return _createHeroTable(context, snapshot); return Padding( padding: EdgeInsets.all(10), child: Align( alignment: Alignment.center, child: Column( children: <Widget>[ Text( 'Não foram encontrados heróis com essa pesquisa. =( ', style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold, color: Colors.red[500], ), ) ], ), )); } } }), ), ], )); } Widget _createHeroTable(BuildContext context, AsyncSnapshot snapshot) { return GridView.builder( padding: EdgeInsets.all(10), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 10.0, mainAxisSpacing: 10), itemCount: snapshot.data["data"]["results"].length, itemBuilder: (context, index) { int id = snapshot.data["data"]["results"][index]['id']; String name = snapshot.data["data"]["results"][index]['name']; return GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => SuperHero(id: id, name: name)), ); }, child: CachedNetworkImage( imageUrl: '${snapshot.data["data"]["results"][index]["thumbnail"]["path"]}/portrait_xlarge.${snapshot.data["data"]["results"][index]["thumbnail"]["extension"]}', height: 700.0, fit: BoxFit.fill, ), ); }); } void errorToast() { Toast.show("Erro ao carregar os dados", context, duration: 2, gravity: Toast.BOTTOM); } }
0
mirrored_repositories/marvelopedia-flutter-app/lib
mirrored_repositories/marvelopedia-flutter-app/lib/screens/login.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:marvelopedia_flutter_app/screens/sign_in.dart'; import 'package:marvelopedia_flutter_app/screens/tabs.dart'; import 'register.dart'; class Login extends StatefulWidget { @override _LoginState createState() => _LoginState(); } class _LoginState extends State<Login> { bool senhaEscondida = true; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: EdgeInsets.fromLTRB(0, 0, 0, 8), child: Container( width: MediaQuery.of(context).size.width * 0.9, decoration: BoxDecoration( borderRadius: BorderRadius.circular(40), color: Colors.white), child: TextField( style: TextStyle(color: Colors.black), decoration: InputDecoration( hintStyle: TextStyle(fontSize: 20.0, color: Colors.grey), prefixIcon: Icon( Icons.email, size: 20.0, color: Colors.red[600], ), contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), hintText: "Email", labelStyle: TextStyle(color: Colors.black), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.circular(32.0), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(32.0), borderSide: BorderSide(color: Colors.white), ), ), ), ), ), Container( width: MediaQuery.of(context).size.width * 0.9, decoration: BoxDecoration( borderRadius: BorderRadius.circular(40), color: Colors.white), child: TextField( obscureText: this.senhaEscondida, maxLines: 1, style: TextStyle( color: Colors.black, ), decoration: InputDecoration( hintStyle: TextStyle(fontSize: 20.0, color: Colors.grey), prefixIcon: IconButton( icon: FaIcon(FontAwesomeIcons.lock, size: 20, color: Colors.red[600]), onPressed: () {}, ), suffixIcon: IconButton( icon: FaIcon( !this.senhaEscondida ? FontAwesomeIcons.eye : FontAwesomeIcons.eyeSlash, size: 20.0, color: Colors.red[600]), onPressed: () { setState(() { this.senhaEscondida = !this.senhaEscondida; }); }, ), contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), hintText: "Password", labelStyle: TextStyle(color: Colors.black), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white), borderRadius: BorderRadius.circular(32.0), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(32.0), borderSide: BorderSide(color: Colors.white), ), ), ), ), Padding( padding: EdgeInsets.fromLTRB(0, 10, 0, 0), child: Container( width: MediaQuery.of(context).size.width * 0.9, height: 60, child: RaisedButton( shape: OutlineInputBorder( borderSide: BorderSide(color: Colors.white, width: 3), borderRadius: BorderRadius.circular(32.0), ), elevation: 0.0, color: Colors.transparent, child: Text( "Entrar", style: TextStyle(color: Colors.white, fontSize: 25), ), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => Tabs()), ); }, ), ), ), Container( width: MediaQuery.of(context).size.width * 0.9, height: 60, child: Padding( padding: EdgeInsets.fromLTRB(0, 10, 0, 0), child: _signInButton(), ), ) ], ), ), ), bottomNavigationBar: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height * 0.08, color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( "Não tem uma conta?", style: TextStyle( fontWeight: FontWeight.w800, fontSize: 15, color: Colors.black), ), FlatButton( onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => Register()), ); }, child: Text( "Criar uma conta", style: TextStyle( color: Colors.red[600], fontSize: 15, fontWeight: FontWeight.w800), ), ), ], ), ), ); } void controlaVisibilidadeSenha() { this.senhaEscondida = !this.senhaEscondida; } Widget _signInButton() { return FlatButton( color: Colors.white, onPressed: () { signInWithGoogle().whenComplete(() => { Navigator.of(context).push( MaterialPageRoute( builder: (context) { return Tabs(); }, ), ) }); }, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), /* highlightElevation: 0, /* */ borderSide: BorderSide(color: Colors.grey), */ child: Padding( padding: const EdgeInsets.fromLTRB(0, 10, 0, 10), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Image( image: AssetImage("assets/google_logo.png"), height: 35.0, ), Padding( padding: const EdgeInsets.only(left: 10), child: Text( 'Sign in with Google', style: TextStyle( fontSize: 20, color: Colors.grey, ), ), ) ], ), ), ); } }
0
mirrored_repositories/Flutter-Basics-quiz-app
mirrored_repositories/Flutter-Basics-quiz-app/lib/quiz.dart
import 'package:flutter/material.dart'; import 'package:quiz_app/question.dart'; import 'package:quiz_app/answer.dart'; class Quiz extends StatelessWidget { final List<Map<String, Object>> questions; final questionIndex; final Function answerQuestion; Quiz( {@required this.answerQuestion, @required this.questions, @required this.questionIndex}); @override Widget build(BuildContext context) { return Column( children: [ Question(questions[questionIndex]['questionText']), ...(questions[questionIndex]['answers'] as List<Map<String, Object>>) .map((answer) { return Answer(() => answerQuestion(answer['score']), answer['text']); }).toList() ], ); } }
0
mirrored_repositories/Flutter-Basics-quiz-app
mirrored_repositories/Flutter-Basics-quiz-app/lib/question.dart
import 'package:flutter/material.dart'; class Question extends StatelessWidget { final String questionText; Question(this.questionText); @override Widget build(BuildContext context) { return Container( width: double.infinity, margin: EdgeInsets.all(10.0), child: Text( questionText, style: TextStyle(fontSize: 28.0), textAlign: TextAlign.center, ), ); } }
0
mirrored_repositories/Flutter-Basics-quiz-app
mirrored_repositories/Flutter-Basics-quiz-app/lib/answer.dart
import 'package:flutter/material.dart'; class Answer extends StatelessWidget { final Function _selectHandler; final String answerText; Answer(this._selectHandler, this.answerText); @override Widget build(BuildContext context) { return Container( width: double.infinity, child: RaisedButton( child: Text(answerText), color: Colors.blue, textColor: Colors.white, onPressed: _selectHandler, ), ); } }
0
mirrored_repositories/Flutter-Basics-quiz-app
mirrored_repositories/Flutter-Basics-quiz-app/lib/result.dart
import 'package:flutter/material.dart'; class Result extends StatelessWidget { final int resultScore; final Function resetHandler; Result(this.resultScore, this.resetHandler); String get resultPhrase { String resultText; if (resultScore <= 8) { resultText = "You are awesome and innocent!"; } else if (resultScore <= 12) { resultText = "Preety likable"; } else if (resultScore <= 12) { resultText = "You are ... strange?"; } else { resultText = "You are ... Bad"; } return resultText; } @override Widget build(BuildContext context) { return Center( child: Column( children: <Widget>[ Text(resultPhrase, style: TextStyle( fontSize: 36.0, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center), FlatButton(onPressed: resetHandler, child: Text('Restart quiz')) ], )); } }
0
mirrored_repositories/Flutter-Basics-quiz-app
mirrored_repositories/Flutter-Basics-quiz-app/lib/main.dart
import 'package:flutter/material.dart'; import 'package:quiz_app/quiz.dart'; import 'package:quiz_app/result.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override State<StatefulWidget> createState() { return _MyAppState(); } } class _MyAppState extends State<MyApp> { final _questions = const [ { 'questionText': 'What\'s your favorite color?', 'answers': [ {'text': 'Black', 'score': 10}, {'text': 'Red', 'score': 5}, {'text': 'Green', 'score': 3}, {'text': 'White', 'score': 1} ] }, { 'questionText': 'What\'s your favorite animal?', 'answers': [ {'text': 'Rabbit', 'score': 3}, {'text': 'Snake', 'score': 11}, {'text': 'Elephant', 'score': 5}, {'text': 'Lion', 'score': 9} ] }, { 'questionText': 'Whos is your favorite instructor?', 'answers': [ {'text': 'Max', 'score': 1}, {'text': 'Max', 'score': 1}, {'text': 'Max', 'score': 1}, {'text': 'Max', 'score': 1} ] }, ]; var _questionIndex = 0; var _totalScore = 0; void _resetQuiz() { setState(() { _questionIndex = 0; _totalScore = 0; }); } void _answerQuestion(int score) { setState(() { _questionIndex += 1; _totalScore += score; }); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Quiz App'), ), body: _questionIndex < _questions.length ? Quiz( answerQuestion: _answerQuestion, questions: _questions, questionIndex: _questionIndex) : Result(_totalScore, _resetQuiz), ), ); } }
0
mirrored_repositories/Flutter-Basics-quiz-app
mirrored_repositories/Flutter-Basics-quiz-app/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:quiz_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Flutter-CRUD-API-Sample
mirrored_repositories/Flutter-CRUD-API-Sample/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_crud_api_sample_app/src/app.dart'; void main() => runApp(App());
0
mirrored_repositories/Flutter-CRUD-API-Sample/lib
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/app.dart
import 'package:flutter/material.dart'; import 'package:flutter_crud_api_sample_app/src/ui/formadd/form_add_screen.dart'; import 'package:flutter_crud_api_sample_app/src/ui/home/home_screen.dart'; GlobalKey<ScaffoldState> _scaffoldState = GlobalKey<ScaffoldState>(); class App extends StatefulWidget { @override _AppState createState() => _AppState(); } class _AppState extends State<App> { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( primaryColor: Colors.orange, accentColor: Colors.orangeAccent, ), home: Scaffold( key: _scaffoldState, appBar: AppBar( title: Text( "Flutter CRUD API", style: TextStyle( color: Colors.white, ), ), actions: <Widget>[ GestureDetector( onTap: () async { var result = await Navigator.push( _scaffoldState.currentContext, MaterialPageRoute(builder: (BuildContext context) { return FormAddScreen(); }), ); if (result != null) { setState(() {}); } }, child: Padding( padding: const EdgeInsets.only(right: 16.0), child: Icon( Icons.add, color: Colors.white, ), ), ), ], ), body: HomeScreen(), ), ); } }
0
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/model/profile.dart
import 'dart:convert'; class Profile { int id; String name; String email; int age; Profile({this.id = 0, this.name, this.email, this.age}); factory Profile.fromJson(Map<String, dynamic> map) { return Profile( id: map["id"], name: map["name"], email: map["email"], age: map["age"]); } Map<String, dynamic> toJson() { return {"id": id, "name": name, "email": email, "age": age}; } @override String toString() { return 'Profile{id: $id, name: $name, email: $email, age: $age}'; } } List<Profile> profileFromJson(String jsonData) { final data = json.decode(jsonData); return List<Profile>.from(data.map((item) => Profile.fromJson(item))); } String profileToJson(Profile data) { final jsonData = data.toJson(); return json.encode(jsonData); }
0
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/api/api_service.dart
import 'package:flutter_crud_api_sample_app/src/model/profile.dart'; import 'package:http/http.dart' show Client; class ApiService { final String baseUrl = "http://api.bengkelrobot.net:8001"; Client client = Client(); Future<List<Profile>> getProfiles() async { final response = await client.get("$baseUrl/api/profile"); if (response.statusCode == 200) { return profileFromJson(response.body); } else { return null; } } Future<bool> createProfile(Profile data) async { final response = await client.post( "$baseUrl/api/profile", headers: {"content-type": "application/json"}, body: profileToJson(data), ); if (response.statusCode == 201) { return true; } else { return false; } } Future<bool> updateProfile(Profile data) async { final response = await client.put( "$baseUrl/api/profile/${data.id}", headers: {"content-type": "application/json"}, body: profileToJson(data), ); if (response.statusCode == 200) { return true; } else { return false; } } Future<bool> deleteProfile(int id) async { final response = await client.delete( "$baseUrl/api/profile/$id", headers: {"content-type": "application/json"}, ); if (response.statusCode == 200) { return true; } else { return false; } } }
0
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/ui
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/ui/home/home_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_crud_api_sample_app/src/api/api_service.dart'; import 'package:flutter_crud_api_sample_app/src/model/profile.dart'; import 'package:flutter_crud_api_sample_app/src/ui/formadd/form_add_screen.dart'; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { BuildContext context; ApiService apiService; @override void initState() { super.initState(); apiService = ApiService(); } @override Widget build(BuildContext context) { this.context = context; return SafeArea( child: FutureBuilder( future: apiService.getProfiles(), builder: (BuildContext context, AsyncSnapshot<List<Profile>> snapshot) { if (snapshot.hasError) { return Center( child: Text("Something wrong with message: ${snapshot.error.toString()}"), ); } else if (snapshot.connectionState == ConnectionState.done) { List<Profile> profiles = snapshot.data; return _buildListView(profiles); } else { return Center( child: CircularProgressIndicator(), ); } }, ), ); } Widget _buildListView(List<Profile> profiles) { return Padding( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), child: ListView.builder( itemBuilder: (context, index) { Profile profile = profiles[index]; return Padding( padding: const EdgeInsets.only(top: 8.0), child: Card( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( profile.name, style: Theme.of(context).textTheme.title, ), Text(profile.email), Text(profile.age.toString()), Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ FlatButton( onPressed: () { showDialog( context: context, builder: (context) { return AlertDialog( title: Text("Warning"), content: Text("Are you sure want to delete data profile ${profile.name}?"), actions: <Widget>[ FlatButton( child: Text("Yes"), onPressed: () { Navigator.pop(context); apiService.deleteProfile(profile.id).then((isSuccess) { if (isSuccess) { setState(() {}); Scaffold.of(this.context) .showSnackBar(SnackBar(content: Text("Delete data success"))); } else { Scaffold.of(this.context) .showSnackBar(SnackBar(content: Text("Delete data failed"))); } }); }, ), FlatButton( child: Text("No"), onPressed: () { Navigator.pop(context); }, ) ], ); }); }, child: Text( "Delete", style: TextStyle(color: Colors.red), ), ), FlatButton( onPressed: () async { var result = await Navigator.push(context, MaterialPageRoute(builder: (context) { return FormAddScreen(profile: profile); })); if (result != null) { setState(() {}); } }, child: Text( "Edit", style: TextStyle(color: Colors.blue), ), ), ], ), ], ), ), ), ); }, itemCount: profiles.length, ), ); } }
0
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/ui
mirrored_repositories/Flutter-CRUD-API-Sample/lib/src/ui/formadd/form_add_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_crud_api_sample_app/src/api/api_service.dart'; import 'package:flutter_crud_api_sample_app/src/model/profile.dart'; final GlobalKey<ScaffoldState> _scaffoldState = GlobalKey<ScaffoldState>(); class FormAddScreen extends StatefulWidget { Profile profile; FormAddScreen({this.profile}); @override _FormAddScreenState createState() => _FormAddScreenState(); } class _FormAddScreenState extends State<FormAddScreen> { bool _isLoading = false; ApiService _apiService = ApiService(); bool _isFieldNameValid; bool _isFieldEmailValid; bool _isFieldAgeValid; TextEditingController _controllerName = TextEditingController(); TextEditingController _controllerEmail = TextEditingController(); TextEditingController _controllerAge = TextEditingController(); @override void initState() { if (widget.profile != null) { _isFieldNameValid = true; _controllerName.text = widget.profile.name; _isFieldEmailValid = true; _controllerEmail.text = widget.profile.email; _isFieldAgeValid = true; _controllerAge.text = widget.profile.age.toString(); } super.initState(); } @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldState, appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Text( widget.profile == null ? "Form Add" : "Change Data", style: TextStyle(color: Colors.white), ), ), body: Stack( children: <Widget>[ Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ _buildTextFieldName(), _buildTextFieldEmail(), _buildTextFieldAge(), Padding( padding: const EdgeInsets.only(top: 8.0), child: RaisedButton( child: Text( widget.profile == null ? "Submit".toUpperCase() : "Update Data".toUpperCase(), style: TextStyle( color: Colors.white, ), ), onPressed: () { if (_isFieldNameValid == null || _isFieldEmailValid == null || _isFieldAgeValid == null || !_isFieldNameValid || !_isFieldEmailValid || !_isFieldAgeValid) { _scaffoldState.currentState.showSnackBar( SnackBar( content: Text("Please fill all field"), ), ); return; } setState(() => _isLoading = true); String name = _controllerName.text.toString(); String email = _controllerEmail.text.toString(); int age = int.parse(_controllerAge.text.toString()); Profile profile = Profile(name: name, email: email, age: age); if (widget.profile == null) { _apiService.createProfile(profile).then((isSuccess) { setState(() => _isLoading = false); if (isSuccess) { Navigator.pop(_scaffoldState.currentState.context, true); } else { _scaffoldState.currentState.showSnackBar(SnackBar( content: Text("Submit data failed"), )); } }); } else { profile.id = widget.profile.id; _apiService.updateProfile(profile).then((isSuccess) { setState(() => _isLoading = false); if (isSuccess) { Navigator.pop(_scaffoldState.currentState.context, true); } else { _scaffoldState.currentState.showSnackBar(SnackBar( content: Text("Update data failed"), )); } }); } }, color: Colors.orange[600], ), ) ], ), ), _isLoading ? Stack( children: <Widget>[ Opacity( opacity: 0.3, child: ModalBarrier( dismissible: false, color: Colors.grey, ), ), Center( child: CircularProgressIndicator(), ), ], ) : Container(), ], ), ); } Widget _buildTextFieldName() { return TextField( controller: _controllerName, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: "Full name", errorText: _isFieldNameValid == null || _isFieldNameValid ? null : "Full name is required", ), onChanged: (value) { bool isFieldValid = value.trim().isNotEmpty; if (isFieldValid != _isFieldNameValid) { setState(() => _isFieldNameValid = isFieldValid); } }, ); } Widget _buildTextFieldEmail() { return TextField( controller: _controllerEmail, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( labelText: "Email", errorText: _isFieldEmailValid == null || _isFieldEmailValid ? null : "Email is required", ), onChanged: (value) { bool isFieldValid = value.trim().isNotEmpty; if (isFieldValid != _isFieldEmailValid) { setState(() => _isFieldEmailValid = isFieldValid); } }, ); } Widget _buildTextFieldAge() { return TextField( controller: _controllerAge, keyboardType: TextInputType.number, decoration: InputDecoration( labelText: "Age", errorText: _isFieldAgeValid == null || _isFieldAgeValid ? null : "Age is required", ), onChanged: (value) { bool isFieldValid = value.trim().isNotEmpty; if (isFieldValid != _isFieldAgeValid) { setState(() => _isFieldAgeValid = isFieldValid); } }, ); } }
0
mirrored_repositories/RestaurantAppUIKit
mirrored_repositories/RestaurantAppUIKit/lib/main.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:restaurant_ui_kit/providers/app_provider.dart'; import 'package:restaurant_ui_kit/screens/splash.dart'; import 'package:restaurant_ui_kit/util/const.dart'; import 'util/const.dart'; void main() { runApp( MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => AppProvider()), ], child: MyApp(), ), ); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return Consumer<AppProvider>( builder: (BuildContext context, AppProvider appProvider, Widget child) { return MaterialApp( key: appProvider.key, debugShowCheckedModeBanner: false, navigatorKey: appProvider.navigatorKey, title: Constants.appName, theme: appProvider.theme, darkTheme: Constants.darkTheme, home: SplashScreen(), ); }, ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/widgets/slider_item.dart
import 'package:flutter/material.dart'; import 'package:restaurant_ui_kit/screens/details.dart'; import 'package:restaurant_ui_kit/util/const.dart'; import 'package:restaurant_ui_kit/widgets/smooth_star_rating.dart'; class SliderItem extends StatelessWidget { final String name; final String img; final bool isFav; final double rating; final int raters; SliderItem({ Key key, @required this.name, @required this.img, @required this.isFav, @required this.rating, @required this.raters}) :super(key: key); @override Widget build(BuildContext context) { return InkWell( child: ListView( shrinkWrap: true, primary: false, children: <Widget>[ Stack( children: <Widget>[ Container( height: MediaQuery.of(context).size.height / 3.2, width: MediaQuery.of(context).size.width, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.asset( "$img", fit: BoxFit.cover, ), ), ), Positioned( right: -10.0, bottom: 3.0, child: RawMaterialButton( onPressed: (){}, fillColor: Colors.white, shape: CircleBorder(), elevation: 4.0, child: Padding( padding: EdgeInsets.all(5), child: Icon( isFav ?Icons.favorite :Icons.favorite_border, color: Colors.red, size: 17, ), ), ), ), ], ), Padding( padding: EdgeInsets.only(bottom: 2.0, top: 8.0), child: Text( "$name", style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.w900, ), maxLines: 2, ), ), Padding( padding: EdgeInsets.only(bottom: 5.0, top: 2.0), child: Row( children: <Widget>[ SmoothStarRating( starCount: 5, color: Constants.ratingBG, allowHalfRating: true, rating: rating, size: 10.0, ), Text( " $rating ($raters Reviews)", style: TextStyle( fontSize: 11.0, ), ), ], ), ), ], ), onTap: (){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return ProductDetails(); }, ), ); }, ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/widgets/home_category.dart
import 'package:flutter/material.dart'; import 'package:restaurant_ui_kit/screens/categories_screen.dart'; class HomeCategory extends StatefulWidget { final IconData icon; final String title; final String items; final Function tap; final bool isHome; HomeCategory({ Key key, @required this.icon, @required this.title, @required this.items, this.tap, this.isHome}) : super(key: key); @override _HomeCategoryState createState() => _HomeCategoryState(); } class _HomeCategoryState extends State<HomeCategory> { @override Widget build(BuildContext context) { return InkWell( onTap: widget.isHome?(){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return CategoriesScreen(); }, ), ); }:widget.tap, child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0)), elevation: 4.0, child: Padding( padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), child: Row( children: <Widget>[ Padding( padding: EdgeInsets.only(left: 0.0, right: 10.0), child: Icon( widget.icon, color: Theme.of(context).accentColor, ), ), SizedBox(width: 5), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ SizedBox(height: 10.0), Text( "${widget.title}", style: TextStyle( fontWeight: FontWeight.w900, fontSize: 17, ), ), Text( "${widget.items} Items", style: TextStyle( fontWeight: FontWeight.w400, fontSize: 10, ), ), SizedBox(height: 5), ], ), SizedBox(width: 5), ], ), ), ), ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/widgets/cart_item.dart
import 'package:flutter/material.dart'; import 'package:restaurant_ui_kit/screens/details.dart'; import 'package:restaurant_ui_kit/util/const.dart'; import 'package:restaurant_ui_kit/widgets/smooth_star_rating.dart'; class CartItem extends StatelessWidget { final String name; final String img; final bool isFav; final double rating; final int raters; CartItem({ Key key, @required this.name, @required this.img, @required this.isFav, @required this.rating, @required this.raters}) :super(key: key); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.fromLTRB(0, 4, 0, 4), child: InkWell( onTap: (){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return ProductDetails(); }, ), ); }, child: Row( children: <Widget>[ Padding( padding: EdgeInsets.only(left: 0.0, right: 10.0), child: Container( height: MediaQuery.of(context).size.width/3.5, width: MediaQuery.of(context).size.width/3, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.asset( "$img", fit: BoxFit.cover, ), ), ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ Text( "$name", style: TextStyle( // fontSize: 15, fontWeight: FontWeight.w900, ), ), SizedBox(height: 10.0), Row( children: <Widget>[ SmoothStarRating( starCount: 1, color: Constants.ratingBG, allowHalfRating: true, rating: 5.0, size: 12.0, ), SizedBox(width: 6.0), Text( "5.0 (23 Reviews)", style: TextStyle( fontSize: 12, fontWeight: FontWeight.w300, ), ), ], ), SizedBox(height: 10.0), Row( children: <Widget>[ Text( "20 Pieces", style: TextStyle( fontSize: 11.0, fontWeight: FontWeight.w300, ), ), SizedBox(width: 10.0), Text( r"$90", style: TextStyle( fontSize: 14.0, fontWeight: FontWeight.w900, color: Theme.of(context).accentColor, ), ), ], ), SizedBox(height: 10.0), Text( "Quantity: 1", style: TextStyle( fontSize: 11.0, fontWeight: FontWeight.w300, ), ), ], ), ], ), ), ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/widgets/grid_product.dart
import 'package:flutter/material.dart'; import 'package:restaurant_ui_kit/screens/details.dart'; import 'package:restaurant_ui_kit/util/const.dart'; import 'package:restaurant_ui_kit/widgets/smooth_star_rating.dart'; class GridProduct extends StatelessWidget { final String name; final String img; final bool isFav; final double rating; final int raters; GridProduct({ Key key, @required this.name, @required this.img, @required this.isFav, @required this.rating, @required this.raters}) :super(key: key); @override Widget build(BuildContext context) { return InkWell( child: ListView( shrinkWrap: true, primary: false, children: <Widget>[ Stack( children: <Widget>[ Container( height: MediaQuery.of(context).size.height / 3.6, width: MediaQuery.of(context).size.width / 2.2, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.asset( "$img", fit: BoxFit.cover, ), ), ), Positioned( right: -10.0, bottom: 3.0, child: RawMaterialButton( onPressed: (){}, fillColor: Colors.white, shape: CircleBorder(), elevation: 4.0, child: Padding( padding: EdgeInsets.all(5), child: Icon( isFav ?Icons.favorite :Icons.favorite_border, color: Colors.red, size: 17, ), ), ), ), ], ), Padding( padding: EdgeInsets.only(bottom: 2.0, top: 8.0), child: Text( "$name", style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.w900, ), maxLines: 2, ), ), Padding( padding: EdgeInsets.only(bottom: 5.0, top: 2.0), child: Row( children: <Widget>[ SmoothStarRating( starCount: 5, color: Constants.ratingBG, allowHalfRating: true, rating: rating, size: 10.0, ), Text( " $rating ($raters Reviews)", style: TextStyle( fontSize: 11.0, ), ), ], ), ), ], ), onTap: (){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return ProductDetails(); }, ), ); }, ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/widgets/smooth_star_rating.dart
import 'package:flutter/material.dart'; typedef void RatingChangeCallback(double rating); class SmoothStarRating extends StatelessWidget { final int starCount; final double rating; final RatingChangeCallback onRatingChanged; final Color color; final Color borderColor; final double size; final bool allowHalfRating; final double spacing; SmoothStarRating( {this.starCount = 5, this.rating = 0.0, this.onRatingChanged, this.color, this.borderColor, this.size, this.spacing = 0.0, this.allowHalfRating = true}) { assert(this.rating != null); } Widget buildStar(BuildContext context, int index) { Icon icon; if (index >= rating) { icon = new Icon( Icons.star_border, color: borderColor ?? Theme.of(context).primaryColor, size: size ?? 25.0, ); } else if (index > rating - (allowHalfRating ? 0.5 : 1.0) && index < rating) { icon = new Icon( Icons.star_half, color: color ?? Theme.of(context).primaryColor, size: size ?? 25.0, ); } else { icon = new Icon( Icons.star, color: color ?? Theme.of(context).primaryColor, size: size ?? 25.0, ); } return new GestureDetector( onTap: () { if (this.onRatingChanged != null) onRatingChanged(index + 1.0); }, onHorizontalDragUpdate: (dragDetails) { RenderBox box = context.findRenderObject(); var _pos = box.globalToLocal(dragDetails.globalPosition); var i = _pos.dx / size; var newRating = allowHalfRating ? i : i.round().toDouble(); if (newRating > starCount) { newRating = starCount.toDouble(); } if (newRating < 0) { newRating = 0.0; } if (this.onRatingChanged != null) onRatingChanged(newRating); }, child: icon, ); } @override Widget build(BuildContext context) { return new Material( color: Colors.transparent, child: new Wrap( alignment: WrapAlignment.start, spacing: spacing, children: new List.generate( starCount, (index) => buildStar(context, index))), ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/widgets/badge.dart
import 'package:flutter/material.dart'; class IconBadge extends StatefulWidget { final IconData icon; final double size; IconBadge({Key key, @required this.icon, @required this.size}) : super(key: key); @override _IconBadgeState createState() => _IconBadgeState(); } class _IconBadgeState extends State<IconBadge> { @override Widget build(BuildContext context) { return Stack( children: <Widget>[ Icon( widget.icon, size: widget.size, ), Positioned( right: 0.0, child: Container( padding: EdgeInsets.all(1), decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(6), ), constraints: BoxConstraints( minWidth: 13, minHeight: 13, ), child: Padding( padding: EdgeInsets.only(top: 1), child:Text( "3", style: TextStyle( color: Colors.white, fontSize: 8, ), textAlign: TextAlign.center, ), ), ), ), ], ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/util/comments.dart
List comments = [ { "img": "assets/cm1.jpeg", "comment": "Nulla porttitor accumsan tincidunt. Vestibulum ante " "ipsum primis in faucibus orci luctus et ultrices posuere " "cubilia Curae", "name": "Jane Doe" }, { "img": "assets/cm2.jpeg", "comment": "Nulla porttitor accumsan tincidunt. Vestibulum ante " "ipsum primis in faucibus orci luctus et ultrices posuere " "cubilia Curae", "name": "Jane Joe" }, { "img": "assets/cm3.jpeg", "comment": "Nulla porttitor accumsan tincidunt. Vestibulum ante " "ipsum primis in faucibus orci luctus et ultrices posuere " "cubilia Curae", "name": "Mary Jane" }, { "img": "assets/cm4.jpeg", "comment": "Nulla porttitor accumsan tincidunt. Vestibulum ante " "ipsum primis in faucibus orci luctus et ultrices posuere " "cubilia Curae", "name": "Jane Jones" } ];
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/util/foods.dart
List<Map> foods = [ { "img": "assets/food1.jpeg", "name": "Fruit Salad" }, { "img": "assets/food2.jpeg", "name": "Fruit Salad" }, { "img": "assets/food3.jpeg", "name": "Hamburger" }, { "img": "assets/food4.jpeg", "name": "Fruit Salad" }, { "img": "assets/food5.jpeg", "name": "Hamburger" }, { "img": "assets/food6.jpeg", "name": "Steak" }, { "img": "assets/food7.jpeg", "name": "Pizza" }, { "img": "assets/food8.jpeg", "name": "Asparagus" }, { "img": "assets/food9.jpeg", "name": "Salad" }, { "img": "assets/food10.jpeg", "name": "Pizza" }, { "img": "assets/food11.jpeg", "name": "Pizza" }, { "img": "assets/food12.jpg", "name": "Salad" }, ];
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/util/categories.dart
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; List categories = [ { "name": "Drinks", "icon": FontAwesomeIcons.wineBottle, "items": 5 }, { "name": "Miscellaneous", "icon": FontAwesomeIcons.cannabis, "items": 20 }, { "name": "Desert", "icon": FontAwesomeIcons.birthdayCake, "items": 9 }, { "name": "Fast Food", "icon": FontAwesomeIcons.pizzaSlice, "items": 5 }, { "name": "Meals", "icon": FontAwesomeIcons.breadSlice, "items": 15 }, ];
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/util/const.dart
import 'package:flutter/material.dart'; class Constants{ static String appName = "Restaurant App UI KIT"; //Colors for theme // Color(0xfffcfcff); static Color lightPrimary = Color(0xfffcfcff); static Color darkPrimary = Colors.black; static Color lightAccent = Colors.red; static Color darkAccent = Colors.red[400]; static Color lightBG = Color(0xfffcfcff); static Color darkBG = Colors.black; static Color ratingBG = Colors.yellow[600]; static ThemeData lightTheme = ThemeData( backgroundColor: lightBG, primaryColor: lightPrimary, accentColor: lightAccent, cursorColor: lightAccent, scaffoldBackgroundColor: lightBG, appBarTheme: AppBarTheme( textTheme: TextTheme( title: TextStyle( color: darkBG, fontSize: 18.0, fontWeight: FontWeight.w800, ), ), // iconTheme: IconThemeData( // color: lightAccent, // ), ), ); static ThemeData darkTheme = ThemeData( brightness: Brightness.dark, backgroundColor: darkBG, primaryColor: darkPrimary, accentColor: darkAccent, scaffoldBackgroundColor: darkBG, cursorColor: darkAccent, appBarTheme: AppBarTheme( textTheme: TextTheme( title: TextStyle( color: lightBG, fontSize: 18.0, fontWeight: FontWeight.w800, ), ), // iconTheme: IconThemeData( // color: darkAccent, // ), ), ); }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/podo/food.dart
class Food { String img; String name; Food( {this.img, this.name}); Food.fromJson(Map<String, dynamic> json) { name = json['name']; img = json['img']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['img'] = this.img; data['name'] = this.name; return data; } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/screens/register.dart
import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:restaurant_ui_kit/screens/main_screen.dart'; class RegisterScreen extends StatefulWidget { @override _RegisterScreenState createState() => _RegisterScreenState(); } class _RegisterScreenState extends State<RegisterScreen> { final TextEditingController _usernameControl = new TextEditingController(); final TextEditingController _emailControl = new TextEditingController(); final TextEditingController _passwordControl = new TextEditingController(); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.fromLTRB(20.0,0,20,0), child: ListView( shrinkWrap: true, children: <Widget>[ SizedBox(height: 10.0), Container( alignment: Alignment.center, margin: EdgeInsets.only( top: 25.0, ), child: Text( "Create an account", style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.w700, color: Theme.of(context).accentColor, ), ), ), SizedBox(height: 30.0), Card( elevation: 3.0, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( Radius.circular(5.0), ), ), child: TextField( style: TextStyle( fontSize: 15.0, color: Colors.black, ), decoration: InputDecoration( contentPadding: EdgeInsets.all(10.0), border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: BorderSide(color: Colors.white,), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white,), borderRadius: BorderRadius.circular(5.0), ), hintText: "Username", prefixIcon: Icon( Icons.perm_identity, color: Colors.black, ), hintStyle: TextStyle( fontSize: 15.0, color: Colors.black, ), ), maxLines: 1, controller: _usernameControl, ), ), ), SizedBox(height: 10.0), Card( elevation: 3.0, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( Radius.circular(5.0), ), ), child: TextField( style: TextStyle( fontSize: 15.0, color: Colors.black, ), decoration: InputDecoration( contentPadding: EdgeInsets.all(10.0), border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: BorderSide(color: Colors.white,), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white,), borderRadius: BorderRadius.circular(5.0), ), hintText: "Email", prefixIcon: Icon( Icons.mail_outline, color: Colors.black, ), hintStyle: TextStyle( fontSize: 15.0, color: Colors.black, ), ), maxLines: 1, controller: _emailControl, ), ), ), SizedBox(height: 10.0), Card( elevation: 3.0, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( Radius.circular(5.0), ), ), child: TextField( style: TextStyle( fontSize: 15.0, color: Colors.black, ), decoration: InputDecoration( contentPadding: EdgeInsets.all(10.0), border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: BorderSide(color: Colors.white,), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.white,), borderRadius: BorderRadius.circular(5.0), ), hintText: "Password", prefixIcon: Icon( Icons.lock_outline, color: Colors.black, ), hintStyle: TextStyle( fontSize: 15.0, color: Colors.black, ), ), obscureText: true, maxLines: 1, controller: _passwordControl, ), ), ), SizedBox(height: 40.0), Container( height: 50.0, child: RaisedButton( child: Text( "Register".toUpperCase(), style: TextStyle( color: Colors.white, ), ), onPressed: (){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return MainScreen(); }, ), ); }, color: Theme.of(context).accentColor, ), ), SizedBox(height: 10.0), Divider(color: Theme.of(context).accentColor,), SizedBox(height: 10.0), Center( child: Container( width: MediaQuery.of(context).size.width/2, child: Row( children: <Widget>[ RawMaterialButton( onPressed: (){}, fillColor: Colors.blue[800], shape: CircleBorder(), elevation: 4.0, child: Padding( padding: EdgeInsets.all(15), child: Icon( FontAwesomeIcons.facebookF, color: Colors.white, // size: 24.0, ), ), ), RawMaterialButton( onPressed: (){}, fillColor: Colors.white, shape: CircleBorder(), elevation: 4.0, child: Padding( padding: EdgeInsets.all(15), child: Icon( FontAwesomeIcons.google, color: Colors.blue[800], // size: 24.0, ), ), ), ], ), ), ), SizedBox(height: 20.0), ], ), ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/screens/details.dart
import 'package:flutter/material.dart'; import 'package:restaurant_ui_kit/screens/notifications.dart'; import 'package:restaurant_ui_kit/util/comments.dart'; import 'package:restaurant_ui_kit/util/const.dart'; import 'package:restaurant_ui_kit/util/foods.dart'; import 'package:restaurant_ui_kit/widgets/badge.dart'; import 'package:restaurant_ui_kit/widgets/smooth_star_rating.dart'; class ProductDetails extends StatefulWidget { @override _ProductDetailsState createState() => _ProductDetailsState(); } class _ProductDetailsState extends State<ProductDetails> { bool isFav = false; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, leading: IconButton( icon: Icon( Icons.keyboard_backspace, ), onPressed: ()=>Navigator.pop(context), ), centerTitle: true, title: Text( "Item Details", ), elevation: 0.0, actions: <Widget>[ IconButton( icon: IconBadge( icon: Icons.notifications, size: 22.0, ), onPressed: (){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return Notifications(); }, ), ); }, ), ], ), body: Padding( padding: EdgeInsets.fromLTRB(10.0,0,10.0,0), child: ListView( children: <Widget>[ SizedBox(height: 10.0), Stack( children: <Widget>[ Container( height: MediaQuery.of(context).size.height / 3.2, width: MediaQuery.of(context).size.width, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.asset( "${foods[1]['img']}", fit: BoxFit.cover, ), ), ), Positioned( right: -10.0, bottom: 3.0, child: RawMaterialButton( onPressed: (){}, fillColor: Colors.white, shape: CircleBorder(), elevation: 4.0, child: Padding( padding: EdgeInsets.all(5), child: Icon( isFav ?Icons.favorite :Icons.favorite_border, color: Colors.red, size: 17, ), ), ), ), ], ), SizedBox(height: 10.0), Text( "${foods[1]['name']}", style: TextStyle( fontSize: 20, fontWeight: FontWeight.w800, ), maxLines: 2, ), Padding( padding: EdgeInsets.only(bottom: 5.0, top: 2.0), child: Row( children: <Widget>[ SmoothStarRating( starCount: 5, color: Constants.ratingBG, allowHalfRating: true, rating: 5.0, size: 10.0, ), SizedBox(width: 10.0), Text( "5.0 (23 Reviews)", style: TextStyle( fontSize: 11.0, ), ), ], ), ), Padding( padding: EdgeInsets.only(bottom: 5.0, top: 2.0), child: Row( children: <Widget>[ Text( "20 Pieces", style: TextStyle( fontSize: 11.0, fontWeight: FontWeight.w300, ), ), SizedBox(width: 10.0), Text( r"$90", style: TextStyle( fontSize: 14.0, fontWeight: FontWeight.w900, color: Theme.of(context).accentColor, ), ), ], ), ), SizedBox(height: 20.0), Text( "Product Description", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w800, ), maxLines: 2, ), SizedBox(height: 10.0), Text( "Nulla quis lorem ut libero malesuada feugiat. Lorem ipsum dolor " "sit amet, consectetur adipiscing elit. Curabitur aliquet quam " "id dui posuere blandit. Pellentesque in ipsum id orci porta " "dapibus. Vestibulum ante ipsum primis in faucibus orci luctus " "et ultrices posuere cubilia Curae; Donec velit neque, auctor " "sit amet aliquam vel, ullamcorper sit amet ligula. Donec" " rutrum congue leo eget malesuada. Vivamus magna justo," " lacinia eget consectetur sed, convallis at tellus." " Vivamus suscipit tortor eget felis porttitor volutpat." " Donec rutrum congue leo eget malesuada." " Pellentesque in ipsum id orci porta dapibus.", style: TextStyle( fontSize: 13, fontWeight: FontWeight.w300, ), ), SizedBox(height: 20.0), Text( "Reviews", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w800, ), maxLines: 2, ), SizedBox(height: 20.0), ListView.builder( shrinkWrap: true, primary: false, physics: NeverScrollableScrollPhysics(), itemCount: comments == null?0:comments.length, itemBuilder: (BuildContext context, int index) { Map comment = comments[index]; return ListTile( leading: CircleAvatar( radius: 25.0, backgroundImage: AssetImage( "${comment['img']}", ), ), title: Text("${comment['name']}"), subtitle: Column( children: <Widget>[ Row( children: <Widget>[ SmoothStarRating( starCount: 5, color: Constants.ratingBG, allowHalfRating: true, rating: 5.0, size: 12.0, ), SizedBox(width: 6.0), Text( "February 14, 2020", style: TextStyle( fontSize: 12, fontWeight: FontWeight.w300, ), ), ], ), SizedBox(height: 7.0), Text( "${comment["comment"]}", ), ], ), ); }, ), SizedBox(height: 10.0), ], ), ), bottomNavigationBar: Container( height: 50.0, child: RaisedButton( child: Text( "ADD TO CART", style: TextStyle( color: Colors.white, ), ), color: Theme.of(context).accentColor, onPressed: (){}, ), ), ); } }
0
mirrored_repositories/RestaurantAppUIKit/lib
mirrored_repositories/RestaurantAppUIKit/lib/screens/main_screen.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:restaurant_ui_kit/screens/cart.dart'; import 'package:restaurant_ui_kit/screens/favorite_screen.dart'; import 'package:restaurant_ui_kit/screens/home.dart'; import 'package:restaurant_ui_kit/screens/notifications.dart'; import 'package:restaurant_ui_kit/screens/profile.dart'; import 'package:restaurant_ui_kit/screens/search.dart'; import 'package:restaurant_ui_kit/util/const.dart'; import 'package:restaurant_ui_kit/widgets/badge.dart'; class MainScreen extends StatefulWidget { @override _MainScreenState createState() => _MainScreenState(); } class _MainScreenState extends State<MainScreen> { PageController _pageController; int _page = 0; @override Widget build(BuildContext context) { return WillPopScope( onWillPop: ()=>Future.value(false), child: Scaffold( appBar: AppBar( automaticallyImplyLeading: false, centerTitle: true, title: Text( Constants.appName, ), elevation: 0.0, actions: <Widget>[ IconButton( icon: IconBadge( icon: Icons.notifications, size: 22.0, ), onPressed: (){ Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context){ return Notifications(); }, ), ); }, tooltip: "Notifications", ), ], ), body: PageView( physics: NeverScrollableScrollPhysics(), controller: _pageController, onPageChanged: onPageChanged, children: <Widget>[ Home(), FavoriteScreen(), SearchScreen(), CartScreen(), Profile(), ], ), bottomNavigationBar: BottomAppBar( child: new Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ SizedBox(width:7), IconButton( icon: Icon( Icons.home, size: 24.0, ), color: _page == 0 ? Theme.of(context).accentColor : Theme .of(context) .textTheme.caption.color, onPressed: ()=>_pageController.jumpToPage(0), ), IconButton( icon:Icon( Icons.favorite, size: 24.0, ), color: _page == 1 ? Theme.of(context).accentColor : Theme .of(context) .textTheme.caption.color, onPressed: ()=>_pageController.jumpToPage(1), ), IconButton( icon: Icon( Icons.search, size: 24.0, color: Theme.of(context).primaryColor, ), color: _page == 2 ? Theme.of(context).accentColor : Theme .of(context) .textTheme.caption.color, onPressed: ()=>_pageController.jumpToPage(2), ), IconButton( icon: IconBadge( icon: Icons.shopping_cart, size: 24.0, ), color: _page == 3 ? Theme.of(context).accentColor : Theme .of(context) .textTheme.caption.color, onPressed: ()=>_pageController.jumpToPage(3), ), IconButton( icon: Icon( Icons.person, size: 24.0, ), color: _page == 4 ? Theme.of(context).accentColor : Theme .of(context) .textTheme.caption.color, onPressed: ()=>_pageController.jumpToPage(4), ), SizedBox(width:7), ], ), color: Theme.of(context).primaryColor, shape: CircularNotchedRectangle(), ), floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: FloatingActionButton( elevation: 4.0, child: Icon( Icons.search, ), onPressed: ()=>_pageController.jumpToPage(2), ), ), ); } void navigationTapped(int page) { _pageController.jumpToPage(page); } @override void initState() { super.initState(); _pageController = PageController(); } @override void dispose() { super.dispose(); _pageController.dispose(); } void onPageChanged(int page) { setState(() { this._page = page; }); } }
0