repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/QuizApp-Flutter/lib/utils
mirrored_repositories/QuizApp-Flutter/lib/utils/codePicker/country_code_picker.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter/material.dart'; import 'package:nb_utils/nb_utils.dart'; import 'package:quiz/utils/AppWidget.dart'; import 'package:quiz/utils/codePicker/selection_dialog.dart'; import '../../../main.dart'; import 'country_code.dart'; import 'country_codes.dart'; export 'country_code.dart'; class CountryCodePicker extends StatefulWidget { final ValueChanged<CountryCode>? onChanged; //Exposed new method to get the initial information of the country final ValueChanged<CountryCode?>? onInit; final String? initialSelection; final List<String> favorite; final TextStyle? textStyle; final EdgeInsetsGeometry padding; final bool showCountryOnly; final InputDecoration searchDecoration; final TextStyle? searchStyle; final WidgetBuilder? emptySearchBuilder; final Function(CountryCode?)? builder; /// shows the name of the country instead of the dialcode final bool showOnlyCountryWhenClosed; /// aligns the flag and the Text left /// /// additionally this option also fills the available space of the widget. /// this is especially usefull in combination with [showOnlyCountryWhenClosed], /// because longer countrynames are displayed in one line final bool alignLeft; /// shows the flag final bool showFlag; /// contains the country codes to load only the specified countries. final List<String> countryFilter; CountryCodePicker({ this.onChanged, this.onInit, this.initialSelection, this.favorite = const [], this.countryFilter = const [], this.textStyle, this.padding = const EdgeInsets.all(0.0), this.showCountryOnly = false, this.searchDecoration = const InputDecoration(), this.searchStyle, this.emptySearchBuilder, this.showOnlyCountryWhenClosed = false, this.alignLeft = false, this.showFlag = true, this.builder, }); @override State<StatefulWidget> createState() { List<Map> jsonList = codes; List<CountryCode> elements = jsonList .map((s) => CountryCode( name: s['name'], code: s['code'], dialCode: s['dial_code'], flagUri: '', // add icon urls here )) .toList(); if (countryFilter.length > 0) { elements = elements.where((c) => countryFilter.contains(c.code)).toList(); } return new _CountryCodePickerState(elements); } } class _CountryCodePickerState extends State<CountryCodePicker> { CountryCode? selectedItem; List<CountryCode> elements = []; List<CountryCode> favoriteElements = []; _CountryCodePickerState(this.elements); @override Widget build(BuildContext context) { Widget _widget; if (widget.builder != null) _widget = InkWell( onTap: _showSelectionDialog, child: widget.builder!(selectedItem), ); else { _widget = TextButton( style: TextButton.styleFrom( padding: widget.padding, ), onPressed: _showSelectionDialog, child: Flex( direction: Axis.horizontal, mainAxisSize: MainAxisSize.min, children: <Widget>[ widget.showFlag ? Flexible( flex: widget.alignLeft ? 0 : 1, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, child: Padding( padding: widget.alignLeft ? const EdgeInsets.only(right: 8.0, left: 8.0) : const EdgeInsets.only(right: 8.0), child: CachedNetworkImage( imageUrl: selectedItem!.flagUri!, width: 25.0, ), ), ) : Container(), Flexible( fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, child: text(selectedItem!.toCountryCodeString(), textColor: textPrimaryColor, fontSize: 16.0), ), ], ), ); } return _widget; } @override void didUpdateWidget(CountryCodePicker oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.initialSelection != widget.initialSelection) { if (widget.initialSelection != null) { selectedItem = elements.firstWhere((e) => (e.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) || (e.dialCode == widget.initialSelection.toString()), orElse: () => elements[0]); } else { selectedItem = elements[0]; } } } @override initState() { if (widget.initialSelection != null) { selectedItem = elements.firstWhere((e) => (e.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) || (e.dialCode == widget.initialSelection.toString()), orElse: () => elements[0]); } else { selectedItem = elements[0]; } //Change added: get the initial entered country information _onInit(selectedItem); favoriteElements = elements.where((e) => widget.favorite.firstWhereOrNull((f) => e.code == f.toUpperCase() || e.dialCode == f.toString()) != null).toList(); super.initState(); } void _showSelectionDialog() { showDialog( context: context, builder: (_) => SelectionDialog(elements, favoriteElements, showCountryOnly: widget.showCountryOnly, emptySearchBuilder: widget.emptySearchBuilder, searchDecoration: widget.searchDecoration, searchStyle: widget.searchStyle, showFlag: widget.showFlag), ).then((e) { if (e != null) { setState(() { selectedItem = e; }); _publishSelection(e); } }); } void _publishSelection(CountryCode e) { if (widget.onChanged != null) { widget.onChanged!(e); } } void _onInit(CountryCode? initialData) { if (widget.onInit != null) { widget.onInit!(initialData); } } }
0
mirrored_repositories/QuizApp-Flutter
mirrored_repositories/QuizApp-Flutter/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:quiz/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/whatsmyip
mirrored_repositories/whatsmyip/lib/my_app.dart
import 'package:flutter/material.dart'; import 'package:whatsmyip/screens/error_screen.dart'; import 'package:whatsmyip/screens/home_screen.dart'; class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { ErrorWidget.builder = getErrorScreen; return const MaterialApp( debugShowCheckedModeBanner: false, home: HomeScreen(), ); } }
0
mirrored_repositories/whatsmyip
mirrored_repositories/whatsmyip/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:whatsmyip/my_app.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setPreferredOrientations( [ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ], ); runApp( Phoenix( child: const MyApp(), ), ); }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/models/ip_data_model.dart
import 'dart:convert'; IpDataModel ipDataModelFromJson(String str) => IpDataModel.fromJson(json.decode(str)); class IpDataModel { IpDataModel({ required this.ip, required this.city, required this.region, required this.country, required this.loc, required this.org, required this.postal, required this.timezone, }); String ip; String city; String region; String country; String loc; String org; String postal; String timezone; factory IpDataModel.fromJson(Map<String, dynamic> json) => IpDataModel( ip: json["ip"], city: json["city"], region: json["region"], country: json["country"], loc: json["loc"], org: json["org"], postal: json["postal"], timezone: json["timezone"], ); }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/services/get_device_ip_address.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:whatsmyip/models/ip_data_model.dart'; import 'package:http/http.dart' as http; Future<List<IpDataModel>> getDeviceIpAddress( String baseURL, ValueNotifier<List<IpDataModel>> ipDataModel, ) async { final response = await http.get( Uri.parse(baseURL), ); var data = jsonDecode(response.body); if (response.statusCode == 200) { IpDataModel user = IpDataModel( ip: data["ip"].toString(), city: data["city"].toString(), region: data["region"].toString(), country: data["country"].toString(), loc: data["loc"].toString(), org: data["org"].toString(), postal: data["postal"].toString(), timezone: data["timezone"].toString(), ); ipDataModel.value.add(user); return ipDataModel.value; } else { return ipDataModel.value; } }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/services/copy_ip_address.dart
import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; void copyIpAddress(String text) { Clipboard.setData(ClipboardData(text: text)) .onError( (error, stackTrace) => Fluttertoast.showToast( msg: error.toString(), ), ) .then( (value) => Fluttertoast.showToast( msg: 'IP Address Copied', ), ); }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/screens/error_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; Widget getErrorScreen(FlutterErrorDetails error) { return const ErrorScreen(); } class ErrorScreen extends HookWidget { const ErrorScreen({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle.dark.copyWith( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark, statusBarBrightness: Brightness.dark, ), ); return Scaffold( body: Container( color: const Color(0xFFD0D2C8), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'An error occured, Please try again!', textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF263525), fontWeight: FontWeight.w600, fontSize: 15, ), ), const SizedBox( height: 20, ), SizedBox( width: 200, height: 50, child: ElevatedButton.icon( onPressed: () { Phoenix.rebirth(context); }, style: ElevatedButton.styleFrom( backgroundColor: const Color(0xFF4F6C4E), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0), ), ), icon: const Icon( Icons.refresh_rounded, color: Color(0xFFD0D2C8), ), label: const Text( 'Try Again', textAlign: TextAlign.center, style: TextStyle( color: Color(0xFFD0D2C8), fontWeight: FontWeight.w600, fontSize: 20, ), ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/screens/home_scaffold.dart
import 'package:flutter/material.dart'; import 'package:whatsmyip/models/ip_data_model.dart'; import 'package:whatsmyip/services/copy_ip_address.dart'; class HomeScaffold extends StatelessWidget { const HomeScaffold({ Key? key, required this.data, }) : super(key: key); final IpDataModel data; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFFD0D2C8), appBar: AppBar( backgroundColor: const Color(0xFF4F6C4E), centerTitle: true, title: const Text( 'WhatsMyIP', ), ), body: Center( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: InkWell( onTap: () { copyIpAddress(data.ip); }, child: Ink( decoration: BoxDecoration( color: const Color(0xFFD0D2C8), borderRadius: BorderRadius.circular(5), boxShadow: const [ BoxShadow( color: Colors.grey, offset: Offset(0.0, 1.0), blurRadius: 6.0, ), ], ), child: Padding( padding: const EdgeInsets.all(12.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Content( title: 'IP Address: ', content: data.ip, ), Content( title: 'City: ', content: data.city, ), Content( title: 'Region: ', content: data.region, ), Content( title: 'Country: ', content: data.country, ), Content( title: 'Location: ', content: data.loc, ), Content( title: 'Organition: ', content: data.org, ), Content( title: 'Postal Code: ', content: data.postal, ), Content( title: 'Timezone: ', content: data.timezone, ), ], ), ), ), ), ), ), ); } } class Content extends StatelessWidget { const Content({ Key? key, required this.title, required this.content, }) : super(key: key); final String title; final String content; @override Widget build(BuildContext context) { return RichText( textAlign: TextAlign.left, text: TextSpan( text: title, style: const TextStyle( color: Color(0xFF263525), fontWeight: FontWeight.w500, fontSize: 16, ), children: <TextSpan>[ TextSpan( text: content, style: const TextStyle( color: Color(0xFF263525), fontWeight: FontWeight.bold, fontSize: 16, ), ), ], ), ); } }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/screens/loading_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:loading_animation_widget/loading_animation_widget.dart'; class LoadingScreen extends StatelessWidget { const LoadingScreen({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle.dark.copyWith( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark, statusBarBrightness: Brightness.dark, ), ); return Scaffold( body: Container( color: const Color(0xFFD0D2C8), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ LoadingAnimationWidget.discreteCircle( color: const Color(0xFF263525), size: 35, ), const SizedBox( height: 15, ), const Text( 'Loading...', textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF263525), fontWeight: FontWeight.bold, fontSize: 18, ), ), ], ), ), ), ); } }
0
mirrored_repositories/whatsmyip/lib
mirrored_repositories/whatsmyip/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:whatsmyip/models/ip_data_model.dart'; import 'package:whatsmyip/screens/error_screen.dart'; import 'package:whatsmyip/screens/home_scaffold.dart'; import 'package:whatsmyip/screens/loading_screen.dart'; import 'package:whatsmyip/services/get_device_ip_address.dart'; class HomeScreen extends HookWidget { const HomeScreen({super.key}); @override Widget build(BuildContext context) { const baseURL = 'https://ipinfo.io?token=5b4f759a748189'; final ipDataModel = useState<List<IpDataModel>>([]); return FutureBuilder( future: getDeviceIpAddress(baseURL, ipDataModel), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const LoadingScreen(); } else if (snapshot.hasData) { var data = ipDataModel.value[0]; return HomeScaffold( data: data, ); } else { return const ErrorScreen(); } }, ); } }
0
mirrored_repositories/VirQ
mirrored_repositories/VirQ/lib/main.dart
import 'package:VirQ/screens/wrapper.dart'; import 'package:VirQ/services/auth.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:VirQ/models/user.dart'; void main() async { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return StreamProvider<User>.value( value: AuthService().user, child: MaterialApp( debugShowCheckedModeBanner: false, theme: new ThemeData(canvasColor: Color(0xFF008604)), home: Wrapper(), ), ); } }
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/shared/loading.dart
import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; class Loading extends StatelessWidget { @override Widget build(BuildContext context) { return Container( color: Color(0xFF008604), child: Center( child: SpinKitFadingCube( color: Color(0xFF00EE45), size: 50.0, ), ) ); } }
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/shared/constants.dart
import 'package:flutter/material.dart'; const textInputDecoration = InputDecoration( hintStyle: TextStyle(color: Colors.white), border: OutlineInputBorder(), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(15)), borderSide: BorderSide(color: Color(0xFF00EE45), width: 3.0) ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(15)), borderSide: BorderSide(color: Color(0xFF00EE45), width: 2.0) ), );
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/models/place.dart
class Place { final String name; final int tokenAvailable; final int totalPeople; final String address; final int time; final String coverPic; final String galleryPic1; final String galleryPic2; final String galleryPic3; Place({ this.name, this.tokenAvailable, this.totalPeople, this.address, this.time, this.coverPic, this.galleryPic1, this.galleryPic2, this.galleryPic3 }); } class PlaceData { final String uid; final String name; final int tokenAvailable; final int totalPeople; final String address; final int time; final String coverPic; final String galleryPic1; final String galleryPic2; final String galleryPic3; PlaceData({this.uid, this.name, this.tokenAvailable, this.totalPeople, this.address, this.time, this.coverPic, this.galleryPic1, this.galleryPic2, this.galleryPic3 }); }
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/models/user.dart
class User { final String uid; final String email; final String status; final String queueAt; final int token; final String time; final int eta; User({ this.uid, this.email, this.status, this.queueAt, this.token, this.time, this.eta }); }
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/services/auth.dart
import 'package:VirQ/models/user.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'database.dart'; class AuthService { final FirebaseAuth _auth = FirebaseAuth.instance; User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid) : null; } Stream<User> get user { return _auth.onAuthStateChanged //.map((FirebaseUser user) => _userFromFirebaseUser(user)); .map(_userFromFirebaseUser); } Future signInAnon() async { try { AuthResult result = await _auth.signInAnonymously(); FirebaseUser user = result.user; return _userFromFirebaseUser(user); } catch(e) { print(e.toString()); return null; } } Future signInWithEmailAndPassword(String email, String password) async { try { AuthResult result = await _auth.signInWithEmailAndPassword(email: email, password: password); FirebaseUser user = result.user; return _userFromFirebaseUser(user); } catch(e) { print(e.toString()); return null; } } Future registerWithEmailAndPassword(String email, String password) async { try { AuthResult result = await _auth.createUserWithEmailAndPassword(email: email, password: password); FirebaseUser user = result.user; //await DatabaseService(uid: user.uid).updatePlaceData('abc',0,0); await UserDatabaseService(uid: user.uid).updateUserData(email, 'false','none', 0, 'none', 0); print(user.uid); return _userFromFirebaseUser(user); } catch(e) { print(e.toString()); return null; } } Future signOut() async { try { return await _auth.signOut(); } catch(e) { print(e.toString()); return null; } } }
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/services/database.dart
import 'package:VirQ/models/place.dart'; import 'package:VirQ/models/user.dart'; import "package:cloud_firestore/cloud_firestore.dart"; class DatabaseService { final String uid; DatabaseService({ this.uid }); final CollectionReference placesCollection = Firestore.instance.collection('places'); Future updatePlaceData(String name, int tokenAvailable, int totalPeople) async { return await placesCollection.document(uid).setData({ 'name': name, 'tokenAvailable': tokenAvailable, 'totalPeople': totalPeople, }); } List<Place> _placeListFromSnapshot(QuerySnapshot snapshot) { return snapshot.documents.map((doc){ return Place( name: doc.data['name'] ?? '', tokenAvailable: doc.data['tokenAvailable'] ?? 0, totalPeople: doc.data['totalPeople'] ?? 0, address: doc.data['address'] ?? '', coverPic: doc.data['coverPic'] ?? '', galleryPic1: doc.data['galleryPic1'] ?? '', galleryPic2: doc.data['galleryPic2'] ?? '', galleryPic3: doc.data['galleryPic3'] ?? '', ); }).toList(); } PlaceData _placeDataFromSnapshot(DocumentSnapshot snapshot){ return PlaceData( uid: uid, name: snapshot.data['name'], tokenAvailable: snapshot.data['tokenAvailable'], totalPeople: snapshot.data['totalPeople'], address: snapshot.data['address'], coverPic: snapshot.data['coverPic'], galleryPic1: snapshot.data['galleryPic1'], galleryPic2: snapshot.data['galleryPic2'], galleryPic3: snapshot.data['galleryPic3'], ); } Stream<List<Place>> get places { return placesCollection.snapshots() .map(_placeListFromSnapshot); } Stream<PlaceData> get placeData { return placesCollection.document(uid).snapshots() .map(_placeDataFromSnapshot); } } class UserDatabaseService { final String uid; UserDatabaseService({ this.uid }); final CollectionReference userCollection = Firestore.instance.collection('users'); Future updateUserData(String email, String status, String queueAt, int token, String time, int eta) async { return await userCollection.document(uid).setData({ 'email': email, 'status': status, 'queueAt': queueAt, 'token': token, 'time': time, 'eta': eta, }); } List<User> _userListFromSnapshot(QuerySnapshot snapshot) { return snapshot.documents.map((doc){ return User( uid: doc.documentID ?? '', email: doc.data['email'] ?? 0, status: doc.data['status'] ?? 0, queueAt: doc.data['queueAt'] ?? '', token: doc.data['token'] ?? '', time: doc.data['time'] ?? '', eta: doc.data['eta'] ?? '', ); }).toList(); } Stream<List<User>> get users { return userCollection.snapshots() .map(_userListFromSnapshot); } }
0
mirrored_repositories/VirQ/lib
mirrored_repositories/VirQ/lib/screens/wrapper.dart
import 'package:VirQ/screens/authenticate/authenticate.dart'; import 'package:VirQ/screens/home/home.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:VirQ/models/user.dart'; class Wrapper extends StatelessWidget { @override Widget build(BuildContext context) { final user = Provider.of<User>(context); print(user); if(user == null){ return Authenticate(); } else { return Home(); } } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/authenticate/register.dart
import 'package:VirQ/services/auth.dart'; import 'package:VirQ/shared/constants.dart'; import 'package:VirQ/shared/loading.dart'; import 'package:flutter/material.dart'; class Register extends StatefulWidget { final Function toggleView; Register({ this.toggleView }); @override _RegisterState createState() => _RegisterState(); } class _RegisterState extends State<Register> { final AuthService _auth = AuthService(); final _formKey = GlobalKey<FormState>(); bool loading = false; String email = ''; String password = ''; String error = ''; @override Widget build(BuildContext context) { return loading ? Loading() : Scaffold( resizeToAvoidBottomInset: false, backgroundColor: Color(0xFF008604), body: Container( margin: EdgeInsets.only(left:50, right:50, top:200, bottom: 40), child: Form( key: _formKey, child: Column( children: <Widget>[ TextFormField( decoration: textInputDecoration.copyWith(hintText: 'Email', hintStyle: TextStyle(color: Color(0xFF470045))), style: TextStyle(color: Colors.white), validator: (val) => val.isEmpty ? 'Enter an email' : null, onChanged: (val) { setState(() => email = val); } ), SizedBox(height: 20.0), TextFormField( decoration: textInputDecoration.copyWith(hintText: 'Password', hintStyle: TextStyle(color: Color(0xFF470045))), style: TextStyle(color: Colors.white), obscureText: true, validator: (val) => val.length < 6 ? 'Enter a password with atleast 6 characters' : null, onChanged: (val) { setState(() => password = val); } ), SizedBox(height: 12.0), Text( error, style: TextStyle(color: Colors.red, fontSize: 14.0), ), SizedBox(height: 20.0, width: 30.0), RaisedButton( padding: EdgeInsets.fromLTRB(27, 10, 27, 10), color: Color(0xFF470045), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), child: Text( 'Sign Up', style: TextStyle(color: Colors.white), ), onPressed: () async { if (_formKey.currentState.validate()){ setState(() => loading = true); dynamic result = await _auth.registerWithEmailAndPassword(email, password); if(result == null) { setState(() { error = 'Please provide a valid email'; loading = false; }); } } } ), SizedBox(height: 20.0), RaisedButton( elevation: 0, hoverElevation: 0, focusElevation: 0, highlightElevation: 0, color: Color(0xFF008604), child: Text( 'Already have an account? Sign In', style: TextStyle(color: Colors.white), ), onPressed: () { widget.toggleView(); } ), ], ) ) ) ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/authenticate/authenticate.dart
import 'package:VirQ/screens/authenticate/sign_in.dart'; import 'package:flutter/material.dart'; import 'package:VirQ/screens/authenticate/register.dart'; class Authenticate extends StatefulWidget { @override _AuthenticateState createState() => _AuthenticateState(); } class _AuthenticateState extends State<Authenticate> { bool showSignIn = true; void toggleView() { setState(() => showSignIn = !showSignIn); } @override Widget build(BuildContext context) { if (showSignIn) { return SignIn(toggleView: toggleView); } else { return Register(toggleView: toggleView); } } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/authenticate/sign_in.dart
import 'package:VirQ/services/auth.dart'; import 'package:VirQ/shared/loading.dart'; import 'package:flutter/material.dart'; import 'package:VirQ/shared/constants.dart'; class SignIn extends StatefulWidget { final Function toggleView; SignIn({ this.toggleView }); @override _SignInState createState() => _SignInState(); } class _SignInState extends State<SignIn> { final AuthService _auth = AuthService(); final _formKey = GlobalKey<FormState>(); bool loading = false; String email = ''; String password = ''; String error = ''; @override Widget build(BuildContext context) { return loading ? Loading() : Scaffold( resizeToAvoidBottomInset: false, backgroundColor: Color(0xFF008604), body: Container( margin: EdgeInsets.only(left:50, right:50, top:200, bottom: 40), child: Form( key: _formKey, child: Column( children: <Widget>[ TextFormField( decoration: textInputDecoration.copyWith(hintText: 'Email', hintStyle: TextStyle(color: Color(0xFF470045))), style: TextStyle(color: Colors.white), validator: (val) => val.isEmpty ? 'Enter an email' : null, onChanged: (val) { setState(() => email = val); } ), SizedBox(height: 20.0), TextFormField( decoration: textInputDecoration.copyWith(hintText: 'Password', hintStyle: TextStyle(color: Color(0xFF470045))), style: TextStyle(color: Colors.white), validator: (val) => val.length < 6 ? 'Enter a password with atleast 6 characters' : null, obscureText: true, onChanged: (val) { setState(() => password = val); } ), SizedBox(height: 12.0), Text( error, style: TextStyle(color: Colors.red, fontSize: 14.0), ), SizedBox(height: 20.0, width: 30.0), RaisedButton( padding: EdgeInsets.fromLTRB(30, 10, 30, 10), color: Color(0xFF470045), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), child: Text( 'Sign In', style: TextStyle(color: Colors.white), ), onPressed: () async { if (_formKey.currentState.validate()){ setState(() => loading = true); dynamic result = await _auth.signInWithEmailAndPassword(email, password); if(result == null) { setState(() { error = 'Please provide valid credentials'; loading = false; }); } } } ), SizedBox(height: 20.0), RaisedButton( elevation: 0, hoverElevation: 0, focusElevation: 0, highlightElevation: 0, color: Color(0xFF008604), child: Text( 'New here? Sign Up', style: TextStyle(color: Colors.white), ), onPressed: () { widget.toggleView(); } ), ], ) ) ) ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/home/ticket_list.dart
import 'package:VirQ/services/database.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:ticket_pass_package/ticket_pass.dart'; //ignore: must_be_immutable class TicketList extends StatefulWidget { String value; TicketList({this.value}); @override _TicketListState createState() => _TicketListState(value); } class _TicketListState extends State<TicketList> { int userETA; int placeTime; updateUserData() async { String place; int userDeleted; final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseUser user = await auth.currentUser(); String uid = user.uid; UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.documentID == uid) { place = doc.data['queueAt']; userDeleted = doc.data['token']; //print(place); Firestore.instance.collection('users').document(doc.documentID).updateData({ "status": 'false', "queueAt": 'none', "token": 0, "time": 'none', "eta": 0, }).then((result) { print("User data updated"); }).catchError((onError){ print("Received an error"); }); DatabaseService().placesCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.data['name']==place) { placeTime = doc.data['time']; Firestore.instance.collection('places').document(doc.documentID).updateData({ "tokenAvailable": FieldValue.increment(-1), "totalPeople": FieldValue.increment(-1), }).then((result){ print("Place data updated"); }).catchError((onError){ print("Received an error"); }); Firestore.instance.collection('places'+'/'+doc.documentID+'/queue').document(uid).delete(); } }); }); updateQueue(uid, place, userDeleted); } }); }); } updateQueue(uid, place, deleted) { UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.documentID != uid && doc.data['queueAt']==place && doc.data['token'] > deleted) { userETA = doc.data['eta']; //print(place); Firestore.instance.collection('users').document(doc.documentID).updateData({ "token": FieldValue.increment(-1), "eta": (doc.data['token']-2)*placeTime, }).then((result) { print(doc.data['email']+" : data updated"); }).catchError((onError){ print("Received an error"); }); } }); }); localNotification.cancelAll(); } FlutterLocalNotificationsPlugin localNotification; @override void initState() { super.initState(); var androidInitialize = new AndroidInitializationSettings("ic_launcher"); var iOSInitialize = new IOSInitializationSettings(); var initializationSettings = new InitializationSettings(android: androidInitialize, iOS: iOSInitialize); localNotification = new FlutterLocalNotificationsPlugin(); localNotification.initialize(initializationSettings); } Future _showNotification(placeName, tokenNumber, eta) async { var androidDetails = new AndroidNotificationDetails("channelId", "Local Notification", "channelDescription", importance: Importance.high, onlyAlertOnce: true); var iosDetails = new IOSNotificationDetails(); var generalNotificationDetails = new NotificationDetails(android: androidDetails, iOS: iosDetails); localNotification.cancel(1); localNotification.cancel(2); await localNotification.show(0, "Joined queue at "+placeName, "Token : "+tokenNumber.toString() + " | ETA : "+eta.toString()+" min", generalNotificationDetails); } Future _showNotificationReady(placeName, tokenNumber, eta) async { var androidDetails = new AndroidNotificationDetails("channelId", "Local Notification", "channelDescription", importance: Importance.high, onlyAlertOnce: true); var iosDetails = new IOSNotificationDetails(); var generalNotificationDetails = new NotificationDetails(android: androidDetails, iOS: iosDetails); localNotification.cancel(0); localNotification.cancel(2); await localNotification.show(1, "You are up next at "+placeName+". Get Ready !", "Token : "+tokenNumber.toString() + " | ETA : "+eta.toString()+" min", generalNotificationDetails); } Future _showNotificationTurn(placeName, tokenNumber, eta) async { var androidDetails = new AndroidNotificationDetails("channelId", "Local Notification", "channelDescription", importance: Importance.high, onlyAlertOnce: true); var iosDetails = new IOSNotificationDetails(); var generalNotificationDetails = new NotificationDetails(android: androidDetails, iOS: iosDetails); localNotification.cancel(0); localNotification.cancel(1); await localNotification.show(2, "It's your turn at "+placeName, "Get in there !", generalNotificationDetails); } String value; _TicketListState(this.value); Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Tickets'), backgroundColor: Color(0xFF008604), ), //floatingActionButton: null, backgroundColor: Color(0xFF008604), body: Align( alignment: Alignment.topCenter, child: Container( margin: EdgeInsets.symmetric(vertical: 25.0, horizontal: 10.0), child: StreamBuilder( stream: Firestore.instance.collection('users').document(value).snapshots(), builder: (context, snapshot) { if(snapshot.data['status']=='false') { localNotification.cancel(0); return Container( margin: EdgeInsets.symmetric(vertical: 25.0, horizontal: 10.0), child: Center( child: Text( "You haven't joined any queue", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: 18, ), ), ), ); } else { if(snapshot.data['token']==2) { _showNotificationReady(snapshot.data['queueAt'], snapshot.data['token'], snapshot.data['eta']); } else if(snapshot.data['token']==1) { _showNotificationTurn(snapshot.data['queueAt'], snapshot.data['token'], snapshot.data['eta']); } else { _showNotification(snapshot.data['queueAt'], snapshot.data['token'], snapshot.data['eta']); } return TicketPass( alignment: Alignment.center, animationDuration: Duration(seconds: 1), expandedHeight: 400, expandIcon: FlatButton( child: Tooltip( message: "Leave", child: Icon(Icons.delete, color: Colors.red), ), onPressed: () async { updateUserData(); } //size: 20, ), expansionTitle: Text( '', style: TextStyle( fontWeight: FontWeight.w600, ), ), purchaserList: [], //separatorColor: Colors.black, //separatorHeight: 2.0, color: Colors.white, curve: Curves.easeOut, titleColor: Color(0xFF470045), shrinkIcon: Align( alignment: Alignment.centerRight, child: CircleAvatar( maxRadius: 14, child: Icon( Icons.keyboard_arrow_up, color: Colors.white, size: 20, ), ), ), ticketTitle: Text( '', style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w600, fontSize: 18, ), ), titleHeight: 50, width: 350, height: 220, shadowColor: Colors.green, elevation: 8, shouldExpand: true, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 45.0, vertical: 15), child: Container( height: 140, child: Padding( padding: const EdgeInsets.symmetric(vertical: 2.0), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Expanded( child: Container( child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( 'ETA', style: TextStyle( color: Colors.black.withOpacity(0.5)), ), Text( snapshot.data['eta'].toString()+" min", style: TextStyle( fontWeight: FontWeight.w600), ), ], ), ), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( 'PLACE', style: TextStyle( color: Colors.black.withOpacity(0.5), ), ), Text( snapshot.data['queueAt'], overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( fontWeight: FontWeight.w600, ), ), ], ), ), ], ), ), ), Expanded( child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( 'ISSUED', style: TextStyle( color: Colors.black.withOpacity(0.5)), ), Text( snapshot.data['time'].substring(0,10), style: TextStyle( fontWeight: FontWeight.w600), ), ], ), ), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( 'TOKEN', style: TextStyle( color: Colors.black.withOpacity(0.5)), ), Text( snapshot.data['token'].toString(), style: TextStyle( fontWeight: FontWeight.w600), ), ], ), ), ], ), ), ], ), ), ), ), ); } }, ) ) ) ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/home/place_tile.dart
import 'package:VirQ/screens/home/queue_details_form.dart'; import 'package:VirQ/services/database.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:VirQ/models/place.dart'; //ignore: must_be_immutable class PlaceTile extends StatelessWidget { final Place place; PlaceTile({ this.place }); getUserById(String id) { DatabaseService().placesCollection.document(id).get().then((DocumentSnapshot doc) { print(doc.data); }); } Place value; @override Widget build(BuildContext context) { void showQueueDetailsPanel() { showModalBottomSheet(context: context, builder: (context) { return Container( color: Color(0xFF008604), padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 40.0), child: QueueDetails(value: place), ); }); } return Padding( padding: EdgeInsets.only(top: 8.0), child: Card( color: Color(0xFF008604), shape: RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular(15)), side: BorderSide(width:2, color: Color(0xFF00B906))), margin: EdgeInsets.fromLTRB(20.0, 6.0, 20.0, 0.0), child: ListTile( isThreeLine: true, leading: CircleAvatar( child: Image.network(place.coverPic), radius: 25.0, backgroundColor: Color(0xFF008604), ), title: Text(place.name, style: TextStyle(color: Colors.white)), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text(""), Text("Token "+place.tokenAvailable.toString(), style: TextStyle(color: Colors.white)), ], ), trailing: FlatButton.icon( icon: Icon(Icons.add_box_rounded, color: Colors.white), label: Text('View', style: TextStyle(color: Colors.white)), onPressed: () async { showQueueDetailsPanel(); }, ) ), ) ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/home/qr_scan.dart
import 'package:barcode_scan/barcode_scan.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class QRScan extends StatefulWidget { @override _QRScanState createState() => _QRScanState(); } class _QRScanState extends State<QRScan> { String result = ''; Future _scanQR() async { try { String qrResult = await BarcodeScanner.scan(); setState(() { result = qrResult; }); } on PlatformException catch (ex) { if(ex.code == BarcodeScanner.CameraAccessDenied) { setState(() { result = "Camera permission was denied"; }); } else { setState(() { result = "Unkown error $ex"; }); } } on FormatException { setState(() { result = "Couldn't scan anything"; }); } catch (ex) { setState(() { result = "Unknown Error $ex"; }); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Scan QR Code"), ), body: Center( child: Text( result, style: new TextStyle(fontSize: 30.0, fontWeight: FontWeight.bold), ), ), floatingActionButton: FloatingActionButton.extended( icon: Icon(Icons.camera_alt), label: Text("Scan"), onPressed: _scanQR, ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/home/place_list.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:VirQ/models/place.dart'; import 'package:VirQ/screens/home/place_tile.dart'; class PlaceList extends StatefulWidget { @override _PlaceListState createState() => _PlaceListState(); } class _PlaceListState extends State<PlaceList> { @override Widget build(BuildContext context) { final places = Provider.of<List<Place>>(context); return ListView.builder( itemCount: places?.length ?? 0, itemBuilder: (context, index) { return PlaceTile(place: places[index]); }, ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/home/queue_details_form.dart
import 'dart:async'; import 'package:VirQ/models/place.dart'; import 'package:VirQ/services/database.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:fluttertoast/fluttertoast.dart'; //ignore: must_be_immutable class QueueDetails extends StatefulWidget { final Place value; QueueDetails({this.value}); @override _QueueDetailsState createState() => _QueueDetailsState(value); } class _QueueDetailsState extends State<QueueDetails> { Place value; _QueueDetailsState(this.value); final _formKey = GlobalKey<FormState>(); String uid; String userEmail; int userETA; int userToken; String userStatus; String userPlace; String name; int tokenAvailable; int totalPeople; String place; int tokenUser; int time; updatePlaceData(name) { DatabaseService().placesCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot docu) { if(docu.data['name']==name) { place = docu.data['name']; tokenUser = docu.data['tokenAvailable']; time = docu.data['time']; Firestore.instance.collection('places').document(docu.documentID).updateData({ "tokenAvailable": FieldValue.increment(1), "totalPeople": FieldValue.increment(1), }).then((result){ print("Place data updated"); }).catchError((onError){ print("Received an error"); }); _showNotification(place, tokenUser, (tokenUser-1)*time); Firestore.instance.collection('places'+'/'+docu.documentID+'/queue').document(uid).setData({ "email": userEmail, "token": tokenUser, "eta": (tokenUser-1)*time, }); } }); }); } String placeName; int placeToken; searchPlaceData(name) { DatabaseService().placesCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.data['name']==name) { placeName = doc.data['name']; placeToken = doc.data['tokenAvailable']; } } ); } ); } updateUserData() async { final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseUser user = await auth.currentUser(); uid = user.uid; UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.documentID == uid && doc.data['status']=='false') { updatePlaceData(value.name); UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { Firestore.instance.collection('users').document(uid).updateData({ "status": "true", "queueAt": place, "token": tokenUser, "time": DateTime.now().toString(), "eta": (tokenUser-1)*time, }).then((result) { print(doc.data['email']+" data updated"); }).catchError((onError){ print(doc.data['email']+" : Received an error"); }); }); }); userEmail = doc.data['email']; userETA = doc.data['eta']; Navigator.pop(context); Fluttertoast.showToast( msg: "Your slot details are available inside Tickets section", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM, ); } else if(doc.documentID == uid && doc.data['status']=='true') { print(doc.data['email']+" already present in some other queue"); Navigator.pop(context); Fluttertoast.showToast( msg: "You are already enrolled in a queue", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, ); } }); }); } Timer timer; void updateETA() { UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.documentID == uid && doc.data['status'] == 'true') { userETA = doc.data['eta']-1; userToken = doc.data['token']; userStatus = doc.data['status']; userPlace = doc.data['queueAt']; if(userETA > 0 && userToken != 1 && userStatus == 'true') { Firestore.instance.collection('users').document(uid).updateData({ "eta": FieldValue.increment(-1), }); print("ETA"+userETA.toString()); _showNotification(userPlace, userToken, userETA); print("RUN1"); } else if(userETA == 0 && userToken != 1 && userStatus == 'true') { Firestore.instance.collection('users').document(uid).updateData({ "eta": 2, }); _showNotification(userPlace, userToken, userETA+2); print("RUN2"); } else if(userETA == -1 && userToken == 1 && userStatus == 'true') { _showNotification(userPlace, userToken, userETA+1); print("RUN3"); } } }); }); } FlutterLocalNotificationsPlugin localNotification; @override void initState() { super.initState(); timer = Timer.periodic(Duration(minutes: 1), (Timer timer) => updateETA()); var androidInitialize = new AndroidInitializationSettings("ic_launcher"); var iOSInitialize = new IOSInitializationSettings(); var initializationSettings = new InitializationSettings(android: androidInitialize, iOS: iOSInitialize); localNotification = new FlutterLocalNotificationsPlugin(); localNotification.initialize(initializationSettings); } Future _showNotification(placeName, tokenNumber, eta) async { var androidDetails = new AndroidNotificationDetails("channelId", "Local Notification", "channelDescription", importance: Importance.high, onlyAlertOnce: true); var iosDetails = new IOSNotificationDetails(); var generalNotificationDetails = new NotificationDetails(android: androidDetails, iOS: iosDetails); var androidInitialize = new AndroidInitializationSettings("ic_launcher"); var iOSInitialize = new IOSInitializationSettings(); var initializationSettings = new InitializationSettings(android: androidInitialize, iOS: iOSInitialize); localNotification = new FlutterLocalNotificationsPlugin(); localNotification.initialize(initializationSettings); if(tokenNumber == 2) { localNotification.cancel(0); localNotification.cancel(2); await localNotification.show(1, "You are up next at "+placeName+". Get Ready !", "Token : "+tokenNumber.toString() + " | ETA : "+eta.toString()+" min", generalNotificationDetails); } else if(tokenNumber == 1) { localNotification.cancel(0); localNotification.cancel(1); await localNotification.show(2, "It's your turn at "+placeName, "Get in there !", generalNotificationDetails); } else { localNotification.cancel(1); localNotification.cancel(2); await localNotification.show(0, "Joined queue at "+placeName, "Token : "+tokenNumber.toString() + " | ETA : "+eta.toString()+" min", generalNotificationDetails); } } @override Widget build(BuildContext context) { return Form( key: _formKey, child: Column( children: <Widget>[ Text( value.name, style: TextStyle(fontSize: 25.0, color: Colors.white, fontWeight: FontWeight.w900), ), Text( '', ), Text( value.address, style: TextStyle(fontSize: 15.0, color: Colors.white), ), Text( '', ), Text( "Token available : "+value.tokenAvailable.toString(), style: TextStyle(fontSize: 15.0, color: Colors.white), ), //Image.network(value.galleryPic1, height: MediaQuery.of(context).size.width * 0.5, width: MediaQuery.of(context).size.width * 0.5), Container( padding: EdgeInsets.fromLTRB(0, 3, 0, 5), //height: 140, height: 195, child: ListView( scrollDirection: Axis.horizontal, children: <Widget>[ Container( padding: EdgeInsets.fromLTRB(5, 5, 5, 5), height: 195, width: 200, child: Image.network(value.galleryPic1) ), Container( padding: EdgeInsets.fromLTRB(5, 5, 5, 5), height: 195, width: 200, child: Image.network(value.galleryPic2) ), Container( padding: EdgeInsets.fromLTRB(5, 5, 5, 5), height: 195, width: 200, child: Image.network(value.galleryPic3) ), ], ), ), //SizedBox(height: 20.0), RaisedButton( //padding: EdgeInsets.fromLTRB(27, 10, 27, 10), color: Color(0xFF470045), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), child: Text( 'Join Queue', style: TextStyle(color: Colors.white), ), onPressed: () async { //updateData(value); updateUserData(); } ), ], ), ); } }
0
mirrored_repositories/VirQ/lib/screens
mirrored_repositories/VirQ/lib/screens/home/home.dart
import 'package:VirQ/screens/home/ticket_list.dart'; import 'package:VirQ/services/auth.dart'; import 'package:barcode_scan/barcode_scan.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:VirQ/services/database.dart'; import 'package:flutter/services.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; import 'package:VirQ/models/place.dart'; import 'package:VirQ/screens/home/place_list.dart'; //ignore: must_be_immutable class Home extends StatelessWidget { String place; int tokenUser; int time; updatePlaceData(name) { DatabaseService().placesCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot docu) { if(docu.documentID==name) { place = docu.data['name']; tokenUser = docu.data['tokenAvailable']; time = docu.data['time']; Firestore.instance.collection('places').document(name).updateData({ "tokenAvailable": FieldValue.increment(1), "totalPeople": FieldValue.increment(1), }).then((result){ print("Place data updated"); }).catchError((onError){ print("Received an error"); }); _showNotification(place, tokenUser, (tokenUser-1)*time); } }); }); } updateUserData(qrResult) async { final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseUser user = await auth.currentUser(); String uid = user.uid; UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { if(doc.documentID == uid && doc.data['status']=='false') { updatePlaceData(qrResult); UserDatabaseService().userCollection.getDocuments().then((QuerySnapshot snapshot) { snapshot.documents.forEach((DocumentSnapshot doc) { Firestore.instance.collection('users').document(uid).updateData({ "status": "true", "queueAt": place, "token": tokenUser, "time": DateTime.now().toString(), "eta": (tokenUser-1)*time, }).then((result) { print(doc.data['email']+" data updated"); }).catchError((onError){ print(doc.data['email']+" : Received an error"); }); }); }); Fluttertoast.showToast( msg: "Your slot details are available inside Tickets section", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM, ); } else if(doc.documentID == uid && doc.data['status']=='true') { Fluttertoast.showToast( msg: "You are already enrolled in a queue", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM, ); } }); }); } String qrResult = ''; Future _scanQR() async { try { String qrResult = await BarcodeScanner.scan(); qrResult = qrResult; print(qrResult); updateUserData(qrResult); } on PlatformException catch (ex) { if(ex.code == BarcodeScanner.CameraAccessDenied) { qrResult = "Camera permission was denied"; } else { qrResult = "Unkown error $ex"; } } on FormatException { qrResult = "Couldn't scan anything"; } catch (ex) { qrResult = "Unknown Error $ex"; } } FlutterLocalNotificationsPlugin localNotification; Future _showNotification(placeName, tokenNumber, eta) async { var androidInitialize = new AndroidInitializationSettings("ic_launcher"); var iOSInitialize = new IOSInitializationSettings(); var initializationSettings = new InitializationSettings(android: androidInitialize, iOS: iOSInitialize); localNotification = new FlutterLocalNotificationsPlugin(); localNotification.initialize(initializationSettings); var androidDetails = new AndroidNotificationDetails("channelId", "Local Notification", "channelDescription", importance: Importance.high, onlyAlertOnce: true); var iosDetails = new IOSNotificationDetails(); var generalNotificationDetails = new NotificationDetails(android: androidDetails, iOS: iosDetails); if(tokenNumber == 2) { localNotification.cancel(0); localNotification.cancel(2); await localNotification.show(1, "You are up next at "+placeName+". Get Ready !", "Token : "+tokenNumber.toString() + " | ETA : "+eta.toString()+" min", generalNotificationDetails); } else if(tokenNumber == 1) { localNotification.cancel(0); localNotification.cancel(1); await localNotification.show(2, "It's your turn at "+placeName, "Get in there !", generalNotificationDetails); } else { localNotification.cancel(1); localNotification.cancel(2); await localNotification.show(0, "Joined queue at "+placeName, "Token : "+tokenNumber.toString() + " | ETA : "+eta.toString()+" min", generalNotificationDetails); } } @override Widget build(BuildContext context) { return StreamProvider<List<Place>>.value( value: DatabaseService().places, child: Scaffold( drawer: SideDrawer(), appBar: AppBar( backgroundColor: Color(0xFF008604), actions: <Widget>[ IconButton( tooltip: "Scan QR code", icon: Icon( Icons.qr_code_scanner, color: Colors.white, ), onPressed: () { _scanQR(); }, ) ] ), body: PlaceList(), backgroundColor: Color(0xFF008604), ), ); } } //ignore: must_be_immutable class SideDrawer extends StatelessWidget { final AuthService _auth = AuthService(); String uid; String value; Future<void> userData(BuildContext context) async { final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseUser user = await auth.currentUser(); uid = user.uid; return ticketScreen(context, uid); } Future<void> ticketScreen(BuildContext context, String uid) async { await Navigator.push( context, MaterialPageRoute( builder: (context) => TicketList(value: uid), ), ); } @override Widget build(BuildContext context) { return Drawer( child: Column( children: <Widget>[ DrawerHeader( child: Center( ), decoration: BoxDecoration( color: Color(0xFF470045), ), ), ListTile( leading: Icon(Icons.account_balance_wallet_rounded, color: Colors.white), title: Text('Tickets', style: TextStyle(color: Colors.white)), onTap: () { userData(context); }, ), ListTile( leading: Icon(Icons.exit_to_app, color: Colors.white), title: Text('Sign Out', style: TextStyle(color: Colors.white)), onTap: () async { await _auth.signOut(); }, ), ], ), ); } }
0
mirrored_repositories/VirQ
mirrored_repositories/VirQ/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:VirQ/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/destini_flutter
mirrored_repositories/destini_flutter/lib/story.dart
class Story{ String storyTitle=''; String choice1=''; String choice2=''; Story({String q='', String c1='', String c2=''}){ storyTitle=q; choice1=c1; choice2=c2; } }
0
mirrored_repositories/destini_flutter
mirrored_repositories/destini_flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:destini/storybrain.dart'; void main() => runApp(Destini()); class Destini extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.dark(), home: StoryPage(), ); } } StoryBrain storyBrain= StoryBrain(); class StoryPage extends StatefulWidget { _StoryPageState createState() => _StoryPageState(); } class _StoryPageState extends State<StoryPage> { @override Widget build(BuildContext context) { return Scaffold( body: Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage('images/galaxy.png') ), ), padding: EdgeInsets.symmetric(vertical: 50.0, horizontal: 15.0), constraints: BoxConstraints.expand(), child: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Expanded( flex: 12, child: Center( child: Text( storyBrain.getStory(), style: TextStyle( fontSize: 25.0, ), ), ), ), Expanded( flex: 2, child: TextButton( onPressed: () { setState((){ storyBrain.nextStory(1); }); //Choice 1 made by user. }, style: TextButton.styleFrom( backgroundColor: Colors.red, ), child: Text( storyBrain.getChoice1(), style: TextStyle( fontSize: 20.0, ), ), ), ), SizedBox( height: 20.0, ), Expanded( flex: 2, //TODO: Step 26 - Use a Flutter Visibility Widget to wrap this FlatButton. //TODO: Step 28 - Set the "visible" property of the Visibility Widget to equal the output from the buttonShouldBeVisible() method in the storyBrain. child: Visibility( visible: storyBrain.isVisible(), child: TextButton( onPressed: () { setState((){ storyBrain.nextStory(2); });//Choice 2 made by user. }, style: TextButton.styleFrom( backgroundColor: Colors.blue, ), child: Text( storyBrain.getChoice2(), style: TextStyle( fontSize: 20.0, color: Colors.red, ), ), ), ), ), ], ), ), ), ); } } //TODO: Step 24 - Run the app and try to figure out what code you need to add to this file to make the story change when you press on the choice buttons. //TODO: Step 29 - Run the app and test it against the Story Outline to make sure you've completed all the steps. The code for the completed app can be found here: https://github.com/londonappbrewery/destini-challenge-completed/
0
mirrored_repositories/destini_flutter
mirrored_repositories/destini_flutter/lib/storybrain.dart
import 'package:destini/story.dart'; class StoryBrain { int choiceNumber=0; int _sNumber = 0; List<Story> _stories = [ Story( q: 'Your car has blown a tire on a winding road in the middle of nowhere with no cell phone reception. You decide to hitchhike. A rusty pickup truck rumbles to a stop next to you. A man with a wide brimmed hat with soulless eyes opens the passenger door for you and asks: "Need a ride, boy?".', c1: 'I\'ll hop in. Thanks for the help!', c2: 'Better ask him if he\'s a murderer first.'), Story( q: 'He nods slowly, unphased by the question.', c1: 'At least he\'s honest. I\'ll climb in.', c2: 'Wait, I know how to change a tire.'), Story( q: 'As you begin to drive, the stranger starts talking about his relationship with his mother. He gets angrier and angrier by the minute. He asks you to open the glovebox. Inside you find a bloody knife, two severed fingers, and a cassette tape of Elton John. He reaches for the glove box.', c1: 'I love Elton John! Hand him the cassette tape.', c2: 'It\'s him or me! You take the knife and stab him.'), Story( q: 'What? Such a cop out! Did you know traffic accidents are the second leading cause of accidental death for most adult age groups?', c1: 'Restart', c2: ''), Story( q: 'As you smash through the guardrail and careen towards the jagged rocks below you reflect on the dubious wisdom of stabbing someone while they are driving a car you are in.', c1: 'Restart', c2: ''), Story( q: 'You bond with the murderer while crooning verses of "Can you feel the love tonight". He drops you off at the next town. Before you go he asks you if you know any good places to dump bodies. You reply: "Try the pier".', c1: 'Restart', c2: '') ]; String getStory(){ return _stories[_sNumber].storyTitle; } String getChoice1(){ return _stories[_sNumber].choice1; } String getChoice2(){ return _stories[_sNumber].choice2; } void nextStory(int choiceNumber){ if(_sNumber==0 && choiceNumber==1){ _sNumber=2; getStory(); getChoice1(); getChoice2(); }else if(_sNumber==0 && choiceNumber==2){ _sNumber=1; getStory(); getChoice1(); getChoice2(); }else if(_sNumber==1 && choiceNumber==1){ _sNumber=2; getStory(); getChoice1(); getChoice2(); }else if(_sNumber==1 && choiceNumber==2){ _sNumber=3; getStory(); getChoice1(); getChoice2(); }else if(_sNumber==2 && choiceNumber==1){ _sNumber=5; getStory(); getChoice1(); getChoice2(); }else if(_sNumber==2 && choiceNumber==2){ _sNumber=4; getStory(); getChoice1(); getChoice2(); }else if(_sNumber==3 || _sNumber==4 || _sNumber==5){ reset(_sNumber); } } void reset(int sNumber){ _sNumber=0; } bool isVisible(){ if(_sNumber==3 || _sNumber==4 || _sNumber==5){ return false; } else{ return true; } } }
0
mirrored_repositories/destini_flutter
mirrored_repositories/destini_flutter/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:destini/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/flutter-audio-recorder
mirrored_repositories/flutter-audio-recorder/lib/main.dart
import 'package:flutter/material.dart'; import 'package:intl/intl.dart' show DateFormat; import 'package:intl/date_symbol_data_local.dart'; import 'dart:io'; import 'dart:async'; import 'package:flutter_sound/flutter_sound.dart'; void main() { runApp(new AudioRecorder()); } class AudioRecorder extends StatefulWidget { @override _AudioRecorderState createState() => new _AudioRecorderState(); } class _AudioRecorderState extends State<AudioRecorder> { bool _isRecording = false; bool _isPlaying = false; StreamSubscription _recorderSubscription; StreamSubscription _dbPeakSubscription; StreamSubscription _playerSubscription; FlutterSound flutterSound; String _recorderTxt = '00:00:00'; String _playerTxt = '00:00:00'; double _dbLevel; double slider_current_position = 0.0; double max_duration = 1.0; @override void initState() { super.initState(); flutterSound = new FlutterSound(); flutterSound.setSubscriptionDuration(0.01); flutterSound.setDbPeakLevelUpdate(0.8); flutterSound.setDbLevelEnabled(true); initializeDateFormatting(); } void startRecorder() async { try { String path = await flutterSound.startRecorder(null); print('startRecorder: $path'); _recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) { DateTime date = new DateTime.fromMillisecondsSinceEpoch( e.currentPosition.toInt(), isUtc: true); String txt = DateFormat('mm:ss:SS', 'pt_BR').format(date); this.setState(() { this._recorderTxt = txt.substring(0, 8); }); }); _dbPeakSubscription = flutterSound.onRecorderDbPeakChanged.listen((value) { print("got update -> $value"); setState(() { this._dbLevel = value; }); }); this.setState(() { this._isRecording = true; }); } catch (err) { print('startRecorder error: $err'); } } void stopRecorder() async { try { String result = await flutterSound.stopRecorder(); print('stopRecorder: $result'); if (_recorderSubscription != null) { _recorderSubscription.cancel(); _recorderSubscription = null; } if (_dbPeakSubscription != null) { _dbPeakSubscription.cancel(); _dbPeakSubscription = null; } this.setState(() { this._isRecording = false; }); } catch (err) { print('stopRecorder error: $err'); } } void startPlayer() async { String path = await flutterSound.startPlayer(null); await flutterSound.setVolume(1.0); print('startPlayer: $path'); try { _playerSubscription = flutterSound.onPlayerStateChanged.listen((e) { if (e != null) { slider_current_position = e.currentPosition; max_duration = e.duration; DateTime date = new DateTime.fromMillisecondsSinceEpoch( e.currentPosition.toInt(), isUtc: true); String txt = DateFormat('mm:ss:SS', 'pt_BR').format(date); this.setState(() { this._isPlaying = true; this._playerTxt = txt.substring(0, 8); }); } }); } catch (err) { print('error: $err'); } } void stopPlayer() async { try { String result = await flutterSound.stopPlayer(); print('stopPlayer: $result'); if (_playerSubscription != null) { _playerSubscription.cancel(); _playerSubscription = null; } this.setState(() { this._isPlaying = false; }); } catch (err) { print('error: $err'); } } void pausePlayer() async { String result = await flutterSound.pausePlayer(); print('pausePlayer: $result'); } void resumePlayer() async { String result = await flutterSound.resumePlayer(); print('resumePlayer: $result'); } void seekToPlayer(int milliSecs) async { String result = await flutterSound.seekToPlayer(milliSecs); print('seekToPlayer: $result'); } @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData(primarySwatch: Colors.pink), home: Scaffold( appBar: AppBar( centerTitle: true, title: const Text('Audio Recorder'), ), body: ListView( children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: EdgeInsets.only(top: 24.0, bottom: 16.0), child: Text( this._recorderTxt, style: TextStyle( fontSize: 48.0, color: Colors.black, ), ), ), _isRecording ? LinearProgressIndicator( value: 100.0 / 160.0 * (this._dbLevel ?? 1) / 100, valueColor: AlwaysStoppedAnimation<Color>(Colors.green), backgroundColor: Colors.red, ) : Container() ], ), Row( children: <Widget>[ Container( width: 56.0, height: 56.0, margin: EdgeInsets.all(10.0), child: FloatingActionButton( onPressed: () { if (!this._isRecording) { return this.startRecorder(); } this.stopRecorder(); }, child: this._isRecording ? Icon(Icons.stop) : Icon(Icons.mic), ), ), ], mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, ), Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: EdgeInsets.only(top: 60.0, bottom: 16.0), child: Text( this._playerTxt, style: TextStyle( fontSize: 48.0, color: Colors.black, ), ), ), ], ), Row( children: <Widget>[ Container( width: 56.0, height: 56.0, margin: EdgeInsets.all(8.0), child: FloatingActionButton( onPressed: () { startPlayer(); }, child: Icon(Icons.play_arrow), ), ), Container( width: 56.0, height: 56.0, margin: EdgeInsets.all(8.0), child: FloatingActionButton( onPressed: () { pausePlayer(); }, child: Icon(Icons.pause), ), ), Container( width: 56.0, height: 56.0, margin: EdgeInsets.all(8.0), child: FloatingActionButton( onPressed: () { stopPlayer(); }, child: Icon(Icons.stop), ), ), ], mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, ), Container( height: 56.0, child: Slider( value: slider_current_position, min: 0.0, max: max_duration, onChanged: (double value) async { await flutterSound.seekToPlayer(value.toInt()); }, divisions: max_duration.toInt())) ], ), ), ); } }
0
mirrored_repositories/flutter-audio-recorder
mirrored_repositories/flutter-audio-recorder/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:audio_recorder/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(AudioRecorder()); // 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_mail_app
mirrored_repositories/flutter_mail_app/lib/profile.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', home: Profile(), ); } } class Profile extends StatefulWidget { Profile({Key key, this.title}) : super(key: key); final String title; @override _ProfileState createState() => _ProfileState(); } class _ProfileState extends State<Profile> { @override Widget build(BuildContext context) { return Scaffold( ); } }
0
mirrored_repositories/flutter_mail_app
mirrored_repositories/flutter_mail_app/lib/favorite.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', home: Favorite(), ); } } class Favorite extends StatefulWidget { Favorite({Key key, this.title}) : super(key: key); final String title; @override _FavoriteState createState() => _FavoriteState(); } class _FavoriteState extends State<Favorite> { @override Widget build(BuildContext context) { return Scaffold( ); } }
0
mirrored_repositories/flutter_mail_app
mirrored_repositories/flutter_mail_app/lib/search.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', home: Search(), ); } } class Search extends StatefulWidget { Search({Key key, this.title}) : super(key: key); final String title; @override _SearchState createState() => _SearchState(); } class _SearchState extends State<Search> { @override Widget build(BuildContext context) { return Scaffold( ); } }
0
mirrored_repositories/flutter_mail_app
mirrored_repositories/flutter_mail_app/lib/inbox.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', home: Inbox(), ); } } class Inbox extends StatefulWidget { Inbox({Key key, this.title}) : super(key: key); final String title; @override _InboxState createState() => _InboxState(); } class _InboxState extends State<Inbox> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.blue[50].withOpacity(0.5), body: SingleChildScrollView( child: Column( children: <Widget>[ Container( width: MediaQuery.of(context).size.width, height: 300.0, decoration: BoxDecoration( color: Colors.blue[600], borderRadius: BorderRadius.only( bottomRight: Radius.circular(40.0), bottomLeft: Radius.circular(40.0), )), child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.only( left: 30.0, right: 30.0, top: 70.0), child: Row( children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( "All Mails", style: TextStyle( color: Colors.white, fontSize: 26.0, fontWeight: FontWeight.bold, ), ), SizedBox( height: 10.0, ), Text( "You have got 3 new mails", style: TextStyle( color: Colors.blue[50], fontSize: 14.0), ) ], ), Spacer(), CircleAvatar( backgroundColor: Colors.white, child: Icon(Icons.add), ) ], ), ), SizedBox( height: 70.0, ), Stack( alignment: Alignment.center, overflow: Overflow.visible, children: <Widget>[ Container( height: 70.0, width: 300.0, decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(15.0)), ), Positioned( bottom: 10.0, child: Container( height: 70.0, width: 330.0, decoration: BoxDecoration( color: Colors.white70, borderRadius: BorderRadius.circular(15.0)), ), ), Positioned( bottom: 20.0, child: Container( height: 95.0, width: 350.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.0), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(10.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Image.asset( "assets/boy.png", height: 60.0, width: 60.0, ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Text( "Protorix Code", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), Spacer(), Text( "8:16 AM", style: TextStyle( color: Colors.grey, fontSize: 12.0), ), ], ), Text( "Your opinion matters", style: TextStyle( color: Colors.black, fontSize: 14.0), ), SizedBox( height: 3.0, ), Row( children: <Widget>[ Text( "You have a mail. Check it!", style: TextStyle( color: Colors.black, fontSize: 12.0), ), Spacer(), Icon( Icons.star_border, color: Colors.orange, size: 20.0, ) ], ) ], ), ), ) ], ), ), ), ) ], ) ], ), ), SizedBox( height: 30.0, ), Padding( padding: const EdgeInsets.only(left: 30.0), child: Row( children: <Widget>[ Text( "RECENTS", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), SizedBox( width: 10.0, ), Text( "(634 mails)", style: TextStyle( color: Colors.grey, ), ), ], ), ), SizedBox( height: 20.0, ), InkWell( onTap: () { openBottomSheet(); }, child: Container( height: 95.0, width: 350.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.0), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(10.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Image.asset( "assets/boy.png", height: 60.0, width: 60.0, ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Text( "Protorix Code", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), Spacer(), Text( "8:16 AM", style: TextStyle( color: Colors.grey, fontSize: 12.0), ), ], ), Text( "Your opinion matters", style: TextStyle( color: Colors.black, fontSize: 14.0), ), SizedBox( height: 3.0, ), Row( children: <Widget>[ Text( "You have a mail. Check it!", style: TextStyle( color: Colors.black, fontSize: 12.0), ), Spacer(), Icon( Icons.star_border, color: Colors.orange, size: 20.0, ) ], ) ], ), ), ) ], ), ), ), ), SizedBox( height: 10.0, ), Container( height: 140.0, width: 350.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.0), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(10.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Image.asset( "assets/boy.png", height: 60.0, width: 60.0, ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Text( "Nwoye Akachi", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), Spacer(), Text( "8:16 AM", style: TextStyle( color: Colors.grey, fontSize: 12.0), ), ], ), Text( "Wireframe for hotel booking app", style: TextStyle( color: Colors.black, fontSize: 14.0), ), SizedBox( height: 3.0, ), Row( children: <Widget>[ Text( "Please check the attachment", style: TextStyle( color: Colors.black, fontSize: 12.0), ), Spacer(), Icon( Icons.star_border, color: Colors.orange, size: 20.0, ) ], ) ], ), ), ) ], ), SizedBox( height: 3.0, ), Padding( padding: const EdgeInsets.only(left: 75.0), child: Row( children: <Widget>[ Container( width: 70.0, decoration: BoxDecoration( color: Colors.red[100], borderRadius: BorderRadius.circular(5.0), border: Border.all(color: Colors.redAccent)), child: Padding( padding: const EdgeInsets.all(5.0), child: Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(5.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Text( "PDF", style: TextStyle( color: Colors.white, fontSize: 10.0), ), ), ), SizedBox( width: 5.0, ), Text( "Ticket", style: TextStyle( color: Colors.black, fontSize: 10.0), ) ], ), ), ), SizedBox( width: 10.0, ), Container( decoration: BoxDecoration( color: Colors.blue[100], borderRadius: BorderRadius.circular(5.0), border: Border.all(color: Colors.blue)), child: Padding( padding: const EdgeInsets.all(5.0), child: Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(5.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Text( "DOC", style: TextStyle( color: Colors.white, fontSize: 10.0), ), ), ), SizedBox( width: 5.0, ), Text( "User flow", style: TextStyle( color: Colors.black, fontSize: 10.0), ) ], ), ), ), ], ), ) ], ), ), ), SizedBox( height: 10.0, ), Container( height: 140.0, width: 350.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.0), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(10.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Image.asset( "assets/boy.png", height: 60.0, width: 60.0, ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Text( "Booking.com", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), Spacer(), Text( "8:16 AM", style: TextStyle( color: Colors.grey, fontSize: 12.0), ), ], ), Text( "Ticket confirmation", style: TextStyle( color: Colors.black, fontSize: 14.0), ), SizedBox( height: 3.0, ), Row( children: <Widget>[ Text( "Please check the ticket", style: TextStyle( color: Colors.black, fontSize: 12.0), ), Spacer(), Icon( Icons.star_border, color: Colors.orange, size: 20.0, ) ], ) ], ), ), ) ], ), SizedBox( height: 3.0, ), Padding( padding: const EdgeInsets.only(left: 75.0), child: Container( width: 70.0, decoration: BoxDecoration( color: Colors.red[100], borderRadius: BorderRadius.circular(5.0), border: Border.all(color: Colors.redAccent)), child: Padding( padding: const EdgeInsets.all(5.0), child: Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(5.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Text( "PDF", style: TextStyle( color: Colors.white, fontSize: 10.0), ), ), ), SizedBox( width: 5.0, ), Text( "Ticket", style: TextStyle( color: Colors.black, fontSize: 10.0), ) ], ), ), ), ) ], ), ), ), SizedBox( height: 10.0, ), Container( height: 95.0, width: 350.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.0), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(10.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Image.asset( "assets/boy.png", height: 60.0, width: 60.0, ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Text( "Protorix Code", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), Spacer(), Text( "8:16 AM", style: TextStyle( color: Colors.grey, fontSize: 12.0), ), ], ), Text( "Your opinion matters", style: TextStyle( color: Colors.black, fontSize: 14.0), ), SizedBox( height: 3.0, ), Row( children: <Widget>[ Text( "You have a mail. Check it!", style: TextStyle( color: Colors.black, fontSize: 12.0), ), Spacer(), Icon( Icons.star_border, color: Colors.orange, size: 20.0, ) ], ) ], ), ), ) ], ), ), ), SizedBox( height: 100.0, ), ], ), ), ); } void openBottomSheet() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (BuildContext bc) { return Padding( padding: const EdgeInsets.all(10.0), child: Container( height: 500.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30.0), ), child: Padding( padding: const EdgeInsets.all(15.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.circular(20.0)), child: Padding( padding: const EdgeInsets.all(3.0), child: Image.asset( "assets/boy.png", height: 60.0, width: 60.0, ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Text( "Protorix Code", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0), ), Spacer(), Icon( Icons.delete_outline, color: Colors.blue[700], ), Icon( Icons.more_vert, color: Colors.blue[700], ), ], ), Text( "Your opinion matters", style: TextStyle( color: Colors.black, fontSize: 14.0), ) ], ), ), ) ], ), SizedBox(height: 20.0,), Text("Code,", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 18.0 ),), SizedBox(height: 10.0,), Text("To add custom fonts to your application, add a fonts section here,in this section. Each entry in this list should have a key with the font family name, and a ", style: TextStyle( color: Colors.black, fontSize: 18.0 ),), SizedBox(height: 30.0,), Text("Thank you,", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 18.0 ),), SizedBox(height: 5.0,), Text("Protorix Code", style: TextStyle( color: Colors.black, fontSize: 18.0 ),), SizedBox(height: 15.0,), Container( decoration: BoxDecoration( color: Colors.blue[50], borderRadius: BorderRadius.circular(30.0) ), child: Padding( padding: const EdgeInsets.all(10.0), child: Row( children: <Widget>[ Text("Reply..", style: TextStyle( color: Colors.blueGrey, fontSize: 18.0 ),), Spacer(), CircleAvatar( backgroundColor: Colors.blue[600], child: Icon(Icons.arrow_forward, color: Colors.white,), ) ], ), ), ) ], ), ), ), ); }); } }
0
mirrored_repositories/flutter_mail_app
mirrored_repositories/flutter_mail_app/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_gmail_redesign/favorite.dart'; import 'package:flutter_gmail_redesign/inbox.dart'; import 'package:flutter_gmail_redesign/profile.dart'; import 'package:flutter_gmail_redesign/search.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; import 'package:line_icons/line_icons.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', home: GmailHome(), ); } } class GmailHome extends StatefulWidget { GmailHome({Key key, this.title}) : super(key: key); final String title; @override _GmailHomeState createState() => _GmailHomeState(); } class _GmailHomeState extends State<GmailHome> { int selectedIndex = 0; PageController controller = PageController(); List<GButton> tabs = new List(); final List<Widget> _children = [ Inbox(), Search(), Favorite(), Profile(), ]; @override void initState() { super.initState(); var padding = EdgeInsets.symmetric(horizontal: 12, vertical: 5); double gap = 30; tabs.add(GButton( gap: gap, iconActiveColor: Colors.blue, iconColor: Colors.blue, textColor: Colors.blue, color: Colors.blue[50], iconSize: 24, padding: padding, icon: LineIcons.inbox, // textStyle: t.textStyle, text: 'Inbox', )); tabs.add(GButton( gap: gap, iconActiveColor: Colors.blue, iconColor: Colors.blue, textColor: Colors.blue, color: Colors.blue[50], iconSize: 24, padding: padding, icon: LineIcons.search, // textStyle: t.textStyle, text: 'Search', )); tabs.add(GButton( gap: gap, iconActiveColor: Colors.blue, iconColor: Colors.blue, textColor: Colors.blue, color: Colors.blue[50], iconSize: 24, padding: padding, icon: LineIcons.star, // textStyle: t.textStyle, text: 'Favourite', )); tabs.add(GButton( gap: gap, iconActiveColor: Colors.blue, iconColor: Colors.blue, textColor: Colors.blue, color: Colors.blue[50], iconSize: 24, padding: padding, icon: LineIcons.user, // textStyle: t.textStyle, text: 'Profile', )); } @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( extendBody: true, body: PageView.builder( onPageChanged: (page) { setState(() { selectedIndex = page; }); }, controller: controller, itemBuilder: (context, position) { return Container(child: _children[position],); }, itemCount: tabs.length, // Can be null ), // backgroundColor: Colors.green, // body: Container(color: Colors.red,), bottomNavigationBar: SafeArea( child: Container( decoration: BoxDecoration(color :Colors.white,boxShadow: [ BoxShadow(spreadRadius: -10, blurRadius: 60, color: Colors.black.withOpacity(.20), offset: Offset(0,15)) ]), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10), child: GNav( tabs: tabs, selectedIndex: selectedIndex, onTabChange: (index) { print(index); setState(() { selectedIndex = index; }); controller.jumpToPage(index); }), ), ), ), ), ); } }
0
mirrored_repositories/flutter_mail_app
mirrored_repositories/flutter_mail_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:flutter_gmail_redesign/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/submission-dicoding-flutter
mirrored_repositories/submission-dicoding-flutter/lib/theme.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; Color kGreenColor = const Color(0xff24C690); Color kBlackColor = const Color(0xff000000); Color kGreyColor = const Color(0xff89807A); Color kCyanColor = const Color(0xff24C6C6); Color kWhiteColor = const Color(0xffFFFFFF); Color kTransparentColor = Colors.transparent; Color kLightBlueColor = const Color(0xffBECCE3); Color kLightGreyColor = const Color(0xffF0F0F0); FontWeight light = FontWeight.w300; FontWeight regular = FontWeight.w400; FontWeight medium = FontWeight.w500; FontWeight semiBold = FontWeight.w600; FontWeight bold = FontWeight.w700; TextStyle blackTextStyle = GoogleFonts.poppins( color: kBlackColor, ); TextStyle greenTextStyle = GoogleFonts.poppins( color: kGreenColor, ); TextStyle greyTextStyle = GoogleFonts.poppins( color: kGreyColor, ); TextStyle cyanTextStyle = GoogleFonts.poppins( color: kCyanColor, ); TextStyle whiteTextStyle = GoogleFonts.poppins( color: kWhiteColor, ); TextStyle lightGreyTextStyle = GoogleFonts.poppins( color: kGreyColor, );
0
mirrored_repositories/submission-dicoding-flutter
mirrored_repositories/submission-dicoding-flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:submission_dicoding_tedo_hc/cubit/page_cubit.dart'; import 'package:submission_dicoding_tedo_hc/cubit/travel_cubit.dart'; import 'package:submission_dicoding_tedo_hc/pages/home_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/main_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/onboarding_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/profil_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/search_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/sign_in_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/splash_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/wishlist_page.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider( create: (context) => PageCubit(), ), BlocProvider( create: (context) => TravelCubit(), ), ], child: MaterialApp( debugShowCheckedModeBanner: false, routes: { '/': (context) => const SplashPage(), '/onboarding': (context) => const OnBoardingPage(), '/sign-in': (context) => const SignInPage(), '/main': (context) => const MainPage(), '/home': (context) => const HomePage(), '/wishlist': (context) => const WishlistPage(), '/profil': (context) => const ProfilPage(), '/search-page': (context) => const SearchPage(), }, ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/menu_travel_navigation_item.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:submission_dicoding_tedo_hc/cubit/travel_cubit.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class MenuTravelNavigationItem extends StatelessWidget { final int index; final String menu; const MenuTravelNavigationItem({ Key? key, required this.index, required this.menu, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { context.read<TravelCubit>().setMenuTravel(index); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 20, height: 4, margin: const EdgeInsets.only(right: 37), decoration: BoxDecoration( color: context.read<TravelCubit>().state == index ? kGreenColor : kTransparentColor, borderRadius: BorderRadius.circular(18), ), ), Container( height: 18, margin: const EdgeInsets.only(right: 37), child: Text( menu, style: context.read<TravelCubit>().state == index ? greenTextStyle.copyWith( fontSize: 12, fontWeight: bold, ) : blackTextStyle.copyWith( fontSize: 12, fontWeight: bold, ), ), ), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/custom_button_navigation_item.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:submission_dicoding_tedo_hc/cubit/page_cubit.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class CustomButtonNavigationItem extends StatelessWidget { final String imageUrl; final int index; const CustomButtonNavigationItem({ Key? key, required this.index, required this.imageUrl, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { context.read<PageCubit>().setPage(index); }, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const SizedBox(), Image.asset( imageUrl, width: 24, height: 24, color: context.read<PageCubit>().state == index ? kGreenColor : kLightBlueColor, ), Container( width: 30, height: 2, decoration: BoxDecoration( color: context.read<PageCubit>().state == index ? kGreenColor : kTransparentColor, borderRadius: BorderRadius.circular(18), ), ), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/onboarding_item.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class OnBoardingItem extends StatelessWidget { final String imageUrl; final String title; final String subtitle; const OnBoardingItem({ Key? key, required this.imageUrl, required this.title, required this.subtitle, }) : super(key: key); @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.only(left: 30, right: 30), child: Column( children: [ const SizedBox(height: 100), Image.asset(imageUrl, width: double.infinity, height: 250), const SizedBox(height: 77), Text( title, style: blackTextStyle.copyWith( fontSize: 22, ), ), const SizedBox(height: 10), Text( subtitle, style: greyTextStyle.copyWith( fontSize: 14, ), textAlign: TextAlign.center, ), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/wishlist_item_card.dart
import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/pages/detail_page.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class WishlistItemCard extends StatelessWidget { final String imageUrl; final String price; final String name; final String nation; final String day; final bool isWishlist; const WishlistItemCard({ Key? key, required this.imageUrl, required this.price, required this.name, required this.nation, required this.day, this.isWishlist = false, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => DetailPage( imageUrl: imageUrl, name: name, price: price, day: day, ratting: '4.5', ), ), ); }, child: Container( width: 144, height: 221, //margin: const EdgeInsets.only(right: 25), padding: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(18), color: kWhiteColor, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( width: 144, height: 135, decoration: BoxDecoration( borderRadius: BorderRadius.circular(9), image: DecorationImage( image: AssetImage(imageUrl), fit: BoxFit.fill, ), ), ), Align( alignment: Alignment.topRight, child: Column( children: [ Container( margin: const EdgeInsets.only( top: 9, ), child: Image.asset( 'assets/img_wishlist_active.png', width: 22, height: 22, ), ), Container( width: 48, height: 24, margin: const EdgeInsets.only( right: 9, top: 67, ), padding: const EdgeInsets.only(top: 5), decoration: BoxDecoration( color: Colors.white.withOpacity(0.38), borderRadius: const BorderRadius.all(Radius.circular(20)), ), child: Text( '\$ ' + price, style: whiteTextStyle.copyWith( fontSize: 10, fontWeight: semiBold, ), textAlign: TextAlign.center, ), ), ], ), ), ], ), const SizedBox(height: 7), Text( name, style: blackTextStyle.copyWith( fontSize: 12, fontWeight: semiBold, ), ), const SizedBox(height: 7), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // ignore: avoid_unnecessary_containers Container( child: Row( children: [ Image.asset( 'assets/icon_location.png', width: 9, ), const SizedBox(width: 3), Text( nation, style: greyTextStyle.copyWith( fontSize: 10, fontWeight: semiBold, ), ), ], ), ), Container( width: 48, height: 25, padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 5), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(11)), color: kLightGreyColor, ), child: Text( day, style: greyTextStyle.copyWith( fontSize: 10, ), ), ), ], ), ], ), ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/primary_button.dart
import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class PrimaryButton extends StatelessWidget { final double width; final double height; final double borderRadius; final String text; final double fontSize; const PrimaryButton({ Key? key, this.width = 335, this.height = 69, this.borderRadius = 16, this.text = '', this.fontSize = 16, }) : super(key: key); @override Widget build(BuildContext context) { return Container( width: width, height: height, decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(borderRadius), ), color: kGreenColor, ), padding: const EdgeInsets.only(top: 20), child: Text( 'Book Now', style: whiteTextStyle.copyWith( fontSize: 16, fontWeight: semiBold, ), textAlign: TextAlign.center, ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/skeleton_item.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class SkeletonItem extends StatelessWidget { const SkeletonItem({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), child: Container( width: (MediaQuery.of(context).size.width - 82) / 2, padding: EdgeInsets.all(20), child: Column( children: [ Shimmer.fromColors( child: Container( width: double.infinity, height: 122, color: kLightGreyColor, ), baseColor: kLightGreyColor, highlightColor: kGreyColor, ), SizedBox(height: 20), Shimmer.fromColors( child: Container( width: double.infinity, height: 22, color: kLightGreyColor, ), baseColor: kLightGreyColor, highlightColor: kGreyColor, ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Shimmer.fromColors( child: Container( width: 62, height: 22, color: kLightGreyColor, ), baseColor: kLightGreyColor, highlightColor: kGreyColor, ), Shimmer.fromColors( child: Container( width: 26, height: 26, decoration: BoxDecoration( shape: BoxShape.circle, color: kLightGreyColor, ), ), baseColor: kLightGreyColor, highlightColor: kGreyColor, ), ], ), ], ), ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/schedule_tile.dart
import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class ScheduleTile extends StatelessWidget { final String imageUrl; final String name; final String nation; const ScheduleTile({ Key? key, required this.imageUrl, required this.name, required this.nation, }) : super(key: key); @override Widget build(BuildContext context) { return Container( width: 329, height: 81, decoration: BoxDecoration( color: kLightGreyColor, borderRadius: BorderRadius.circular(18), ), padding: const EdgeInsets.all(13), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( width: 74, height: 55, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), image: DecorationImage( image: AssetImage(imageUrl), fit: BoxFit.fill, ), ), ), const SizedBox(width: 10), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( name, style: blackTextStyle.copyWith( fontSize: 13, fontWeight: semiBold, ), ), const SizedBox(height: 7), Row( children: [ Image.asset( 'assets/icon_location.png', width: 9, ), const SizedBox(width: 3), Text( nation, style: greyTextStyle.copyWith( fontSize: 10, fontWeight: semiBold, ), ), ], ), ], ), ], ), Container( width: 70, height: 32, padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 16, ), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(26)), color: kGreenColor, ), child: Text( 'Joined', style: whiteTextStyle.copyWith( fontSize: 11, fontWeight: semiBold, ), ), ), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/widgets/travel_card.dart
import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/pages/detail_page.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class TravelCard extends StatelessWidget { final String imageUrl; final String price; final String name; final String nation; final String day; final bool isWishlist; const TravelCard({ Key? key, required this.imageUrl, required this.price, required this.name, required this.nation, required this.day, this.isWishlist = false, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => DetailPage( imageUrl: imageUrl, name: name, price: price, day: day, ratting: '4.5', ), ), ); }, child: Container( width: 164, height: 221, margin: const EdgeInsets.only(right: 25), padding: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(18), color: kWhiteColor, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( width: 144, height: 135, decoration: BoxDecoration( borderRadius: BorderRadius.circular(9), image: DecorationImage( image: AssetImage(imageUrl), fit: BoxFit.fill, ), ), ), Align( alignment: Alignment.topRight, child: Column( children: [ Container( margin: const EdgeInsets.only( top: 9, ), child: Image.asset( 'assets/img_wishlist_active.png', width: 22, height: 22, ), ), Container( width: 48, height: 24, margin: const EdgeInsets.only( right: 9, top: 67, ), padding: const EdgeInsets.only(top: 5), decoration: BoxDecoration( color: Colors.white.withOpacity(0.38), borderRadius: const BorderRadius.all(Radius.circular(20)), ), child: Text( '\$ ' + price, style: whiteTextStyle.copyWith( fontSize: 10, fontWeight: semiBold, ), textAlign: TextAlign.center, ), ), ], ), ), ], ), const SizedBox(height: 7), Text( name, style: blackTextStyle.copyWith( fontSize: 12, fontWeight: semiBold, ), ), const SizedBox(height: 7), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // ignore: avoid_unnecessary_containers Container( child: Row( children: [ Image.asset( 'assets/icon_location.png', width: 9, ), const SizedBox(width: 3), Text( nation, style: greyTextStyle.copyWith( fontSize: 10, fontWeight: semiBold, ), ), ], ), ), Container( width: 48, height: 25, padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 5), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(11)), color: kLightGreyColor, ), child: Text( day, style: greyTextStyle.copyWith( fontSize: 10, ), ), ), ], ), ], ), ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/detail_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import 'package:submission_dicoding_tedo_hc/widgets/primary_button.dart'; class DetailPage extends StatelessWidget { final String imageUrl; final String name; final String price; final String day; final String ratting; const DetailPage({ Key? key, required this.imageUrl, required this.name, required this.price, required this.day, required this.ratting, }) : super(key: key); @override Widget build(BuildContext context) { Widget backButton() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: () { Navigator.pop(context); }, child: Container( width: 60, margin: EdgeInsets.only( top: 36, left: 10, ), padding: EdgeInsets.all(10), child: Image.asset( 'assets/btn_back.png', ), ), ), GestureDetector( onTap: () { Navigator.pop(context); }, child: Container( width: 60, margin: EdgeInsets.only( top: 36, right: 10, ), padding: EdgeInsets.all(10), child: Image.asset( 'assets/btn_wishlist.png', ), ), ), ], ); } Widget backgroundImage() { return Container( width: double.infinity, height: 436, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage(imageUrl), ), ), ); } Widget content() { return Container( margin: EdgeInsets.only(top: 338), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ //? NOTE : TITLE AND PRICE Container( width: double.infinity, margin: EdgeInsets.only(top: 30), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 30), decoration: BoxDecoration( color: kWhiteColor, borderRadius: BorderRadius.circular(36), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ //? NOTE: TITLE Text( name, style: blackTextStyle.copyWith( fontSize: 20, fontWeight: semiBold, ), ), SizedBox(width: 28), Container( height: 56, decoration: BoxDecoration( color: kLightGreyColor, borderRadius: BorderRadius.all(Radius.circular(11)), ), padding: EdgeInsets.symmetric(horizontal: 8), child: Row( children: [ Text( '\$ $price ', style: blackTextStyle.copyWith( fontSize: 18, fontWeight: semiBold, ), ), Text( '/person', style: greyTextStyle.copyWith( fontSize: 10, fontWeight: semiBold, ), ) ], ), ), ], ), SizedBox(height: 17), Text( 'Overview', style: greenTextStyle.copyWith( fontSize: 14, fontWeight: semiBold, ), ), SizedBox(height: 16), //Duration and Stars Row( children: [ Image.asset( 'assets/icon_time_detail.png', width: 32, height: 32, ), SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Duration', style: greyTextStyle.copyWith( fontWeight: bold, fontSize: 10, ), ), Text( day, style: blackTextStyle.copyWith( fontWeight: bold, fontSize: 10, ), ), ], ), SizedBox(width: 20), Image.asset( 'assets/icon_ratting_detail.png', width: 32, height: 32, ), SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Rating', style: greyTextStyle.copyWith( fontWeight: bold, fontSize: 10, ), ), Text( '$ratting out of 5', style: blackTextStyle.copyWith( fontWeight: bold, fontSize: 10, ), ), ], ), ], ), SizedBox(height: 26), Text( 'Have you ever been on holiday to the Greek\nislands before? There’s a good chance you may\nhave come across Santorini before. ', style: greyTextStyle.copyWith( fontSize: 13, fontWeight: semiBold, ), ), SizedBox(height: 32), PrimaryButton( text: 'Book Now', ), ], ), ), ], ), ); } return Scaffold( backgroundColor: kWhiteColor, body: SingleChildScrollView( child: Stack( children: [ backgroundImage(), content(), backButton(), ], ), ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/home_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:submission_dicoding_tedo_hc/cubit/travel_cubit.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import 'package:submission_dicoding_tedo_hc/widgets/menu_travel_navigation_item.dart'; import 'package:submission_dicoding_tedo_hc/widgets/schedule_tile.dart'; import 'package:submission_dicoding_tedo_hc/widgets/travel_card.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { int categoryIndex = 0; @override Widget build(BuildContext context) { Widget header() { return Row( children: [ Container( width: 54, height: 54, margin: const EdgeInsets.only(right: 17), decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18)), image: DecorationImage( image: AssetImage('assets/profile_picture.png'), ), ), ), Text( 'Hello Admin', style: blackTextStyle.copyWith( fontSize: 15, fontWeight: semiBold, ), ), ], ); } Widget searchArea() { return Container( margin: const EdgeInsets.only(top: 23), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Explore the \nBeautiful World!', style: blackTextStyle.copyWith( fontSize: 20, fontWeight: semiBold, ), ), const SizedBox(height: 23), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ GestureDetector( onTap: () { Navigator.pushNamed(context, '/search-page'); }, child: Container( width: 235, height: 54, decoration: BoxDecoration( color: kLightGreyColor, borderRadius: BorderRadius.circular(21), ), child: Container( margin: const EdgeInsets.symmetric( vertical: 20, horizontal: 21, ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon( Icons.search, size: 14, ), const SizedBox(width: 11), Text( 'Search Places', style: greyTextStyle.copyWith( fontSize: 11, ), ) ], ), ), ), ), const SizedBox(width: 12), Image.asset( 'assets/btn_filter.png', width: 72, height: 72, ), ], ), ], ), ); } Widget travelPlace() { return Container( margin: const EdgeInsets.only(top: 23), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Travel Places', style: blackTextStyle.copyWith( fontSize: 18, fontWeight: semiBold, ), ), Text( 'Show more >', style: greyTextStyle.copyWith( fontSize: 11, ), ) ], ), const SizedBox(height: 17), Row( children: [ SizedBox( width: 24, child: RotatedBox( quarterTurns: 3, child: BlocBuilder<TravelCubit, int>( builder: (context, state) { return Row( mainAxisAlignment: MainAxisAlignment.center, // ignore: prefer_const_literals_to_create_immutables children: [ MenuTravelNavigationItem(index: 0, menu: 'All'), MenuTravelNavigationItem(index: 1, menu: 'Latest'), MenuTravelNavigationItem(index: 2, menu: 'Popular') ], ); }, ), ), ), const SizedBox(width: 30), Expanded( child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: const [ TravelCard( imageUrl: 'assets/destination_1.png', price: '750', name: 'City Rome', nation: 'Italy', day: '5 Days', ), TravelCard( imageUrl: 'assets/destination_2.png', price: '850', name: 'Santoriny Island', nation: 'Greece', day: '5 Days', ), TravelCard( imageUrl: 'assets/destination_3.png', price: '890', name: 'Mount ALbrus', nation: 'Italy', day: '7 Days', ) ], ), ), ), ], ), ], ), ); } Widget mySchedule() { return Container( margin: const EdgeInsets.only(top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'My Schedule', style: blackTextStyle.copyWith( fontSize: 18, fontWeight: semiBold, ), ), Text( 'Show more >', style: greyTextStyle.copyWith( fontSize: 11, ), ) ], ), const SizedBox(height: 23), const ScheduleTile( imageUrl: 'assets/destination_3.png', name: 'Mount ALbrus', nation: 'Italy', ), const SizedBox(height: 10), const ScheduleTile( imageUrl: 'assets/destination_4.png', name: 'Burj Khalifa', nation: 'Dubai', ), const SizedBox(height: 10), const ScheduleTile( imageUrl: 'assets/destination_2.png', name: 'Santoriny Island', nation: 'Greece', ), ], ), ); } return Container( margin: const EdgeInsets.only( left: 20, right: 20, top: 45, bottom: 100, ), child: ListView( children: [ header(), searchArea(), travelPlace(), mySchedule(), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/wishlist_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import 'package:submission_dicoding_tedo_hc/widgets/skeleton_item.dart'; import 'package:submission_dicoding_tedo_hc/widgets/wishlist_item_card.dart'; class WishlistPage extends StatefulWidget { const WishlistPage({Key? key}) : super(key: key); @override State<WishlistPage> createState() => _WishlistPageState(); } class _WishlistPageState extends State<WishlistPage> { bool isLoading = true; @override void initState() { Future.delayed(Duration(seconds: 2), () { setState(() { isLoading = false; }); }); super.initState(); } @override Widget build(BuildContext context) { Widget buildLoading() { return Wrap( crossAxisAlignment: WrapCrossAlignment.center, spacing: 18, runSpacing: 18, children: const [ SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), SkeletonItem(), ], ); } Widget buildGrid() { return Wrap( crossAxisAlignment: WrapCrossAlignment.center, spacing: 10, runSpacing: 10, // ignore: prefer_const_literals_to_create_immutables children: [ WishlistItemCard( imageUrl: 'assets/destination_1.png', price: '750', name: 'City Rome', nation: 'Italy', day: '5 Days', ), WishlistItemCard( imageUrl: 'assets/destination_2.png', price: '850', name: 'Santoriny Island', nation: 'Greece', day: '5 Days', ), WishlistItemCard( imageUrl: 'assets/destination_3.png', price: '890', name: 'Mount ALbrus', nation: 'Italy', day: '7 Days', ), WishlistItemCard( imageUrl: 'assets/destination_4.png', price: '1080', name: 'Burj Khalifa', nation: 'Dubai', day: '9 Days', ) ], ); } return Scaffold( appBar: PreferredSize( preferredSize: Size(double.infinity, 60), child: AppBar( elevation: 0, backgroundColor: kWhiteColor, automaticallyImplyLeading: false, title: Row( children: [ GestureDetector( onTap: () { Navigator.pop(context); }, child: Icon( Icons.chevron_left, color: kBlackColor, ), ), SizedBox(width: 18), Text( 'Wishlist', style: blackTextStyle.copyWith( fontSize: 16, fontWeight: semiBold, ), ), Spacer(), // Image.asset( // 'assets/icon_search.png', // width: 22, // ), ], ), ), ), body: ListView( padding: EdgeInsets.symmetric( horizontal: 24, ), children: [ SizedBox(height: 30), isLoading ? buildLoading() : buildGrid(), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/profil_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class ProfilPage extends StatefulWidget { const ProfilPage({Key? key}) : super(key: key); @override State<ProfilPage> createState() => _ProfilPageState(); } class _ProfilPageState extends State<ProfilPage> { Widget settingItem({required String iconUrl, required String content}) { return GestureDetector( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset( iconUrl, width: 20, height: 20, ), SizedBox(width: 30), Text( content, style: greyTextStyle.copyWith( fontSize: 14, fontWeight: semiBold, ), ), ], ), Icon( Icons.keyboard_arrow_right, color: kGreyColor, ), ], ), ); } @override Widget build(BuildContext context) { return SafeArea( child: Container( margin: EdgeInsets.all(20), child: Column( children: [ Center( child: Column( children: [ Image.asset( 'assets/profile_picture.png', width: 80, height: 80, ), SizedBox(height: 16), Text( 'Admin', style: blackTextStyle.copyWith(fontSize: 18, fontWeight: bold), ), SizedBox(height: 4), Text( 'user', style: greyTextStyle.copyWith( fontWeight: semiBold, ), ), SizedBox(height: 20), Divider(color: kGreyColor), SizedBox(height: 20), GestureDetector( onTap: () {}, child: settingItem( iconUrl: 'assets/icon_profile_setting_page.png', content: 'Profile', ), ), SizedBox(height: 25), settingItem( iconUrl: 'assets/icon_setting_setting_page.png', content: 'Setting', ), SizedBox(height: 25), settingItem( iconUrl: 'assets/icon_help_setting_page.png', content: 'Help', ), SizedBox(height: 25), GestureDetector( onTap: () { Navigator.pushNamedAndRemoveUntil( context, '/sign-in', (route) => false); }, child: settingItem( iconUrl: 'assets/icon_logout_setting_page.png', content: 'Logout', ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/sign_in_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import 'package:fluttertoast/fluttertoast.dart'; class SignInPage extends StatefulWidget { const SignInPage({Key? key}) : super(key: key); @override State<SignInPage> createState() => _SignInPageState(); } class _SignInPageState extends State<SignInPage> { late FToast fToast; final usernameController = TextEditingController(text: ''); final passwordController = TextEditingController(text: ''); bool isPasswordError = false; bool isLoading = false; @override void initState() { super.initState(); fToast = FToast(); fToast.init(context); } @override Widget build(BuildContext context) { Widget title() { return Container( margin: EdgeInsets.only(top: 84), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Login to your\naccount', style: greenTextStyle.copyWith( fontWeight: bold, fontSize: 24, ), ), SizedBox(height: 20), Row( children: [ Container( margin: EdgeInsets.only(right: 4), width: 87, height: 4, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: kGreenColor, ), ), Container( width: 8, height: 4, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: kGreenColor, ), ), ], ), ], ), ); } Widget usernameInput() { return Container( margin: EdgeInsets.only(top: 48), padding: EdgeInsets.all(16), decoration: BoxDecoration( color: kLightGreyColor, borderRadius: BorderRadius.circular(14), ), child: TextFormField( controller: usernameController, decoration: InputDecoration.collapsed( hintText: 'Username', hintStyle: greyTextStyle.copyWith( fontSize: 16, fontWeight: semiBold, ), ), ), ); } Widget passwordInput() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( margin: EdgeInsets.only(top: 32), padding: EdgeInsets.all(16), decoration: BoxDecoration( color: kLightGreyColor, borderRadius: BorderRadius.circular(14), ), child: Row( children: [ Expanded( child: TextFormField( controller: passwordController, obscureText: true, decoration: InputDecoration.collapsed( hintText: 'Password', hintStyle: greyTextStyle.copyWith( fontSize: 16, fontWeight: semiBold, ), ), ), ), Icon( Icons.visibility_outlined, color: kGreyColor, ), ], ), ), ], ); } Widget rememberCheckbox() { return Container( margin: EdgeInsets.only(top: 32), child: Row( children: [ SizedBox( width: 20, height: 20, child: Checkbox( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4), ), onChanged: (bool? value) {}, value: false, ), ), SizedBox(width: 12), Text('Remember me') ], ), ); } Widget errorToast() { return Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(10), ), child: Text( 'Email atau Password Salah, silahkan masukan [email protected] dan password admin', style: whiteTextStyle.copyWith( fontSize: 14, fontWeight: semiBold, ), ), ); } Widget loginButton() { return Container( margin: EdgeInsets.only(top: 32), height: 56, width: double.infinity, child: TextButton( onPressed: () { setState(() { isLoading = true; }); Future.delayed(Duration(seconds: 2), () { setState(() { isLoading = false; }); if (usernameController.text != 'admin' || passwordController.text != 'admin') { setState(() { isPasswordError = true; }); fToast.showToast( child: errorToast(), toastDuration: Duration(seconds: 4), gravity: ToastGravity.BOTTOM, ); } else { Navigator.restorablePushNamedAndRemoveUntil( context, '/main', (Route<dynamic> route) => false); } }); }, style: TextButton.styleFrom( backgroundColor: kGreenColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(14), ), ), child: isLoading ? CircularProgressIndicator( color: kWhiteColor, backgroundColor: kGreyColor, ) : Text( 'Login', style: whiteTextStyle.copyWith( fontSize: 16, fontWeight: semiBold, ), ), ), ); } Widget registerButton() { return Container( margin: EdgeInsets.only(top: 48, bottom: 40), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Don`t have an account ?', style: greyTextStyle.copyWith( fontSize: 14, fontWeight: semiBold, ), ), TextButton( onPressed: () {}, child: Text( 'Register', style: greenTextStyle.copyWith( fontSize: 14, fontWeight: semiBold, ), ), ) ], ), ); } return Scaffold( body: ListView( padding: EdgeInsets.symmetric( horizontal: 24, ), children: [ title(), usernameInput(), passwordInput(), rememberCheckbox(), loginButton(), registerButton(), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/search_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import 'package:submission_dicoding_tedo_hc/widgets/schedule_tile.dart'; class SearchPage extends StatefulWidget { const SearchPage({Key? key}) : super(key: key); @override State<SearchPage> createState() => _SearchPageState(); } class _SearchPageState extends State<SearchPage> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: kWhiteColor, appBar: PreferredSize( preferredSize: Size(double.infinity, 70), child: AppBar( automaticallyImplyLeading: false, backgroundColor: kWhiteColor, elevation: 0, title: Row( children: [ GestureDetector( onTap: () { Navigator.pop(context); }, child: Icon( Icons.chevron_left, color: kBlackColor, ), ), SizedBox(width: 18), Expanded( child: Container( padding: EdgeInsets.all(16), decoration: BoxDecoration( color: kLightGreyColor, borderRadius: BorderRadius.circular(14), ), child: Row( children: [ Expanded( child: TextFormField( textInputAction: TextInputAction.go, onFieldSubmitted: (value) { Navigator.pushNamed(context, '/search-result'); }, decoration: InputDecoration.collapsed( hintText: 'Search Destination', ), ), ), SizedBox(width: 10), Icon( Icons.close, color: kGreyColor, ), ], ), ), ), ], ), ), ), body: ListView( padding: EdgeInsets.symmetric( horizontal: 24, ), children: [ SizedBox(height: 41), Text( 'Recomendation', style: blackTextStyle.copyWith( fontWeight: semiBold, ), ), SizedBox(height: 20), ScheduleTile( imageUrl: 'assets/destination_3.png', name: 'Mount ALbrus', nation: 'Italy', ), SizedBox(height: 20), ScheduleTile( imageUrl: 'assets/destination_1.png', name: 'Mount ALbrus', nation: 'Italy', ), SizedBox(height: 20), ScheduleTile( imageUrl: 'assets/destination_2.png', name: 'Mount ALbrus', nation: 'Italy', ), SizedBox(height: 20), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/splash_page.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; class SplashPage extends StatefulWidget { const SplashPage({Key? key}) : super(key: key); @override State<SplashPage> createState() => _SplashPageState(); } class _SplashPageState extends State<SplashPage> { @override void initState() { Timer(const Duration(seconds: 3), () { Navigator.pushNamedAndRemoveUntil( context, '/onboarding', (route) => false); }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: kGreenColor, body: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 98, height: 82, // ignore: prefer_const_constructors margin: EdgeInsets.only(right: 16), decoration: const BoxDecoration( image: DecorationImage( image: AssetImage( 'assets/travello_logo.png', ), ), ), ), Text( 'Travellou', style: whiteTextStyle.copyWith( fontSize: 36, fontWeight: bold, ), ), ], ), ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/main_page.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:submission_dicoding_tedo_hc/cubit/page_cubit.dart'; import 'package:submission_dicoding_tedo_hc/pages/home_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/profil_page.dart'; import 'package:submission_dicoding_tedo_hc/pages/wishlist_page.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import '../widgets/custom_button_navigation_item.dart'; class MainPage extends StatelessWidget { const MainPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { Widget buildContent(int currentIndex) { switch (currentIndex) { case 0: return const HomePage(); case 1: return const WishlistPage(); case 2: return const ProfilPage(); default: return const HomePage(); } } Widget customButtonNavigation() { return Align( child: Container( width: double.infinity, height: 60, margin: const EdgeInsets.all(20), decoration: BoxDecoration( color: kWhiteColor, borderRadius: BorderRadius.circular(39), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, // ignore: prefer_const_literals_to_create_immutables children: [ CustomButtonNavigationItem( index: 0, imageUrl: 'assets/icon_home.png', ), CustomButtonNavigationItem( imageUrl: 'assets/icon_wishlist.png', index: 1, ), CustomButtonNavigationItem( imageUrl: 'assets/icon_profile.png', index: 2, ), ], ), ), alignment: Alignment.bottomCenter, ); } return BlocBuilder<PageCubit, int>( builder: (context, currentIndex) { return Scaffold( body: Stack( children: [ buildContent(currentIndex), customButtonNavigation(), ], ), ); }, ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/pages/onboarding_page.dart
import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:submission_dicoding_tedo_hc/theme.dart'; import '../widgets/onboarding_item.dart'; class OnBoardingPage extends StatefulWidget { const OnBoardingPage({Key? key}) : super(key: key); @override State<OnBoardingPage> createState() => _OnBoardingPageState(); } class _OnBoardingPageState extends State<OnBoardingPage> { CarouselController controller = CarouselController(); int currentIndex = 0; @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Expanded( child: CarouselSlider( items: const [ OnBoardingItem( imageUrl: 'assets/onboarding1-picture.png', title: 'Jelajahi Dunia', subtitle: 'Pilih destinasi wisata mu seluruh dunia di dalam satu aplikasi', ), OnBoardingItem( imageUrl: 'assets/onboarding2-picture.png', title: 'Pemesanan Mudah', subtitle: 'Pemesanan perjalanan yang mudah, hanya dengan santai di rumah', ), OnBoardingItem( imageUrl: 'assets/onboarding3-picture.png', title: 'Fitur Lengkap', subtitle: 'Fitur lengkap aplikasi memudahkan mu dalam pemesanan liburanmu', ), ], options: CarouselOptions( height: double.infinity, viewportFraction: 1, enableInfiniteScroll: false, initialPage: currentIndex, onPageChanged: (index, _) { setState(() { currentIndex = index; }); }), carouselController: controller, ), ), Container( margin: const EdgeInsets.symmetric( horizontal: 40, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ TextButton( onPressed: () { controller.animateToPage(2); }, child: Text( 'SKIP', style: blackTextStyle.copyWith( fontSize: 18, ), ), ), Row( children: [ Container( width: 10, height: 10, decoration: BoxDecoration( shape: BoxShape.circle, color: currentIndex == 0 ? kGreenColor : kLightGreyColor, ), ), const SizedBox(width: 10), Container( width: 10, height: 10, decoration: BoxDecoration( shape: BoxShape.circle, color: currentIndex == 1 ? kGreenColor : kLightGreyColor, ), ), const SizedBox(width: 10), Container( width: 10, height: 10, decoration: BoxDecoration( shape: BoxShape.circle, color: currentIndex == 2 ? kGreenColor : kLightGreyColor, ), ), ], ), TextButton( onPressed: () { if (currentIndex == 2) { Navigator.pushNamedAndRemoveUntil( context, '/sign-in', (Route<dynamic> route) => false); } else { controller.nextPage(); } }, child: Text( 'NEXT', style: blackTextStyle.copyWith( fontSize: 18, ), ), ), ], ), ), const SizedBox(height: 29), ], ), ); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/cubit/travel_state.dart
part of 'travel_cubit.dart'; @immutable abstract class TravelState {} class TravelInitial extends TravelState {}
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/cubit/page_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; part 'page_state.dart'; class PageCubit extends Cubit<int> { PageCubit() : super(0); void setPage(int newPage) { emit(newPage); } }
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/cubit/page_state.dart
part of 'page_cubit.dart'; @immutable abstract class PageState {} class PageInitial extends PageState {}
0
mirrored_repositories/submission-dicoding-flutter/lib
mirrored_repositories/submission-dicoding-flutter/lib/cubit/travel_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; part 'travel_state.dart'; class TravelCubit extends Cubit<int> { TravelCubit() : super(0); void setMenuTravel(int newMenu) { emit(newMenu); } }
0
mirrored_repositories/submission-dicoding-flutter
mirrored_repositories/submission-dicoding-flutter/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:submission_dicoding_tedo_hc/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/flutter_c19dashboard
mirrored_repositories/flutter_c19dashboard/lib/other_widgets.dart
import 'dart:collection'; import 'dart:convert'; import 'package:intl/intl.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_c19dashboard/main.dart'; import 'package:http/http.dart' as http; import 'models.dart'; class StateLeveTestReult { final String sname; final TestResult tests; StateLeveTestReult(this.sname, this.tests); } class StatesTests extends StatelessWidget { //Styles static const TextStyle stylHead = TextStyle( color: Colors.yellowAccent, fontSize: 18, fontWeight: FontWeight.w300); static const TextStyle stylDName = TextStyle(color: Colors.grey, fontSize: 25, fontWeight: FontWeight.w300); static const TextStyle styText = TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w300); const StatesTests({Key key}) : super(key: key); Future<List<StateLeveTestReult>> _getdataOffline(BuildContext context) async { var data = await DefaultAssetBundle.of(context) .loadString('assets/state_district_wise.json'); var jdata = json.decode(data) as Map; //Test Data var test_data = await DefaultAssetBundle.of(context) .loadString('assets/state_test_data.json'); JsonDecoder decoder = null; var tdata = json.decode(test_data); List<StateLeveTestReult> jlist = []; DateTime today = DateTime.now(); FilterState(String sname) { int act = 0, con = 0, rec = 0, dec = 0; List<DistInfo> districs = []; //test data var ddata = jdata[sname]['districtData'] as Map; var t_data = tdata['states_tested_data'] as List; FilterTest(String name, {DateTime dt = null}) { double tpo = 0, tne = 0, tunc = 0, tp_p = 0, r_fr_q = 0, c_in_q = 0, ttested = 0; var ye = new DateFormat("dd/MM/yyyy") .format(DateTime.now().subtract(Duration(days: 1)).toLocal()); var l = t_data .where((element) => element['updatedon'] == ye && element['state'] == name) .toList(); for (LinkedHashMap t in l) { bool flag = false; t.forEach((key, value) { if (key == 'state' && value == name) { flag = true; } }); if (flag == true) { t.forEach((key, value) { if (key == 'positive' && value != "" && value != null) { tpo += double.tryParse(t['positive']); } if (key == 'negative' && value != "" && value != null) { try { tne += double.tryParse(t['negative']); ; } catch (e) {} } if (key == 'unconfirmed' && value != "") { try { tunc += int.tryParse(t['unconfirmed']); } catch (e) { // TODO } } if (key == 'totaltested' && value != "") { try { ttested += int.tryParse(t['totaltested']); } catch (e) { // TODO } } if (key == 'totalpeoplecurrentlyinquarantine' && value != "") { try { c_in_q += int.tryParse(t['totalpeoplecurrentlyinquarantine']); } catch (e) { // TODO } } if (key == 'totalpeoplereleasedfromquarantine' && value != "") { try { r_fr_q += int.tryParse(t['totalpeoplereleasedfromquarantine']); } catch (e) { // TODO } } if (key == 'testsperpositivecase' && value != "") { try { tp_p += int.tryParse(t['testsperpositivecase']); } catch (e) { // TODO } } }); } } TestResult testResult = new TestResult(tpo, tne, tunc, tp_p, r_fr_q, c_in_q, ttested); return testResult; } var tests = FilterTest(sname); var stateTest = StateLeveTestReult(sname, tests); return stateTest; } for (var s in jdata.keys) { var stateInfo = FilterState(s); jlist.add(stateInfo); } return jlist; } Future<List<StateLeveTestReult>> _getdata() async { List<StateLeveTestReult> jlist = []; try { var data = await http.get('https://api.covid19india.org/state_district_wise.json'); // var data=DefaultAssetBundle.of(context).loadString('assets/state_district_wise.json'); var jdata = json.decode(data.body) as Map; //Test Data var test_data = await http.get('https://api.covid19india.org/state_test_data.json'); var tdata = json.decode(test_data.body); DateTime today = DateTime.now(); FilterState(String sname) { int act = 0, con = 0, rec = 0, dec = 0; List<DistInfo> districs = []; //test data var ddata = jdata[sname]['districtData'] as Map; var t_data = tdata['states_tested_data'] as List; FilterTest(String name, {DateTime dt = null}) { double tpo = 0, tne = 0, tunc = 0, tp_p = 0, r_fr_q = 0, c_in_q = 0, ttested = 0; var ye = new DateFormat("dd/MM/yyyy") .format(DateTime.now().subtract(Duration(days: 1)).toLocal()); var l = t_data .where((element) => element['updatedon'] == ye && element['state'] == name) .toList(); for (LinkedHashMap t in l) { bool flag = false; t.forEach((key, value) { if (key == 'state' && value == name) { flag = true; } }); if (flag == true) { t.forEach((key, value) { if (key == 'positive' && value != "" && value != null) { tpo += double.tryParse(t['positive']); } if (key == 'negative' && value != "" && value != null) { try { tne += double.tryParse(t['negative']); ; } catch (e) {} } if (key == 'unconfirmed' && value != "") { try { tunc += int.tryParse(t['unconfirmed']); } catch (e) { // TODO } } if (key == 'totaltested' && value != "") { try { ttested += int.tryParse(t['totaltested']); } catch (e) { // TODO } } if (key == 'totalpeoplecurrentlyinquarantine' && value != "") { try { c_in_q += int.tryParse(t['totalpeoplecurrentlyinquarantine']); } catch (e) { // TODO } } if (key == 'totalpeoplereleasedfromquarantine' && value != "") { try { r_fr_q += int.tryParse(t['totalpeoplereleasedfromquarantine']); } catch (e) { // TODO } } if (key == 'testsperpositivecase' && value != "") { try { tp_p += int.tryParse(t['testsperpositivecase']); } catch (e) { // TODO } } }); } } TestResult testResult = new TestResult( tpo, tne, tunc, tp_p, r_fr_q, c_in_q, ttested); return testResult; } var tests = FilterTest(sname); var stateTest = StateLeveTestReult(sname, tests); return stateTest; } for (var s in jdata.keys) { var stateInfo = FilterState(s); jlist.add(stateInfo); } } catch(e){} return jlist; } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: Text('State Test List'), ), bottomNavigationBar: BottomAppBar( color: Colors.brown, child: Container( alignment: Alignment.center, color: Colors.white, child: Wrap( children: [ GestureDetector( child: Tooltip( message: 'Refresh', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.home, size: 40, ), ), ), onTap: () { Navigator.push(context, new MaterialPageRoute(builder: (context) => MyApp())); }, ), SizedBox( width: 35, ), GestureDetector( child: Tooltip( message: 'Test Results', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.control_point_duplicate, size: 40, color: Colors.lightBlueAccent, ), ), ), onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => StatesTests())); }, ), ], ), height: 50, ), ), body: Container( child: FutureBuilder( future: _getdata(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.data != null) { return ListView.builder( itemCount: snapshot.data.length, itemBuilder: (context, index) { return Card( color: Colors.indigo, child: Padding( padding: const EdgeInsets.all(8.0), child: Column(children: [ Text( snapshot.data[index].sname, style: stylDName, ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( children: [ SizedBox( height: 8, ), Row(children: [ Column( children: [ Column(children: [ Text( 'Positive', style: stylHead, ), SizedBox( width: 8, ), Text( snapshot.data[index].tests.positive .toString(), style: styText, ), SizedBox( width: 8, ), ]), ], ), SizedBox( width: 48, ), Column(children: [ Text('Negative', style: stylHead), SizedBox( width: 8, ), Text( snapshot.data[index].tests.negaitive .toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('Un Confirmed', style: stylHead), SizedBox( width: 8, ), Text( snapshot.data[index].tests.unconfirmed .toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('In Quarantine', style: stylHead), SizedBox( width: 8, ), Text( snapshot.data[index].tests .currently_in_quarantine .toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('Left Quarantine', style: stylHead), SizedBox( width: 8, ), Text( snapshot.data[index].tests .released_from_quarantine .toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('Case v/s +ve', style: stylHead), SizedBox( width: 8, ), Text( snapshot.data[index].tests .tests_per_positive_case .toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('Total Tests', style: stylHead), SizedBox( width: 8, ), Text( snapshot.data[index].tests.totaltested .toString(), style: styText), ]) ]), ], ), ), ]), ), ); }, ); } else { return Container( child: Center( child: CircularProgressIndicator(), ), ); } }, ), ), )); } } class DistrictDetailPage extends StatelessWidget { final DistInfo distInfo; const DistrictDetailPage({Key key, this.distInfo}) : super(key: key); @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: Text( 'District Details', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), ), bottomNavigationBar: BottomAppBar( color: Colors.brown, child: Container( alignment: Alignment.center, color: Colors.white, child: Wrap( children: [ GestureDetector( child: Tooltip( message: 'Refressh', child: Icon( Icons.home, size: 55, ), ), onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => MyApp())); }, ), ], ), height: 50, ), ), body: Column( children: [ Padding( padding: const EdgeInsets.all(18.0), child: Column( children: [ Text( 'Active', style: TextStyle(color: Colors.grey, fontSize: 18), ), Icon( Icons.airline_seat_recline_extra, color: Colors.orange, size: 45, ), Text( distInfo.status.active.toString(), style: TextStyle( fontSize: 26, fontWeight: FontWeight.bold), ), SizedBox( height: 18, ), Text( 'Confirmed', style: TextStyle(color: Colors.grey, fontSize: 18), ), Icon( Icons.airline_seat_flat_angled, color: Colors.deepOrange, size: 45, ), SizedBox( height: 15, ), Text( distInfo.status.confirmed.toString(), style: TextStyle( fontSize: 26, fontWeight: FontWeight.bold), ), SizedBox( height: 18, ), Text( 'Recovered', style: TextStyle(color: Colors.grey, fontSize: 18), ), Icon( Icons.airline_seat_recline_normal, color: Colors.greenAccent, size: 45, ), SizedBox( height: 18, ), Text( distInfo.status.recovered.toString(), style: TextStyle( fontSize: 26, fontWeight: FontWeight.bold), ), SizedBox( height: 18, ), Text( 'Death', style: TextStyle(color: Colors.grey, fontSize: 18), ), SizedBox( height: 18, ), Tooltip( child: Icon( Icons.airline_seat_recline_normal, color: Colors.redAccent, size: 45, ), message: 'No of people dead', waitDuration: Duration(seconds: 2), ), SizedBox( width: 15, ), Text( distInfo.status.deceased.toString(), style: TextStyle( fontSize: 26, fontWeight: FontWeight.bold), ), ], ), ) ], ))); } } class DistrictReport extends StatelessWidget { final List<DistInfo> distList; //Styles static const TextStyle stylHead = TextStyle( color: Colors.yellowAccent, fontSize: 18, fontWeight: FontWeight.w300); static const TextStyle stylDName = TextStyle(color: Colors.grey, fontSize: 25, fontWeight: FontWeight.w300); static const TextStyle styText = TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w300); Widget get_data(BuildContext context, int index) { return Card( color: Colors.blueGrey, child: Padding( padding: const EdgeInsets.all(8.0), child: Column(children: [Text( distList[index].dname.trim(), style: stylDName, ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( children: [ SizedBox( height: 8, ), Row(children: [ Column( children: [ Column(children: [ Text( 'Active', style: stylHead, ), SizedBox( width: 8, ), Text( distList[index].status.active.toString(), style: styText, ), SizedBox( width: 8, ), ]), ], ), SizedBox( width: 48, ), Column(children: [ Text('Confirmed', style: stylHead), SizedBox( width: 8, ), Text(distList[index].status.confirmed.toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('Recovered', style: stylHead), SizedBox( width: 8, ), Text(distList[index].status.recovered.toString(), style: styText), ]), SizedBox( width: 48, ), Column(children: [ Text('Deceased', style: stylHead), SizedBox( width: 8, ), Text(distList[index].status.deceased.toString(), style: styText), ]) ]), ], ), ), ]), ), ); } const DistrictReport({Key key, this.distList}) : super(key: key); @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: Text('District Status'), ), bottomNavigationBar: BottomAppBar( color: Colors.brown, child: Container( alignment: Alignment.center, color: Colors.white, child: Wrap( children: [ GestureDetector( child: Tooltip( message: 'Refresh', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.home, size: 40, ), ), ), onTap: () { Navigator.push(context, new MaterialPageRoute(builder: (context) => MyApp())); }, ), SizedBox( width: 35, ), GestureDetector( child: Tooltip( message: 'Test Results', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.control_point_duplicate, size: 40, color: Colors.lightBlueAccent, ), ), ), onTap: () {}, ), ], ), height: 50, ), ), body: Container( child: Column( children: [ Text( 'All district Data', style: TextStyle(fontStyle: FontStyle.italic), ), Expanded( child: ListView.builder( itemBuilder: get_data, itemCount: distList.length, ), ) ], ), ), )); } } class StateDetailPage extends StatelessWidget { @override final StateInfo info; const StateDetailPage({Key key, this.info}) : super(key: key); Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( info.sname, ), ), bottomNavigationBar: BottomAppBar( color: Colors.brown, child: Container( alignment: Alignment.center, color: Colors.white, child: Wrap( children: [ GestureDetector( child: Tooltip( message: 'Refressh', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.home, size: 40, ), ), ), onTap: () { Navigator.push(context, new MaterialPageRoute(builder: (context) => MyApp())); }, ), SizedBox( width: 35, ), Tooltip( message: 'District Data', child: GestureDetector( onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => DistrictReport(distList: info.distInfo))); }, child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.recent_actors, color: Colors.brown, size: 40, ), ), ), ), ], ), height: 50, ), ), body: Container( child: Column( children: <Widget>[ TestStatus( result: info.tests, ), Expanded( child: DistrictList( dist: info.distInfo, )) ], ))); } } class DistrictList extends StatelessWidget { final List<DistInfo> dist; const DistrictList({Key key, this.dist}) : super(key: key); Widget _buildDistirictInfo(BuildContext context, int index) { return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ ListTile( onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => DistrictDetailPage( distInfo: dist[index], ))); }, hoverColor: Colors.grey, focusColor: Colors.deepOrange, leading: CircleAvatar( child: Text(dist[index].dname.substring(0, 2).toUpperCase()), backgroundColor: Colors.greenAccent, ), title: Text( dist[index].dname, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), trailing: Icon(Icons.apps), shape: StadiumBorder(), subtitle: Text( "Recovered " + dist[index].status.recovered.toString() + " | " + "Confirmed " + dist[index].status.confirmed.toString(), style: TextStyle( color: Colors.brown, fontSize: 15, fontWeight: FontWeight.bold), ), ) ], ), ); } @override Widget build(BuildContext context) { return ListView.builder( itemBuilder: _buildDistirictInfo, itemCount: dist.length, ); } } class TestStatus extends StatelessWidget { final TestResult result; const TestStatus({Key key, this.result}) : super(key: key); @override Widget build(BuildContext context) { return Container( width: 1201, child: Row( // margin: EdgeInsets.symmetric(horizontal: 20,vertical: 20), children: [ Flexible( child: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Column(children: [ Tooltip( message: 'Positive count', child: Icon( Icons.add, color: Colors.redAccent, )), // Text( // 'Positive', // style: TextStyle(color: Colors.black, fontSize: 20), // ), SizedBox( width: 8, ), Text( result.positive.toString(), style: TextStyle( fontSize: 15, color: Colors.grey, fontWeight: FontWeight.bold), ), ]), ), ), ), Flexible( child: Padding( padding: const EdgeInsets.all(2.0), child: Center( child: Column(children: [ Tooltip( message: 'Negative count', child: Icon( Icons.airline_seat_recline_normal, color: Colors.green, ), ), SizedBox( width: 8, ), Text( result.negaitive.toString(), style: TextStyle( fontSize: 15, color: Colors.green, fontWeight: FontWeight.bold), ), ]), ), ), ), Flexible( child: Padding( padding: const EdgeInsets.all(2.0), child: Center( child: Column(children: [ Tooltip( message: 'Unconfirmed count', child: Icon( Icons.airline_seat_recline_normal, color: Colors.orangeAccent, ), ), SizedBox( width: 8, ), Text( result.unconfirmed.toString(), style: TextStyle( fontSize: 15, color: Colors.green, fontWeight: FontWeight.bold), ), ]), ), ), ), Flexible( child: Padding( padding: const EdgeInsets.all(2.0), child: Center( child: Column(children: [ Tooltip( message: 'Total Tested ', child: Icon( Icons.title, color: Colors.blue, ), ), SizedBox( width: 8, ), Text( result.totaltested.toString(), style: TextStyle( fontSize: 15, color: Colors.green, fontWeight: FontWeight.bold), ), ]), ), ), ), ]), ); } }
0
mirrored_repositories/flutter_c19dashboard
mirrored_repositories/flutter_c19dashboard/lib/customFloatingButon.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; //This Widget written by [manojap.github.io] class MButon extends StatelessWidget { MButon({@required this.onPressed,@required this.title, this.style, this.splash, this.background_color, this.newshape, this.newicon, this.iconColor}); final String title; final GestureTapCallback onPressed; final TextStyle style; final Color splash; final Color background_color; final ShapeBorder newshape; final IconData newicon; final Color iconColor; @override Widget build(BuildContext context) { return RawMaterialButton( fillColor: background_color, splashColor: splash, shape:newshape!=null ? newshape: const StadiumBorder(), child: Padding( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 20), child: Row(mainAxisSize: MainAxisSize.min, children: [ Icon( newicon!=null ? newicon : Icons.help, color: iconColor!=null ? iconColor: Colors.amber, ), SizedBox( width: 8, ), Text( title, style: style, ), ], ), ), onPressed: onPressed, ); } }
0
mirrored_repositories/flutter_c19dashboard
mirrored_repositories/flutter_c19dashboard/lib/models.dart
class Status { final int active; final int confirmed; final int recovered; final int deceased; Status(this.active, this.confirmed, this.recovered, this.deceased); } class TestResult { final double positive; final double negaitive; final double unconfirmed; final double tests_per_positive_case; final double released_from_quarantine; final double currently_in_quarantine; final double totaltested; TestResult(this.positive, this.negaitive, this.unconfirmed, this.tests_per_positive_case, this.released_from_quarantine, this.currently_in_quarantine, this.totaltested); } class StateInfo { final String sname; final String abr; final Status status; final TestResult tests; final List<DistInfo> distInfo; StateInfo(this.sname, this.abr, this.status, this.distInfo, this.tests); } class DistInfo { // final TestResult tests; final String dname; final Status status; DistInfo(this.dname, this.status ); }
0
mirrored_repositories/flutter_c19dashboard
mirrored_repositories/flutter_c19dashboard/lib/main.dart
import 'dart:collection'; import 'dart:math'; import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart' as http; import 'customFloatingButon.dart'; import 'models.dart'; import 'other_widgets.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'C19 Dashboard', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'States'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { Future<List<StateInfo>> _getdata() async { List<StateInfo> jlist = []; List<DistInfo> dlist = []; try { var data = await http .get('https://api.covid19india.org/state_district_wise.json'); // var data=DefaultAssetBundle.of(context).loadString('assets/state_district_wise.json'); var jdata = json.decode(data.body) as Map; //Test Data var test_data = await http.get('https://api.covid19india.org/state_test_data.json'); var tdata = json.decode(test_data.body); FilterDistrict(String state, String dname) { var data = jdata[state]['districtData'][dname] as Map; Status status = Status(data['active'], data['confirmed'], data['recovered'], data['deceased']); return status; } DateTime today = DateTime.now(); FilterState(String sname) { int act = 0, con = 0, rec = 0, dec = 0; List<DistInfo> districs = []; //test data var ddata = jdata[sname]['districtData'] as Map; var t_data = tdata['states_tested_data'] as List; FilterTest(String name, {DateTime dt = null}) { double tpo = 0, tne = 0, tunc = 0, tp_p = 0, r_fr_q = 0, c_in_q = 0, ttested = 0; var ye = new DateFormat("dd/MM/yyyy") .format(DateTime.now().subtract(Duration(days: 1)).toLocal()); var l = t_data .where((element) => element['updatedon'] == ye && element['state'] == name) .toList(); for (LinkedHashMap t in l) { t.forEach((key, value) { if (key == 'positive' && value != "" && value != null) { tpo += double.tryParse(t['positive']); } if (key == 'negative' && value != "" && value != null) { try { tne += double.tryParse(t['negative']); ; } catch (e) {} } if (key == 'unconfirmed' && value != "") { try { tunc += int.tryParse(t['unconfirmed']); } catch (e) { // TODO } } if (key == 'totaltested' && value != "") { try { ttested += int.tryParse(t['totaltested']); } catch (e) { // TODO } } if (key == 'totalpeoplecurrentlyinquarantine' && value != "") { try { c_in_q += int.tryParse(t['totalpeoplecurrentlyinquarantine']); } catch (e) { // TODO } } if (key == 'totalpeoplereleasedfromquarantine' && value != "") { try { r_fr_q += int.tryParse(t['totalpeoplereleasedfromquarantine']); } catch (e) { // TODO } } if (key == 'testsperpositivecase' && value != "") { try { tp_p += int.tryParse(t['testsperpositivecase']); } catch (e) { // TODO } } }); } TestResult testResult = new TestResult(tpo, tne, tunc, tp_p, r_fr_q, c_in_q, ttested); return testResult; } var tests = FilterTest(sname); for (var dn in ddata.keys) { var data = FilterDistrict(sname, dn); act += data.active; con += data.confirmed; rec += data.recovered; dec += data.deceased; districs.add(new DistInfo(dn, data)); } StateInfo stateInfo = new StateInfo( sname, jdata[sname]['statecode'], new Status( act, con, rec, dec, ), districs, tests); return stateInfo; } for (var s in jdata.keys) { var stateInfo = FilterState(s); jlist.add(stateInfo); } } catch (e) {} return jlist; } Future<List<StateInfo>> _getdataOffline(BuildContext context) async { var data = await DefaultAssetBundle.of(context) .loadString('assets/state_district_wise.json'); var jdata = json.decode(data) as Map; //Test Data var test_data = await DefaultAssetBundle.of(context) .loadString('assets/state_test_data.json'); JsonDecoder decoder = null; var tdata = json.decode(test_data); List<StateInfo> jlist = []; List<DistInfo> dlist = []; FilterDistrict(String state, String dname) { var data = jdata[state]['districtData'][dname] as Map; Status status = Status(data['active'], data['confirmed'], data['recovered'], data['deceased']); return status; } DateTime today = DateTime.now(); FilterState(String sname) { int act = 0, con = 0, rec = 0, dec = 0; List<DistInfo> districs = []; //test data var ddata = jdata[sname]['districtData'] as Map; var t_data = tdata['states_tested_data'] as List; FilterTest(String name, {DateTime dt = null}) { double tpo = 0, tne = 0, tunc = 0, tp_p = 0, r_fr_q = 0, c_in_q = 0, ttested = 0; var ye = new DateFormat("dd/MM/yyyy") .format(DateTime.now().subtract(Duration(days: 1)).toLocal()); var l = t_data .where((element) => element['updatedon'] == ye && element['state'] == name) .toList(); for (LinkedHashMap t in l) { bool flag = false; t.forEach((key, value) { if (key == 'state' && value == name) { flag = true; } }); if (flag == true) { t.forEach((key, value) { if (key == 'positive' && value != "" && value != null) { tpo += double.tryParse(t['positive']); } if (key == 'negative' && value != "" && value != null) { try { tne += double.tryParse(t['negative']); ; } catch (e) {} } if (key == 'unconfirmed' && value != "") { try { tunc += int.tryParse(t['unconfirmed']); } catch (e) { // TODO } } if (key == 'totaltested' && value != "") { try { ttested += int.tryParse(t['totaltested']); } catch (e) { // TODO } } if (key == 'totalpeoplecurrentlyinquarantine' && value != "") { try { c_in_q += int.tryParse(t['totalpeoplecurrentlyinquarantine']); } catch (e) { // TODO } } if (key == 'totalpeoplereleasedfromquarantine' && value != "") { try { r_fr_q += int.tryParse(t['totalpeoplereleasedfromquarantine']); } catch (e) { // TODO } } if (key == 'testsperpositivecase' && value != "") { try { tp_p += int.tryParse(t['testsperpositivecase']); } catch (e) { // TODO } } }); } } TestResult testResult = new TestResult(tpo, tne, tunc, tp_p, r_fr_q, c_in_q, ttested); return testResult; } var tests = FilterTest(sname); for (var dn in ddata.keys) { var data = FilterDistrict(sname, dn); act += data.active; con += data.confirmed; rec += data.recovered; dec += data.deceased; districs.add(new DistInfo(dn, data)); } StateInfo stateInfo = new StateInfo( sname, jdata[sname]['statecode'], new Status( act, con, rec, dec, ), districs, tests); return stateInfo; } for (var s in jdata.keys) { var stateInfo = FilterState(s); jlist.add(stateInfo); } return jlist; } void showAboutDialog({ @required BuildContext context, String applicationName, String applicationVersion, Widget applicationIcon, String applicationLegalese, List<Widget> children, bool useRootNavigator = true, RouteSettings routeSettings, }) { assert(context != null); assert(useRootNavigator != null); showDialog<void>( context: context, useRootNavigator: useRootNavigator, builder: (BuildContext context) { return AboutDialog( applicationName: applicationName, applicationVersion: applicationVersion, applicationIcon: applicationIcon, applicationLegalese: applicationLegalese, children: children, ); }, routeSettings: routeSettings, ); } @override Widget build(BuildContext context) { //Style constants const TextStyle all_india_sub_title = TextStyle( fontSize: 12, color: Colors.yellow, fontWeight: FontWeight.bold); return SafeArea( child: Scaffold( appBar: AppBar( title: Text( 'C19 Dashboard', style: TextStyle(color: Colors.black), ), leading: Icon( Icons.menu, color: Colors.black, ), backgroundColor: Colors.white, actions: <Widget>[ IconButton( icon: Icon(Icons.search, color: Colors.black), onPressed: () {}, ), IconButton( icon: Icon(Icons.person, color: Colors.black), tooltip: 'About', onPressed: () {}, ) ], ), floatingActionButton: (MButon( title: 'About', style: TextStyle(color: Colors.black), background_color: Colors.deepOrange, splash: Colors.orange, // newshape: RoundedRectangleBorder( // borderRadius: BorderRadius.all(Radius.circular(10))), onPressed: () { showAboutDialog( context: context, applicationName: "Dashboard - This is an open source project based on the data provide by http://api.covid19india.org", applicationVersion: "1.0.0", children: [ Text('Developer: Manoj A.P'), Text('can be reached @ [email protected]'), Text('Web:' + 'http://manojap.github.io'), ], applicationIcon: Icon(Icons.games)); }, )), floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, bottomNavigationBar: BottomAppBar( color: Colors.brown, child: Container( alignment: Alignment.center, color: Colors.white, child: Wrap( children: [ GestureDetector( child: Tooltip( message: 'Refresh', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.home, size: 40, ), ), ), onTap: () { Navigator.push(context, new MaterialPageRoute(builder: (context) => MyApp())); }, ), SizedBox( width: 35, ), GestureDetector( child: Tooltip( message: 'Test Results', child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.control_point_duplicate, size: 40,color: Colors.lightBlueAccent, ), ), ), onTap: () { Navigator.push(context, new MaterialPageRoute(builder: (context) => StatesTests())); }, ), ], ), height: 50, ), ), body: Container( child: FutureBuilder( future: _getdataOffline(context), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.data != null) { return ListView.builder( itemCount: snapshot.data.length, itemBuilder: (context, index) { return ListTile( shape: StadiumBorder(), trailing: Icon(Icons.more_horiz), hoverColor: Colors.cyan, leading: CircleAvatar( child: Text( snapshot.data[index].abr, style: TextStyle(fontWeight: FontWeight.bold), ), ), title: Text(snapshot.data[index].sname, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.blue)), focusColor: Colors.deepOrangeAccent, subtitle: Text( "Recovered:" + snapshot.data[index].status.recovered.toString() + " | " + "Dead:" + snapshot.data[index].status.deceased.toString(), style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: Colors.black54), ), onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => StateDetailPage( info: snapshot.data[index], ))); }, ); }, ); } else { return Container( child: Center( child: CircularProgressIndicator(), ), ); } }, ), ), )); } }
0
mirrored_repositories/flutter_c19dashboard
mirrored_repositories/flutter_c19dashboard/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:flutter_c19dashboard/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/Xylophone-Application
mirrored_repositories/Xylophone-Application/lib/main.dart
import 'package:flutter/material.dart'; import 'package:audioplayers/audio_cache.dart'; void main() => runApp(XylophoneApp()); class XylophoneApp extends StatelessWidget { void playSound(int sound) { final player = AudioCache(); player.play('note$sound.wav'); } Expanded buildKey({ Color color , int number }) { return Expanded( child: FlatButton( color: color, onPressed: () { playSound(number); }, child: null, ), ); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.blue[700], title: Text('XyloPhonE'), actions: <Widget>[ // action button IconButton( onPressed: () {}, icon: Icon(Icons.settings), ), // action button ], ), body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ buildKey(color: Colors.orange, number:1), buildKey(color: Colors.red, number:2), buildKey(color: Colors.yellow, number:3), buildKey(color: Colors.green, number:4), buildKey(color: Colors.pink, number:5), buildKey(color: Colors.lightBlue, number:6), buildKey(color: Colors.grey, number:7), ], ), ), ), ); } }
0
mirrored_repositories/login-grey
mirrored_repositories/login-grey/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(const LoginGrey()); } class LoginGrey extends StatelessWidget { const LoginGrey({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: SafeArea( child: Container( decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xFFffffff), Color(0xffffd3d0), Color(0xfffff0ed), // Color(0xFFfcb69f), ])), child: Scaffold( backgroundColor: Colors.transparent, body: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Icons.ac_unit, size: 150, ), const SizedBox(height: 10), const Text( 'Hello, Again', style: TextStyle( fontFamily: 'Cal', fontSize: 50, fontWeight: FontWeight.w700), ), const SizedBox(height: 10), const Text('Welcome back, We missed you', style: TextStyle(fontSize: 27, fontWeight: FontWeight.w300)), const SizedBox(height: 50), Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Container( decoration: BoxDecoration( // color: Colors.grey[200], color: Colors.white, border: Border.all(color: const Color(0xffeddffc), width: 2), borderRadius: BorderRadius.circular(12)), child: const Padding( padding: EdgeInsets.only(bottom: 10), child: TextField( decoration: InputDecoration( hintText: ' Email', prefix: Icon( Icons.alternate_email, color: Colors.lightGreen, ), border: InputBorder.none, ), ), ), ), ), const SizedBox( height: 10, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Container( decoration: BoxDecoration( color: Colors.white, border: Border.all(color: const Color(0xffeddffc), width: 2), borderRadius: BorderRadius.circular(12)), child: const Padding( padding: EdgeInsets.only(bottom: 10), child: TextField( obscureText: true, decoration: InputDecoration( hintText: ' Password', prefix: Icon( Icons.lock, color: Colors.lightBlue, ), border: InputBorder.none, ), ), ), ), ), const SizedBox(height: 10), Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( gradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Colors.white, Color(0XFF64DFDF), // Color(0xffffd3d0), Color.fromARGB(255, 14, 163, 255), ]), // color: Colors.pink[400], color: const Color(0xff64dfdf), borderRadius: BorderRadius.circular(12)), child: const Center( child: Text( "Sign In", style: TextStyle( fontSize: 18, color: Colors.white, ), ), )), ), const SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.center, children: const [ Text('Not a member?'), Text(' Register Now', style: TextStyle(color: Color.fromARGB(255, 255, 0, 102))), ], ) ]), ), ), ), ); } }
0
mirrored_repositories/login-grey
mirrored_repositories/login-grey/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:login_grey_300/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/gratis
mirrored_repositories/gratis/lib/widgets.dart
import 'package:flutter/material.dart'; Widget sectionTitle(String title) { return Container( margin: const EdgeInsets.only( left: 20.0, right: 20.0, ), child: Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Text( capitalize(title), style: TextStyle( fontWeight: FontWeight.w800, fontSize: 20, ), ), ), ); } InputDecoration elevatedTextFieldInputDecoration(context, String hintText) { return InputDecoration( filled: true, fillColor: Colors.white, contentPadding: EdgeInsets.symmetric( vertical: 20, horizontal: 25, ), hintText: hintText, hintStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w400, ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(100), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100), borderSide: BorderSide(color: Theme.of(context).primaryColor, width: 3.0), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100), borderSide: BorderSide(color: Colors.transparent, width: 3.0), ), errorStyle: TextStyle(height: 0), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100), borderSide: BorderSide(color: Colors.red, width: 3.0), ), ); } InputDecoration elevatedPasswordInputDecoration(context, String hintText) { return InputDecoration( hintText: hintText, hintStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w400, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100), borderSide: BorderSide(color: Theme.of(context).primaryColor, width: 3.0), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100), borderSide: BorderSide(color: Colors.transparent, width: 3.0), ), filled: true, fillColor: Colors.white, contentPadding: EdgeInsets.symmetric( vertical: 20, horizontal: 25, ), suffixIcon: Icon(Icons.remove_red_eye), ); } String capitalize(String s) => s[0].toUpperCase() + s.substring(1); String capitalizeFirstOfEach(String s) => s.split(" ").map((str) => capitalize(str)).join(" "); class DescriptionTextWidget extends StatefulWidget { final String text; DescriptionTextWidget({@required this.text}); @override _DescriptionTextWidgetState createState() => new _DescriptionTextWidgetState(); } class _DescriptionTextWidgetState extends State<DescriptionTextWidget> { String firstHalf; String secondHalf; bool flag = true; @override void initState() { super.initState(); if (widget.text.length > 200) { firstHalf = widget.text.substring(0, 200); secondHalf = widget.text.substring(200, widget.text.length); } else { firstHalf = widget.text; secondHalf = ""; } } @override Widget build(BuildContext context) { return new Container( padding: new EdgeInsets.symmetric( horizontal: 20.0, ), child: secondHalf.isEmpty ? new Text(firstHalf) : new Column( children: <Widget>[ new Text(flag ? (firstHalf + "...") : (firstHalf + secondHalf)), flag ? InkWell( child: new Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Padding( padding: EdgeInsets.symmetric( vertical: 10.0, ), child: Text( "read more", style: new TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600, ), ), ), ], ), onTap: () { setState(() { flag = !flag; }); }, ) : Container( margin: const EdgeInsets.only( bottom: 10.0, ), ), ], ), ); } }
0
mirrored_repositories/gratis
mirrored_repositories/gratis/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:gratis/routes/home.dart'; import 'package:gratis/services/shared_preferences.dart'; import 'package:gratis/services/auth.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, systemNavigationBarColor: Colors.black, systemNavigationBarIconBrightness: Brightness.light, )); SystemChrome.setEnabledSystemUIOverlays([]); await Firebase.initializeApp(); runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { bool userIsLoggedIn; @override void initState() { getLoggedInState(); super.initState(); WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false; //<-- SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarColor: Color(0xFF1f1e30), systemNavigationBarColor: Color(0xFF1f1e30), ), ); } getLoggedInState() async { await HelperFunctions.getUserLoggedInPreference().then((value) { setState(() { userIsLoggedIn = value; }); }); } @override Widget build(BuildContext context) { return MaterialApp( title: "Welcome to Gratis", debugShowCheckedModeBanner: false, home: userIsLoggedIn != null ? userIsLoggedIn ? HomeScreen() : Authenticate() : Authenticate(), theme: ThemeData( primarySwatch: Colors.teal, primaryColor: Color(0xFF54d3c2), disabledColor: Colors.red, splashColor: Color(0xFF54d3c2), buttonTheme: ButtonThemeData( padding: EdgeInsets.symmetric( vertical: 15.0, horizontal: 15.0, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100.0), side: BorderSide( color: Color(0xFF54d3c2), )), buttonColor: Color(0xFF54d3c2), textTheme: ButtonTextTheme.primary, // <-- this auto selects the right color ), ), ); } }
0
mirrored_repositories/gratis
mirrored_repositories/gratis/lib/database.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:shared_preferences/shared_preferences.dart'; class DatabaseMethods { getUserInfo(String email) async { return FirebaseFirestore.instance .collection("users") .where("email", isEqualTo: email) .get() .catchError((e) { print(e.toString()); }); } getUserByUserEmail(String userEmail) async { return await FirebaseFirestore.instance .collection("users") .where("email", isEqualTo: userEmail) .get(); } setUserInfo(userMap) { FirebaseFirestore.instance.collection("users").add(userMap).catchError((e) { print(e.toString()); }); } getAllLocations() async { return await FirebaseFirestore.instance .collection("locations") .orderBy("locationName") .get() .catchError((e) { print(e.toString()); }); } getLocationTripInfo(String locationName) async { return await FirebaseFirestore.instance .collection("locations") .where("locationName", isEqualTo: locationName) .get() .catchError((e) { print(e.toString()); }); } getLocationReviews(String locationName) async { return await FirebaseFirestore.instance .collection("reviews") .where("reviewLocation", isEqualTo: locationName) .get() .catchError((e) { print(e.toString()); }); } getLocationGallery(String locationName) async { return await FirebaseFirestore.instance .collection("galleries") .where("galleryLocation", isEqualTo: locationName) .get() .catchError((e) { print(e.toString()); }); } getGalleryImages(String locationName) async { return await FirebaseFirestore.instance .collection("galleries") .where("galleryLocation", isEqualTo: locationName) .get() .catchError((e) { print(e.toString()); }); } getUserFavorite(String locationName) async { return await FirebaseFirestore.instance .collection("favorites") .where("galleryLocation", isEqualTo: locationName) .get() .catchError((e) { print(e.toString()); }); } } class HelperFunctions { static String sharedPreferenceUserKey = "ISLOGGEDIN"; static String sharedPreferenceUserNameKey = "USERNAMEKEY"; static String sharedPreferenceUserEmailKey = "USEREMAILKEY"; static Future<void> saveUserLoggedInPreference(bool userLoggedIn) async { SharedPreferences prefs = await SharedPreferences.getInstance(); return await prefs.setBool(sharedPreferenceUserKey, userLoggedIn); } static Future<void> saveUserNamePreference(String userName) async { SharedPreferences prefs = await SharedPreferences.getInstance(); return await prefs.setString(sharedPreferenceUserNameKey, userName); } static Future<void> saveUserEmailPreference(String userEmail) async { SharedPreferences prefs = await SharedPreferences.getInstance(); return await prefs.setString(sharedPreferenceUserEmailKey, userEmail); } static Future<bool> getUserLoggedInPreference() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getBool(sharedPreferenceUserKey); } static Future<String> getUserNamePreference() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString(sharedPreferenceUserNameKey); } static Future<void> getUserEmailPreference() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString(sharedPreferenceUserEmailKey); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/profile.dart
import 'package:flutter/material.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/database.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cached_network_image/cached_network_image.dart'; class ProfilePage extends StatefulWidget { final String userFullName; ProfilePage(this.userFullName); @override _ProfilePageState createState() => _ProfilePageState(userFullName); } class _ProfilePageState extends State<ProfilePage> { final String userFullName; _ProfilePageState(this.userFullName); DatabaseMethods databaseMethods = new DatabaseMethods(); QuerySnapshot userSnapshot; QuerySnapshot reviewSnapshot; getLocationReviews(locationName) async { print(locationName); databaseMethods.getLocationReviews(locationName).then((val) { print(val.toString()); setState(() { userSnapshot = val; print(userSnapshot.toString()); }); }); } @override void initState() { super.initState(); } Widget reviewsList() { return reviewSnapshot != null ? ListView.builder( scrollDirection: Axis.vertical, itemCount: reviewSnapshot.docs.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return reviewItem( reviewUser: reviewSnapshot.docs[index].data()["reviewUser"], reviewBody: reviewSnapshot.docs[index].data()["reviewBody"], ); }, ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget reviewItem({String reviewUser, String reviewBody}) { return Container( margin: const EdgeInsets.only( left: 20.0, bottom: 20.0, right: 20.0, ), child: Column( children: [ Divider(), Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 40.0, height: 40.0, margin: const EdgeInsets.only( right: 15.0, ), decoration: new BoxDecoration( border: Border.all(color: Colors.white), shape: BoxShape.circle, image: new DecorationImage( fit: BoxFit.fill, image: new CachedNetworkImageProvider( "https://i.imgur.com/iQkzaTO.jpg"), ), ), ), Padding( padding: const EdgeInsets.only( right: 20.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( reviewUser, style: TextStyle( fontSize: 15, fontWeight: FontWeight.w700, ), ), Text( "Posted November 1, 2020", style: TextStyle( fontSize: 12, color: Colors.grey, ), ), ], ), ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Padding( padding: const EdgeInsets.only( bottom: 3.0, ), child: Text("Rating"), ), Row( children: [ Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star_half, color: Theme.of(context).primaryColor, size: 18, ), ], ), ], ), ], ), Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Column( children: [ Text( reviewBody, style: TextStyle( color: Colors.grey, ), ), ], ), ), ], ), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Container( child: reviewsList(), ), ), ); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/gallery.dart
import 'package:flutter/material.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/database.dart'; import 'package:photo_view/photo_view.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cached_network_image/cached_network_image.dart'; class GalleryPage extends StatefulWidget { final String locationName; GalleryPage(this.locationName); @override _GalleryPageState createState() => _GalleryPageState(locationName); } class _GalleryPageState extends State<GalleryPage> { final String locationName; _GalleryPageState(this.locationName); DatabaseMethods databaseMethods = new DatabaseMethods(); QuerySnapshot gallerySnapshot; getGalleryImages(locationName) async { print(locationName); databaseMethods.getGalleryImages(locationName).then((val) { print(val.toString()); setState(() { gallerySnapshot = val; print(gallerySnapshot.toString()); }); }); } @override void initState() { getGalleryImages(locationName); super.initState(); } Widget reviewsList() { return gallerySnapshot != null ? Container( margin: const EdgeInsets.only( right: 20.0, ), child: GridView.builder( scrollDirection: Axis.vertical, itemCount: gallerySnapshot.docs.length, shrinkWrap: true, gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3), physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return reviewItem( galleryLocation: gallerySnapshot.docs[index].data()["galleryLocation"], galleryPath: gallerySnapshot.docs[index].data()["galleryPath"], ); }, ), ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget reviewItem({String galleryLocation, String galleryPath}) { return Container( margin: const EdgeInsets.only( left: 20.0, bottom: 20.0, ), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: CachedNetworkImageProvider(galleryPath), ), borderRadius: BorderRadius.all(Radius.circular(8.0)), ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Container( child: reviewsList(), ), ), ); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/signUp.dart
import 'package:flutter/material.dart'; import 'package:gratis/routes/home.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:gratis/routes/signIn.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/database.dart'; import 'package:gratis/services/auth.dart'; class SignUpPage extends StatefulWidget { final Function toggleView; SignUpPage(this.toggleView); @override _SignUpPageState createState() => _SignUpPageState(); } class _SignUpPageState extends State<SignUpPage> { bool isLoading = false; AuthMethods authMethods = new AuthMethods(); DatabaseMethods databaseMethods = new DatabaseMethods(); final formKey = GlobalKey<FormState>(); TextEditingController firstNameTextEditingController = new TextEditingController(); TextEditingController lastNameTextEditingController = new TextEditingController(); TextEditingController emailTextEditingController = new TextEditingController(); TextEditingController passwordTextEditingController = new TextEditingController(); signUpAccount() { if (formKey.currentState.validate()) { Map<String, String> userInfoMap = { "firstName": firstNameTextEditingController.text, "lastName": lastNameTextEditingController.text, "email": emailTextEditingController.text, "fullName": '${firstNameTextEditingController.text} ${lastNameTextEditingController.text}', }; HelperFunctions.saveUserNamePreference( firstNameTextEditingController.text); HelperFunctions.saveUserEmailPreference(emailTextEditingController.text); setState(() { isLoading = true; }); authMethods .signUpWithEmailAndPassword(emailTextEditingController.text, passwordTextEditingController.text) .then((val) { databaseMethods.setUserInfo(userInfoMap); HelperFunctions.saveUserLoggedInPreference(true); Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => HomeScreen())); }); } } @override Widget build(BuildContext context) { return Scaffold( extendBodyBehindAppBar: true, resizeToAvoidBottomInset: true, appBar: AppBar( backgroundColor: Colors.transparent, elevation: 0.0, ), backgroundColor: Color(0xFFf6f6f6), body: Center( child: SingleChildScrollView( physics: ClampingScrollPhysics(), child: Container( margin: const EdgeInsets.only( top: 80.0, left: 30.0, right: 30.0, bottom: 30.0, ), width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Sign up", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 30, ), ), Divider( height: 30, ), Text( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.', style: TextStyle( color: Color(0xFF9f9f9f), fontSize: 16, ), ), Form( key: formKey, child: Column( children: [ Container( margin: EdgeInsets.only( top: 20.0, ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.075), offset: Offset(0, 10), blurRadius: 15, spreadRadius: 0, ), ], ), child: TextFormField( controller: firstNameTextEditingController, // style: TextStyle( // color: Theme.of(context).primaryColor), keyboardType: TextInputType.text, decoration: elevatedTextFieldInputDecoration( context, "First Name"), ), ), ), Container( margin: EdgeInsets.only( top: 20.0, ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.075), offset: Offset(0, 10), blurRadius: 15, spreadRadius: 0), ], ), child: TextFormField( controller: lastNameTextEditingController, keyboardType: TextInputType.text, decoration: elevatedTextFieldInputDecoration( context, "Last Name"), ), ), ), Container( margin: EdgeInsets.only( top: 20.0, ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.075), offset: Offset(0, 10), blurRadius: 15, spreadRadius: 0), ], ), child: TextFormField( controller: emailTextEditingController, keyboardType: TextInputType.emailAddress, validator: (val) { return RegExp( r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+|.[a-zA-Z]+") .hasMatch(val) ? null : "Please enter a valid email address"; }, decoration: elevatedTextFieldInputDecoration( context, "Email Address"), ), ), ), Container( margin: EdgeInsets.only( top: 20.0, ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.075), offset: Offset(0, 10), blurRadius: 15, spreadRadius: 0), ], ), child: TextFormField( obscureText: true, keyboardType: TextInputType.visiblePassword, validator: (val) { return val.length > 6 ? null : "Password must be greater than 6 characters"; }, controller: passwordTextEditingController, textCapitalization: TextCapitalization.none, decoration: elevatedPasswordInputDecoration( context, "Password"), ), ), ), Container( margin: const EdgeInsets.only( top: 30.0, ), width: double.infinity, child: RaisedButton( onPressed: () { signUpAccount(); }, child: Text( "Sign up", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, color: Color(0xFFFFFFFF), ), ), ), ), Container( margin: const EdgeInsets.only( top: 15.0, left: 30.0, right: 30.0, ), width: double.infinity, child: Text( 'By signing up, you agree with our Terms of Services and Privacy Policy.', textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF9f9f9f), fontSize: 13, ), ), ), Container( margin: const EdgeInsets.only( top: 30.0, ), width: double.infinity, child: InkWell( onTap: () { ; Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => SignInPage(widget.toggleView), ), ); }, child: RichText( textAlign: TextAlign.center, text: TextSpan( children: <TextSpan>[ TextSpan( text: 'Already have an account?', style: TextStyle( color: Color(0xFF9f9f9f), fontWeight: FontWeight.w600, ), ), TextSpan( text: ' Login instead', style: TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600, ), ), ], ), ), ), ), ], ), ), ], ), ), ), )); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/reviews.dart
import 'package:flutter/material.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/database.dart'; import 'package:photo_view/photo_view.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cached_network_image/cached_network_image.dart'; class ReviewsPage extends StatefulWidget { final String locationName; ReviewsPage(this.locationName); @override _ReviewsPageState createState() => _ReviewsPageState(locationName); } class _ReviewsPageState extends State<ReviewsPage> { final String locationName; _ReviewsPageState(this.locationName); DatabaseMethods databaseMethods = new DatabaseMethods(); QuerySnapshot reviewSnapshot; getLocationReviews(locationName) async { print(locationName); databaseMethods.getLocationReviews(locationName).then((val) { print(val.toString()); setState(() { reviewSnapshot = val; print(reviewSnapshot.toString()); }); }); } @override void initState() { getLocationReviews(locationName); super.initState(); } Widget reviewsList() { return reviewSnapshot != null ? ListView.builder( scrollDirection: Axis.vertical, itemCount: reviewSnapshot.docs.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return reviewItem( reviewUser: reviewSnapshot.docs[index].data()["reviewUser"], reviewBody: reviewSnapshot.docs[index].data()["reviewBody"], ); }, ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget reviewItem({String reviewUser, String reviewBody}) { return Container( margin: const EdgeInsets.only( left: 20.0, bottom: 20.0, right: 20.0, ), child: Column( children: [ Divider(), Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 40.0, height: 40.0, margin: const EdgeInsets.only( right: 15.0, ), decoration: new BoxDecoration( border: Border.all(color: Colors.white), shape: BoxShape.circle, image: new DecorationImage( fit: BoxFit.fill, image: new CachedNetworkImageProvider( "https://i.imgur.com/iQkzaTO.jpg"), ), ), ), Padding( padding: const EdgeInsets.only( right: 20.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( capitalizeFirstOfEach(reviewUser), style: TextStyle( fontSize: 15, fontWeight: FontWeight.w700, ), ), Text( "Posted November 1, 2020", style: TextStyle( fontSize: 12, color: Colors.grey, ), ), ], ), ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Padding( padding: const EdgeInsets.only( bottom: 3.0, ), child: Text("Rating"), ), Row( children: [ Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star_half, color: Theme.of(context).primaryColor, size: 18, ), ], ), ], ), ], ), Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Column( children: [ Text( reviewBody, style: TextStyle( color: Colors.grey, ), ), ], ), ), ], ), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Container( child: reviewsList(), ), ), ); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/destination.dart
import 'package:flutter/material.dart'; import 'package:gratis/routes/gallery.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/database.dart'; import 'package:gratis/routes/reviews.dart'; import 'package:photo_view/photo_view.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cached_network_image/cached_network_image.dart'; class DestinationPage extends StatefulWidget { final String locationName; DestinationPage(this.locationName); @override _DestinationPageState createState() => _DestinationPageState(locationName); } class _DestinationPageState extends State<DestinationPage> { String locationName; _DestinationPageState(this.locationName); DatabaseMethods databaseMethods = new DatabaseMethods(); QuerySnapshot destinationSnapshot; QuerySnapshot gallerySnapshot; QuerySnapshot reviewSnapshot; getDestinationGallery(locationName) async { print(locationName); databaseMethods.getLocationGallery(locationName).then((val) { print(val.toString()); setState(() { gallerySnapshot = val; print(gallerySnapshot.toString()); }); }); } getDestinationInfo(locationName) async { print(locationName); databaseMethods.getLocationTripInfo(locationName).then((val) { print(val.toString()); setState(() { destinationSnapshot = val; print(destinationSnapshot.toString()); }); }); } getLocationReviews(locationName) async { print(locationName); databaseMethods.getLocationReviews(locationName).then((val) { print(val.toString()); setState(() { reviewSnapshot = val; print(reviewSnapshot.toString()); }); }); } Widget loadDestinationBackdrop() { return destinationSnapshot != null ? CachedNetworkImage( imageUrl: destinationSnapshot.docs[0].data()["backdropPath"], imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( image: DecorationImage( image: imageProvider, fit: BoxFit.cover, ), ), ), ) : Image.asset( "assets/images/destination.jpg", fit: BoxFit.cover, ); } Widget loadDestinationInfo() { return destinationSnapshot != null ? Container( child: ListView.builder( itemCount: destinationSnapshot.docs.length, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemBuilder: (context, index) { String locationName = capitalizeFirstOfEach( destinationSnapshot.docs[index].data()["locationName"]); String city = capitalize(destinationSnapshot.docs[index].data()["city"]); String country = capitalize( destinationSnapshot.docs[index].data()["country"]); String rateUSD = capitalize( destinationSnapshot.docs[index].data()["rateUSD"]); return SingleChildScrollView( child: Container( margin: const EdgeInsets.only( top: 5.0, ), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( margin: const EdgeInsets.only( left: 20.0, right: 20.0, ), child: Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Text( capitalize(locationName) ?? "error", style: TextStyle( fontWeight: FontWeight.w800, fontSize: 20, ), ), ), ), Container( margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, ), child: Text( '$city, $country' ?? "error", style: TextStyle( color: Colors.grey, ), ), ), ], ), ), Container( margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( r"$" + rateUSD, style: TextStyle( fontSize: 24.0, fontWeight: FontWeight.w900, ), ), Container( margin: const EdgeInsets.only( top: 5.0, ), child: Text( "/ night", style: TextStyle( color: Colors.grey, ), ), ), ], ), ), ], ), Container( margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, ), child: Divider(), ), Container( margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, ), child: destinationTitle("Summary"), ), Container( margin: const EdgeInsets.only( top: 10.0, ), child: new DescriptionTextWidget( text: destinationSnapshot.docs[index] .data()["summary"] ?? "error", ), ), Container( width: double.infinity, margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, bottom: 10.0, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.05), offset: Offset(0, 5), blurRadius: 10, spreadRadius: 0, ), ], ), child: Padding( padding: const EdgeInsets.all( 15.0, ), child: Column( children: [ Padding( padding: const EdgeInsets.only( bottom: 10.0, ), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.only( right: 20.0, ), child: Text( "4.5", style: TextStyle( fontSize: 36.0, color: Theme.of(context).primaryColor, fontWeight: FontWeight.w900, ), ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.only( bottom: 3.0, ), child: Text("Total Score"), ), Row( children: [ Icon( Icons.star, color: Theme.of(context) .primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context) .primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context) .primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context) .primaryColor, size: 18, ), Icon( Icons.star_half, color: Theme.of(context) .primaryColor, size: 18, ), ], ), ], ), ], ), ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.only( right: 20.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Room", ), Text( "Service", ), Text( "Location", ), Text( "Price", ), ], ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 8.0, margin: const EdgeInsets.symmetric( vertical: 4.0, ), decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: BorderRadius.all( Radius.circular(8.0)), ), width: MediaQuery.of(context) .size .width * 0.54, ), Container( height: 8.0, margin: const EdgeInsets.symmetric( vertical: 4.0, ), decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: BorderRadius.all( Radius.circular(8.0)), ), width: MediaQuery.of(context) .size .width * 0.56, ), Container( height: 8.0, margin: const EdgeInsets.symmetric( vertical: 4.0, ), decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: BorderRadius.all( Radius.circular(8.0)), ), width: MediaQuery.of(context) .size .width * 0.60, ), Container( height: 8.0, margin: const EdgeInsets.symmetric( vertical: 4.0, ), decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: BorderRadius.all( Radius.circular(8.0)), ), width: MediaQuery.of(context) .size .width * 0.50, ), ], ), ], ), ], ), ), ), galleryImages(), Container( margin: const EdgeInsets.only( left: 20.0, right: 20.0, ), child: Divider(), ), reviewsList(), Container( margin: const EdgeInsets.only( top: 15.0, left: 20.0, right: 20.0, bottom: 25.0, ), width: double.infinity, child: RaisedButton( onPressed: () {}, child: Text( "Book Now", style: TextStyle( fontWeight: FontWeight.w700, fontSize: 16, color: Color(0xFFFFFFFF), ), ), ), ), ], ), ), ); }, ), ) : Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, ), body: Container( alignment: Alignment.center, child: CircularProgressIndicator(), ), ); } Widget reviewsList() { return reviewSnapshot.docs.length != 0 ? ListView.builder( scrollDirection: Axis.vertical, itemCount: 2, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return reviewList( reviewUser: reviewSnapshot.docs[index].data()["reviewUser"], reviewBody: reviewSnapshot.docs[index].data()["reviewBody"], ); }, ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget reviewList({String reviewUser, String reviewBody}) { return reviewSnapshot.docs.length != 0 ? Column( children: [ Container( margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ destinationTitle("Reviews (15)"), InkWell( child: Padding( padding: EdgeInsets.symmetric( vertical: 10.0, ), child: Text( "View All", style: new TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600, ), ), ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => ReviewsPage(locationName), ), ); }, ), ], ), ), Container( margin: const EdgeInsets.only( left: 20.0, bottom: 20.0, right: 20.0, ), child: Column( children: [ Divider(), Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 40.0, height: 40.0, margin: const EdgeInsets.only( right: 15.0, ), decoration: new BoxDecoration( border: Border.all(color: Colors.white), shape: BoxShape.circle, image: new DecorationImage( fit: BoxFit.fill, image: new CachedNetworkImageProvider( "https://i.imgur.com/iQkzaTO.jpg"), ), ), ), Padding( padding: const EdgeInsets.only( right: 20.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( capitalizeFirstOfEach(reviewUser), style: TextStyle( fontSize: 15, fontWeight: FontWeight.w700, ), ), Text( "Posted November 1, 2020", style: TextStyle( fontSize: 12, color: Colors.grey, ), ), ], ), ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Padding( padding: const EdgeInsets.only( bottom: 3.0, ), child: Text("Rating"), ), Row( children: [ Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star, color: Theme.of(context).primaryColor, size: 18, ), Icon( Icons.star_half, color: Theme.of(context).primaryColor, size: 18, ), ], ), ], ), ], ), Padding( padding: const EdgeInsets.only( top: 15.0, ), child: Column( children: [ Text( reviewBody, style: TextStyle( color: Colors.grey, ), ), ], ), ), ], ), ), ], ), ) ], ) : Container(); } Widget galleryImages() { return gallerySnapshot.docs.length != 0 ? Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: const EdgeInsets.only( top: 10.0, left: 20.0, right: 20.0, ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ destinationTitle("Photos"), InkWell( child: Padding( padding: EdgeInsets.symmetric( vertical: 10.0, ), child: Text( "View All", style: new TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600, ), ), ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => GalleryPage(locationName), ), ); }, ), ], ), ), Container( margin: const EdgeInsets.only( top: 10.0, bottom: 10.0, ), height: 100, child: Container( child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: gallerySnapshot.docs.length, shrinkWrap: true, itemBuilder: (context, index) { return Container( width: 100.0, margin: const EdgeInsets.only( left: 20.0, ), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: CachedNetworkImageProvider(gallerySnapshot .docs[index] .data()["galleryPath"]), ), borderRadius: BorderRadius.all(Radius.circular(8.0)), ), ); }, ), ), ) ], ) : Container(); } @override void initState() { getDestinationInfo(locationName); getDestinationGallery(locationName); getLocationReviews(locationName); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( // extendBody: true, resizeToAvoidBottomInset: true, extendBodyBehindAppBar: true, backgroundColor: Color(0xFFFFFFFF), body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ SliverAppBar( actions: <Widget>[ IconButton( icon: const Icon(Icons.favorite_border), tooltip: 'Next page', onPressed: () {}, ), ], iconTheme: IconThemeData( color: Colors.white, ), expandedHeight: 200.0, floating: false, pinned: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, background: loadDestinationBackdrop(), ), ), ]; }, body: loadDestinationInfo(), ), ); } } Widget destinationTitle(String title) { return Text( title, style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w400, fontSize: 16, ), ); } Material destinationGallery(context, String galleryImagePath) { return Material( color: Colors.white, child: Container( width: 100.0, margin: const EdgeInsets.only( left: 20.0, ), child: PhotoView( imageProvider: AssetImage("assets/images/destination.jpg"), ), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: AssetImage("assets/images/destination.jpg"), ), borderRadius: BorderRadius.all(Radius.circular(8.0)), ), ), ); }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/signIn.dart
import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:gratis/routes/getStarted.dart'; import 'package:gratis/routes/home.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/database.dart'; import 'package:gratis/services/auth.dart'; import 'package:gratis/services/shared_preferences.dart'; class SignInPage extends StatefulWidget { final Function toggleView; SignInPage(this.toggleView); @override _SignInPageState createState() => _SignInPageState(); } class _SignInPageState extends State<SignInPage> with TickerProviderStateMixin { TextEditingController emailTextEditingController = new TextEditingController(); TextEditingController passwordTextEditingController = new TextEditingController(); AuthMethods authService = new AuthMethods(); final formKey = GlobalKey<FormState>(); bool isLoading = false; signIn() async { if (formKey.currentState.validate()) { setState(() { isLoading = true; }); await authService .signInWithEmailAndPassword(emailTextEditingController.text, passwordTextEditingController.text) .then((result) async { if (result != null) { QuerySnapshot userInfoSnapshot = await DatabaseMethods() .getUserInfo(emailTextEditingController.text); CheckSharedPreferences.saveUserLoggedInSharedPreference(true); CheckSharedPreferences.saveNameSharedPreference( userInfoSnapshot.docs[0].data()["name"]); CheckSharedPreferences.saveUserEmailSharedPreference( userInfoSnapshot.docs[0].data()["email"]); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => HomeScreen(), ), ); } else { setState(() { isLoading = false; // TODO }); } }); } } @override Widget build(BuildContext context) { return Scaffold( extendBodyBehindAppBar: true, resizeToAvoidBottomInset: true, appBar: AppBar( backgroundColor: Colors.transparent, elevation: 0.0, leading: IconButton( icon: Icon(Icons.arrow_back, color: Colors.black), onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => Authenticate())); }, ), ), backgroundColor: Color(0xFFf6f6f6), body: Center( child: SingleChildScrollView( physics: ClampingScrollPhysics(), child: Container( margin: const EdgeInsets.only( top: 80.0, left: 30.0, right: 30.0, bottom: 30.0, ), width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Sign In", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 30, ), ), Divider( height: 30, ), Text( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.', style: TextStyle( color: Color(0xFF9f9f9f), fontSize: 16, ), ), Form( key: formKey, child: Column( children: [ Container( margin: EdgeInsets.only( top: 20.0, ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.075), offset: Offset(0, 10), blurRadius: 15, spreadRadius: 0), ], ), child: TextFormField( controller: emailTextEditingController, keyboardType: TextInputType.emailAddress, validator: (val) { return RegExp( r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+|.[a-zA-Z]+") .hasMatch(val) ? null : "Please enter a valid email address"; }, decoration: elevatedTextFieldInputDecoration( context, "Email Address"), ), ), ), Container( margin: EdgeInsets.only( top: 20.0, ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.075), offset: Offset(0, 10), blurRadius: 15, spreadRadius: 0), ], ), child: TextFormField( obscureText: true, keyboardType: TextInputType.visiblePassword, validator: (val) { return val.length > 6 ? null : "Password must be greater than 6 characters"; }, controller: passwordTextEditingController, textCapitalization: TextCapitalization.none, decoration: elevatedPasswordInputDecoration( context, "Password"), ), ), ), Container( margin: const EdgeInsets.only( top: 30.0, ), width: double.infinity, child: RaisedButton( onPressed: () { signIn(); }, child: Text( "Sign In", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, color: Color(0xFFFFFFFF), ), ), ), ), Container( margin: const EdgeInsets.only( top: 30.0, ), width: double.infinity, child: InkWell( onTap: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => Authenticate(), ), ); }, child: RichText( textAlign: TextAlign.center, text: TextSpan( children: <TextSpan>[ TextSpan( text: "Don't have an account?", style: TextStyle( color: Color(0xFF9f9f9f), fontWeight: FontWeight.w600, ), ), TextSpan( text: ' Sign up instead', style: TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600, ), ), ], ), ), ), ), ], ), ), ], ), ), ), )); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/home.dart
import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:gratis/routes/destination.dart'; import 'package:gratis/routes/profile.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/services/auth.dart'; import 'package:gratis/services/user.dart'; import 'package:gratis/services/shared_preferences.dart'; import 'package:gratis/database.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cached_network_image/cached_network_image.dart'; DocumentSnapshot snapshot; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { DatabaseMethods databaseMethods = new DatabaseMethods(); QuerySnapshot locationSnapshot; int _selectedIndex = 0; static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); static const List<Widget> _widgetOptions = <Widget>[ Text( 'Index 0: Home', style: optionStyle, ), Text( 'Index 1: Business', style: optionStyle, ), Text( 'Index 2: School', style: optionStyle, ), ]; getLocations() async { databaseMethods.getAllLocations().then((val) { print(val.toString()); setState(() { locationSnapshot = val; print(locationSnapshot); }); }); } Widget locationList() { return locationSnapshot != null ? ListView.builder( scrollDirection: Axis.horizontal, itemCount: locationSnapshot.docs.length, shrinkWrap: true, itemBuilder: (context, index) { return locationCard( locationName: locationSnapshot.docs[index].data()["locationName"], locationBackdropImagePath: locationSnapshot.docs[index].data()["backdropPath"]); }, ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget destinationList() { return locationSnapshot != null ? ListView.builder( scrollDirection: Axis.horizontal, itemCount: locationSnapshot.docs.length, shrinkWrap: true, itemBuilder: (context, index) { return destinationCard( locationName: locationSnapshot.docs[index].data()["locationName"], locationBackdropImagePath: locationSnapshot.docs[index].data()["backdropPath"]); }, ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget bestDealsList() { return locationSnapshot != null ? ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, itemCount: locationSnapshot.docs.length, itemBuilder: (context, index) { return destinationCard( locationName: locationSnapshot.docs[index].data()["locationName"], locationBackdropImagePath: locationSnapshot.docs[index].data()["backdropPath"]); }, ) : Container( child: Center( child: Padding( padding: const EdgeInsets.symmetric( vertical: 30.0, ), child: CircularProgressIndicator(), ), ), ); } Widget locationCard({String locationName, String locationBackdropImagePath}) { return Container( margin: const EdgeInsets.only( top: 20.0, right: 0.0, bottom: 20.0, left: 20.0, ), width: 150.0, decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.05), offset: Offset(0, 5), blurRadius: 10, spreadRadius: 0, ), ], ), child: Material( child: InkWell( customBorder: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), splashColor: Colors.white, onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => DestinationPage(locationName), ), ); }, child: Ink( width: 150.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), ), child: Column( children: [ Container( height: 100, width: double.infinity, decoration: BoxDecoration( image: new DecorationImage( image: CachedNetworkImageProvider(locationBackdropImagePath), fit: BoxFit.cover, ), borderRadius: BorderRadius.only( topRight: Radius.circular(20), topLeft: Radius.circular(20), ), ), ), Container( width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20), ), ), child: Padding( padding: EdgeInsets.all( 15.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AutoSizeText( capitalizeFirstOfEach(locationName), style: TextStyle( fontWeight: FontWeight.w800, fontSize: 16, ), maxLines: 2, ), Padding( padding: EdgeInsets.only( top: 10.0, ), child: Text( "Jan 15 - 25", style: TextStyle( fontWeight: FontWeight.w500, color: Colors.grey, fontSize: 13, ), ), ), ], ), ), ), ], ), ), ), ), ); } Widget destinationCard( {String locationName, String locationBackdropImagePath}) { return Container( margin: const EdgeInsets.only( top: 20.0, right: 0.0, bottom: 20.0, left: 20.0, ), width: MediaQuery.of(context).size.width * 0.66, decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.05), offset: Offset(0, 5), blurRadius: 10, spreadRadius: 0, ), ], ), child: Ink( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(20), ), image: DecorationImage( image: CachedNetworkImageProvider(locationBackdropImagePath), fit: BoxFit.cover, colorFilter: ColorFilter.mode( Colors.black87.withOpacity(0.2), BlendMode.darken), ), ), child: InkWell( borderRadius: BorderRadius.all( Radius.circular(20), ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => DestinationPage(locationName), ), ); }, splashColor: Colors.brown.withOpacity(0.5), child: Container( height: 150, width: double.infinity, child: Container( alignment: Alignment.bottomLeft, child: Padding( padding: const EdgeInsets.only( left: 25.0, right: 60.0, bottom: 20.0, ), child: AutoSizeText( capitalizeFirstOfEach(locationName), style: TextStyle( color: Colors.white, fontWeight: FontWeight.w800, fontSize: 18, ), maxLines: 2, ), ), ), ), ), ), ); } getUserInfo() async { Constants.userFullName = await CheckSharedPreferences.getNameSharedPreference(); setState(() { print("Shared Preferences: users name: ${Constants.userFullName}"); }); } void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override void initState() { getLocations(); getUserInfo(); } @override Widget build(BuildContext context) { AuthMethods authMethods = new AuthMethods(); return Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ SliverAppBar( leading: Container(), actions: <Widget>[ IconButton( icon: Container( width: 32.0, height: 32.0, decoration: new BoxDecoration( border: Border.all(color: Colors.white), shape: BoxShape.circle, image: new DecorationImage( fit: BoxFit.fill, image: CachedNetworkImageProvider( "https://i.imgur.com/iQkzaTO.jpg"), ), ), ), onPressed: () { // authMethods.signOut(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => ProfilePage(Constants.userFullName)), ); }), ], iconTheme: IconThemeData( color: Colors.white, ), expandedHeight: 200.0, floating: false, pinned: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, background: Container( child: Image.asset( "assets/images/getStartedBg.jpg", fit: BoxFit.cover, ), ), ), ), ]; }, body: SingleChildScrollView( child: Container( margin: const EdgeInsets.only( top: 20.0, ), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ sectionTitle("Best Selling"), Container( height: 235, child: ListView( padding: EdgeInsets.zero, scrollDirection: Axis.horizontal, children: <Widget>[ locationList(), ], ), ), sectionTitle("Popular Destinations"), Container( height: 200, child: ListView( padding: EdgeInsets.zero, scrollDirection: Axis.horizontal, children: <Widget>[ destinationList(), ], ), ), sectionTitle("Best Deals"), Container( height: 600, child: ListView( padding: EdgeInsets.zero, scrollDirection: Axis.horizontal, children: <Widget>[ bestDealsList(), ], ), ), ], ), ), ), ), bottomNavigationBar: BottomNavigationBar( selectedFontSize: 12.0, unselectedFontSize: 12.0, items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(Icons.search), title: Padding( padding: const EdgeInsets.only( top: 1.0, ), child: Text( "Explore", style: TextStyle( fontWeight: FontWeight.w700, ), ), ), ), BottomNavigationBarItem( icon: Icon(Icons.airplanemode_active), title: Padding( padding: const EdgeInsets.only( top: 1.0, ), child: Text( "Trips", style: TextStyle( fontWeight: FontWeight.w700, ), ), ), ), BottomNavigationBarItem( icon: Icon(Icons.group), title: Padding( padding: const EdgeInsets.only( top: 1.0, ), child: Text( "Profile", style: TextStyle( fontWeight: FontWeight.w700, ), ), ), ), ], currentIndex: _selectedIndex, selectedItemColor: Theme.of(context).primaryColor, onTap: _onItemTapped, ), ); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/routes/getStarted.dart
import 'package:flutter/material.dart'; import 'package:gratis/routes/home.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:gratis/widgets.dart'; import 'package:gratis/routes/signUp.dart'; import 'package:gratis/routes/signIn.dart'; import 'package:gratis/services/auth.dart'; import 'package:gratis/services/shared_preferences.dart'; class GetStarted extends StatefulWidget { final Function toggleView; GetStarted(this.toggleView); @override _GetStartedState createState() => _GetStartedState(); } class _GetStartedState extends State<GetStarted> { @override Widget build(BuildContext context) { return Scaffold( body: Container( width: double.infinity, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/getStartedBg.jpg"), fit: BoxFit.cover, colorFilter: ColorFilter.mode( Colors.grey.withOpacity(0.3), BlendMode.difference), ), ), child: SafeArea( child: Container( margin: const EdgeInsets.only( left: 30.0, right: 30.0, bottom: 30.0, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: const EdgeInsets.only( top: 70.0, ), child: Column( children: [ Container( margin: const EdgeInsets.only( bottom: 30.0, ), width: 110.0, height: 110.0, child: Padding( padding: const EdgeInsets.all(5.0), child: Image.asset( "assets/images/gratis-light.png", ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Color(0xFF54d3c2), ), ), Padding( padding: const EdgeInsets.only( bottom: 15.0, ), child: Text( "Gratís", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 50, color: Color(0xFFFFFFFF), ), ), ), Text( "Luxury rentals and hotels", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, color: Color(0xFFFFFFFF), ), ), ], ), ), Column( children: [ Container( width: double.infinity, child: RaisedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => SignUpPage(widget.toggleView), ), ); }, child: Text( "Let's Get Started", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, color: Color(0xFFFFFFFF), ), ), ), ), Padding( padding: const EdgeInsets.only( top: 30.0, ), child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => SignInPage(widget.toggleView), ), ); }, child: Text( "Already have an account? Login instead", style: TextStyle( fontWeight: FontWeight.w500, color: Color(0xFFFFFFFF), ), ), ), ), ], ), ], ), ), ), ), ); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/services/auth.dart
import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:gratis/services/user.dart'; import 'package:gratis/routes/signUp.dart'; import 'package:gratis/routes/signIn.dart'; import 'package:gratis/routes/getStarted.dart'; class Authenticate extends StatefulWidget { @override _AuthenticateState createState() => _AuthenticateState(); } class _AuthenticateState extends State<Authenticate> { bool showSignIn = false; void toggleView() { setState(() { showSignIn = !showSignIn; }); } @override Widget build(BuildContext context) { if (showSignIn) { return SignInPage(toggleView); // Navigator.push( // context, // MaterialPageRoute( // builder: (context) => SignInPage(), // ), // ); } else { // Navigator.push( // context, // MaterialPageRoute( // builder: (context) => GetStarted(), // ), // ); return GetStarted(toggleView); } } } class AuthMethods { final FirebaseAuth _auth = FirebaseAuth.instance; CurrentUser _userFromFirebaseUser(User user) { return user != null ? CurrentUser(userId: user.uid) : null; } Future signInWithEmailAndPassword(String email, String password) async { try { UserCredential result = await _auth.signInWithEmailAndPassword( email: email, password: password); User user = result.user; return _userFromFirebaseUser(user); } catch (e) { print(e.toString()); return null; } } Future signUpWithEmailAndPassword(String email, String password) async { try { UserCredential result = await _auth.createUserWithEmailAndPassword( email: email, password: password); User firebaseUser = result.user; return _userFromFirebaseUser(firebaseUser); } catch (e) { print(e.toString()); } } Future resetPassword(String email) async { try { return await _auth.sendPasswordResetEmail(email: email); } catch (e) { print(e.toString()); } } Future signOut() async { try { return await _auth.signOut(); } catch (e) { print(e.toString()); } } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/services/shared_preferences.dart
import 'package:shared_preferences/shared_preferences.dart'; class CheckSharedPreferences { static String sharedPreferenceUserLoggedInKey = "ISLOGGEDIN"; static String sharedPreferencenameKey = "nameKEY"; static String sharedPreferenceUserEmailKey = "USEREMAILKEY"; static Future<bool> saveUserLoggedInSharedPreference( bool isUserLoggedIn) async { SharedPreferences preferences = await SharedPreferences.getInstance(); return await preferences.setBool( sharedPreferenceUserLoggedInKey, isUserLoggedIn); } static Future<bool> saveNameSharedPreference(String name) async { SharedPreferences preferences = await SharedPreferences.getInstance(); return await preferences.setString(sharedPreferencenameKey, name); } static Future<bool> saveUserEmailSharedPreference(String userEmail) async { SharedPreferences preferences = await SharedPreferences.getInstance(); return await preferences.setString(sharedPreferenceUserEmailKey, userEmail); } static Future<bool> getUserLoggedInSharedPreference() async { SharedPreferences preferences = await SharedPreferences.getInstance(); return await preferences.getBool(sharedPreferenceUserLoggedInKey); } static Future<String> getNameSharedPreference() async { SharedPreferences preferences = await SharedPreferences.getInstance(); return await preferences.getString(sharedPreferencenameKey); } static Future<String> getUserEmailSharedPreference() async { SharedPreferences preferences = await SharedPreferences.getInstance(); return await preferences.getString(sharedPreferenceUserEmailKey); } } class HelperFunctions { static String sharedPreferenceUserKey = "ISLOGGEDIN"; static String sharedPreferenceUserNameKey = "USERNAMEKEY"; static String sharedPreferenceUserEmailKey = "USEREMAILKEY"; static Future<void> saveUserLoggedInPreference(bool userLoggedIn) async { SharedPreferences prefs = await SharedPreferences.getInstance(); return await prefs.setBool(sharedPreferenceUserKey, userLoggedIn); } static Future<void> saveUserNamePreference(String userName) async { SharedPreferences prefs = await SharedPreferences.getInstance(); return await prefs.setString(sharedPreferenceUserNameKey, userName); } static Future<void> saveUserEmailPreference(String userEmail) async { SharedPreferences prefs = await SharedPreferences.getInstance(); return await prefs.setString(sharedPreferenceUserEmailKey, userEmail); } static Future<bool> getUserLoggedInPreference() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getBool(sharedPreferenceUserKey); } static Future<String> getUserNamePreference() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString(sharedPreferenceUserNameKey); } static Future<void> getUserEmailPreference() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString(sharedPreferenceUserEmailKey); } }
0
mirrored_repositories/gratis/lib
mirrored_repositories/gratis/lib/services/user.dart
class CurrentUser { String userId; String userFullName; CurrentUser({this.userId, this.userFullName}); } class Constants { static String userFullName = ""; }
0
mirrored_repositories/gratis
mirrored_repositories/gratis/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:gratis/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/stringtuner
mirrored_repositories/stringtuner/lib/home_page.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'tune_page.dart'; import 'instruments.dart'; class HomePage extends StatefulWidget { @override State<StatefulWidget> createState() { return new _HomePage(); } } class _HomePage extends State<HomePage> { String currentQuery = ""; List<Instrument> instruments = new List(); List<Instrument> displayedInstruments = new List(); TextEditingController editingController = TextEditingController(); static final String savedInstrumentsKey = "saved_instruments"; void refreshListView() { if (currentQuery.isNotEmpty) { displayedInstruments.clear(); instruments.forEach((instrument) { if (instrument.name.toLowerCase().contains(currentQuery.toLowerCase())) { displayedInstruments.add(instrument); } }); } else { displayedInstruments.clear(); displayedInstruments.addAll(instruments); } } List<String> getSavedList(SharedPreferences prefs, String key) { List<String> l = prefs.getStringList(key); if (l == null) { return new List<String>(); } else { return l; } } void filterSearch(String query) { setState(() { currentQuery = query; refreshListView(); }); } Future<void> storeSavedInstrument(Instrument instrument) async { SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> savedInstruments = getSavedList(prefs, savedInstrumentsKey); savedInstruments.add(instrument.getId()); prefs.setStringList(savedInstrumentsKey, savedInstruments); setState(() { loadInstruments(savedInstruments); }); } Future<void> removeSavedInstrument(Instrument instrument) async { SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> savedInstruments = getSavedList(prefs, savedInstrumentsKey); savedInstruments.remove(instrument.getId()); prefs.setStringList(savedInstrumentsKey, savedInstruments); setState(() { loadInstruments(savedInstruments); }); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text("String Tuner"), ), body: Column(children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: Theme( data: Theme.of(context) .copyWith(dialogBackgroundColor: Colors.transparent), child: TextField( onChanged: (value) { filterSearch(value); }, controller: editingController, decoration: InputDecoration( labelText: "Search", hintText: "Search", prefixIcon: Icon(Icons.search), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(25.0))), fillColor: Colors.transparent), ), )), Expanded( child: ListView.builder( itemCount: displayedInstruments.length, itemBuilder: (context, rowNum) { Instrument instrument = displayedInstruments[rowNum]; return Container( child: Row(children: <Widget>[ Expanded( flex: 2, child: InkWell( child: Icon( Icons.star, color: instrument.starred ? Colors.yellow : Colors.white , size: 50, ), onTap: () { if (instrument.starred) { removeSavedInstrument(instrument); } else { storeSavedInstrument(instrument); } }, )), Expanded( flex: 8, child: InkWell( child: FittedBox( fit: BoxFit.fitHeight, child: Text(instrument.name.toString(), style: TextStyle(fontSize: 50))), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => TunePage(instrument)), ); }, )), ]), color: Colors.indigoAccent, margin: new EdgeInsets.all(10.0), padding: new EdgeInsets.all(10.0), alignment: Alignment.center, ); })) ])); } void loadInstruments(List<String> savedInstruments) { instruments.forEach((instrument) { instrument.starred = savedInstruments.contains(instrument.getId()); }); instruments.sort((a, b) { if (a.starred && !b.starred) { return -1; } else if (!a.starred && b.starred){ return 1; } else { return a.name.compareTo(b.name); } }); refreshListView(); } @override void initState() { instruments.addAll(instrumentsStore); // Uncomment SharedPreferences & Remove refreshListView after web issue is fixed SharedPreferences.getInstance().then((prefs) { List<String> savedInstruments = getSavedList(prefs, savedInstrumentsKey); setState(() { loadInstruments(savedInstruments); }); }); // refreshListView(); super.initState(); } }
0
mirrored_repositories/stringtuner
mirrored_repositories/stringtuner/lib/generated_plugin_registrant.dart
// // Generated file. Do not edit. // import 'dart:ui'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; void registerPlugins(PluginRegistry registry) { SharedPreferencesPlugin.registerWith(registry.registrarFor(SharedPreferencesPlugin)); registry.registerMessageHandler(); }
0
mirrored_repositories/stringtuner
mirrored_repositories/stringtuner/lib/instruments.dart
import 'dart:async' show Future; import 'package:csv/csv.dart'; import 'package:flutter/services.dart' show rootBundle; Future<String> loadCSV() async { return await rootBundle.loadString('data/instrument_tunings_parsed.csv'); } List<Instrument> parseCSV(String csvStr) { List<List<dynamic>> rowsAsListOfValues = const CsvToListConverter().convert(csvStr); return rowsAsListOfValues.map((line) { return new Instrument(line[1], line[4]); }).toList(); } class Instrument { Instrument(String name, String notes) { this.name = name; this.notes = notes; } String getId() {return this.name;} String name; String notes; bool starred = false; } final List<Instrument> instrumentsStore = [ Instrument("Ahenk", "A3:A3:B3:B3:E4:E4:A4:A4:D5:D5:G5:G5"), Instrument("Akkordolia", "F2:A2:C3:F3"), Instrument("Archlute", "F1:F2:G1:G2:A1:A2:B1:B2:C2:C3:D2:D3:E2:E3:F2:F3:G2:G2:C2:C2:F3:F3:A3:A3:D4:D4:G4"), Instrument("Armonico", "E3:A3:D4:G4:G4:B3:E4"), Instrument("Arpeggione", "E2:A2:D3:G3:B3:E4"), Instrument("Autoharp", "F2:G2:C3:D3:E3:F3:G3:A3:B3:C4:D4:E4:F4:G4:A4:B4:C5:D5:E5:F5:G5:A5:B5:C6"), Instrument("Baglamas", "D4:D5:A4:A4:D5:D5"), Instrument("Bajo quinto", "A2:A1:D3:D2:G2:G2:C3:C3:F3:F3"), Instrument("Bajo Sexto", "E2:E1:A2:A1:D3:D2:G2:G2:C3:C3:F3:F3"), Instrument("Balalaika - Alto", "E3:E3:A3"), Instrument("Balalaika - Bass", "E2:A2:D3"), Instrument("Balalaika - Contrabass", "E1:A1:D2"), Instrument("Balalaika - Descant", "E5:E5:A5"), Instrument("Balalaika - Piccolo", "B4:E5:A5"), Instrument("Balalaika - Prima", "E4:E4:A4"), Instrument("Balalaika - Prima - 6-string", "E4:E4:E4:E4:A4:A4"), Instrument("Balalaika - Secunda", "A3:A3:D4"), Instrument("Balalaika - Tenor", "E3:A3:E4"), Instrument("Bandola Andina Colombiana", "B3:B3:E4:E4:E4:A4:A4:A4:D5:D5:D5:G5:G5:G5"), Instrument("Bandola Llanera", "A2:D3:A3:E4"), Instrument("Bandola Oriental", "G3:G3:D4:D4:A4:A4:E5:E5"), Instrument("Bandolin", "E5:E4:E5:A5:A4:A5:D5:D5:D5:B5:B5:B5"), Instrument("Bandurria - Philippine", "B3:B3:E4:E4:A4:A4:A4:D5:D5:D5:G5:G5:G5"), Instrument("Bandurria - Spanish", "B4:B4:E5:E5:A5:A5"), Instrument("Banjo (5-string)", "G4:D3:G3:B3:D4"), Instrument("Banjo - Bass", "E1:A1:D2:G2"), Instrument("Banjo - Cello", "C2:G2:D3:A3"), Instrument("Banjo - Cello", "G3:D2:G2:B2:D3"), Instrument("Banjo - Contrabass", "E1:A1:D2"), Instrument("Banjo - Long Neck", "E4:B2:E3:B3"), Instrument("Banjo - Plectrum", "C3:G3:B3:D4"), Instrument("Banjo - Tenor", "C3:G3:D4:A4"), Instrument("Banjolin", "G3:D4:A4:E5"), Instrument("Baryton", "A1:D2:G3:C3:E3:A3:D4"), Instrument("Biscernica - 5 string", "B3:E4:E4"), Instrument("Bisernica - 6 string", "E3:A3:D4:D4:G4:G4"), Instrument("Bordonua", "A2:A3:D4:D3:B3:B3:E4:E4"), Instrument("Bouzouki", "C3:C4:F3:F4:A3:A3:D4:D4"), Instrument("Bouzouki", "D3:D4:A3:A3:D4:D4"), Instrument("Brac - 5 string", "E3:A3:D4:G4:G4"), Instrument("Brac - 6 string", "G3:G3:D4:D4:A4:A4"), Instrument("Braguinha", "D4:B4:G4:D5"), Instrument("Bugarija - 5 string", "G2:B2:D3:G3:G3"), Instrument("Bugarija - 6 string", "G2:B2:D3:D3:G3:G3"), Instrument("Cak", "D5:D5:G4:B4"), Instrument("Cavaquinho", "D4:G4:B4:D5"), Instrument("Cello", "C2:G2:D3:A3"), Instrument("Čelovič - 4 string", "E2:A2:D3:G3"), Instrument("Čelovič - Farkas", "D2:G2:C3:C3:G3:G3"), Instrument("Cetera", "C3:C3:D3"), Instrument("Chanzy", "F2:C3:F3"), Instrument("Chapey", "F3:F3:B3"), Instrument("Chapman Stick", "E3:A2:D2:G1:C1:B2:E3:A3:D4"), Instrument("Chapman Stick - Grand Stick", "B3:E3:A2:D2:G1:C1:B2:E3:A3:D4"), Instrument("Charango", "G4:G4:C5:C5:E5:E4:A4:A4:E5:E5"), Instrument("Charango - Ranka", "G4:G4:C5:C5:E5:E4:A4:A4:E5:E5:E6:D4:D4:A4:A4:G5:G4:C5:C5:G5:G5:G6"), Instrument("Charangón", "D4:D4:G4:G4:B4:B3:E4:E4:B4:B4"), Instrument("Chillador", "G3:G3:C4:C4:E4:E3:A3:A3:E4:E4"), Instrument("Chitarra battente", "A3:A3:D4:D4:G3:G3:B3:B3:E4:E4"), Instrument("Chonguri", "D2:F2:D3:A2"), Instrument("Çiftelia", "B3:E3"), Instrument("Cinco Cuatro", "G3:D4:D3:B4"), Instrument("Cittern", "C2:C2:G2:G2:D3:D3:A3:A3:D4:D4"), Instrument("Cretan lyra", "D3:A3:E5"), Instrument("Crwth", "G2:C3:C2:D2:D3"), Instrument("Cuatro Alto", "B3:B4:E4:E4:A4:A4:D5:D5"), Instrument("Cuatro Antiguo", "A3:A3:E4:E4:A4:A4:D5:D5"), Instrument("Cuatro Bajo", "E3:E2:A3:A2:D3:D3:G3:G3:C4:C4"), Instrument("Cuatro Cubano", "G4:G3:C4:C4:E4:E4:A4:A4"), Instrument("Cuatro Soprano", "B4:B4:E5:E5:A5:A5"), Instrument("Cuatro - Puerto Rican", "B3:B2:E4:E3:A3:A3:D4:D4:G4:G4"), Instrument("Cuatro - Venezuelan", "A3:D4:B3"), Instrument("Cuk", "G4:B3:E3"), Instrument("Cümbüş", "A2:A2:B2:B2:E3:E3:A3:A3:D4:D4:G4:G4"), Instrument("Cümbüş - Tambur", "D2:D2:A2:A2:D3:D3"), Instrument("Cura", "D4:D4:A4:A4:E5:E5"), Instrument("Cura", "G3:G3:D4:D4:A4:A4:A4"), Instrument("Cura", "G3:G3:D4:D4:A4:A4:E5:E5"), Instrument("Đàn đáy", "G3:C4:F4"), Instrument("Đàn tranh", "G3:A3:C4:D4:E4:G4:A4:C5:D5:E5:G5:A5:C6:D6:E6:G7:A7"), Instrument("Dihu", "G2:D3:D3:A3"), Instrument("Domra - Alto", "C3:G3:D4:A4"), Instrument("Domra - Alto", "E3:A3:D4"), Instrument("Domra - Bass", "C2:G2:D3:A3"), Instrument("Domra - Bass", "E2:A2:D3"), Instrument("Domra - Contrabass", "E1:A1:D2"), Instrument("Domra - Contrabass", "E1:A1:D2:G2"), Instrument("Domra - Mezzo-soprano", "B3:E4:A4"), Instrument("Domra - Piccolo", "B4:E5:A5"), Instrument("Domra - Piccolo", "C4:G4:D5:A5"), Instrument("Domra - Prima", "E4:A4:D5"), Instrument("Domra - Prima", "G3:D4:A4:E5"), Instrument("Domra - Tenor", "B2:E3:A3"), Instrument("Domra - Tenor", "G2:D3:A3:E4"), Instrument("Dotar", "D3:G3"), Instrument("Dotara", "B4"), Instrument("Dotara", "G2:G3:C4:G4:G4:C5"), Instrument("Double bass", "E1:A1:D2:G2"), Instrument("Double bass - 5-string", "C1:E1:A1:D2:G2"), Instrument("Dranyen", "A3:A3:D3:D3:G3:G3"), Instrument("Dranyen", "A3:A3:D4:D3:D3:G3:G3"), Instrument("Erhu", "D4:A4"), Instrument("Fiddle", "G3:D4:A4:E5"), Instrument("Gadulka", "A3:E3:A4"), Instrument("Gaoyinruan", "G3:D4:G4:D5"), Instrument("Gehu", "C2:G2:D3:A3"), Instrument("Gekkin", "A3:D4:D4:D5"), Instrument("Geyerleier", "E3:E2:B3:B2:E3:E3:B3:B3"), Instrument("Grajappi", "F2:F2:B2:B2"), Instrument("Guitalele", "A2:D3:G3:C4:E4:A4"), Instrument("Guitar", "E2:A2:D3:G3:B3:E4"), Instrument("Guitar - 10 string", "C2:E2:A2:D3:G3:B3:E4"), Instrument("Guitar - 12 string", "E3:E2:A3:A2:D4:D3:G4:G3:B3:B3:E4:E4"), Instrument("Guitar - 7 string", "B1:E2:A2:D3:G3:B3:E4"), Instrument("Guitar - 8 string (low/high)", "B1:E2:A2:D3:G3:B3:E4:A4"), Instrument("Guitar - 9 string", "E2:A2:D3:G4:G3:B3:B3:E4:E4"), Instrument("Guitar - 9 string", "E3:E2:A3:A2:D4:D3:G3:B3:E4"), Instrument("Guitar - Alto (Niibori)", "B2:E3:A3:D4"), Instrument("Guitar - bass", "E1:A1:D2:G2"), Instrument("Guitar - bass (12-string)", "E2:E2:E1:A2:A2:A1:D3:D3:D2:G3:G3:G2"), Instrument("Guitar - bass (5-string)", "B0:E1:A1:D2:G2:E1:A1:D2:G2"), Instrument("Guitar - bass (6-string)", "B0:E1:A1:D2:G2:C3"), Instrument("Guitar - bass (8-string)", "E2:E1:A2:A1:D3:D2:G3:G2"), Instrument("Guitar - octave", "E3:A3:D4:G4:B4:E5"), Instrument("Guitar - tenor", "C3:G3:D4:A4"), Instrument("Guitarra De Golpe", "D3:G3:C4:E3:A3"), Instrument("Guitarro", "B4:D5:A5:E5"), Instrument("Guitarrón", "A1:D2:G2:C3:E3:A2"), Instrument("Guitarron Argentino", "B1:E2:A2:D3:G3:B3"), Instrument("Gusli", "E3:A3:B3:C4:D4:E4:F4:G4"), Instrument("Halszither", "G2:D3:D3:G3:G3:B3:B3:D4:D4"), Instrument("Hardingfele", "A3:D4:A4:E5"), Instrument("Huapanguera", "G2:D3:D4:G3:G3:B3:B3:E3"), Instrument("Huobosi", "E2:A2:D3:G3"), Instrument("Irish bouzouki", "G3:G2:D4:D3:A3:A3:E4:E4"), Instrument("Jarana huasteca", "G3:B3:D4:A4"), Instrument("Jarana Jarocha Requinto", "G2:A2:D2:G3"), Instrument("Jarana Leona", "G2:A2:D3:G3"), Instrument("Kamancheh", "D5:A5:D4:A4"), Instrument("Khonkhota", "G4:G3:C4:D4:D3:A3:D4:D4"), Instrument("Kithara Sarda", "B2:E2:A2:D3:F3:B3"), Instrument("Kokles", "G3:A3:C3:D3:E3:F3:G4:A4:B4:C4:G3:A3:C3:D3:E3:F3:G4:A4:B4:C4"), Instrument("Laouto", "C2:C3:G2:G3:D2:D3:A3:A3"), Instrument("Laúd - Cuban", "D3:D3:B3:B3:E4:E4:A4:A4:D5:D5"), Instrument("Laúd - Philippine", "B2:B2:E3:E3:A3:A3:A3:D4:D4:D4:G4:G4:G4"), Instrument("Lili'u", "G3:G4:C3:C4:E4:E4:A4:A4"), Instrument("Liuto cantabile", "C2:C2:G2:G2:D3:D3:A3:A3:E4:E4"), Instrument("Luc huyen cam", "C3:F3:C4:G4:C5"), Instrument("Luc huyen cam", "E2:A2:D3:G3:B4:E4"), Instrument("Lute", "G2:G2:C3:C3:F3:F3:A3:A3:D4:D4:G4:G4"), Instrument("Lute guitar", "E2:A2:D3:G3:B3:E4"), Instrument("Mandobass", "E1:A1:D2:G2"), Instrument("Mandobass", "G1:G1:D2:D2:A2:A2:E3:E3"), Instrument("Mandocello", "C2:C2:G2:G2:D3:D3:A3:A3"), Instrument("Mandola", "C3:C3:G3:G3:D4:D4:A4:A4"), Instrument("Mandolin", "G3:G3:D4:D4:A4:A4:E5:E5"), Instrument("Mandolin - Octave", "G2:G2:D3:D3:A3:A3:E4:E4"), Instrument("Mandolin - Piccolo", "C4:C4:G4:G4:D5:D5:A5:A5"), Instrument("Mandolinetto", "G3:G3:D4:D4:A4:A4:E5:E5"), Instrument("Mandriola", "G3:G3:G3:D4:D4:D4:A4:A4:A4:E5:E5:E5"), Instrument("Manguerito", "D4:G4:B4:B3:E4:B4:B4"), Instrument("Nevoud", "B2:B2:E3:E3:A3:A3:D4:D4"), Instrument("Octavina", "B1:B1:E2:E2:A2:A2:A2:D3:D3:D3:G3:G3:G3"), Instrument("Octobass", "C1:G1:C2"), Instrument("Oud", "C2:F2:A2:D3:G3:C4"), Instrument("Palida", "D3:A3:E4:B4"), Instrument("Panduri", "G3:A3:C4"), Instrument("Pardessus de Viole", "C4:E4:A4:D5"), Instrument("Phin", "A3:E4:A4"), Instrument("Pipa", "A2:D3:E3:A3"), Instrument("Portuguese guitar", "D3:D2:A3:A2:B3:B2:E3:E3:A3:A3:B3:B3"), Instrument("Qinqin", "G3:D4:A5"), Instrument("Ramkie", "C3:F3:A3:C4"), Instrument("Requinto", "A2:D3:G3:C4:E4:A4"), Instrument("Ronroco", "D4:D4:G4:G4:B4:B3:E4:E4:B4:B4"), Instrument("Russian guitar", "D2:G2:B2:D3:G3:B3:D4"), Instrument("Samica", "B3:E4"), Instrument("Sanshin", "C3:F3:C4"), Instrument("Sanxian", "A2:D3:A3"), Instrument("Sanxian - Large", "G2:D3:G3"), Instrument("Sarangi - Nepalese", "G4:C5:C5:G5"), Instrument("Sargija", "C3:C3:G3:G3:D3:D3"), Instrument("Seis Cinco", "E3:A4:A3:D3:B4"), Instrument("Setar", "C3:C4:G3:C4"), Instrument("Sitar", "C5:C4"), Instrument("Socavon", "G3:D4:A4:B2"), Instrument("Strumstick", "G3:D4:G4"), Instrument("Swedish lute (modern)", "F1:G1:A1:B1:C2:D2"), Instrument("Tambura", "D3:D3:G3:G3:B3:B3:E4:E4"), Instrument("Tarica", "C2:G2:G2:C3:C3"), Instrument("Taropatch", "G3:C3:C4:E4:A4:A4"), Instrument("Terzin Kitarra", "B2:E3:A3:E4"), Instrument("Timple", "G4:C5:E4:A4:D5"), Instrument("Tiple de Menorca", "D4:G4:C5:E5:A5"), Instrument("Tiple Requinto", "C4:C4:C4:E4:E4:E4:A4:A4:A4:D4:D4:D4"), Instrument("Tiple - American", "A4:A3:D4:D3:D4:B3:B3"), Instrument("Tiple - Columbian", "C4:C3:C4:E4:E3:E4:A4:A3:A4:D4:D4:D4"), Instrument("Tiple - Puerto Rican", "E3:A3:D4:G4:C5"), Instrument("Tres - Cuban", "G4:G3:C4:C4:E3:E4"), Instrument("Tres - Puerto Rican", "G4:G3:G4:C4:C4:C4:E4:E3:E4"), Instrument("Tricordia", "G2:G3:G3:D3:D4:D4:A3:A4:A4:E4:E5:E5"), Instrument("Tzouras", "D3:D4:A3:A3:D4:D4"), Instrument("Ukulele - Baritone", "D3:G3:B3:E4"), Instrument("Ukulele - Bass", "E2:A2:D3:G3"), Instrument("Ukulele - Concert", "G4:C4:E4:A4"), Instrument("Ukulele - Contrabass (UBass)", "E1:A1:D2:G2"), Instrument("Ukulele - Pocket", "C5:F5:A5"), Instrument("Ukulele - Soprano", "G4:C4:E4:A4"), Instrument("Ukulele - Tahitian", "G4:G4:C5:C5:E5:E5:A4:A4"), Instrument("Ukulele - Tenor", "G3:C4:E4:A4"), Instrument("Veena", "C3:D3:E3:F3:G3:A3:B3"), Instrument("Vihuela", "A3:D4:G4:B3:E4"), Instrument("Viol - alto", "A2:D3:G3:B3:E4:A4"), Instrument("Viol - bass", "A1:D2:G2:C3:E3:A3:D4"), Instrument("Viol - bass", "D2:G2:C3:E3:A3:D4"), Instrument("Viol - contrabass", "D1:G1:C2:E2:A2:D3"), Instrument("Viol - Tenor", "G2:C3:F3:A3:D4:G4"), Instrument("Viol - Treble", "D3:G3:C4:E4:A4:D5"), Instrument("Viola", "C3:G3:D4:A4"), Instrument("Viola Amarantina", "D3:D2:A3:A2:B3:B2:E3:E3:A3:A3"), Instrument("Viola Beiroa", "D3:D3:A3:A2:D3:D2:G3:G2:B3:B3:D3:D3"), Instrument("Viola Braguesa", "C4:C3:G4:G3:A4:A3:D4:D4:G4:G4"), Instrument("Viola caipira", "A3:A2:D4:D2:A3:A3:D4:D4"), Instrument("Viola Campaniça", "C3:C2:F3:F2:C3:C3:E3:E3:G3:G3"), Instrument("Viola Da Terra", "A3:A3:A2:D4:D4:D3:G3:G3:B3:B3:D4:D4"), Instrument("Viola De Arame", "G3:G2:D3:D2:G3:G3:B3:D3:D3"), Instrument("Viola de cocho", "G3:D3:E3:A3:D4"), Instrument("Viola Terceira", "E3:E3:E2:A3:A3:A2:D4:D4:D3:G4:G3:B3:B3:E3:E3"), Instrument("Viola Toeira", "A3:A3:A2:D4:D4:D3:G4:G3:B3:B3:E3:E3"), Instrument("Violao De Sete Cordas", "C2:E2:A2:D3:G3:B3:E4"), Instrument("Violin", "G3:D4:A4:E5"), Instrument("Violin - Tenor", "G2:D3:A3:E4"), Instrument("Waldzither - bass", "A2:E3:E3:A3"), Instrument("Waldzither - descant", "G3:D4:D4:G4:G4:B4:B4:D5"), Instrument("Waldzither - Heym", "C2:C2:G3:G3:G3:C4:C4:C4:E4:E4:E4:G4:G4"), Instrument("Waldzither - piccolo", "C4:G4:G4:C5:C5:E5:E5:G5:G5"), Instrument("Waldzither - tenor", "C3:G3:G3:C4:C4:E4:E4:G4:G4"), Instrument("Yayli Tambur", "D2:D2:A2:A2:D3:D3"), Instrument("Yueqin", "G3:D4:G4:D5"), Instrument("Yueqin - Taiwanese", "D3:A4"), Instrument("Zheng", "C2:D2:E2:G2:A2:C3:D4:E4:G4:A4:C4:D4:E4:G4:A4:C5:D5"), Instrument("Zhonghu", "G3:D4:A3:E4"), Instrument("Zhongruan", "G2:D3:G3:D4"), Instrument("Zither - Alpine", "A4:A4:D4:G3:C3"), Instrument("Zither - Concert", "A4:A4:D4:G3:C3"), ];
0
mirrored_repositories/stringtuner
mirrored_repositories/stringtuner/lib/tune_page.dart
import 'dart:typed_data'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:soundpool/soundpool.dart'; import 'instruments.dart'; Map<String,String> unicodeSubscriptMap = { '0' : '\u2080', '1' : '\u2081', '2' : '\u2082', '3' : '\u2083', '4' : '\u2084', '5' : '\u2085', '6' : '\u2086', '7' : '\u2087', '8' : '\u2088', '9' : '\u2089', }; Future<void> playTone(note) async { Soundpool pool = Soundpool(streamType: StreamType.notification); int soundId = await rootBundle .load("data/tones/" + note + ".wav") .then((ByteData soundData) { return pool.load(soundData); }); int streamId = await pool.play(soundId); } class TunePage extends StatelessWidget { final Instrument instrument; TunePage(this.instrument); @override Widget build(BuildContext context) { List<String> notesSplit = instrument.notes.split(":"); return new Scaffold( appBar: new AppBar( title: new Text("Tune " + instrument.name), ), body: GridView.count( crossAxisCount: 2, children: List.generate(notesSplit.length, (i) { return InkWell( onTap: () { playTone(notesSplit[i]).then((val) { print("finished tone"); }); }, child: new Container( child: FittedBox( fit: BoxFit.fitHeight, child: RichText( text: TextSpan( children: [ TextSpan(text: notesSplit[i][0], style: TextStyle(fontSize: 500, color: Colors.white)), TextSpan(text: unicodeSubscriptMap[notesSplit[i][1]], style: TextStyle(fontSize: 500, color: Colors.black)) ] ) ), ), color: Colors.indigoAccent, alignment: Alignment.center, margin: EdgeInsets.all(10.0), padding: EdgeInsets.all(10.0), ), enableFeedback: false, ); })), ); } }
0
mirrored_repositories/stringtuner
mirrored_repositories/stringtuner/lib/main.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'home_page.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'String Tuner', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.indigo, ), home: HomePage(), ); } }
0
mirrored_repositories/stringtuner
mirrored_repositories/stringtuner/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:untitled/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/Applying_Filters_and_Effects_to_Images_Flutter
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter/lib/color_effect.dart
import 'dart:ui'; import 'package:flutter/material.dart'; class ColorImage extends StatefulWidget { @override _ColorImageState createState() => _ColorImageState(); } class _ColorImageState extends State<ColorImage> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffcedeee), appBar: AppBar( backgroundColor: Color(0xff0812a1), title: Text("How to Apply Filters & Effects")), body: Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ //Color your asset here ColorFiltered( colorFilter: const ColorFilter.mode(Colors.grey, BlendMode.saturation), child: Image.asset("assets/logo.png")) ])))); } }
0
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter/lib/matrix.dart
import 'dart:typed_data'; import 'dart:ui'; import 'package:flutter/material.dart'; class ImageFilterMatrix extends StatefulWidget { @override _ImageFilterMatrixState createState() => _ImageFilterMatrixState(); } class _ImageFilterMatrixState extends State<ImageFilterMatrix> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffcedeee), appBar: AppBar( backgroundColor: Color(0xff0812a1), title: Text("How to Apply Filters & Effects")), body: Container( child: Center( child: Column(children: [ //Define the Matrix ImageFiltered( imageFilter: ImageFilter.matrix(Float64List.fromList([ 1, 0.5, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ])), child: Image.asset("assets/logo.png", scale: 3.5)) ])))); } }
0
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter/lib/blur_Image.dart
import 'dart:ui'; import 'package:flutter/material.dart'; class BlurImage extends StatefulWidget { @override _BlurImageState createState() => _BlurImageState(); } class _BlurImageState extends State<BlurImage> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffcedeee), appBar: AppBar( backgroundColor: Color(0xff0812a1), title: Text("How to Apply Filters & Effects")), body: Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ //Blur an Image asset ImageFiltered( imageFilter: ImageFilter.blur(sigmaY: 5, sigmaX: 5), child: Image.asset("assets/logo.png")) ])))); } }
0
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter/lib/matrix_rotation.dart
import 'dart:typed_data'; import 'dart:ui'; import 'package:flutter/material.dart'; class Matrix4Rotation extends StatefulWidget { @override _Matrix4RotationState createState() => _Matrix4RotationState(); } class _Matrix4RotationState extends State<Matrix4Rotation> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffcedeee), appBar: AppBar( backgroundColor: Color(0xff0812a1), title: Text("How to Apply Filters & Effects")), body: Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ //Rotate the Matrix of the asset ImageFiltered( imageFilter: ImageFilter.matrix(Matrix4.rotationZ(0.2).storage), child: Image.asset("assets/logo.png", scale: 6)), ])))); } }
0
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_imagefiltered_demo/color_effect.dart'; import 'package:flutter_imagefiltered_demo/blur_Image.dart'; import 'package:flutter_imagefiltered_demo/matrix.dart'; import 'package:flutter_imagefiltered_demo/matrix_rotation.dart'; void main() { runApp(ImageEditor()); } class ImageEditor extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp(debugShowCheckedModeBanner: false, home: HomePage()); } } class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xffcedeee), appBar: AppBar( backgroundColor: Color(0xff0812a1), title: Text('How to Apply Filters & Effects'), centerTitle: true), body: Center( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ // First Button to Blur Images Image.asset("assets/logo.png", scale: 4), // Space before Buttons SizedBox(height: 130), OutlinedButton( child: Text('Blur an Image', style: TextStyle(color: Colors.black)), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => BlurImage())); }, style: ElevatedButton.styleFrom( side: BorderSide( width: 1.0, color: Color(0xff0812a1)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(32.0)))), // Space between Buttons SizedBox(height: 10), // Second Button for Image Matrix OutlinedButton( child: Text('Image Matrix', style: TextStyle(color: Colors.black)), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => ImageFilterMatrix())); }, style: ElevatedButton.styleFrom( side: BorderSide( width: 1.0, color: Color(0xff0812a1)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(32.0)))), // Space between Buttons SizedBox(height: 10), // Third Button for Matrix Rotation OutlinedButton( child: Text('Matrix Rotation', style: TextStyle(color: Colors.black)), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => Matrix4Rotation())); }, style: ElevatedButton.styleFrom( side: BorderSide( width: 1.0, color: Color(0xff0812a1)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(32.0)))), // Space between Buttons SizedBox(height: 10), // Last Button to change color OutlinedButton( child: Text('Color Effect', style: TextStyle(color: Colors.black)), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => ColorImage())); }, style: ElevatedButton.styleFrom( side: BorderSide( width: 1.0, color: Color(0xff0812a1)), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(32.0)))), ])))); } }
0
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter
mirrored_repositories/Applying_Filters_and_Effects_to_Images_Flutter/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:flutter_imagefiltered_demo/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(ImageEditor()); // 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