repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutter_simple_counter/lib
mirrored_repositories/flutter_simple_counter/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { // Propiedad int counter = 10; void increment() { setState(() { counter = counter + 1; }); } void decrement() { setState(() { counter--; }); } void reset() { setState(() { counter = 0; }); } @override Widget build(BuildContext context) { // Variable const fontSize30 = TextStyle(fontSize: 30); return Scaffold( appBar: AppBar( title: const Text('Counter Screen'), elevation: 0, ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ const Text('Número de clicks', style: fontSize30), Text('$counter', style: fontSize30) ], ), ), floatingActionButton: FloatingActionButtonGroup( decrementFn: decrement, incrementFn: increment, resetFn: reset, ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); } } class FloatingActionButtonGroup extends StatelessWidget { final Function incrementFn; final Function decrementFn; final Function resetFn; const FloatingActionButtonGroup({ Key? key, required this.incrementFn, required this.decrementFn, required this.resetFn, }) : super(key: key); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ FloatingActionButton( child: const Icon(Icons.exposure_minus_1_outlined), tooltip: 'Decrement', onPressed: () => decrementFn()), FloatingActionButton( child: const Icon(Icons.exposure_zero_outlined), tooltip: 'Reset', onPressed: () => resetFn()), FloatingActionButton( child: const Icon(Icons.exposure_plus_1_outlined), tooltip: 'Increment', onPressed: () => incrementFn()), ], ); } }
0
mirrored_repositories/flutter_simple_counter
mirrored_repositories/flutter_simple_counter/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:simple_counter/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-Widget-Playground
mirrored_repositories/Flutter-Widget-Playground/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: return macos; case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions web = FirebaseOptions( apiKey: 'AIzaSyA5WjKe6-N5i46h960hL42NwLxMTl0n1OQ', appId: '1:198382239217:web:3a2c7906dadb2e1c3b9850', messagingSenderId: '198382239217', projectId: 'day30s', authDomain: 'day30s.firebaseapp.com', storageBucket: 'day30s.appspot.com', measurementId: 'G-XPBG2MSMS8', ); static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyDmZnjQlfymxhAhxaf8Xtg4QNlW6WI5aeI', appId: '1:198382239217:android:a803bae5868f14763b9850', messagingSenderId: '198382239217', projectId: 'day30s', storageBucket: 'day30s.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyAwjatIbK5K10b9wXNNggryG60QgfXlAJE', appId: '1:198382239217:ios:e27efe07be4b6f6b3b9850', messagingSenderId: '198382239217', projectId: 'day30s', storageBucket: 'day30s.appspot.com', iosBundleId: 'com.example.basicWidget301', ); static const FirebaseOptions macos = FirebaseOptions( apiKey: 'AIzaSyAwjatIbK5K10b9wXNNggryG60QgfXlAJE', appId: '1:198382239217:ios:1847e10a6a9ff7503b9850', messagingSenderId: '198382239217', projectId: 'day30s', storageBucket: 'day30s.appspot.com', iosBundleId: 'com.example.basicWidget301.RunnerTests', ); }
0
mirrored_repositories/Flutter-Widget-Playground
mirrored_repositories/Flutter-Widget-Playground/lib/main.dart
import 'package:basic_widget_30_1/animations/animation_builder.dart'; import 'package:basic_widget_30_1/firebase_contain/day22_auth.dart'; import 'package:basic_widget_30_1/firebase_contain/day23_database.dart'; import 'package:basic_widget_30_1/widgets/alertDialog.dart'; import 'package:basic_widget_30_1/widgets/animatedText.dart'; import 'package:basic_widget_30_1/widgets/animated_bottom_nv.dart'; import 'package:basic_widget_30_1/widgets/bottomSheetDialog.dart'; import 'package:basic_widget_30_1/widgets/bottomnav.dart'; import 'package:basic_widget_30_1/widgets/button.dart'; import 'package:basic_widget_30_1/widgets/custom_list_grid.dart'; import 'package:basic_widget_30_1/widgets/day19ui.dart'; import 'package:basic_widget_30_1/widgets/day20.dart'; import 'package:basic_widget_30_1/widgets/day21ui.dart'; import 'package:basic_widget_30_1/widgets/dismissibleWidget.dart'; import 'package:basic_widget_30_1/widgets/drawerWidget.dart'; import 'package:basic_widget_30_1/widgets/dropdown_list.dart'; import 'package:basic_widget_30_1/widgets/form.dart'; import 'package:basic_widget_30_1/widgets/geolocator.dart'; import 'package:basic_widget_30_1/widgets/imagepicker.dart'; import 'package:basic_widget_30_1/widgets/images.dart'; import 'package:basic_widget_30_1/widgets/list_grid.dart'; import 'package:basic_widget_30_1/widgets/snackbarWidget.dart'; import 'package:basic_widget_30_1/widgets/splash.dart'; import 'package:basic_widget_30_1/widgets/stack.dart'; import 'package:basic_widget_30_1/widgets/tabbar.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:basic_widget_30_1/animations/animated_container.dart'; import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; void main() async { WidgetsFlutterBinding .ensureInitialized(); // Ensure Flutter binding is initialized await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( brightness: Brightness.light, primaryColor: Colors.blueAccent), home: StreamBuilder( stream: FirebaseAuth.instance.authStateChanges(), builder: (context, snapshot) { if (snapshot.hasData) { return DatabaseOptions(); } else { return Day22_Auth(); } })); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/day20.dart
import 'package:flutter/material.dart'; import 'package:basic_widget_30_1/components/card_friend.dart'; import 'package:basic_widget_30_1/components/row_status.dart'; class Day20UI extends StatefulWidget { const Day20UI({Key? key}) : super(key: key); @override _Day20UIState createState() => _Day20UIState(); } class _Day20UIState extends State<Day20UI> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: false, title: Row( children: [ const Text('2z.tzy'), const SizedBox(width: 5), const Icon(Icons.arrow_downward_outlined), const SizedBox(width: 5), Container( width: 10, height: 10, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.red, ), ), ], ), actions: const [ Icon( Icons.add_box_outlined, size: 30, ), SizedBox(width: 10), Icon( Icons.menu, size: 30, ), SizedBox(width: 5), ], ), body: Container( child: Column( children: [ Container( height: 200, child: Row( children: [ Container( margin: EdgeInsets.only(left: 10), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: const EdgeInsets.all(3), decoration: BoxDecoration( border: Border.all(), shape: BoxShape.circle, color: Colors.grey, ), child: const CircleAvatar( radius: 60, backgroundImage: NetworkImage( 'https://scontent.fhan14-3.fna.fbcdn.net/v/t39.30808-6/417781839_344460121869446_1233461574458003244_n.jpg?_nc_cat=103&ccb=1-7&_nc_sid=efb6e6&_nc_eui2=AeGE6-sh8w8STx2GpeThbzPTbcJiDOqLi7VtwmIM6ouLtb5mwnWITJbtAAkDzkczOmFvaU8KwpXYeE6vR8JETK2i&_nc_ohc=rAoSyyGiCxYAX8aqukA&_nc_ht=scontent.fhan14-3.fna&oh=00_AfD16tK14V2lU6RlE8k6eyAkGrGA-DV0RyW0inVY4TKkag&oe=65BDF734', ), ), ), const SizedBox( height: 5, ), const Text( 'Huy Nguyen', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), ], ), ), Expanded( child: Container( margin: EdgeInsets.only(top: 50, left: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( child: RowStatus('4', 'Post'), ), Container( child: RowStatus('49', 'Followers'), ), Container( child: RowStatus('205', 'Following'), ), ], ), ), ), ], ), ), Container( height: 80, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const SizedBox(width: 10), Expanded(child: ButtonProfile('Edit Profile')), const SizedBox(width: 10), Expanded(child: ButtonProfile('Share Profile')), const SizedBox(width: 10), ], ), ), Container( child: Column( children: [ Container( padding: const EdgeInsets.all(12), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Explore more friends', style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold, ), ), Text( 'See all', style: TextStyle( color: Colors.blue, fontSize: 18, fontWeight: FontWeight.bold, ), ), ], ), ), Container( margin: EdgeInsets.only(left: 12), height: 300, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: 6, itemBuilder: (builder, context) { return CardFrends(); // Corrected the typo in CardFriends }, ), ), const SizedBox( height: 24, ), ], ), ), Container( height: 120, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: 6, itemBuilder: (builder, context) { return Column( children: [ Container( margin: EdgeInsets.only(left: 20), decoration: BoxDecoration( border: Border.all(), shape: BoxShape.circle, color: Colors.grey, ), child: const CircleAvatar( radius: 40, backgroundImage: NetworkImage( 'https://scontent.fhan14-3.fna.fbcdn.net/v/t39.30808-6/417781839_344460121869446_1233461574458003244_n.jpg?_nc_cat=103&ccb=1-7&_nc_sid=efb6e6&_nc_eui2=AeGE6-sh8w8STx2GpeThbzPTbcJiDOqLi7VtwmIM6ouLtb5mwnWITJbtAAkDzkczOmFvaU8KwpXYeE6vR8JETK2i&_nc_ohc=rAoSyyGiCxYAX8aqukA&_nc_ht=scontent.fhan14-3.fna&oh=00_AfD16tK14V2lU6RlE8k6eyAkGrGA-DV0RyW0inVY4TKkag&oe=65BDF734', ), ), ), const SizedBox( height: 5, ), Text('data'), ], ); }, ), ), const SizedBox( height: 20, ), Flexible( child: Container( child: Container( child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, crossAxisSpacing: 10.0, mainAxisSpacing: 10.0, ), itemCount: 6, itemBuilder: (context, index) { return Container( height: 100, width: 100, margin: const EdgeInsets.all(10), child: Stack( children: [ const Positioned( right: 0, top: 10, child: Icon(Icons.video_collection_outlined), ), Positioned.fill( child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.network( 'https://scontent.fhan14-3.fna.fbcdn.net/v/t39.30808-6/355103968_215794938069299_451551051807636056_n.jpg?_nc_cat=110&ccb=1-7&_nc_sid=9c7eae&_nc_eui2=AeGN3al-R-BE6g0fulpVlJhf3uG8fWvN8qne4bx9a83yqXPU_qllcFSSe18HgyFFMCdz_uHbtcHv0GxAFnCxUovN&_nc_ohc=ExFD0ii1ApwAX9KKNzH&_nc_ht=scontent.fhan14-3.fna&oh=00_AfBUlPJhjvNKQinoeDCmkTuF0NgFIJV6ImRfTjJbnTbTAA&oe=65BEEA43', fit: BoxFit.cover, ), ), ), ], ), ); }, ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/animated_bottom_nv.dart
import 'package:flutter/material.dart'; class AnimatedBottomNav extends StatefulWidget { const AnimatedBottomNav({super.key}); @override State<AnimatedBottomNav> createState() => _AnimatedBottomNavState(); } class _AnimatedBottomNavState extends State<AnimatedBottomNav> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Animated Bottom Navigation'), ), body: Container(), floatingActionButton: FloatingActionButton(onPressed: () {}), // bottomNavigationBar: , ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/images.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; class ImageWidget extends StatefulWidget { const ImageWidget({super.key}); @override State<ImageWidget> createState() => _ImageWidgetState(); } class _ImageWidgetState extends State<ImageWidget> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Image Example'), ), body: Center( child: Column( children: [ Container( width: 150, height: 200, // đạnh dạng trang trí cho container, decoration: BoxDecoration( // tạo hiệu ứng đổ bóng cho container boxShadow: const [ BoxShadow( //bán kính độ mờ áp dúng cho đổ bóng // tạo ra hiệu ứng có đọi mờ tương ứng với đơn vị tùy chỉnh xung quanh object được đổ bóng blurRadius: 30, color: Colors.yellow, //bán kính lan tỏa của độ bóng // xác định mức mở rộng của đổ bóng ra xung quanh // sẽ đố bóng theo đơn vị từ widget ra thêm ... đơn vị spreadRadius: 5, ), ], borderRadius: BorderRadius.circular(20), color: Colors.red, image: const DecorationImage( image: NetworkImage( 'https://th.bing.com/th/id/OIG.MxQxUggA0RKmKdTjwAqw'), fit: BoxFit.cover), ), ), SizedBox( height: 50, ), //! Lấy hình ảnh trong asset // vào file pubspec.yml , bỏ comment ở mục assets Container( width: 150, height: 200, // đạnh dạng trang trí cho container, decoration: BoxDecoration( // tạo hiệu ứng đổ bóng cho container boxShadow: const [ BoxShadow( //bán kính độ mờ áp dúng cho đổ bóng // tạo ra hiệu ứng có đọi mờ tương ứng với đơn vị tùy chỉnh xung quanh object được đổ bóng blurRadius: 30, color: Colors.red, //bán kính lan tỏa của độ bóng // xác định mức mở rộng của đổ bóng ra xung quanh // sẽ đố bóng theo đơn vị từ widget ra thêm ... đơn vị spreadRadius: 5, ), ], borderRadius: BorderRadius.circular(20), color: Colors.red, image: const DecorationImage( image: AssetImage('assets/img1.jpeg'), fit: BoxFit.cover), ), ), const SizedBox( height: 50, ), //! Cached Image network được sử dụng để load ảnh từ network sau đó sẽ lưu vào bộ nhớ cục bộ //Cải thiện hiệu suất và load ảnh mượt mà hơn vì nếu cùng 1 request lên ảnh đó thì nó sẽ lôi từ trong bộ nhớ mà không cần phải đợi tín hiệu từ internet Container( width: 150, height: 200, child: CachedNetworkImage( imageUrl: "https://pixlr.com/images/index/ai-image-generator-two.webp", imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( blurRadius: 10, color: Colors.white, spreadRadius: 20) ], image: DecorationImage( image: imageProvider, fit: BoxFit.cover, colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn)), ), ), placeholder: (context, url) => Center(child: CircularProgressIndicator()), errorWidget: (context, url, error) => Icon(Icons.error), ), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/imagepicker.dart
import 'dart:io'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; class ImagePickWidget extends StatefulWidget { const ImagePickWidget({Key? key}) : super(key: key); @override State<ImagePickWidget> createState() => _ImagePickWidgetState(); } class _ImagePickWidgetState extends State<ImagePickWidget> { final ImagePicker _picker = ImagePicker(); XFile? file; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Image Picker'), ), body: Center( child: Column( children: [ Container( width: double.infinity, height: 300, color: Colors.grey, child: Center( child: file == null ? const Text('Image Not Picked') : Image.file(File(file!.path)), ), ), const SizedBox( height: 30, ), ElevatedButton( onPressed: () async { XFile? photo = await _picker.pickImage(source: ImageSource.gallery); if (photo != null) { setState(() { file = photo; }); print('Image picked: ${file!.path}'); } }, child: Text('Image Picker'), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/custom_list_grid.dart
import 'package:basic_widget_30_1/utils/const.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; class SliverListGridExample extends StatefulWidget { const SliverListGridExample({Key? key}) : super(key: key); @override SliverListGridExampleState createState() => SliverListGridExampleState(); } class SliverListGridExampleState extends State<SliverListGridExample> { bool isGrid = false; List<String> items = List.generate(newMusicList.length, (index) => 'Item ${index + 1}'); @override Widget build(BuildContext context) { return Scaffold( drawer: const Drawer(), body: CustomScrollView( slivers: <Widget>[ SliverAppBar( pinned: true, flexibleSpace: const FlexibleSpaceBar(title: Text('Motion Tabbar')), actions: [ IconButton( tooltip: isGrid ? 'Grid' : 'List', onPressed: () { setState(() { isGrid = !isGrid; }); debugPrint(isGrid.toString()); }, icon: Icon( isGrid ? Icons.view_list_rounded : Icons.grid_on_rounded, ), ), ], ), if (isGrid) AnimationLimiter( child: SliverGrid( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, ), delegate: SliverChildBuilderDelegate( (context, index) { return AnimationConfiguration.staggeredGrid( position: index, duration: const Duration(milliseconds: 300), columnCount: 2, child: ScaleAnimation( child: buildGridItem(index), ), ); }, childCount: items.length, ), ), ), if (!isGrid) SliverList( delegate: SliverChildBuilderDelegate( (context, index) { return AnimationConfiguration.staggeredList( position: index, duration: const Duration(milliseconds: 300), child: SlideAnimation( verticalOffset: 50.0, child: FadeInAnimation( child: buildListItem(index), ), ), ); }, childCount: items.length, ), ), ], ), ); } Widget buildGridItem(int index) { return Card( clipBehavior: Clip.antiAlias, child: Column( children: [ SizedBox( height: 150.0, width: double.infinity, child: Image.network( newMusicList[index]['img'], fit: BoxFit.cover, ), ), const SizedBox(height: 8.0), Text(newMusicList[index]['title']), const SizedBox(height: 4.0), Text(newMusicList[index]['subtitle']), ], ), ); } Widget buildListItem(int index) { return Card( child: ListTile( leading: Image.network( newMusicList[index]['img'], width: 60, fit: BoxFit.cover, ), title: Text(newMusicList[index]['title']), subtitle: Text(newMusicList[index]['subtitle']), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/list_grid.dart
import 'package:flutter/material.dart'; class ListGridWidget extends StatefulWidget { const ListGridWidget({super.key}); @override State<ListGridWidget> createState() => _ListGridWidgetState(); } class _ListGridWidgetState extends State<ListGridWidget> { List fruts = ['Apple', 'Orage', 'Mango']; Map fruts_person = { 'fruts': ['Apple', 'Orage', 'Mango', 'Onion'], 'person': ['Thang', 'Huy', 'Son'], }; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('List and Gridview'), backgroundColor: Colors.amber, elevation: 9, ), body: // ListView.builder( // // itemCount and itemBuilder la nhung thong so bat buoc phai co trong litview // itemCount: fruts.length, // // item build gom 2 param bat buoc la bien moi truong (context) va index vi tri cua phan tu trong list // itemBuilder: (context, index) { // return Card( // color: Colors.purple, // child: ListTile( // // xu ly su kien khi click vao item o tren list // onTap: () { // //thao tac voi map trong listview -> tro toi key trong map // print(fruts_person['person'][index]); // }, // leading: Icon(Icons.person), // //thao tac voi map trong listview -> tro toi key trong map // title: Text(fruts_person['fruts'][index]), // subtitle: Text(fruts_person['person'][index]), // ), // ); // }, // ), // GridView( // // tuy chinh hien thi o gridview // //crossAxisCount : so luong cot // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( // crossAxisCount: 3, // crossAxisSpacing: 30, // khoang cach giua cac cot // mainAxisSpacing: 20, // khoang cac giua cac hang // childAspectRatio: 2 / 3, // can chinh chieu rong / chieu cao ( 2 : 3) // ), // children: [ // Card( // child: ListTile( // title: Text( // 'Chuc nang so 1', // style: TextStyle(color: Colors.white), // ), // ), // ), // Card( // child: ListTile( // title: Text( // 'Chuc nang so 1', // style: TextStyle(color: Colors.white), // ), // ), // ), // Card( // child: ListTile( // title: Text( // 'Chuc nang so 1', // style: TextStyle(color: Colors.white), // ), // ), // ), // Card( // child: ListTile( // title: Text( // 'Chuc nang so 1', // style: TextStyle(color: Colors.white), // ), // ), // ), // ], // ), // tuong tu nhu ListView.builder // gridview luu y custom layout o gridDelegate GridView.builder( itemCount: fruts.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4), itemBuilder: (context, index) { return Card( child: ListTile( title: Text(fruts[index]), ), ); })); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/alertDialog.dart
import 'package:flutter/material.dart'; class AlertDialogWidget extends StatefulWidget { const AlertDialogWidget({super.key}); @override State<AlertDialogWidget> createState() => _AlertDialogWidgetState(); } class _AlertDialogWidgetState extends State<AlertDialogWidget> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('AlertDialog Example '), ), body: Center( child: ElevatedButton( onPressed: () { _showDialogExample(context); }, child: const Text('Show Dialog'), ), ), ); } } Future<void> _showDialogExample(BuildContext context) async { return showDialog( context: context, builder: (BuildContext context) { return AlertDialog( //! Độ nâng của hộp thoại, tức là từ background đến với dialog // ! Hiểu đơn giản là độ nổi lên trên widget elevation: 1, //! Định dạng đường viên xung quanh shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)), // ! set tiêu đề to cho dialog title: const Text('AlertDialog example'), // ! set nội dụng liên quan ở phần thân dialog // ! sử dụng SingleChildScrollView để có thể cuộn mượt hơn tùy kích thượng màn hình nếu quá dialog có nội dung dài content: const SingleChildScrollView( // ! widget này cho phép các widget con hiển thị bên trong dưới dạng list child: ListBody( children: [ // ! Ở đây có thể tùy chỉnh bằng bất kì widget con hay bằng layout này theo thiết kế Text('Username'), TextField(), SizedBox( height: 10, ), Text('Password'), TextField(), ], ), ), // ! Thêm các event bằng các button ( có thể tùy chỉnh custom tùy ý ) actions: [ TextButton( onPressed: () {}, child: const Text('Submit'), ), TextButton( onPressed: () {}, child: const Text('No'), ), ], ); }); }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/animatedText.dart
import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:flutter/material.dart'; //! https://pub.dev/packages/animated_text_kit //! Tham khảo thêm các kiểu animated text trong pagackge ở link trên class AnimatedTextWidget extends StatefulWidget { const AnimatedTextWidget({super.key}); @override State<AnimatedTextWidget> createState() => _AnimatedTextWidgetState(); } class _AnimatedTextWidgetState extends State<AnimatedTextWidget> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Animated Text Kit Example'), ), body: Center( child: Column( children: [ AnimatedTextKit( animatedTexts: [ FadeAnimatedText('Hello World'), ScaleAnimatedText( 'Then Scale', textStyle: TextStyle(fontSize: 70.0, fontFamily: 'Canterbury'), ), ], ), AnimatedTextKit( animatedTexts: [ RotateAnimatedText('AWESOME'), RotateAnimatedText('OPTIMISTIC'), RotateAnimatedText('DIFFERENT'), ], onTap: () { print("Tap Event"); }, ), SizedBox( width: 250.0, child: DefaultTextStyle( style: const TextStyle( fontSize: 30.0, fontFamily: 'Bobbers', ), child: AnimatedTextKit( animatedTexts: [ TyperAnimatedText('It is not enough to do your best,'), TyperAnimatedText('you must know what to do,'), TyperAnimatedText('and then do your best'), TyperAnimatedText('- W.Edwards Deming'), ], onTap: () { print("Tap Event"); }, ), ), ), SizedBox( width: 250.0, child: DefaultTextStyle( style: const TextStyle( fontSize: 30.0, fontFamily: 'Agne', ), child: AnimatedTextKit( animatedTexts: [ TypewriterAnimatedText('Discipline is the best tool'), TypewriterAnimatedText('Design first, then code'), TypewriterAnimatedText( 'Do not patch bugs out, rewrite them'), TypewriterAnimatedText( 'Do not test bugs out, design them out'), ], onTap: () { print("Tap Event"); }, ), ), ), DefaultTextStyle( style: const TextStyle( fontSize: 20.0, ), child: AnimatedTextKit( animatedTexts: [ WavyAnimatedText('Hello World'), WavyAnimatedText('Look at the waves'), ], isRepeatingAnimation: true, onTap: () { print("Tap Event"); }, ), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/button.dart
import 'dart:math'; import 'package:flutter/material.dart'; class ButtonWidget extends StatelessWidget { const ButtonWidget({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Button Widget Tutorial'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ TextButton( style: ButtonStyle( //set background sau khi click cho textbutton overlayColor: MaterialStateProperty.all(Colors.teal), //set shadow ( do bong cho text button) elevation: MaterialStateProperty.all(20), // set background cho textbutton backgroundColor: MaterialStateProperty.all(Colors.yellow), ), onPressed: () {}, child: const Text( 'Button Widget Tutorial', style: TextStyle(color: Colors.black), ), ), const SizedBox( height: 50, ), // su dung container de dinh dang kich thuong cua button SizedBox( width: 300, height: 50, child: ElevatedButton( // style rieng cho button style: ButtonStyle( //set background backgroundColor: MaterialStateProperty.all(Colors.blue), //set hinh dang, co the la bo tron, ... cho button shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(100), ))), onPressed: () { print('object'); }, // long click ( giu button 1 thoi gian !) onLongPress: () { print('this is long click'); }, child: const Text( "Press me", style: TextStyle(color: Colors.white), ), ), ) ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/dismissibleWidget.dart
import 'package:flutter/material.dart'; class DismissiableWidget extends StatefulWidget { const DismissiableWidget({super.key}); @override State<DismissiableWidget> createState() => _DismissiableWidgetState(); } class _DismissiableWidgetState extends State<DismissiableWidget> { List<String> persons = ['Huy', 'Thang', ' Son', 'Thang']; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Dismissiable Example'), ), body: ListView.builder( itemCount: persons.length, itemBuilder: (context, index) { final person = persons[index]; return Dismissible( onDismissed: (direction) { // xu ly su kien khi nguoi dung vuot sang trai hoac vuot sang phai if (direction == DismissDirection.startToEnd) { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text('Delete'), backgroundColor: Colors.red, )); } else { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text('Archive'), backgroundColor: Colors.green, )); } }, // key de xac dinh gia tri duy nhat cua 1 Dismissable, thường truyền vào là vị trí của phần tử trong mảng key: Key(person), // đây là 1 widget định nghĩa giao diện khi người dùng vuốt từ trái sáng phải background: Container( child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( width: 10, ), Icon(Icons.delete), ], ), color: Colors.red, ), // đây là 1 widget định nghĩa giao diện khi người dùng vuốt từ phải sang trái secondaryBackground: Container( child: Icon(Icons.archive), color: Colors.green, ), child: Card( child: ListTile( title: Text(persons[index]), ), )); }), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/bottomnav.dart
import 'package:basic_widget_30_1/widgets/bottomSheetDialog.dart'; import 'package:basic_widget_30_1/widgets/drawerWidget.dart'; import 'package:basic_widget_30_1/widgets/images.dart'; import 'package:basic_widget_30_1/widgets/list_grid.dart'; import 'package:flutter/material.dart'; class BottomNavigationWidget extends StatefulWidget { const BottomNavigationWidget({super.key}); @override State<BottomNavigationWidget> createState() => _BottomNavigationWidgetState(); } class _BottomNavigationWidgetState extends State<BottomNavigationWidget> { //! lưu trữ index khi chọn bottom navigation int selectedIndexBottomNav = 0; //! quản lý việc chuyển các page final PageController _pageControllerBottomNav = PageController(); //! hàm để cập nhật index khi người dùng nhấn ở bottom navigation void onTapBottomNav(int index) { setState(() { selectedIndexBottomNav = index; }); _pageControllerBottomNav.jumpToPage(index); } @override Widget build(BuildContext context) { return Scaffold( body: PageView( //! controller controller: _pageControllerBottomNav, //! chứa các trang tương ứng khi chọn bottom nav children: const [ ImageWidget(), BottomSheetDialogWidget(), ListGridWidget(), DrawerWidget(), ], ), bottomNavigationBar: BottomNavigationBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'), BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search'), BottomNavigationBarItem(icon: Icon(Icons.list), label: 'List'), BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'), ], //! màu khi các item ở bottom nav không được chọn unselectedItemColor: Colors.grey, //! màu khi các item ở bottom nav được chọn selectedItemColor: Colors.white, //! xử lý event khi click vào bottom onTap: onTapBottomNav, //! set mục nào được chọn currentIndex: selectedIndexBottomNav, ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/dropdown_list.dart
import 'package:flutter/material.dart'; class DropdownList extends StatefulWidget { const DropdownList({super.key}); @override State<DropdownList> createState() => _DropdownListState(); } class _DropdownListState extends State<DropdownList> { //! biến thể hiện giá trị được chọn String selectedValue = 'Huy'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Dropdown List Example'), ), body: Container( child: Padding( padding: const EdgeInsets.all(12.0), child: Center( //! Widget chưa dropdown list child: DropdownButton<String>( //! Icon hiển thị icon: const Icon(Icons.arrow_downward_sharp), //! Màu của list dropdown dropdownColor: Colors.blue, //! cho phép mở rộng ra phủ kín chiều rộng isExpanded: true, //! Giá trị được chọn ở hiện tại value: selectedValue, //! được gọi khi giá trị thay đổi onChanged: (String? newValue) { //! cập nhật giá trị được chọn thông qua setState setState( () { selectedValue = newValue!; }, ); }, //! Danh sách các mục trong list được tạo bằng cách sử dụng map //! và chuyển đổi thành các DropdownItem chứa những giá trị nội dung của các mục items: <String>['Huy', 'Son', 'Thang'] .map<DropdownMenuItem<String>>((String value) { return DropdownMenuItem<String>( value: value, child: Text(value), ); }).toList(), ), ), ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/bottomSheetDialog.dart
import 'package:flutter/material.dart'; class BottomSheetDialogWidget extends StatefulWidget { const BottomSheetDialogWidget({super.key}); @override State<BottomSheetDialogWidget> createState() => _BottomSheetDialogWidgetState(); } class _BottomSheetDialogWidgetState extends State<BottomSheetDialogWidget> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Bottom Sheet Dialog'), ), body: Center( child: ElevatedButton( onPressed: () { //! show bottom dialog //! ở đây khi sử dụng hàm này thì đã show được bottom dialog //! return lại 1 widget tree nào đó để xây dựng UI của dialog showModalBottomSheet( //! những version của flutter cao hơn thì thường đã có bo góc //! nên không nhất phải sử dụng shape shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20)), ), //! độ nổi của dialog elevation: 0, //! màu nền của dialog backgroundColor: Colors.purple, //! context và builder là 2 param required (bắt buộc phải có ) context: context, builder: (context) { //! return lại bất kì 1 tree widget để xây dựng UI của dialog return Padding( padding: const EdgeInsets.all(8.0), child: Column( // ! sử dụng mainAxisSize để định dạng khoảng trống của column mainAxisSize: MainAxisSize.min, children: [ const Text('Username'), const TextField(), const SizedBox( height: 10, ), const Text('Password'), const TextField(), Row( children: [ ElevatedButton( onPressed: () {}, child: const Text('Submit')), ElevatedButton( onPressed: () {}, child: const Text('Cancel')), ], ) ], ), ); }); }, child: const Text('Show BottomDialog')), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/geolocator.dart
import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:geolocator/geolocator.dart'; class GeoLocatorWidget extends StatefulWidget { const GeoLocatorWidget({super.key}); @override State<GeoLocatorWidget> createState() => _GeoLocatorWidgetState(); } class _GeoLocatorWidgetState extends State<GeoLocatorWidget> { //! Tạo biến lưu trữ vị trí Position? postion; fetchLocation() async { //! bool servicedEnable; LocationPermission permission; //!! Kiểm tra trạng thái xem của quyền định vị //! Hàm isLocationServiceEnabled() được từ thư viện geolocator để kiểm tra xem quyền định vị được bật hay chưa servicedEnable = await Geolocator.isLocationServiceEnabled(); if (!servicedEnable) { Fluttertoast.showToast(msg: 'Loation permission is disable'); } //! Check xem permisstion được cấp hay chưa permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { //! chưa cấp thì sẽ yêu cầu cấp quyền định vị permission = await Geolocator.requestPermission(); //! Thông báo khi người dùng không đồng ý cấp quyền if (permission == LocationPermission.denied) { Fluttertoast.showToast(msg: 'Loation permission is denied'); } } //! Xử lý khi người dùng không cấp quyền vĩnh viễn if (permission == LocationPermission.deniedForever) { Fluttertoast.showToast(msg: 'Loation permission is denied fovever'); } //! Lấy thông tin vị trí hiện tại và set giá trị cho biến position Position? currentPosition = await Geolocator.getCurrentPosition(); setState(() { postion = currentPosition; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Getch Location'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text(postion == null ? 'Location' : postion.toString()), ElevatedButton( onPressed: () { fetchLocation(); }, child: const Text('Get Location')) ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/form.dart
import 'package:flutter/material.dart'; class FormWidged extends StatefulWidget { const FormWidged({super.key}); @override State<FormWidged> createState() => _FormWidgedState(); } class _FormWidgedState extends State<FormWidged> { String firstname = ''; String lastname = ''; String email = ''; String password = ''; final _formKey = GlobalKey<FormState>(); // !TODO ------------------FUNCTIONS---------------------!! trysubmit() { final isValid = _formKey.currentState!.validate(); if (isValid) { _formKey.currentState!.save(); submitForm(); } else { print('Error'); } } submitForm() { setState(() { firstname = firstname; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Form example'), ), body: Padding( padding: const EdgeInsets.all(12.0), child: Center( child: Form( key: _formKey, child: Column( children: [ TextFormField( key: const ValueKey('firstname'), decoration: const InputDecoration(hintText: 'Enter your First Name'), validator: (value) { if (value.toString().isEmpty) { return 'First name should not be empty'; } else { return null; } }, onSaved: (newValue) { firstname = newValue.toString(); }, ), TextFormField( key: const ValueKey('lastname'), decoration: const InputDecoration(hintText: 'Enter your Last Name'), validator: (value) { if (value.toString().isEmpty) { return 'Last name should not be empty'; } else { return null; } }, onSaved: (newValue) { lastname = newValue.toString(); }, ), TextFormField( key: const ValueKey('email'), decoration: const InputDecoration(hintText: 'Enter your Email'), validator: (value) { if (value.toString().isEmpty) { return 'Email should not be empty'; } else { return null; } }, onSaved: (newValue) { email = newValue.toString(); }, ), TextFormField( obscureText: true, key: const ValueKey('password'), decoration: const InputDecoration(hintText: 'Enter your Password'), validator: (value) { if (value.toString().isEmpty) { return 'Password should not be empty'; } else { return null; } }, onSaved: (newValue) { password = newValue.toString(); }, ), TextButton( onPressed: () { trysubmit(); }, child: const Text('Submit'), ), Text(firstname), Text(lastname), Text(email), Text(password), ], ), )), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/splash.dart
import 'package:basic_widget_30_1/utils/size_config.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:neubrutalism_ui/neubrutalism_ui.dart'; class Splash extends StatefulWidget { const Splash({super.key}); @override State<Splash> createState() => _SplashState(); } class _SplashState extends State<Splash> { @override Widget build(BuildContext context) { return Scaffold( // backgroundColor: Colors.amber[50], body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: MediaQuery.of(context).size.height * .55, child: Image.asset( 'assets/splash.png', fit: BoxFit.cover, ), ), const Spacer(), const Padding( padding: EdgeInsets.only(left: 16.0, right: 16, bottom: 16), child: Text( 'Explore Your New\nskill today', style: TextStyle(fontSize: 30, fontWeight: FontWeight.w900), ), ), const SizedBox(height: 16.0), const Padding( padding: EdgeInsets.symmetric(horizontal: 16.0), child: Text( 'New skills are diversified your job options and help you to keep up with the fast changing world', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400), ), ), const Spacer(), const Spacer(), ], ), bottomNavigationBar: SafeArea( bottom: false, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: NeuTextButton( borderRadius: BorderRadius.circular(12), buttonColor: const Color.fromARGB(255, 236, 199, 211), buttonHeight: 60, buttonWidth: 100, enableAnimation: true, text: Text( "Hello", style: GoogleFonts.robotoCondensed( textStyle: const TextStyle( fontSize: 20, fontWeight: FontWeight.w700, ), ), ), ), ), ), ); } } class BottomNavigationBarExampleApp extends StatelessWidget { const BottomNavigationBarExampleApp({super.key}); @override Widget build(BuildContext context) { return const BottomNavigationBarExample(); } } class BottomNavigationBarExample extends StatefulWidget { const BottomNavigationBarExample({super.key}); @override State<BottomNavigationBarExample> createState() => _BottomNavigationBarExampleState(); } class _BottomNavigationBarExampleState extends State<BottomNavigationBarExample> { int _selectedIndex = 0; static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); static const List<Widget> _widgetOptions = <Widget>[ Home(), Text( 'Index 1: Business', style: optionStyle, ), Text( 'Index 2: School', style: optionStyle, ), ]; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: _widgetOptions.elementAt(_selectedIndex), ), bottomNavigationBar: BottomNavigationBar( items: <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: _selectedIndex != 0 ? const Icon(Icons.home_filled, size: 32, color: Color.fromARGB(255, 96, 36, 84)) : NeuIconButton( enableAnimation: true, buttonHeight: 45.0, borderRadius: BorderRadius.circular(8), buttonColor: _selectedIndex == 0 ? const Color(0xffd744b8) : Colors.white, icon: Icon( Icons.home_filled, color: _selectedIndex == 0 ? const Color(0xff650452) : kBlack, )), // Icon(Icons.home), label: '', ), BottomNavigationBarItem( icon: _selectedIndex != 1 ? const Icon(Icons.bookmark_outline, size: 32, color: Color.fromARGB(255, 96, 36, 84)) : NeuIconButton( enableAnimation: true, buttonHeight: 45, borderRadius: BorderRadius.circular(8), buttonColor: _selectedIndex == 1 ? const Color(0xffd744b8) : Colors.white, icon: Icon( Icons.bookmark_rounded, color: _selectedIndex == 1 ? const Color(0xff650452) : kBlack, )), label: '', ), BottomNavigationBarItem( icon: _selectedIndex != 2 ? const Icon(Icons.person_2_outlined, size: 32, color: Color.fromARGB(255, 96, 36, 84)) : NeuIconButton( enableAnimation: true, buttonHeight: 45, borderRadius: BorderRadius.circular(8), buttonColor: _selectedIndex == 2 ? const Color(0xffd744b8) : Colors.white, icon: Icon( Icons.person_2_rounded, color: _selectedIndex == 2 ? const Color(0xff650452) : kBlack, )), label: '', ), ], currentIndex: _selectedIndex, onTap: _onItemTapped, ), ); } } class Home extends StatefulWidget { const Home({super.key}); @override State<Home> createState() => _HomeState(); } class _HomeState extends State<Home> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: kWhite, body: SafeArea( bottom: false, child: SingleChildScrollView( child: Column( children: [ ListTile( title: const Text( 'Hi, Flutterdartcode', style: TextStyle(fontSize: 25, fontWeight: FontWeight.w900), ), subtitle: const Text('Become a better worker today'), trailing: NeuContainer( height: 50, width: 50, borderWidth: .5, borderRadius: BorderRadius.circular(4), child: Image.asset('assets/user 2.png'), ), ), const SizedBox(height: 16.0), ListTile( title: NeuSearchBar( borderRadius: BorderRadius.circular(8), searchBarColor: Colors.white, hintText: 'What are you looking for', // searchBarIcon: const Icon( // Icons.search, // color: Colors.black, // ), hintStyle: const TextStyle(color: Colors.black), ), trailing: NeuIconButton( enableAnimation: true, borderRadius: BorderRadius.circular(8), buttonColor: Colors.white, icon: const Icon( Icons.filter_alt_rounded, color: Colors.black, )), ), const SizedBox(height: 16.0), const ListTile( title: Text( 'Course in Progress', style: TextStyle(fontSize: 25, fontWeight: FontWeight.w800), ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: NeuContainer( borderRadius: BorderRadius.circular(8), color: Colors.white, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ NeuContainer( height: 50, width: 50, borderWidth: .5, borderRadius: BorderRadius.circular(4), child: Image.asset('assets/user 1.png'), ), const SizedBox(width: 16.0), const Text( "English Course", style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700), ), ], ), const SizedBox(height: 16), RichText( text: const TextSpan( text: 'Instructor : ', style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black54), children: <TextSpan>[ TextSpan( text: 'Flutterdartcode', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold)), ], ), ), const SizedBox(height: 8.0), Row( children: [ Text( '18 lessons', style: TextStyle( color: Colors.teal.shade600, fontWeight: FontWeight.w700), ), const SizedBox(width: 8), Icon( Icons.circle, size: 5, color: Colors.teal.shade600, ), const SizedBox(width: 8), Text( '50% completed', style: TextStyle( color: Colors.teal.shade600, fontWeight: FontWeight.w700), ), const Spacer(), const Text( '36 lessons', style: TextStyle( color: Colors.black54, fontWeight: FontWeight.w700), ), ], ), h8, LinearProgressIndicator( value: .6, backgroundColor: Colors.grey[300], valueColor: AlwaysStoppedAnimation<Color>( Colors.teal.shade600, ), minHeight: 10, semanticsLabel: 'Linear progress indicator', ), ], ), ), ), ), const SizedBox(height: 16.0), const ListTile( title: Text( 'Popular Courses', style: TextStyle(fontSize: 25, fontWeight: FontWeight.w800), ), trailing: Text( 'See all', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600), ), ), SizedBox( height: 280.0, width: double.infinity, child: ListView.builder( itemCount: 5, padding: const EdgeInsets.symmetric(horizontal: 8.0), physics: const ClampingScrollPhysics(), scrollDirection: Axis.horizontal, shrinkWrap: true, itemBuilder: (BuildContext context, int index) { return Padding( padding: const EdgeInsets.all(8.0), child: NeuContainer( borderRadius: BorderRadius.circular(8), color: Colors.white, child: Column( children: [ Image.asset( index.isEven ? 'assets/hs1.png' : 'assets/hs2.png', // : musicList[index]['img'], height: 150, width: 250, fit: BoxFit.cover, ), const SizedBox(height: 8.0), Container( width: 250, padding: const EdgeInsets.symmetric(horizontal: 8.0), child: const Text( '3D Design Essentials - Cinema 4d', style: TextStyle( fontSize: 15, fontWeight: FontWeight.w800), ), ), const SizedBox(height: 8.0), Container( width: 250, padding: const EdgeInsets.symmetric(horizontal: 8.0), child: const Row( children: [ Icon(Icons.restore, color: Colors.black54), SizedBox(width: 8.0), Expanded( child: Text( '72 Hours', style: TextStyle( fontSize: 15, color: Colors.black54, fontWeight: FontWeight.w400), )), Icon(Icons.star_outline, color: Colors.black54), SizedBox(width: 8.0), Expanded( child: Text( '4.5', style: TextStyle( fontSize: 15, color: Colors.black54, fontWeight: FontWeight.w400), )), ], )) ], ), ), ); }, ), ), const SizedBox(height: 16.0), const ListTile( title: Text( 'Mentor of the week', style: TextStyle(fontSize: 25, fontWeight: FontWeight.w800), ), ), SizedBox( height: 100.0, width: double.infinity, child: ListView.builder( itemCount: 5, padding: const EdgeInsets.symmetric(horizontal: 8.0), physics: const ClampingScrollPhysics(), scrollDirection: Axis.horizontal, shrinkWrap: true, itemBuilder: (BuildContext context, int index) { return Padding( padding: const EdgeInsets.all(8.0), child: NeuContainer( borderRadius: BorderRadius.circular(8), color: Colors.white, child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ const SizedBox(width: 8.0), // CircleAvatar( // radius: 26, // backgroundImage: NetworkImage( // musicList[index]['img'], // ), // ), const SizedBox(height: 8.0), Container( width: 140, padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( index == 0 ? 'Jhon Doe' : index == 1 ? 'Ahmad Saad' : 'Peter Parker', style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w500), ), Text( index == 0 ? 'English Instructor' : index == 1 ? 'Maths Instructor' : 'Physics Instructor', style: const TextStyle( fontSize: 12, fontWeight: FontWeight.w500), ), ], ), ), ], ), ), ); }, ), ), h24 ], ), ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/day21ui.dart
import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:neubrutalism_ui/neubrutalism_ui.dart'; class Day21UI extends StatefulWidget { const Day21UI({super.key}); @override State<Day21UI> createState() => _Day21UIState(); } class _Day21UIState extends State<Day21UI> { @override Widget build(BuildContext context) { return Scaffold( // s body: SingleChildScrollView( child: Column( children: [ Column( children: [ Padding( padding: const EdgeInsets.only(left: 20, right: 20), child: Stack( children: [ Container( height: 400, width: double.infinity, decoration: const BoxDecoration( color: Colors.blue, image: DecorationImage( image: NetworkImage( 'https://bizweb.dktcdn.net/100/438/408/files/fashionista-la-gi-yodyvn3.jpg?v=1668666987549'), fit: BoxFit.cover), borderRadius: BorderRadiusDirectional.all( Radius.circular(20))), ), Positioned( right: 20, top: 40, child: Container( height: 40, width: 40, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, ), child: const Icon(Icons.favorite), )), Positioned( left: 20, top: 40, child: Container( height: 40, width: 40, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, ), child: const Center(child: Icon(Icons.arrow_back)), )), ], ), ), Container( height: 100, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Padding( padding: EdgeInsets.only(left: 20, right: 20), child: Text( 'Modern Light Clothes', style: TextStyle( color: Colors.black, fontSize: 24, fontWeight: FontWeight.bold), maxLines: 1, ), ), Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ BoxShadow(blurRadius: 1, color: Colors.grey) ]), child: const Icon(Icons.add), ), const Text( '1', style: TextStyle(fontSize: 22), ), Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ BoxShadow(blurRadius: 1, color: Colors.grey) ]), child: const Icon(Icons.remove), ) ], )) ], ), ), Row( children: [ Container( margin: const EdgeInsets.only(left: 20), child: RatingBar.builder( initialRating: 3, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, itemSize: 25, itemPadding: const EdgeInsets.symmetric(horizontal: 3.0), itemBuilder: (context, _) => const Icon( Icons.star, color: Colors.amber, ), onRatingUpdate: (rating) { // Text(rating.toString()); }, ), ), const Text( '5.0', style: TextStyle(color: Colors.grey, fontSize: 18), ), const SizedBox( width: 10, ), const Text( '7932 reviews', style: TextStyle( color: Colors.blue, fontSize: 18, fontWeight: FontWeight.bold), ) ], ), const SizedBox( height: 16, ), const Padding( padding: EdgeInsets.all(16.0), child: Text( "Các fashionista đang mặc gì? Có điều gì mới mẻ trên các trang cá nhân của những ngôi sao không? Vào cuối tuần bạn đang thấy giới trẻ diện những outfit gì? Hãy theo dõi thật nhiều người nổi tiếng, biết cách dẫn đầu xu hướng nhất có thể. Từ đó, mọi người sẽ có cái nhìn bao quát hơn về trend thời trang đang diễn ra. Chưa kể, hiện nay cũng có rất nhiều tạp trí, show thời trang hỗ trợ bạn trong quá trình trở thành 1 fashionista thực thụ. Mọi người có thể dễ dàng cập nhật được những thông tin bổ ích về thời trang qua bài blog, video, hình ảnh,.."), ), const Padding( padding: EdgeInsets.all(16.0), child: Text( "Một tín đồ thời trang thường không dành cả tháng lương để hùa theo những trend thời trang nào đó. Mọi người hoàn toàn có thể mặc đẹp theo cách của riêng mình mà không cần đến những mẫu áo cardigan đang hot trend nếu kinh tế không đáp ứng được."), ), const Padding( padding: EdgeInsets.only(left: 16.0, right: 16), child: Divider(), ), Padding( padding: const EdgeInsets.all(16.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Choose Size', style: TextStyle( fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold), ), const SizedBox( height: 12, ), Row( children: [ Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), child: const Center( child: Text( 'S', style: TextStyle(fontWeight: FontWeight.bold), ), ), ), const SizedBox( width: 12, ), Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.black, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), child: const Center( child: Text( 'M', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white), ), ), ), const SizedBox( width: 12, ), Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), child: const Center( child: Text( 'L', style: TextStyle(fontWeight: FontWeight.bold), ), ), ), const SizedBox( width: 12, ), Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), child: const Center( child: Text( 'XL', style: TextStyle(fontWeight: FontWeight.bold), ), ), ), ], ) ], ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Choose Color', style: TextStyle( fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold), ), const SizedBox( height: 12, ), Row( children: [ Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.black, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), child: const Center( child: Text( 'S', style: TextStyle(fontWeight: FontWeight.bold), ), ), ), const SizedBox( width: 12, ), Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.red, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), child: const Center( child: Text( 'M', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.red), ), ), ), const SizedBox( width: 12, ), Container( height: 30, width: 30, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.blue, boxShadow: [ BoxShadow( blurRadius: 1, color: Colors.grey) ]), ), const SizedBox( width: 12, ), ], ) ], ) ], ), ) ], ), Padding( padding: const EdgeInsets.all(16.0), child: Container( height: 50, width: double.infinity, decoration: BoxDecoration( color: Colors.black, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(12), boxShadow: const [ BoxShadow(blurRadius: 1, spreadRadius: 2) ]), child: const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.shopping_bag, color: Colors.white, ), SizedBox( width: 10, ), Text( 'Add To Card | 100.000', style: TextStyle(color: Colors.white), ) ], ), ), ), const SizedBox( height: 20, ), NeuTextButton( borderRadius: BorderRadius.circular(12), buttonColor: const Color.fromARGB(255, 236, 199, 211), buttonHeight: 60, buttonWidth: 100, enableAnimation: true, text: Text( "Hello", style: GoogleFonts.robotoCondensed( textStyle: const TextStyle( fontSize: 20, fontWeight: FontWeight.w700, ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/snackbarWidget.dart
import 'package:flutter/material.dart'; class SnackbarWidget extends StatelessWidget { const SnackbarWidget({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Snack bar demo'), ), body: Center( child: ElevatedButton( onPressed: () { /* content: Là nội dung chính của Snackbar, được đặt trong một widget Text. Trong trường hợp này, nội dung là chuỗi "This is snackbar", và có màu trắng. backgroundColor: Màu nền của Snackbar, được đặt là màu đỏ. behavior: Xác định cách mà Snackbar hoạt động. Trong trường hợp này, SnackBarBehavior.floating cho biết Snackbar sẽ có hiệu ứng floating (nổi lên). duration: Thời gian hiển thị của Snackbar, được đặt là 3 giây. shape: Xác định hình dạng của Snackbar, trong trường hợp này, nó là một hình dạng hình tròn được định nghĩa bởi RoundedRectangleBorder với BorderRadius.circular(20). action: Là một SnackBarAction, thêm một hành động thực hiện được bởi người dùng. Trong trường hợp này, có một nút 'Undo' với màu chữ là màu vàng. Khi người dùng nhấp vào nút này, một hàm được thực hiện (trong trường hợp này là in ra một dòng thông báo "Under the action"). onPressed: Hàm được gọi khi nút hành động được nhấn. Trong trường hợp này, nó in ra dòng thông báo "Under the action". textColor: Màu chữ của văn bản trong nút hành động. Trong trường hợp này, màu chữ là màu vàng. ScaffoldMessenger.of(context).showSnackBar(snackbar); được sử dụng để hiển thị Snackbar trên giao diện người dùng.*/ final snackbar = SnackBar( content: Text( 'This is snackbar', style: TextStyle(color: Colors.white), ), backgroundColor: Colors.red, behavior: SnackBarBehavior.floating, duration: const Duration(seconds: 3), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), action: SnackBarAction( label: 'Undo', onPressed: () { print('Under the action'); }, textColor: Colors.yellow, ), ); ScaffoldMessenger.of(context).showSnackBar(snackbar); }, child: Text('Click show snackbar'), ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/drawerWidget.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class DrawerWidget extends StatefulWidget { const DrawerWidget({super.key}); @override State<DrawerWidget> createState() => _DrawerWidgetState(); } class _DrawerWidgetState extends State<DrawerWidget> { @override Widget build(BuildContext context) { double statusBarHeight = MediaQuery.of(context).padding.top; SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith( statusBarColor: Colors.blue, // Chọn màu phù hợp )); return Scaffold( drawer: Drawer( child: Container( color: Colors.white, child: ListView( children: [ Container( height: statusBarHeight, // Sử dụng chiều cao của thanh trạng thái làm padding color: Colors.blue, ), DrawerHeader( padding: EdgeInsets.zero, child: Container( padding: EdgeInsets.all(12), color: Colors.blue, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ CircleAvatar( radius: 40, backgroundImage: NetworkImage( 'https://static.wikia.nocookie.net/avatar/images/5/52/P%27Li.png/revision/latest?cb=20140825101857'), ), SizedBox( height: 10, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Nguyen Duy Huy', style: TextStyle(fontSize: 15), ), Text( 'huyndph30375@fpt.edu.vn', style: TextStyle(fontSize: 12), ) ], ) ], ), ), ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), trailing: Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.green, borderRadius: BorderRadius.circular(10), ), child: Text( '12', style: TextStyle(color: Colors.white), ), ), // Thêm text ở bên phải cuối ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), Divider(), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), ListTile( onTap: () { print('Home'); }, leading: Icon(Icons.home), title: Text('Home'), ), ], ), ), ), appBar: AppBar( title: Text('Drawer Example'), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/stack.dart
import 'package:flutter/material.dart'; class StackWidget extends StatefulWidget { const StackWidget({super.key}); @override State<StackWidget> createState() => _StackWidgetState(); } class _StackWidgetState extends State<StackWidget> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Stack Example'), ), //! Stack cho phép các widget có thể nằm lên nhau body: Stack( children: [ Container( height: 300, width: MediaQuery.of(context).size.width, decoration: const BoxDecoration( image: DecorationImage( image: AssetImage('assets/img1.jpeg'), fit: BoxFit.cover, ), ), ), //! Positioned cho phép cân chỉnh các widget ở stack dưới theo vị trí top left bottom right //! Positioned thường dùng cho các vị trí chính xác của widget dựa vào 4 thuộc tính ở trên //! 4 thuộc tính trên sẽ cho phép căn chỉnh widget con ở mép widget Stack Positioned( top: 20, left: 20, child: Container( height: 50, width: 50, color: Colors.red, )), //! Align căn chỉnh các widget con theo thuộc tính alignment //! Align sẽ cho phép căn chỉnh dọc theo một trong các góc hoặc điểm ở trung tâm //! Linh hoạt cho việc xác định vị trí mà không cần con số cụ thể căn chỉnh ở các mép Stack Align( alignment: Alignment.bottomCenter, child: Container( height: 50, width: 50, color: Colors.red, ), ) ], ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/tabbar.dart
import 'package:flutter/material.dart'; class TabbarWidget extends StatefulWidget { const TabbarWidget({super.key}); @override State<TabbarWidget> createState() => _TabbarWidgetState(); } class _TabbarWidgetState extends State<TabbarWidget> { @override Widget build(BuildContext context) { return DefaultTabController( initialIndex: 0, length: 10, child: Scaffold( appBar: AppBar( title: const Text('Tabbar Widget'), bottom: const TabBar( isScrollable: true, indicatorColor: Colors.white, indicatorWeight: 2, tabs: [ Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), Tab( icon: Icon(Icons.chat), text: 'Chat', ), ], ), ), body: const TabBarView( children: [ Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), Text('Abc'), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/widgets/day19ui.dart
import 'package:basic_widget_30_1/components/row_icon.dart'; import 'package:flutter/material.dart'; class Day19UI extends StatefulWidget { const Day19UI({super.key}); @override State<Day19UI> createState() => _Day19UIState(); } class _Day19UIState extends State<Day19UI> { @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Positioned( child: SizedBox( height: 500, child: Stack( children: [ Positioned( child: Container( height: 450, decoration: const BoxDecoration( image: DecorationImage( image: NetworkImage( 'https://images.pexels.com/photos/1036148/pexels-photo-1036148.jpeg?cs=srgb&dl=pexels-noel-mcshane-1036148.jpg&fm=jpg', ), fit: BoxFit.cover), ), ), ), const Positioned( right: 30, top: 60, child: Icon( Icons.favorite_border_outlined, color: Colors.white, size: 30, ), ), const Positioned( left: 30, top: 60, child: Icon( Icons.arrow_back, color: Colors.white, size: 30, ), ), const Positioned( bottom: 0, right: 20, child: CircleAvatar( radius: 50, backgroundImage: NetworkImage( 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT_DsloK474CAv8XEwoVikZj-u_EV9jtHKoQA&usqp=CAU'), ), ), ], ))) ], ), Container( padding: const EdgeInsets.only(left: 12, right: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Madrid city tour for desginer', style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold), ), const SizedBox( height: 8, ), Text( 'Made glorious summer by this sun of York; ', style: TextStyle(color: Colors.grey.shade800), ) ], ), ), const SizedBox(height: 16), SizedBox( height: 50, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ RowIcon('20', Icons.favorite), RowIcon('35', Icons.upload), RowIcon('82', Icons.message), RowIcon('295', Icons.emoji_emotions), ], ), ), Container( padding: const EdgeInsets.only(left: 12, right: 12, top: 12), child: const Text( "In the first place we have granted to God, and by this our present charter confirmed for us and our heirs forever that the English Church shall be free, and shall have her rights entire, and her liberties inviolate; and we will that it be thus observed; which is apparent from this that the freedom of elections, which is reckoned most important and very essential to the English Church, we, of our pure and unconstrained will, did grant, and did by our charter confirm and did obtain the ratification of the same from our lord, Pope Innocent III, before the quarrel arose between us and our barons: and this we will observe, and our will is that it be observed in good faith by our heirs forever. We have also granted to all freemen of our kingdom, for us and our heirs forever, all the underwritten liberties, to be had and held by them and their heirs, of us and our heirs forever.", style: TextStyle(fontSize: 14), ), ) ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/pages/pets.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; class PetsPage extends StatefulWidget { const PetsPage({super.key}); @override State<PetsPage> createState() => _PetsPageState(); } class _PetsPageState extends State<PetsPage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('List Pes'), ), body: Container( child: StreamBuilder<QuerySnapshot>( stream: FirebaseFirestore.instance.collection('pets').snapshots(), builder: (context, snapPets) { if (snapPets.connectionState == ConnectionState.waiting) { return const Center( child: CircularProgressIndicator(), ); } else { final petDocs = snapPets.data!.docs; return ListView.builder( itemCount: petDocs.length, itemBuilder: (context, index) { return ListTile( title: Text(petDocs[index]['name']), subtitle: Text(petDocs[index]['gender']), ); }); } }), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/components/row_status.dart
import 'package:flutter/material.dart'; Widget RowStatus(String text1, text2) { return Column( children: [ Text( text1, style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold), ), Text( text2, style: TextStyle(fontSize: 18, fontWeight: FontWeight.normal), ), ], ); } Widget ButtonProfile(String text) { return ElevatedButton( onPressed: () {}, style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.grey.shade300), ), child: Text( text, style: const TextStyle(color: Colors.black), ), ); }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/components/row_icon.dart
import 'package:flutter/material.dart'; Widget RowIcon(String text, IconData icon) { return Row( children: [Text(text), const SizedBox(width: 5), Icon(icon)], ); }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/components/card_friend.dart
import 'package:flutter/material.dart'; class CardFrends extends StatelessWidget { const CardFrends({super.key}); @override Widget build(BuildContext context) { return Container( height: 300, width: 200, child: Card( color: Colors.white, elevation: 1, child: Stack( children: [ Positioned( right: 10, top: 10, child: Icon( Icons.close, color: Colors.grey, ), ), Container( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CircleAvatar( radius: 50, backgroundImage: NetworkImage( 'https://scontent.fhan14-3.fna.fbcdn.net/v/t39.30808-6/417781839_344460121869446_1233461574458003244_n.jpg?_nc_cat=103&ccb=1-7&_nc_sid=efb6e6&_nc_eui2=AeGE6-sh8w8STx2GpeThbzPTbcJiDOqLi7VtwmIM6ouLtb5mwnWITJbtAAkDzkczOmFvaU8KwpXYeE6vR8JETK2i&_nc_ohc=rAoSyyGiCxYAX8aqukA&_nc_ht=scontent.fhan14-3.fna&oh=00_AfD16tK14V2lU6RlE8k6eyAkGrGA-DV0RyW0inVY4TKkag&oe=65BDF734'), ), const SizedBox( height: 5, ), Text( 'Nguyen Duy Huy', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 18), ), Text( 'Folowed you', style: TextStyle(color: Colors.grey, fontSize: 14), ), ], ), ), ), Align( alignment: Alignment.bottomCenter, child: Container( margin: EdgeInsets.only(bottom: 10), width: 160, child: ElevatedButton( onPressed: () {}, child: Text( 'Follow', style: TextStyle(color: Colors.white), ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blue)), ), ), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/utils/size_config.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; const appBgColor = Color(0xFFF7F7F7); const appBarColor = Color(0xFFF7F7F7); const primaryColor = Color(0XFF002147); const lightPrimary = Color(0xff062e5b); const kBlack = Colors.black; const kTransparent = Colors.transparent; const kWhite = Colors.white; const kRed = Colors.red; const kWhite54 = Colors.white54; const kWhite60 = Colors.white60; const kWhite70 = Colors.white70; const textColor = Color(0xff001c3d); const btnColor = Color(0XFFFF9000); // const cardColor = Color(0xfff5f6f9); const blueButton = Color(0xff0654CE); const kBlack12 = Colors.black12; const kBlack54 = Colors.black54; const kGreen = Colors.green; const colorLearn = Color(0xffedf1f7); var style = GoogleFonts.inter(); var textStyle = GoogleFonts.inter( textStyle: const TextStyle(fontWeight: FontWeight.w500, fontSize: 15), ); var textStyleHeading = GoogleFonts.inter( textStyle: const TextStyle(fontWeight: FontWeight.w500, fontSize: 18), ); var loginHeading = GoogleFonts.inter( textStyle: const TextStyle(fontWeight: FontWeight.w500, fontSize: 30), ); var textStyle15 = GoogleFonts.inter( textStyle: const TextStyle(fontWeight: FontWeight.w500, fontSize: 15), ); var textStyle15Color = GoogleFonts.inter( textStyle: const TextStyle( fontWeight: FontWeight.w500, color: primaryColor, fontSize: 15), ); var textStyle15Light = GoogleFonts.inter( textStyle: const TextStyle(fontSize: 12, color: kBlack), ); var textStyle15Light1 = GoogleFonts.inter( textStyle: const TextStyle(fontSize: 12, color: Colors.black54), ); var size18 = GoogleFonts.inter( textStyle: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600)); var f12 = const TextStyle(fontSize: 12); const h16 = SizedBox(height: 16.0); const h0 = SizedBox(height: 0.0); const h4 = SizedBox(height: 4.0); const h8 = SizedBox(height: 8.0); const h24 = SizedBox(height: 24.0); const h32 = SizedBox(height: 32.0); const h48 = SizedBox(height: 48.0); const h56 = SizedBox(height: 56.0); const w0 = SizedBox(width: 0.0); const w4 = SizedBox(width: 4.0); const w8 = SizedBox(width: 8.0); const w16 = SizedBox(width: 16.0); const w24 = SizedBox(width: 24.0); // shapes var shape4 = RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)); var shape8 = RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)); var shape20 = RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)); var moreStyle = const TextStyle( fontWeight: FontWeight.w600, fontSize: 14.0, color: Color(0xff0b4b95)); var lessStyle = const TextStyle(fontSize: 14.0, color: Color(0xff0b4b95));
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/utils/const.dart
List<Map> musicList = [ { 'title': 'Ilzaam', 'img': 'https://i.scdn.co/image/ab67616d0000b27336fb92e4fd4da9df2afaa2d2' }, { 'title': 'O Bedardeya', 'img': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRVbMRddA-HnTdv8EVilu0uYDJ9UyfGd3DtNtMmUdC4nQ&usqp=CAU&ec=48600113' }, { 'title': 'Subah Hone na De', 'img': 'https://i.scdn.co/image/ab67616d0000b273daa89593cc2cde9651665d03' }, { 'title': 'Players', 'img': 'https://mastinew.com/siteuploads/thumb/c/2798_resize2x_200x200.webp' }, { 'title': 'GodSpeed', 'img': 'https://c.saavncdn.com/532/GODSPEED-Punjabi-2022-20220623172310-500x500.jpg' }, { 'title': 'Na Ja', 'img': 'https://c.saavncdn.com/638/Na-Ja-Punjabi-2017-500x500.jpg' }, { 'title': 'Kalank', 'img': 'https://i0.wp.com/www.smartprix.com/bytes/wp-content/uploads/2023/03/ab67616d0000b27341775aba5e8dc068274257cc-photoutils.com_.jpeg?ssl=1' }, { 'title': 'Woofer', 'img': 'https://m.media-amazon.com/images/M/MV5BZDQ2NzU2MTMtODRlMi00N2I5LThhYmItYWMwODg3MmZiYTJjXkEyXkFqcGdeQXVyMTEyOTYzMjQw._V1_.jpg' }, { 'title': 'God\'s Plan', 'img': 'https://www.androidauthority.com/wp-content/uploads/2023/02/drake-stock.jpg' }, { 'title': 'YUNGBLUD', 'img': 'https://www.udiscovermusic.com/wp-content/uploads/2021/06/spotify-singles-yungblud-1-820x820.jpg' }, { 'title': 'Jungle Baby', 'img': 'https://media1.metrotimes.com/metrotimes/imager/u/zoom/29143520/2-sterlgotti-brokenheart.jpg?cb=1647990305' }, { 'title': 'Ilzaam', 'img': 'https://i.scdn.co/image/ab67616d0000b27336fb92e4fd4da9df2afaa2d2' }, { 'title': 'O Bedardeya', 'img': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRVbMRddA-HnTdv8EVilu0uYDJ9UyfGd3DtNtMmUdC4nQ&usqp=CAU&ec=48600113' }, { 'title': 'Subah Hone na De', 'img': 'https://i.scdn.co/image/ab67616d0000b273daa89593cc2cde9651665d03' }, { 'title': 'Players', 'img': 'https://mastinew.com/siteuploads/thumb/c/2798_resize2x_200x200.webp' }, { 'title': 'GodSpeed', 'img': 'https://c.saavncdn.com/532/GODSPEED-Punjabi-2022-20220623172310-500x500.jpg' }, { 'title': 'Na Ja', 'img': 'https://c.saavncdn.com/638/Na-Ja-Punjabi-2017-500x500.jpg' }, { 'title': 'Kalank', 'img': 'https://i0.wp.com/www.smartprix.com/bytes/wp-content/uploads/2023/03/ab67616d0000b27341775aba5e8dc068274257cc-photoutils.com_.jpeg?ssl=1' }, { 'title': 'Woofer', 'img': 'https://m.media-amazon.com/images/M/MV5BZDQ2NzU2MTMtODRlMi00N2I5LThhYmItYWMwODg3MmZiYTJjXkEyXkFqcGdeQXVyMTEyOTYzMjQw._V1_.jpg' }, { 'title': 'God\'s Plan', 'img': 'https://www.androidauthority.com/wp-content/uploads/2023/02/drake-stock.jpg' }, { 'title': 'YUNGBLUD', 'img': 'https://www.udiscovermusic.com/wp-content/uploads/2021/06/spotify-singles-yungblud-1-820x820.jpg' }, { 'title': 'Jungle Baby', 'img': 'https://media1.metrotimes.com/metrotimes/imager/u/zoom/29143520/2-sterlgotti-brokenheart.jpg?cb=1647990305' }, ]; List<Map> dataList = [ { 'title': 'Shi Hu', 'time': '2 hour ago', 'post': 'lorem ipsum doler set amet\nhow you doing?', 'img': 'https://images.unsplash.com/photo-1504608524841-42fe6f032b4b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8NHx8fGVufDB8fHx8&w=1000&q=80' }, { 'title': 'Mao Xueqin', 'time': '20 min ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://techcrunch.com/wp-content/uploads/2019/12/boxed-water-is-better-GoYNk3CrgxQ-unsplash.jpg' }, { 'title': 'Len Glisson', 'time': '10 min ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://thumbs.dreamstime.com/z/pink-green-yellow-colorful-random-acts-kindness-day-instagram-post-251628353.jpg' }, { 'title': 'Drake Harmon', 'time': '1 min ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://cdn.shopify.com/s/files/1/0445/6817/articles/feb19-social-03.jpg?v=1549483422' }, { 'title': 'Chandler Taylor', 'time': '1 hour ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://images.unsplash.com/photo-1577041249022-26cc744ddda3?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1yZWxhdGVkfDExfHx8ZW58MHx8fHw%3D&w=1000&q=80' }, { 'title': 'Chandler Taylor', 'time': '1 hour ago', 'post': 'lorem ipsum doler set amet\nhello there ', 'img': 'https://images.unsplash.com/photo-1490730141103-6cac27aaab94?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&w=1000&q=80' }, { 'title': 'Donald Mitchell', 'time': '2 hour ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://images.unsplash.com/photo-1509391618207-32f1fa13c1d2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8b3JhbmdlJTIwZnJ1aXR8ZW58MHx8MHx8&w=1000&q=80' }, { 'title': 'Johnny Tingey', 'time': '2 hour ago', 'post': 'lorem ipsum doler set amet\nhow are you', 'img': 'https://i.scdn.co/image/ab67616d0000b27336fb92e4fd4da9df2afaa2d2' }, { 'title': 'Shi Hu', 'time': '2 hour ago', 'post': 'lorem ipsum doler set amet\nhow you doing?', 'img': 'https://images.unsplash.com/photo-1504608524841-42fe6f032b4b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8NHx8fGVufDB8fHx8&w=1000&q=80' }, { 'title': 'Mao Xueqin', 'time': '20 min ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://techcrunch.com/wp-content/uploads/2019/12/boxed-water-is-better-GoYNk3CrgxQ-unsplash.jpg' }, { 'title': 'Len Glisson', 'time': '10 min ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://thumbs.dreamstime.com/z/pink-green-yellow-colorful-random-acts-kindness-day-instagram-post-251628353.jpg' }, { 'title': 'Drake Harmon', 'time': '1 min ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://cdn.shopify.com/s/files/1/0445/6817/articles/feb19-social-03.jpg?v=1549483422' }, { 'title': 'Chandler Taylor', 'time': '1 hour ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://images.unsplash.com/photo-1577041249022-26cc744ddda3?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1yZWxhdGVkfDExfHx8ZW58MHx8fHw%3D&w=1000&q=80' }, { 'title': 'Chandler Taylor', 'time': '1 hour ago', 'post': 'lorem ipsum doler set amet\nhello there ', 'img': 'https://images.unsplash.com/photo-1490730141103-6cac27aaab94?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&w=1000&q=80' }, { 'title': 'Donald Mitchell', 'time': '2 hour ago', 'post': 'lorem ipsum doler set amet', 'img': 'https://images.unsplash.com/photo-1509391618207-32f1fa13c1d2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8b3JhbmdlJTIwZnJ1aXR8ZW58MHx8MHx8&w=1000&q=80' }, { 'title': 'Johnny Tingey', 'time': '2 hour ago', 'post': 'lorem ipsum doler set amet\nhow are you', 'img': 'https://i.scdn.co/image/ab67616d0000b27336fb92e4fd4da9df2afaa2d2' }, ]; List<Map> newMusicList = [ { 'title': 'Didn\'t', 'subtitle': 'Human (Delux) 2020', 'img': 'https://i.scdn.co/image/ab67616d0000b27308ac645145d2959e46ae2b7f' }, { 'title': 'Apologize', 'subtitle': 'Dreaming Out Loud 2006', 'img': 'https://i.pinimg.com/736x/48/e2/f5/48e2f5a85b7d312ead4595f86270e0f9.jpg' }, { 'title': 'God\'s Plan', 'subtitle': 'God\'s Plan', 'img': 'https://www.androidauthority.com/wp-content/uploads/2023/02/drake-stock.jpg' }, { 'title': 'YUNGBLUD', 'subtitle': 'YUNGBLUD', 'img': 'https://www.udiscovermusic.com/wp-content/uploads/2021/06/spotify-singles-yungblud-1-820x820.jpg' }, { 'title': 'Jungle Baby', 'subtitle': 'Jungle Baby', 'img': 'https://media1.metrotimes.com/metrotimes/imager/u/zoom/29143520/2-sterlgotti-brokenheart.jpg?cb=1647990305' }, { 'title': 'All the Right Movers', 'subtitle': 'Waking up 2009', 'img': 'https://radio.callmefred.com/en/wp-content/uploads/2023/05/final_cover-All-The-Right-Moves-OneRepublic.jpg' }, { 'title': 'Lose Somebody', 'subtitle': 'Lose Somebody', 'img': 'https://i.scdn.co/image/ab67616d0000b273a74e171f9cd70573a3e25576' }, { 'title': 'Woofer', 'subtitle': 'Woofer', 'img': 'https://m.media-amazon.com/images/M/MV5BZDQ2NzU2MTMtODRlMi00N2I5LThhYmItYWMwODg3MmZiYTJjXkEyXkFqcGdeQXVyMTEyOTYzMjQw._V1_.jpg' }, { 'title': 'Jungle Baby', 'subtitle': 'Jungle Baby', 'img': 'https://media1.metrotimes.com/metrotimes/imager/u/zoom/29143520/2-sterlgotti-brokenheart.jpg?cb=1647990305' }, { 'title': 'All the Right Movers', 'subtitle': 'Waking up 2009', 'img': 'https://radio.callmefred.com/en/wp-content/uploads/2023/05/final_cover-All-The-Right-Moves-OneRepublic.jpg' }, { 'title': 'Lose Somebody', 'subtitle': 'Lose Somebody', 'img': 'https://i.scdn.co/image/ab67616d0000b273a74e171f9cd70573a3e25576' }, { 'title': 'Woofer', 'subtitle': 'Woofer', 'img': 'https://m.media-amazon.com/images/M/MV5BZDQ2NzU2MTMtODRlMi00N2I5LThhYmItYWMwODg3MmZiYTJjXkEyXkFqcGdeQXVyMTEyOTYzMjQw._V1_.jpg' }, ]; final List images = [ 'https://radio.callmefred.com/en/wp-content/uploads/2023/05/final_cover-All-The-Right-Moves-OneRepublic.jpg', 'https://c.saavncdn.com/857/Are-You-Lonely-English-2019-20190213200954-500x500.jpg', 'https://i1.sndcdn.com/artworks-hHRNAPyoL1gTPNV7-mUwz9A-t500x500.jpg', 'https://www.whoa.in/download/raees-shah-rukh-khan-bollywood-movies-poster', 'https://i1.sndcdn.com/artworks-l1XLpGzbyQzrqUuW-8ao2yQ-t500x500.jpg', 'https://media1.metrotimes.com/metrotimes/imager/u/zoom/29143520/2-sterlgotti-brokenheart.jpg?cb=1647990305', 'https://pbs.twimg.com/media/FvUcokBWwAIdldZ.jpg', 'https://www.canadalifecentre.ca/wp-content/uploads/2021/07/GV_NATL_0121_TheWeeknd_AfterHours_RogersPlace_525x525.jpg', 'https://i1.sndcdn.com/artworks-000075942842-c48doi-t500x500.jpg', 'https://i.pinimg.com/originals/67/0a/a0/670aa0f33a730e74e4312417d3ce1af3.jpg', 'https://mir-s3-cdn-cf.behance.net/project_modules/hd/067d5068717917.5b672f7514e44.jpg', 'https://www.udiscovermusic.com/wp-content/uploads/2021/06/spotify-singles-yungblud-1-820x820.jpg', 'https://www.androidauthority.com/wp-content/uploads/2023/02/drake-stock.jpg', ]; final List<Map> itemg = [ { 'name': 'Agamemnon', 'description': 'The old man sat on the bench, watching the children play. He smiled as he remembered a time when he was young and carefree, like them. He had been through a lot in his life, but he had always found a way to keep going. He was a survivor, and he was proud of it.', 'image': 'assets/item1.png', }, { 'name': 'Achilles', 'description': 'The children were running and laughing, oblivious to the world around them. They were so full of life, and it was contagious. The old man felt his own spirits lift', 'image': 'assets/item2.png', }, { 'name': 'Ferdinand', 'description': 'They took a deep breath and stepped off the roof, into the storm.', 'image': 'assets/item3.png', }, { 'name': 'Evangeline', 'description': 'But they knew that they couldn\'t rest yet. There was still work to be done. They had to find a way to stop the storm, before it was too late.', 'image': 'assets/item2.png', }, { 'name': 'Ferdinand', 'description': 'They took a deep breath and stepped off the roof, into the storm.', 'image': 'assets/item3.png', }, { 'name': 'Delilah', 'description': 'They had been through a lot in the past few days, and they were starting to feel the strain. They were tired, both physically and emotionally. They just wanted the storm to end, so they could go home and rest.', 'image': 'assets/item3.png', }, { 'name': 'Guinevere', 'description': 'The rain fell in sheets, obscuring the view of the city below. The wind howled, sending debris flying through the air. A lone figure stood on the edge of the roof, looking out at the storm.', 'image': 'assets/item2.png', }, { 'name': 'Elizabeth', 'description': 'He knew that they would face challenges in their lives, but he also knew that they would overcome them. They were the future, and he was confident that they would make the world a better place.', 'image': 'assets/item3.png', }, { 'name': 'Ferdinand', 'description': 'They took a deep breath and stepped off the roof, into the storm.', 'image': 'assets/item3.png', }, { 'name': 'Anastasia', 'description': 'The old man closed his eyes and took a deep breath. The air was filled with the sound of children playing, and it was the most beautiful sound he had ever heard. He knew that he would never forget this moment, and he was grateful for it.', 'image': 'assets/item2.png', }, { 'name': 'Christopher', 'description': 'The rain fell in sheets, obscuring the view of the city below. The wind howled, sending debris flying through the air. A lone figure stood on the edge of the roof, looking out at the storm.', 'image': 'assets/item3.png', }, // Add more items as needed ];
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/animations/animated_container.dart
import 'package:flutter/material.dart'; class AnimatedContainerWidget extends StatefulWidget { const AnimatedContainerWidget({super.key}); @override State<AnimatedContainerWidget> createState() => _AnimatedContainerWidgetState(); } class _AnimatedContainerWidgetState extends State<AnimatedContainerWidget> { bool isSelected = false; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: GestureDetector( onTap: () { setState(() { isSelected = !isSelected; }); }, child: Center( child: AnimatedContainer( duration: const Duration(milliseconds: 3), ), ), ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/animations/animation_builder.dart
import 'package:flutter/material.dart'; import 'dart:math' as math; class AnimatedBuildWidget extends StatefulWidget { const AnimatedBuildWidget({super.key}); @override State<AnimatedBuildWidget> createState() => _AnimatedBuildWidgetState(); } class _AnimatedBuildWidgetState extends State<AnimatedBuildWidget> with TickerProviderStateMixin { late final AnimationController _controllerAnimation = AnimationController(vsync: this, duration: const Duration(seconds: 10)) ..repeat(); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: AnimatedBuilder( animation: _controllerAnimation, builder: (BuildContext context, Widget? child) { return Transform.rotate( angle: _controllerAnimation.value * 2.0 * math.pi, child: child, ); }, child: Container( height: 100, width: 100, decoration: const BoxDecoration( shape: BoxShape.rectangle, color: Colors.blue), )), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/functions/auth.dart
import 'package:firebase_auth/firebase_auth.dart'; signup(String email, password) async { try { final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: email, password: password, ); print('Success '); } on FirebaseAuthException catch (e) { if (e.code == 'weak-password') { print('The password provided is too weak.'); } else if (e.code == 'email-already-in-use') { print('The account already exists for that email.'); } } catch (e) { print(e); } } login(String email, password) async { try { final credential = await FirebaseAuth.instance .signInWithEmailAndPassword(email: email, password: password); print('Success '); FirebaseAuth.instance.authStateChanges().listen((User? user) { if (user != null) { print(user.uid); } }); } on FirebaseAuthException catch (e) { if (e.code == 'user-not-found') { print('No user found for that email.'); } else if (e.code == 'wrong-password') { print('Wrong password provided for that user.'); } } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/functions/database_crud.dart
import 'package:cloud_firestore/cloud_firestore.dart'; create( String col, doc, name, gender, int age, ) async { await FirebaseFirestore.instance .collection(col) .doc(doc) .set({'name': name, 'gender': gender, 'age': age}); print('Insert ok'); } update(String col, doc, namefield, agefield, var fiedValueName, agefieldValue) async { await FirebaseFirestore.instance .collection(col) .doc(doc) .update({namefield: fiedValueName, agefield: agefieldValue}); print('Update ok'); } delete(String col, doc) async { await FirebaseFirestore.instance.collection(col).doc(doc).delete(); print('Delete Document'); }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/firebase_contain/day22_auth.dart
import 'package:basic_widget_30_1/functions/auth.dart'; import 'package:flutter/material.dart'; class Day22_Auth extends StatefulWidget { const Day22_Auth({super.key}); @override State<Day22_Auth> createState() => _Day22_AuthState(); } class _Day22_AuthState extends State<Day22_Auth> { final _formKey = GlobalKey<FormState>(); bool isLogin = false; String email = ""; String password = ""; String username = ""; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Firebase auth'), ), body: Center( child: Form( key: _formKey, child: Container( margin: const EdgeInsets.all(16), child: Column( children: [ isLogin ? Container() : TextFormField( key: ValueKey('username'), decoration: InputDecoration(hintText: 'Enter Username'), validator: (value) { if (value.toString().length < 3) { return 'Username is too smail'; } else { return null; } }, onSaved: (newValue) { setState(() { username = newValue!; }); }, ), TextFormField( key: ValueKey('email'), decoration: InputDecoration(hintText: 'Enter Email'), validator: (value) { if (!value.toString().contains('@')) { return 'Invalid Email'; } else { return null; } }, onSaved: (newValue) { setState(() { email = newValue!; }); }, ), TextFormField( key: ValueKey('password'), obscureText: true, decoration: InputDecoration(hintText: 'Enter Password'), validator: (value) { if (value.toString().length < 3) { return 'Password is too smail'; } else { return null; } }, onSaved: (newValue) { setState(() { password = newValue!; }); }, ), const SizedBox( height: 20, ), Container( width: double.infinity, height: 50, child: ElevatedButton( onPressed: () { if (_formKey.currentState!.validate()) { _formKey.currentState!.save(); isLogin ? login(email, password) : signup(email, password); } }, style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.black)), child: isLogin ? Text( 'Login', style: TextStyle(color: Colors.white), ) : Text( 'Sign up', style: TextStyle(color: Colors.white), ), ), ), const SizedBox( height: 20, ), TextButton( onPressed: () { setState(() { isLogin = !isLogin; }); }, child: isLogin ? Text('Signup') : Text('Login')) ], ), ))), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/lib
mirrored_repositories/Flutter-Widget-Playground/lib/firebase_contain/day23_database.dart
import 'package:basic_widget_30_1/functions/database_crud.dart'; import 'package:basic_widget_30_1/pages/pets.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; class DatabaseOptions extends StatefulWidget { const DatabaseOptions({super.key}); @override State<DatabaseOptions> createState() => _DatabaseOptionsState(); } class _DatabaseOptionsState extends State<DatabaseOptions> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Database CRUD Firebase'), leading: IconButton( onPressed: () async { await FirebaseAuth.instance.signOut(); }, icon: Icon(Icons.logo_dev)), ), body: Center( child: Container( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: () { create('pets', 'dog', 'july', 'female', 18); }, child: Text('Create')), ElevatedButton( onPressed: () { update('pets', 'dog', 'name', 'age', 'huy', 20); }, child: Text('Update')), ElevatedButton( onPressed: () { delete('pets', 'dog'); }, child: Text('Delete')), ElevatedButton( onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => PetsPage())); }, child: Text('Read')), ], ), ), ), ); } }
0
mirrored_repositories/Flutter-Widget-Playground/.dart_tool
mirrored_repositories/Flutter-Widget-Playground/.dart_tool/dartpad/web_plugin_registrant.dart
// Flutter web plugin registrant file. // // Generated file. Do not edit. // // @dart = 2.13 // ignore_for_file: type=lint import 'package:cloud_firestore_web/cloud_firestore_web.dart'; import 'package:firebase_auth_web/firebase_auth_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; import 'package:fluttertoast/fluttertoast_web.dart'; import 'package:geolocator_web/geolocator_web.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:location_web/location_web.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; void registerPlugins([final Registrar? pluginRegistrar]) { final Registrar registrar = pluginRegistrar ?? webPluginRegistrar; FirebaseFirestoreWeb.registerWith(registrar); FirebaseAuthWeb.registerWith(registrar); FirebaseCoreWeb.registerWith(registrar); FluttertoastWebPlugin.registerWith(registrar); GeolocatorPlugin.registerWith(registrar); ImagePickerPlugin.registerWith(registrar); LocationWebPlugin.registerWith(registrar); registrar.registerMessageHandler(); }
0
mirrored_repositories/Flutter-Widget-Playground/.dart_tool
mirrored_repositories/Flutter-Widget-Playground/.dart_tool/flutter_build/dart_plugin_registrant.dart
// // Generated file. Do not edit. // This file is generated from template in file `flutter_tools/lib/src/flutter_plugins.dart`. // // @dart = 3.2 import 'dart:io'; // flutter_ignore: dart_io_import. import 'package:geolocator_android/geolocator_android.dart'; import 'package:image_picker_android/image_picker_android.dart'; import 'package:path_provider_android/path_provider_android.dart'; import 'package:sqflite/sqflite.dart'; import 'package:geolocator_apple/geolocator_apple.dart'; import 'package:image_picker_ios/image_picker_ios.dart'; import 'package:path_provider_foundation/path_provider_foundation.dart'; import 'package:sqflite/sqflite.dart'; import 'package:file_selector_linux/file_selector_linux.dart'; import 'package:image_picker_linux/image_picker_linux.dart'; import 'package:path_provider_linux/path_provider_linux.dart'; import 'package:file_selector_macos/file_selector_macos.dart'; import 'package:geolocator_apple/geolocator_apple.dart'; import 'package:image_picker_macos/image_picker_macos.dart'; import 'package:path_provider_foundation/path_provider_foundation.dart'; import 'package:sqflite/sqflite.dart'; import 'package:file_selector_windows/file_selector_windows.dart'; import 'package:image_picker_windows/image_picker_windows.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; @pragma('vm:entry-point') class _PluginRegistrant { @pragma('vm:entry-point') static void register() { if (Platform.isAndroid) { try { GeolocatorAndroid.registerWith(); } catch (err) { print( '`geolocator_android` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { ImagePickerAndroid.registerWith(); } catch (err) { print( '`image_picker_android` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { PathProviderAndroid.registerWith(); } catch (err) { print( '`path_provider_android` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { SqflitePlugin.registerWith(); } catch (err) { print( '`sqflite` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } } else if (Platform.isIOS) { try { GeolocatorApple.registerWith(); } catch (err) { print( '`geolocator_apple` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { ImagePickerIOS.registerWith(); } catch (err) { print( '`image_picker_ios` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { PathProviderFoundation.registerWith(); } catch (err) { print( '`path_provider_foundation` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { SqflitePlugin.registerWith(); } catch (err) { print( '`sqflite` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } } else if (Platform.isLinux) { try { FileSelectorLinux.registerWith(); } catch (err) { print( '`file_selector_linux` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { ImagePickerLinux.registerWith(); } catch (err) { print( '`image_picker_linux` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { PathProviderLinux.registerWith(); } catch (err) { print( '`path_provider_linux` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } } else if (Platform.isMacOS) { try { FileSelectorMacOS.registerWith(); } catch (err) { print( '`file_selector_macos` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { GeolocatorApple.registerWith(); } catch (err) { print( '`geolocator_apple` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { ImagePickerMacOS.registerWith(); } catch (err) { print( '`image_picker_macos` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { PathProviderFoundation.registerWith(); } catch (err) { print( '`path_provider_foundation` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { SqflitePlugin.registerWith(); } catch (err) { print( '`sqflite` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } } else if (Platform.isWindows) { try { FileSelectorWindows.registerWith(); } catch (err) { print( '`file_selector_windows` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { ImagePickerWindows.registerWith(); } catch (err) { print( '`image_picker_windows` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } try { PathProviderWindows.registerWith(); } catch (err) { print( '`path_provider_windows` threw an error: $err. ' 'The app may not function as expected until you remove this plugin from pubspec.yaml' ); } } } }
0
mirrored_repositories/Flutter-Widget-Playground
mirrored_repositories/Flutter-Widget-Playground/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:basic_widget_30_1/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/auto_oasis_App
mirrored_repositories/auto_oasis_App/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: return macos; case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions web = FirebaseOptions( apiKey: 'AIzaSyCwp7M4dEfKtDtW0EBKFSy6fOtdGUi9CcA', appId: '1:421924305521:web:df4c5cc7009bb94da079d0', messagingSenderId: '421924305521', projectId: 'car-app-410f4', authDomain: 'car-app-410f4.firebaseapp.com', storageBucket: 'car-app-410f4.appspot.com', measurementId: 'G-19M733XJHX', ); static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyBPjr72rUH8Bw-GyCs5rME1xbRwLokbws4', appId: '1:421924305521:android:e0f1e2a17ffff1e1a079d0', messagingSenderId: '421924305521', projectId: 'car-app-410f4', storageBucket: 'car-app-410f4.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyB8-404x65EgRao5G24RSeX00Ei5UsdEUY', appId: '1:421924305521:ios:f1fcc20e20be548fa079d0', messagingSenderId: '421924305521', projectId: 'car-app-410f4', storageBucket: 'car-app-410f4.appspot.com', iosClientId: '421924305521-tqpdni12as64c458jrkvf4l8043768kr.apps.googleusercontent.com', iosBundleId: 'com.example.autoOasis', ); static const FirebaseOptions macos = FirebaseOptions( apiKey: 'AIzaSyB8-404x65EgRao5G24RSeX00Ei5UsdEUY', appId: '1:421924305521:ios:b3da7f46dea2e3e6a079d0', messagingSenderId: '421924305521', projectId: 'car-app-410f4', storageBucket: 'car-app-410f4.appspot.com', iosClientId: '421924305521-cpbvv2ck3caa4i1mvbo89lmo14r7ksd5.apps.googleusercontent.com', iosBundleId: 'com.example.autoOasis.RunnerTests', ); }
0
mirrored_repositories/auto_oasis_App
mirrored_repositories/auto_oasis_App/lib/main.dart
// ignore_for_file: unused_import import 'package:auto_oasis/App/Modules/Main/mainModule.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'App/Modules/Login/login.dart'; import 'App/Modules/Onboarding/onboarding.dart'; import 'App/Modules/Product_Details/product_details.dart'; import 'App/Modules/Profile/profile.dart'; import 'Cubit/carCuibt.dart'; import 'Cubit/carStates.dart'; import 'Network/Local/cacheHelper.dart'; import 'Shared/Constants/constants.dart'; import 'Shared/Styles/styles.dart'; import 'firebase_options.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); await CacheHelper.init(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); var onbCache = await CacheHelper.getData(key: 'displayOnBoarding'); displayOnBoarding = onbCache; // await CacheHelper.removeData(key: 'displayOnBoarding'); /* Map<String, dynamic> carData = { 'vehicle_brand': 'KIA', 'vehicle_image': 'https://firebasestorage.googleapis.com/v0/b/car-app-410f4.appspot.com/o/2019-kia-rio-s-sedan-angular-front.webp?alt=media&token=5f57d3ec-1e3b-4548-b4bc-905efbb8fa20', 'vehicle_name': 'Kia Rio', 'vehicle_price': '125', 'vehicle_type': 'Sedan', 'brand_image': 'https://firebasestorage.googleapis.com/v0/b/car-app-410f4.appspot.com/o/Kia-logo.png?alt=media&token=a081a121-e1f7-42cd-bcf8-8837cf33dc85', }; await FirebaseFirestore.instance .collection('vehicles') .add(carData) .then((value) { print(value.id); }); */ // FOR ADDING MORE VEHICLES TO THE DATA BASE runApp(const MyApp()); } var displayOnBoarding; class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { Widget home; if (displayOnBoarding == null) { home = const onboarding(); } else if (uid != null) { home = MainWidget(); } else { home = Login(); } return BlocProvider( create: (context) => CarCubit()..loadUserData(), child: BlocConsumer<CarCubit, CarState>( listener: (context, state) { // TODO: implement listener }, builder: (context, state) { return MaterialApp( title: 'Auto Oasis', theme: ThemeData( useMaterial3: true, ), home: home, debugShowCheckedModeBanner: false, ); }, ), ); } } class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[900], body: Center( child: Image.asset('assets/images/onboarding_car.png'), ), ); } } void batchUpdateDocuments() async { final batch = FirebaseFirestore.instance.batch(); // Get all documents QuerySnapshot querySnapshot = await FirebaseFirestore.instance.collection('vehicles').get(); // Loop through documents for (DocumentSnapshot doc in querySnapshot.docs) { batch.update( doc.reference, {'year': '2019'}, ); } // Commit batch write await batch.commit(); }
0
mirrored_repositories/auto_oasis_App/lib/Network
mirrored_repositories/auto_oasis_App/lib/Network/Local/cacheHelper.dart
// ignore_for_file: unused_import import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CacheHelper { static SharedPreferences? sharedPreferences; static init() async { sharedPreferences = await SharedPreferences.getInstance(); } static Future<bool?> putBoolean({ required String key, required bool value, }) async { return await sharedPreferences?.setBool(key, value); } static dynamic getData({ required String key, }) { print(sharedPreferences?.get(key)); return sharedPreferences?.get(key); } static Future<bool?> saveData({ required String key, required dynamic value, }) async { if (value is String) return await sharedPreferences?.setString(key, value); if (value is int) return await sharedPreferences?.setInt(key, value); if (value is bool) return await sharedPreferences?.setBool(key, value); return await sharedPreferences?.setDouble(key, value); } static Future<bool?> removeData({ required String key, }) async { return await sharedPreferences?.remove(key); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Product_Details/product_details.dart
import 'package:flutter/material.dart'; class CarDetails extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Car Details'), backgroundColor: Colors.blue, ), body: Column( children: [ const Image( image: AssetImage('assets/car.png'), height: 200, width: double.infinity, ), const SizedBox(height: 20), const Text( 'Audi Q5 2020', style: TextStyle( color: Colors.blue, fontSize: 24, fontWeight: FontWeight.bold), ), const SizedBox(height: 10), Row( children: [ const Icon( Icons.star, color: Colors.amber, ), Icon( Icons.star, color: Colors.amber, ), //... 23 more widgets ], ), const SizedBox(height: 10), Padding( padding: const EdgeInsets.all(10.0), child: RichText( text: TextSpan( text: '\$100', style: TextStyle( color: Colors.blue, fontSize: 30, fontWeight: FontWeight.bold, ), children: <TextSpan>[ // more widgets ])), ), ], ), ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Main/mainModule.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../../../Cubit/carStates.dart'; class MainWidget extends StatelessWidget { const MainWidget({super.key}); @override Widget build(BuildContext context) { return BlocConsumer<CarCubit, CarState>( listener: (context, state) { // TODO: implement listener }, builder: (context, state) { return Scaffold( body: CarCubit.get(context).Screens[CarCubit.get(context).indexs], bottomNavigationBar: ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0), ), child: BottomNavigationBar( selectedItemColor: Colors.black, currentIndex: CarCubit.get(context).indexs, type: BottomNavigationBarType.fixed, onTap: (index) { CarCubit.get(context).changeIndex(index); }, selectedLabelStyle: GoogleFonts.inter( fontWeight: FontWeight.bold, ), unselectedLabelStyle: GoogleFonts.inter( fontWeight: FontWeight.normal, ), items: [ BottomNavigationBarItem( icon: Image.asset( 'assets/Icons/home_Icon.png', width: 32, height: 32, ), label: 'Home'), BottomNavigationBarItem( icon: Image.asset( 'assets/Icons/vehicles_Icon.png', width: 32, height: 32, ), label: 'Vehicles'), BottomNavigationBarItem( icon: Image.asset( 'assets/Icons/settings_Icon.png', width: 32, height: 32, ), label: 'Settings'), ]), ), ); }, ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Vehicles/vehicles.dart
import 'package:auto_oasis/Cubit/carStates.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../Home/home.dart'; class VehiclesPage extends StatelessWidget { const VehiclesPage({super.key}); @override Widget build(BuildContext context) { return BlocConsumer<CarCubit, CarState>( listener: (context, state) {}, builder: (context, state) { List<Widget> popularBrands = [ const brandWidget(brand_image: 'assets/images/Nissan_logo.png'), const brandWidget(brand_image: 'assets/images/tesla_logo.png'), const brandWidget(brand_image: 'assets/images/Hyundai-Logo.png'), const brandWidget(brand_image: 'assets/images/citroen_logo.png'), const brandWidget(brand_image: 'assets/images/toyota_logo.png'), ]; return Scaffold( body: SafeArea( child: SingleChildScrollView( child: Column( children: [ Container( height: 90, padding: const EdgeInsets.only(top: 34, left: 15, right: 15), child: TextField( decoration: InputDecoration( hintStyle: const TextStyle( fontWeight: FontWeight.w500, color: Colors.black, ), prefixIcon: const Icon(Icons.search), suffixIcon: IconButton( icon: Image.asset('assets/images/onboarding_car.png'), onPressed: () { // Clear the search field }, ), filled: true, focusedBorder: const OutlineInputBorder( borderSide: BorderSide(color: Colors.black), ), fillColor: const Color.fromRGBO(227, 227, 227, 1), hintText: 'Search for a vehicle', border: OutlineInputBorder( borderRadius: BorderRadius.circular(45)), ), ), ), const SizedBox( height: 40, ), Padding( padding: const EdgeInsets.only(left: 24.0), child: Row( children: [ Image.asset( 'assets/images/star.png', height: 30, width: 30, ), const SizedBox( width: 8, ), Text( 'Popular Brands', style: GoogleFonts.inter( fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black, ), ), ], ), ), const SizedBox( height: 14, ), Padding( padding: const EdgeInsets.only(left: 25.0), child: SizedBox( height: 70, child: ListView.separated( scrollDirection: Axis.horizontal, itemCount: popularBrands.length, separatorBuilder: (BuildContext context, int index) { return const SizedBox( width: 18, ); }, itemBuilder: (BuildContext context, int index) { return popularBrands[index]; }, ), ), ), const SizedBox( height: 40, ), Padding( padding: const EdgeInsets.only(left: 24.0), child: Row( children: [ Image.asset( 'assets/images/liked.png', height: 30, width: 30, ), const SizedBox( width: 8, ), Text( 'Top Rated', style: GoogleFonts.inter( fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black, ), ), ], ), ), const SizedBox( height: 14, ), CarouselSlider( items: [ LocalCarAd( car_brand: 'assets/images/Nissan_logo.png', car_image: 'assets/images/nissan_navara.png', car_name: 'Nissan Navara', car_price: '120/Day', car_type: 'SUV', ), LocalCarAd( car_brand: 'assets/images/toyota_logo.png', car_image: 'assets/images/2019camry.png', car_name: 'Toyota Camry', car_price: '170/Day', car_type: 'Sedan', ), LocalCarAd( car_brand: 'assets/images/tesla_logo.png', car_image: 'assets/images/model_Y.png', car_name: 'Tesla Model Y', car_price: '230/Day', car_type: 'Sedan', ), ], options: CarouselOptions(autoPlay: true, viewportFraction: 1), ), const SizedBox( height: 40, ), Padding( padding: const EdgeInsets.only(left: 24.0), child: Row( children: [ Image.asset( 'assets/images/fire.png', height: 30, width: 30, ), const SizedBox( width: 8, ), Text( 'Hot Deals', style: GoogleFonts.inter( fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black, ), ), ], ), ), const SizedBox( height: 14, ), SizedBox( height: 1400, // specify a fixed height child: ListView.separated( physics: NeverScrollableScrollPhysics(), itemCount: 6, separatorBuilder: (BuildContext context, int index) { return const SizedBox( height: 20, ); }, itemBuilder: (BuildContext context, int index) { return Padding( padding: const EdgeInsets.all(8.0), child: LocalCarAd( car_brand: 'assets/images/Nissan_logo.png', car_image: 'assets/images/nissan_navara.png', car_name: 'Nissan Navara', car_price: '120/Day', car_type: 'SUV', ), ); }, ), ), ], ), )), ); }, ); } } class brandWidget extends StatelessWidget { const brandWidget({ super.key, required this.brand_image, }); final brand_image; @override Widget build(BuildContext context) { return Container( height: 70, width: 70, child: Padding( padding: const EdgeInsets.all(4.0), child: Image.asset( '$brand_image', width: 60, height: 60, ), ), decoration: BoxDecoration( border: Border.all( color: Colors.black, width: 1, ), borderRadius: BorderRadius.circular(18), color: const Color.fromRGBO(234, 234, 234, 1)), ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Settings/settings.dart
// ignore_for_file: invalid_use_of_visible_for_testing_member, invalid_use_of_protected_member, unused_import import 'package:auto_oasis/App/Modules/Login/login.dart'; import 'package:auto_oasis/Cubit/carStates.dart'; import 'package:auto_oasis/Shared/Components/components.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../../../Network/Local/cacheHelper.dart'; import '../../../Shared/Constants/constants.dart'; import '../../../main.dart'; import '../Profile/profile.dart'; class SettingsPage extends StatelessWidget { const SettingsPage({super.key}); @override Widget build(BuildContext context) { var themes = ['Light', 'Dark']; var languages = ['English', 'Spanish', 'French']; var selectedLanguage = 'English'; return Scaffold( backgroundColor: Colors.grey[200], body: BlocConsumer<CarCubit, CarState>( listener: (context, state) { print(state); }, builder: (context, state) { if (selectedTheme == null) { selectedTheme = 0; } return SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column(children: [ const SizedBox(height: 42.0), Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( padding: EdgeInsets.all(16.0), child: Text( 'General', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), const Divider(height: 1.0), ListTile( title: const Text('Notifications'), trailing: Switch( value: switchvalue ??= true, activeColor: Colors.blue, onChanged: (value) { CacheHelper.saveData( key: 'enableNotifications', value: value); print(CacheHelper.getData( key: 'enableNotifications', )); switchvalue = value; CarCubit.get(context).emit(ChangedSettingsState()); }, ), ), ], ), ), ), const SizedBox(height: 6.0), Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( padding: EdgeInsets.all(16.0), child: Text( 'Appearance', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), const Divider(height: 1.0), Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Theme', style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16.0), Wrap( spacing: 8.0, children: themes .asMap() .entries .map( (entry) => GestureDetector( onTap: () { if (selectedTheme == 0) { CacheHelper.saveData( key: 'Theme', value: 1); selectedTheme = 1; CarCubit.get(context) .emit(ChangedSettingsState()); } else if (selectedTheme == 1) { CacheHelper.saveData( key: 'Theme', value: 0); selectedTheme = 0; CarCubit.get(context) .emit(ChangedSettingsState()); } }, child: Container( decoration: BoxDecoration( color: selectedTheme == entry.key ? Colors.blue : Colors.grey[200], borderRadius: BorderRadius.circular(8.0), ), padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 8.0, ), child: Text( entry.value, style: const TextStyle( color: Colors.white, ), ), ), ), ) .toList(), ), const SizedBox(height: 16.0), ], ), ), ], ), ), ), const SizedBox(height: 6.0), Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( padding: EdgeInsets.all(16.0), child: Text( 'Language', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), const Divider(height: 1.0), Padding( padding: const EdgeInsets.all(16.0), child: DropdownButtonFormField<String>( value: selectedLanguage, onChanged: (v) {}, items: languages.map((language) { return DropdownMenuItem<String>( value: language, child: Text(language), ); }).toList(), ), ), ], ), ), ), const SizedBox(height: 6.0), Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( padding: EdgeInsets.all(16.0), child: Text( 'Account', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), const Divider(height: 1.0), ListTile( title: const Text('Profile'), leading: Image.asset( 'assets/Icons/profile.png', width: 24, height: 24, ), onTap: () { navigateTo(context, UserProfile()); }, ), ListTile( title: const Text('Security'), leading: Image.asset( 'assets/Icons/security_Icon.png', width: 28, height: 28, ), onTap: () {}, ), ListTile( title: const Text('Rent History'), leading: Icon(Icons.history), onTap: () {}, ), ListTile( title: const Text('Sign out'), leading: Image.asset( 'assets/Icons/signout_Icon.png', width: 24, height: 24, ), onTap: () { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text( 'Log out', style: GoogleFonts.inter(), ), content: Text( 'Are you sure you want to log out?', style: GoogleFonts.inter(), ), actions: <Widget>[ TextButton( onPressed: () { Navigator.of(context) .pop(); // Dismiss the dialog and return false }, child: Text( 'Cancel', style: GoogleFonts.inter(), ), ), ElevatedButton( onPressed: () { CacheHelper.removeData(key: 'uid') .then((value) { navigateToAndFinish(context, Login()); }); }, child: Text( 'Log out', style: GoogleFonts.inter(), ), ), ], ); }, ); }), ], ), ), ), ]), ); }, ), ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Register/register.dart
// ignore_for_file: unused_local_variable import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../../../Cubit/carStates.dart'; import '../../../Shared/Components/components.dart'; import '../Main/mainModule.dart'; class Register extends StatelessWidget { const Register({super.key}); @override Widget build(BuildContext context) { var formKey = GlobalKey<FormState>(); var emailController = TextEditingController(); var passwordController = TextEditingController(); var usernameController = TextEditingController(); var confirmPasswordController = TextEditingController(); var phoneNumberController = TextEditingController(); return BlocConsumer<CarCubit, CarState>( listener: (context, state) { if (state is SuccessRegisterState) { navigateToAndFinish(context, const MainWidget()); } }, builder: (context, state) { return Scaffold( backgroundColor: Colors.grey[900], body: Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 80.0, height: 80.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(40.0), ), child: Icon( Icons.person, color: Colors.grey[900], size: 40.0, ), ), const SizedBox( width: 20, ), Container( decoration: const BoxDecoration( color: Colors.white, shape: BoxShape.circle, ), alignment: Alignment.center, width: 80, height: 80, child: Image.asset( "assets/images/onboarding_car.png", fit: BoxFit.contain, ), ), ], ), const SizedBox( height: 40, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Column(children: [ TextFormField( controller: usernameController, validator: (value) { if (value!.isEmpty) { return 'Username cannot be left empty.'; } return null; }, decoration: InputDecoration( hintText: 'Username', hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.person, color: Colors.white, ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( validator: (value) { if (value!.isEmpty) { return 'E-mail cannot be left empty.'; } else if (!RegExp( r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$') .hasMatch(value)) { return 'Please enter a valid email address'; } return null; }, keyboardType: TextInputType.emailAddress, controller: emailController, decoration: InputDecoration( hintText: 'Email', hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.email, color: Colors.white, ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( controller: passwordController, validator: (value) { if (value!.isEmpty) { return 'Password cannot be left empty.'; } return null; }, obscureText: CarCubit.get(context).isViewable, decoration: InputDecoration( hintText: 'Password', hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.lock, color: Colors.white, ), suffixIcon: InkWell( onTap: () { CarCubit.get(context).changeViewable(); }, child: const Icon( Icons.visibility, color: Colors.white, ), ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( controller: phoneNumberController, validator: (value) { if (value!.isEmpty) { return 'Field cannnot be left empty.'; } if (value.length < 11) { return 'Incorrect phone number format.'; } return null; }, decoration: InputDecoration( hintText: 'Phone Number', hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.phone_android, color: Colors.white, ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( controller: confirmPasswordController, validator: (value) { if (value!.isEmpty) { return 'Field cannnot be left empty.'; } if (value.toString() != passwordController.text) { return 'Please recheck your password before proceeding.'; } return null; }, obscureText: CarCubit.get(context).isViewable, decoration: InputDecoration( hintText: 'Confirm Password', hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.lock, color: Colors.white, ), suffixIcon: InkWell( onTap: () { CarCubit.get(context).changeViewable(); }, child: const Icon( Icons.visibility, color: Colors.white, ), ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), const SizedBox( height: 30, ), ElevatedButton( onPressed: () { if (formKey.currentState!.validate()) { CarCubit.get(context).register( phone: phoneNumberController.text, context: context, email: emailController.text, name: usernameController.text, password: passwordController.text, ); } }, style: ElevatedButton.styleFrom( primary: Colors.white, onPrimary: Colors.blue[700], shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), padding: const EdgeInsets.symmetric( horizontal: 40, vertical: 10), ), child: Text( 'CREATE YOUR ACCOUNT', style: GoogleFonts.roboto( color: Colors.grey[900], fontSize: 18, fontWeight: FontWeight.w300), ), ), const SizedBox(height: 20), ])) ]), )); }, ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Home/home.dart
// ignore_for_file: must_be_immutable import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../../../Cubit/carStates.dart'; import '../../../Shared/Components/components.dart'; class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { return BlocConsumer<CarCubit, CarState>( listener: (context, state) {}, builder: (context, state) { final CollectionReference collectionRef = FirebaseFirestore.instance.collection('vehicles'); return Scaffold( body: SafeArea( child: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( children: [ Container( height: 90, padding: const EdgeInsets.only(top: 34, left: 15, right: 15), child: TextField( decoration: InputDecoration( hintStyle: const TextStyle( fontWeight: FontWeight.w500, color: Colors.black, ), prefixIcon: const Icon(Icons.search), suffixIcon: IconButton( icon: Image.asset( 'assets/images/onboarding_car.png', ), onPressed: () { // Clear the search field }, ), filled: true, focusedBorder: const OutlineInputBorder( borderSide: BorderSide(color: Colors.black), ), fillColor: const Color.fromRGBO(227, 227, 227, 1), hintText: 'Search for a vehicle', border: OutlineInputBorder( borderRadius: BorderRadius.circular(45)), ), ), ), const SizedBox( height: 30, ), Padding( padding: const EdgeInsets.only(left: 15, right: 15), child: Container( height: 80, width: 360, decoration: BoxDecoration( border: Border.all( width: 1, color: const Color.fromRGBO(195, 195, 195, 1)), borderRadius: BorderRadius.circular(35), ), child: Row( children: [ Padding( padding: const EdgeInsets.only(left: 17), child: Container( decoration: BoxDecoration( color: const Color.fromRGBO(195, 195, 195, 1), borderRadius: BorderRadius.circular(18)), height: 50, width: 50, ), ), Image.asset( 'assets/images/model_Y.png', ), // Add this SizedBox const Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Model Y', style: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black, )), Text('Sedan', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w200, )), ], ), ), ], ), ), ), const SizedBox( height: 10, ), Padding( padding: const EdgeInsets.only(left: 15, right: 15), child: Container( height: 80, width: 360, decoration: BoxDecoration( border: Border.all( width: 1, color: const Color.fromRGBO(195, 195, 195, 1)), borderRadius: BorderRadius.circular(35), ), child: Row( children: [ Padding( padding: const EdgeInsets.only(left: 17), child: Container( decoration: BoxDecoration( color: const Color.fromRGBO(195, 195, 195, 1), borderRadius: BorderRadius.circular(18)), height: 50, width: 50, ), ), Image.asset( 'assets/images/model_Y.png', ), // Add this SizedBox const Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Model Y', style: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black, )), Text('Sedan', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w200, )), ], ), ), ], ), ), ), const SizedBox( height: 30, ), const Text('Trending Vehicles', style: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black, )), const SizedBox( height: 10, ), Padding( padding: const EdgeInsets.all(12.0), child: StreamBuilder<QuerySnapshot?>( stream: collectionRef.snapshots(), builder: (context, snapshot) { if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } if (snapshot.connectionState == ConnectionState.waiting) { return const CircularProgressIndicator(); } final QuerySnapshot? querySnapshot = snapshot.data; if (querySnapshot == null) { print('DATA DOES NOT EXIST.'); return bigText( text: 'No data available', color: Colors.black); } return ListView.separated( separatorBuilder: (BuildContext context, int index) => const SizedBox( height: 10, ), physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: querySnapshot.docs.length, itemBuilder: (BuildContext context, int index) { final DocumentSnapshot<Object?> document = querySnapshot.docs[index]; return CarAd( car_image: document['vehicle_image'], car_brand: document['brand_image'], car_price: document['vehicle_price'], car_year: document['year'], car_name: document['vehicle_name'], car_type: document['vehicle_type']); }, ); }, ), ), ], ), ), ), ); }, ); } } class CarAd extends StatelessWidget { CarAd( {super.key, required this.car_image, required this.car_brand, required this.car_price, required this.car_name, required this.car_type, required this.car_year}); var car_image; var car_brand; var car_type; var car_name; var car_price; var car_year; @override Widget build(BuildContext context) { return Container( height: 320, width: 320, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3), ), ], border: Border.all( width: 1, color: const Color.fromRGBO(195, 195, 195, 1), ), borderRadius: BorderRadius.circular(35), ), child: GestureDetector( onTap: () { print('Clicked'); }, child: Stack( children: [ Positioned( right: -250, top: -100, child: ClipRRect( child: Image.network( '$car_image', height: 550, width: 550, ), ), ), Padding( padding: const EdgeInsets.only(bottom: 230, left: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '$car_name', style: GoogleFonts.inter( fontSize: 24, fontWeight: FontWeight.w600, color: Colors.black, ), ), Text( '$car_type', style: GoogleFonts.inter( fontSize: 18, fontWeight: FontWeight.w300, color: const Color.fromRGBO(40, 40, 40, 1)), ), ], ), ), Padding( padding: const EdgeInsets.all(15.0), child: Align( alignment: Alignment.topRight, child: Container( child: Padding( padding: const EdgeInsets.all(4), child: Image.network( '$car_brand', ), ), decoration: BoxDecoration( border: Border.all( color: Colors.black, width: 1, ), color: const Color.fromRGBO(234, 234, 234, 1), borderRadius: BorderRadius.circular(18), ), height: 65, width: 65, ), ), ), Padding( padding: const EdgeInsets.all(20.0), child: Align( alignment: Alignment.bottomLeft, child: Container( padding: const EdgeInsets.symmetric( horizontal: 6.0, vertical: 2.5), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.0), color: Colors.green[800], ), child: Row( mainAxisSize: MainAxisSize.min, children: [ const Icon( Icons.attach_money, color: Colors.white, size: 16.0, ), const SizedBox(width: 4.0), Text( '$car_price/Day', style: const TextStyle( color: Colors.white, fontSize: 16.0, ), ), ], ), ), ), ) ], ), ), ); } } class LocalCarAd extends StatelessWidget { LocalCarAd( {super.key, required this.car_image, required this.car_brand, required this.car_price, required this.car_name, required this.car_type}); var car_image; var car_brand; var car_type; var car_name; var car_price; @override Widget build(BuildContext context) { return Container( height: 320, width: 320, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3), ), ], border: Border.all( width: 1, color: const Color.fromRGBO(195, 195, 195, 1), ), borderRadius: BorderRadius.circular(35), ), child: GestureDetector( onTap: () { print('Clicked'); }, child: Stack( children: [ Positioned( right: -250, top: -100, child: ClipRRect( child: Image.asset( '$car_image', height: 550, width: 550, ), ), ), Padding( padding: const EdgeInsets.all(15.0), child: Align( alignment: Alignment.topRight, child: Container( child: Padding( padding: const EdgeInsets.all(4), child: Image.asset( '$car_brand', ), ), decoration: BoxDecoration( border: Border.all( color: Colors.black, width: 1, ), color: const Color.fromRGBO(234, 234, 234, 1), borderRadius: BorderRadius.circular(18), ), height: 65, width: 65, ), ), ), Padding( padding: const EdgeInsets.all(20.0), child: Align( alignment: Alignment.bottomLeft, child: Container( padding: const EdgeInsets.symmetric( horizontal: 6.0, vertical: 2.5), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.0), color: Colors.green[800], ), child: Row( mainAxisSize: MainAxisSize.min, children: [ const Icon( Icons.attach_money, color: Colors.white, size: 16.0, ), const SizedBox(width: 4.0), Text( '$car_price/Day', style: const TextStyle( color: Colors.white, fontSize: 16.0, ), ), ], ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Onboarding/onboarding.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../../../Cubit/carStates.dart'; import '../../../Network/Local/cacheHelper.dart'; import '../../../Shared/Components/components.dart'; import '../Login/login.dart'; class onboarding extends StatelessWidget { const onboarding({super.key}); @override Widget build(BuildContext context) { return BlocConsumer<CarCubit, CarState>( listener: (context, state) {}, builder: (context, state) { return Scaffold( backgroundColor: Colors.grey[900], body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Center( child: Stack( children: [ Center( child: Container( decoration: BoxDecoration( color: Colors.grey[700], shape: BoxShape.circle, ), alignment: Alignment.center, width: 300, height: 300, child: Image.asset( "assets/images/onboarding_car.png", fit: BoxFit.contain, ), ), ), ], ), ), const SizedBox( height: 20, ), bigText( context: context, color: Colors.white, weight: FontWeight.bold, text: 'Your ride, your way', ), Padding( padding: const EdgeInsets.all(8.0), child: Text( 'We put you in control, with flexible pick-up and drop-off locations, customizable rental periods, and a variety of vehicle options to choose from. You can create a rental experience that meets your unique needs and preferences.', textAlign: TextAlign.center, style: GoogleFonts.roboto(color: Colors.white, fontSize: 12), ), ), const SizedBox( height: 30, ), Align( alignment: Alignment.bottomCenter, child: OutlinedButton( onPressed: () async { await CacheHelper.saveData( key: 'displayOnBoarding', value: false) .then((value) { print('Onboarding page displayed.'); navigateToAndFinish(context, Login()); }); }, style: OutlinedButton.styleFrom( primary: Colors.white, // button border color shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), // rounded corners ), side: const BorderSide( color: Colors.white, width: 1), // button border padding: const EdgeInsets.symmetric( horizontal: 120, vertical: 14), // button padding ), child: const Text( 'Next', style: TextStyle( fontSize: 18, letterSpacing: 1, ), ), ), ) ], ), ); }, ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Login/login.dart
// ignore_for_file: unused_import import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Cubit/carCuibt.dart'; import '../../../Cubit/carStates.dart'; import '../../../Shared/Components/components.dart'; import '../Home/home.dart'; import '../Main/mainModule.dart'; import '../Register/register.dart'; class Login extends StatelessWidget { const Login({super.key}); @override Widget build(BuildContext context) { var formKey = GlobalKey<FormState>(); var emailController = TextEditingController(); var passwordController = TextEditingController(); bool fieldStatus = true; Widget suffixWidgetPassword = const Icon( Icons.visibility, color: Colors.white, ); Widget? suffixWidgetEmail = null; return BlocConsumer<CarCubit, CarState>( listener: (context, state) { print(state); if (state is LoadingLoginState) { fieldStatus = false; suffixWidgetEmail = const CircularProgressIndicator( color: Colors.white38, strokeWidth: 1, ); suffixWidgetPassword = const CircularProgressIndicator( color: Colors.white38, strokeWidth: 1, ); } else { fieldStatus = true; suffixWidgetEmail = null; suffixWidgetPassword = const Icon( Icons.visibility, color: Colors.white, ); } if (state is SuccessLoginState) { navigateToAndFinish(context, const MainWidget()); } }, builder: (context, state) { return Scaffold( backgroundColor: Colors.grey[900], body: Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 80.0, height: 80.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(40.0), ), child: Icon( Icons.lock, color: Colors.grey[900], size: 40.0, ), ), const SizedBox( width: 20, ), Container( decoration: const BoxDecoration( color: Colors.white, shape: BoxShape.circle, ), alignment: Alignment.center, width: 80, height: 80, child: Image.asset( "assets/images/onboarding_car.png", fit: BoxFit.contain, ), ), ], ), const SizedBox( height: 40, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Column(children: [ TextFormField( controller: emailController, validator: (value) { if (value!.isEmpty) { return 'E-mail cannot be left empty.'; } else if (!RegExp( r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$') .hasMatch(value)) { return 'Please enter a valid email address'; } return null; }, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( hintText: 'Email', suffixIcon: suffixWidgetEmail, enabled: fieldStatus, hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.email, color: Colors.white, ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( controller: passwordController, validator: (value) { if (value!.isEmpty) { return 'Password cannot be left empty.'; } return null; }, obscureText: CarCubit.get(context).isViewable, decoration: InputDecoration( hintText: 'Password', enabled: fieldStatus, hintStyle: GoogleFonts.robotoCondensed(), prefixIcon: const Icon( Icons.lock, color: Colors.white, ), suffixIcon: InkWell( onTap: () { CarCubit.get(context).changeViewable(); }, child: suffixWidgetPassword, ), filled: true, fillColor: Colors.white.withOpacity(0.3), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), const SizedBox( height: 30, ), ElevatedButton( onPressed: () { if (formKey.currentState!.validate()) { CarCubit.get(context) .loginUser(emailController.text, passwordController.text, context) .then((value) {}); } }, style: ElevatedButton.styleFrom( primary: Colors.white, onPrimary: Colors.blue[700], shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), padding: const EdgeInsets.symmetric( horizontal: 40, vertical: 10), ), child: Text( 'LOGIN', style: GoogleFonts.roboto( color: Colors.grey[900], fontSize: 18, fontWeight: FontWeight.w300), ), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Don\'t have an account?', style: GoogleFonts.roboto( color: Colors.white, fontWeight: FontWeight.w300), ), TextButton( child: Text( 'REGISTER NOW', style: GoogleFonts.roboto( color: Colors.white, fontWeight: FontWeight.w500), ), onPressed: () { navigateTo(context, Register()); }, ), ], ), ])) ]), )); }, ); } }
0
mirrored_repositories/auto_oasis_App/lib/App/Modules
mirrored_repositories/auto_oasis_App/lib/App/Modules/Profile/profile.dart
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../Shared/Constants/constants.dart'; class TrianglePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final fillPaint = Paint() ..color = const Color.fromRGBO(173, 0, 255, 1) ..style = PaintingStyle.fill; final strokePaint = Paint() ..color = Colors.black ..style = PaintingStyle.stroke ..strokeWidth = 1.0 ..strokeJoin = StrokeJoin.round; final height = (sqrt(3) / 2) * size.width; final path = Path() ..moveTo(size.width / 2, 0) ..lineTo(size.width, height) ..lineTo(0, height) ..close(); canvas.drawPath(path, fillPaint); canvas.drawPath(path, strokePaint); } @override bool shouldRepaint(TrianglePainter oldDelegate) => false; } class UserProfile extends StatelessWidget { const UserProfile({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, actions: [ Padding( padding: const EdgeInsets.all(8.0), child: InkWell( onTap: () {}, child: Image.asset( 'assets/images/edit.png', ), ), ), ], ), body: Column( children: [ const SizedBox( height: 20, ), Container( decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( color: Colors.black, width: 1.0, ), ), child: CircleAvatar( minRadius: 60, backgroundColor: const Color.fromRGBO(207, 207, 207, 1), child: Center( child: CustomPaint( painter: TrianglePainter(), size: const Size.fromRadius(40), ), ), ), ), const SizedBox( height: 10, ), Text( interuser.get('name'), style: GoogleFonts.inter( fontSize: 30, color: Colors.black, fontWeight: FontWeight.w500), ), Text( interuser.get('email'), style: GoogleFonts.inter( fontSize: 20, color: Colors.black, fontWeight: FontWeight.w200), ), const SizedBox( height: 40, ), SizedBox( width: 300, child: Align( alignment: Alignment.centerLeft, child: Text( 'Phone Number', style: GoogleFonts.inter( fontSize: 20, color: Colors.black, fontWeight: FontWeight.w400), ), ), ), Padding( padding: const EdgeInsets.all(13.0), child: TextFormField( enabled: false, initialValue: interuser.get('phone'), decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide(color: Color.fromRGBO(199, 199, 199, 1)), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide(color: Color.fromRGBO(199, 199, 199, 1)), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide( color: Color.fromRGBO(199, 199, 199, 1), width: 2.0, ), ), ), ), ), SizedBox( width: 300, child: Align( alignment: Alignment.centerLeft, child: Text( 'E-mail Address', style: GoogleFonts.inter( fontSize: 20, color: Colors.black, fontWeight: FontWeight.w400), ), ), ), Padding( padding: const EdgeInsets.all(13.0), child: TextFormField( enabled: false, initialValue: interuser.get('email'), decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide(color: Color.fromRGBO(199, 199, 199, 1)), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide(color: Color.fromRGBO(199, 199, 199, 1)), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide( color: Color.fromRGBO(199, 199, 199, 1), width: 2.0, ), ), ), ), ), SizedBox( width: 300, child: Align( alignment: Alignment.centerLeft, child: Text( 'Password', style: GoogleFonts.inter( fontSize: 20, color: Colors.black, fontWeight: FontWeight.w400), ), ), ), Padding( padding: const EdgeInsets.all(13.0), child: TextFormField( enabled: false, initialValue: '***************', decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide(color: Color.fromRGBO(199, 199, 199, 1)), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide(color: Color.fromRGBO(199, 199, 199, 1)), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(100.0), borderSide: const BorderSide( color: Color.fromRGBO(199, 199, 199, 1), width: 2.0, ), ), ), ), ) ], ), ); } }
0
mirrored_repositories/auto_oasis_App/lib/Shared
mirrored_repositories/auto_oasis_App/lib/Shared/Constants/constants.dart
import '../../Network/Local/cacheHelper.dart'; var uid = CacheHelper.getData(key: 'uid'); var switchvalue = CacheHelper.getData(key: 'enableNotifications'); var selectedTheme = CacheHelper.getData(key: 'Theme'); var interuser;
0
mirrored_repositories/auto_oasis_App/lib/Shared
mirrored_repositories/auto_oasis_App/lib/Shared/Styles/styles.dart
0
mirrored_repositories/auto_oasis_App/lib/Shared
mirrored_repositories/auto_oasis_App/lib/Shared/Components/components.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; Widget bigText({ required var text, var color, context, var weight, bool? textTheme, }) => Text( text, style: GoogleFonts.roboto( color: color, textStyle: Theme.of(context).textTheme.displayLarge!.copyWith( fontWeight: weight, )), ); Widget uText({ required var text, var color, context, var weight, bool? textTheme, var size, }) => Text(text, style: GoogleFonts.roboto( color: color, fontSize: size, )); Future<void> navigateToAndFinish(context, widget) async => Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => widget), (route) => false, ); Future<void> navigateTo(context, widget) async => Navigator.push( context, MaterialPageRoute(builder: (context) => widget), );
0
mirrored_repositories/auto_oasis_App/lib
mirrored_repositories/auto_oasis_App/lib/Cubit/carCuibt.dart
// ignore_for_file: unused_import import 'package:auto_oasis/App/Modules/Home/home.dart'; import 'package:auto_oasis/App/Modules/Settings/settings.dart'; import 'package:auto_oasis/App/Modules/Vehicles/vehicles.dart'; import 'package:auto_oasis/Network/Local/cacheHelper.dart'; import 'package:bloc/bloc.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../Shared/Constants/constants.dart'; import 'carStates.dart'; class CarCubit extends Cubit<CarState> { CarCubit() : super(CarInitial()); static CarCubit get(context) => BlocProvider.of(context); bool isViewable = false; void changeViewable() { if (isViewable == true) { isViewable = false; } else if (isViewable == false) { isViewable = true; } print(isViewable); emit(SuffixChangeState()); } int indexs = 0; void changeIndex(index) { indexs = index; emit(BNBChangeState()); } List<Widget> Screens = [ HomePage(), VehiclesPage(), SettingsPage(), ]; Future<Object?> register( {required String email, required String password, required context, required String phone, required String name}) async { final FirebaseAuth _auth = FirebaseAuth.instance; try { emit(LoadingRegisterState()); UserCredential userCredential = await _auth .createUserWithEmailAndPassword( email: email, password: password, ) .then((value) async { print(value.user?.uid); // CREATION OF USER------------- FirebaseFirestore.instance .collection('users') .doc(value.user?.uid) .set({ 'name': name, 'email': email, 'profile_image': 'https://firebasestorage.googleapis.com/v0/b/car-app-410f4.appspot.com/o/vehicles_Icon.png?alt=media&token=0994d376-c08d-477d-aa48-f3290b0dc85d', 'uid': value.user?.uid, 'phone': phone, }); await CacheHelper.saveData(key: 'uid', value: value.user?.uid); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.green, content: Text("Account created successfully!", style: TextStyle(color: Colors.white)), duration: Duration(seconds: 3), )); emit(SuccessRegisterState()); return value; }); return userCredential; } on FirebaseAuthException catch (e) { emit(ErrorRegisterState()); if (e.code == 'weak-password') { ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.red, content: Text("The password provided is too weak.", style: TextStyle(color: Colors.white)), duration: Duration(seconds: 3), )); print('The password provided is too weak.'); } else if (e.code == 'email-already-in-use') { ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.red, content: Text("The account already exists for that email.", style: TextStyle(color: Colors.white)), duration: Duration(seconds: 3), )); } return e.message; } catch (e) { return e.toString(); } } Future<UserCredential?> loginUser( String email, String password, context, ) async { FirebaseAuth auth = FirebaseAuth.instance; try { emit(LoadingLoginState()); UserCredential userCredential = await auth .signInWithEmailAndPassword(email: email, password: password) .then((value) async { print(value.user?.uid); await CacheHelper.saveData(key: 'uid', value: value.user?.uid); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.green, content: Text("Login Success!", style: TextStyle(color: Colors.white)), duration: Duration(seconds: 3), )); emit(SuccessLoginState()); return value; }); return userCredential; } on FirebaseAuthException catch (e) { emit(ErrorLoginState()); if (e.code == 'user-not-found') { ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.red, content: Text("User not found.", style: TextStyle(color: Colors.white)), duration: Duration(seconds: 3), )); print('No user found for that email.'); } else if (e.code == 'wrong-password') { print('Wrong password provided for that user.'); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Colors.red, content: Text("Wrong password provided for that user.", style: TextStyle(color: Colors.white)), duration: Duration(seconds: 3), )); } return null; } } Future<dynamic> loadUserData() async { DocumentSnapshot documentSnapshot = await FirebaseFirestore.instance.collection('users').doc(uid).get(); interuser = documentSnapshot; } // SETTINGS PAGE }
0
mirrored_repositories/auto_oasis_App/lib
mirrored_repositories/auto_oasis_App/lib/Cubit/carStates.dart
import 'package:flutter/material.dart'; @immutable abstract class CarState {} class CarInitial extends CarState {} class SuffixChangeState extends CarState {} class BNBChangeState extends CarState {} // LOGIN STATES class LoadingLoginState extends CarState {} class ErrorLoginState extends CarState {} class SuccessLoginState extends CarState {} // REGISTER STATES class LoadingRegisterState extends CarState {} class ErrorRegisterState extends CarState {} class SuccessRegisterState extends CarState {} // SETTINGS class ChangedSettingsState extends CarState {} class ScrollExpansionState extends CarState {}
0
mirrored_repositories/auto_oasis_App
mirrored_repositories/auto_oasis_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 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:auto_oasis/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/trivia_example
mirrored_repositories/trivia_example/lib/main.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import 'src/homepage.dart'; import 'src/models/appstate.dart'; import 'src/models/theme.dart'; void main() => runApp(App()); class App extends StatelessWidget { final appState = AppState(); @override Widget build(BuildContext context) { return AppStateProvider<AppState>( appState: appState, child: MaterialPage(), ); } } class MaterialPage extends StatelessWidget { @override Widget build(BuildContext context) { final theme = AppStateProvider.of<AppState>(context).currentTheme; return ValueBuilder<MyTheme>( streamed: theme, builder: (context, snapshot) { return MaterialApp( title: 'Trivia example', theme: _buildThemeData(snapshot.data), home: HomePage()); }); } ThemeData _buildThemeData(MyTheme appTheme) { return ThemeData( brightness: appTheme.brightness, backgroundColor: appTheme.backgroundColor, scaffoldBackgroundColor: appTheme.scaffoldBackgroundColor, primaryColor: appTheme.primaryColor, primaryColorBrightness: appTheme.primaryColorBrightness, accentColor: appTheme.accentColor, ); } }
0
mirrored_repositories/trivia_example/lib
mirrored_repositories/trivia_example/lib/src/styles.dart
import 'package:flutter/material.dart'; // // ** Trivia page ** // const textColor = Colors.white; const scoreHeaderStyle = TextStyle( letterSpacing: 2.0, color: Colors.orange, fontSize: 16, fontWeight: FontWeight.w400, shadows: [ Shadow( blurRadius: 2.0, color: Colors.red, ), ], ); const questionsHeaderStyle = TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.w400, fontStyle: FontStyle.italic); const answerBoxColor = Color(0xff283593); const questionCircleAvatarBackground = Color(0xff22273a); const questionCircleAvatarRadius = 14.0; const answersLeadingStyle = TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w700); const answersStyle = TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500); // // ** Summary page ** // const dividerHeight = 12.0; const dividerColor = Colors.white; const circleAvatarRadius = 12.0; //const circleAvatarBackground = Colors.blue; const circleAvatarBackground = Color(0xff4a5580); const summaryScoreStyle = TextStyle( color: Colors.lime, fontSize: 22, fontWeight: FontWeight.w600, fontStyle: FontStyle.italic); const questionHeaderStyle = TextStyle( color: Colors.white54, fontSize: 12, fontWeight: FontWeight.w600, fontStyle: FontStyle.italic); const questionStyle = TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.w600, ); const correctsHeaderStyle = TextStyle( color: Colors.greenAccent, fontSize: 14, fontWeight: FontWeight.w600, ); const wrongsHeaderStyle = TextStyle( color: Colors.redAccent, fontSize: 14, fontWeight: FontWeight.w600, ); const notAnsweredHeaderStyle = TextStyle( color: Color(0xffe1e1e1), fontSize: 14, fontWeight: FontWeight.w600, ); const correctAnswerStyle = TextStyle(color: Colors.green, fontWeight: FontWeight.w600); const wrongAnswerStyle = TextStyle( color: Colors.red, fontWeight: FontWeight.w400, fontStyle: FontStyle.italic); const notChosenStyle = TextStyle( color: Color(0xffe1e1e1), fontWeight: FontWeight.w400, fontStyle: FontStyle.italic);
0
mirrored_repositories/trivia_example/lib
mirrored_repositories/trivia_example/lib/src/homepage.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import 'models/appstate.dart'; import 'models/models.dart'; import 'screens/main_page.dart'; import 'screens/settings_page.dart'; import 'screens/summary_page.dart'; import 'screens/trivia_page.dart'; /// Styles const textStyle = TextStyle(color: Colors.blue); const iconColor = Colors.blueGrey; class HomePage extends StatelessWidget { Widget _switchTab(AppTab tab, AppState appState) { switch (tab) { case AppTab.main: return MainPage(); break; case AppTab.trivia: return TriviaPage(); break; case AppTab.summary: return SummaryPage(stats: appState.triviaBloc.stats); break; default: return MainPage(); } } @override Widget build(BuildContext context) { final appState = AppStateProvider.of<AppState>(context); return ValueBuilder( streamed: appState.tabController, builder: (context, snapshot) => Scaffold( appBar: snapshot.data != AppTab.main ? null : AppBar(), drawer: DrawerWidget(), body: _switchTab(snapshot.data, appState), ), ); } } class DrawerWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Drawer( child: ListView( padding: EdgeInsets.zero, children: <Widget>[ DrawerHeader( child: Center( child: const Text( 'TRIVIA', style: TextStyle( fontSize: 36.0, fontWeight: FontWeight.w700, color: Colors.white, letterSpacing: 4.0, shadows: [ Shadow( blurRadius: 8.0, color: Colors.lightBlueAccent, offset: Offset(3.0, 4.5), ), ], ), ), ), decoration: BoxDecoration( color: Theme.of(context).primaryColor, ), ), ListTile( title: const Text('Settings'), onTap: () { Navigator.pop(context); Navigator.push( context, MaterialPageRoute(builder: (context) => SettingsPage()), ); }, ), const AboutListTile( child: Text('Made with Flutter'), ), ], ), ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/widgets/countdown_widget.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import '../models/models.dart'; class CountdownWidget extends StatefulWidget { const CountdownWidget( {@required this.width, Key key, this.duration, this.triviaState}) : assert(width != null), super(key: key); final double width; final int duration; // Milliseconds final TriviaState triviaState; @override CountdownWidgetState createState() { return CountdownWidgetState(); } } class CountdownWidgetState extends State<CountdownWidget> with SingleTickerProviderStateMixin { Animation<double> animation; AnimationController controller; Color color; final double countdownBarHeight = 24.0; @override void initState() { super.initState(); controller = AnimationController( duration: Duration(milliseconds: widget.duration), vsync: this); animation = Tween<double>(begin: widget.width, end: 0).animate(controller) ..addListener(() { setState(() { // Animate the countdown bar from green to red final value = (animation.value ~/ 2).toInt(); color = Color.fromRGBO(255 - value, value > 255 ? 255 : value, 0, 1); }); // Stop the animation if an anwser is chosen if (widget.triviaState.isAnswerChosen) { controller.stop(); } }); color = Colors.green; } @override void didUpdateWidget(CountdownWidget oldWidget) { super.didUpdateWidget(oldWidget); color = Colors.green; // If the user click on an anwser the countdown animation // will stop. if (widget.triviaState.isAnswerChosen) { controller.stop(); } // Otherwise, when a new question appears on the screen and // the widget rebuilds, then reset and play the countdown bar // animation. else { controller ..reset() ..forward(); } } @override void dispose() { controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Row( children: <Widget>[ Container( height: countdownBarHeight, width: animation.value, child: BlurWidget( sigmaX: 12.0, sigmaY: 13.0, child: Container( color: color, ), ), ), ], ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/widgets/question_widget.dart
import 'package:flutter/material.dart'; import '../blocs/trivia_bloc.dart'; import '../models/question.dart'; class QuestionWidget extends StatelessWidget { const QuestionWidget({this.bloc, this.question}); final Question question; final TriviaBloc bloc; @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(14.0), alignment: Alignment.center, height: 18 * 4.0, child: Text( '${bloc.triviaState.value.questionIndex} - ${question.question}', textAlign: TextAlign.center, style: const TextStyle( fontSize: 18.0, fontWeight: FontWeight.w500, color: Colors.white, shadows: [ Shadow( blurRadius: 2.0, color: Colors.lightBlueAccent, ), ], ), ), ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/widgets/answers_widget.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import '../styles.dart'; import '../blocs/trivia_bloc.dart'; import '../models/models.dart'; import '../models/question.dart'; const questionLeadings = ['A', 'B', 'C', 'D']; const boxHeight = 72.0; class AnswersWidget extends StatefulWidget { const AnswersWidget( {this.bloc, this.question, this.answerAnimation, this.isTriviaEnd}); final Question question; final TriviaBloc bloc; final AnswerAnimation answerAnimation; final bool isTriviaEnd; @override _AnswersWidgetState createState() => _AnswersWidgetState(); } class _AnswersWidgetState extends State<AnswersWidget> with TickerProviderStateMixin { bool isCorrect = false; final Map<int, Animation<double>> animations = {}; AnimationController controller; Animation<Color> colorAnimation; Color color; @override void initState() { super.initState(); controller = AnimationController( duration: Duration(milliseconds: 1250), vsync: this); } @override void didChangeDependencies() { super.didChangeDependencies(); _initAnimation(); } @override void dispose() { controller.dispose(); super.dispose(); } void _checkCorrectAnswer() { // Check if the answer chosen is correct or false isCorrect = widget.question.correctAnswerIndex == widget.answerAnimation.chosenAnswerIndex ? true : false; } Future _initAnimation() async { for (int i = 0; i < 4; i++) { animations[i] = Tween<double>(begin: boxHeight * i, end: boxHeight * i) .animate(controller); } colorAnimation = ColorTween( begin: answerBoxColor, end: answerBoxColor, ).animate(controller); } Future _startAnimation() async { _checkCorrectAnswer(); final index = widget.answerAnimation.chosenAnswerIndex; for (int i = 0; i < 4; i++) { // Set the animations for the answer but the one chosen if (i != index) { // From the answer original position to the chosen one animations[i] = Tween<double>(begin: boxHeight * i, end: boxHeight * index) .animate(controller) ..addListener(() { setState(() {}); if (controller.status == AnimationStatus.completed) { widget.bloc.onChosenAnwserAnimationEnd(); controller.reset(); } }); } } var newColor; if (isCorrect) { newColor = Colors.green; } else { newColor = Colors.red; } colorAnimation = ColorTween( begin: answerBoxColor, end: newColor, ).animate(controller); await controller.forward(); } @override void didUpdateWidget(AnswersWidget oldWidget) { super.didUpdateWidget(oldWidget); } Future _playAnimation(String answer) async { widget.bloc.onChosenAnswer(answer); await _startAnimation(); } @override Widget build(BuildContext context) { final widgets = widget.question.answers.map((answer) { final index = widget.question.answers.indexOf(answer); return Positioned( width: MediaQuery.of(context).size.width - 46.0, height: 54.0, // If the answer isn't the chosen one to the top parameter // is passed the value of the animation, while for the chosen // answer it is passed a fixed position. top: (index != widget.answerAnimation.chosenAnswerIndex ? animations[index].value : boxHeight * index), left: 0.0, child: GestureDetector( child: FadeInWidget( duration: 750, child: Container( decoration: BoxDecoration( color: (index == widget.answerAnimation.chosenAnswerIndex) ? colorAnimation.value : const Color(0xff283593), borderRadius: const BorderRadius.only( topLeft: Radius.circular(35), topRight: Radius.circular(15), bottomLeft: Radius.circular(35), bottomRight: Radius.circular(15), ), boxShadow: [ BoxShadow( color: (colorAnimation.status == AnimationStatus.forward) ? colorAnimation.value : Colors.blue[500], blurRadius: (colorAnimation.status == AnimationStatus.forward) ? 19.0 : 3.0, spreadRadius: (colorAnimation.status == AnimationStatus.forward) ? 2.5 : 1.5), ]), child: ListTile( leading: CircleAvatar( radius: questionCircleAvatarRadius, backgroundColor: questionCircleAvatarBackground, child: Text( questionLeadings[index], style: answersLeadingStyle, )), title: Text(answer, style: answersStyle), ), ), ), onTap: () { if (!widget.isTriviaEnd) { _playAnimation(answer); } }), ); }).toList(); // Swap the last item with the chosen anwser so that it can // be shown as the last on the stack. final last = widgets.last; final chosen = widgets[widget.answerAnimation.chosenAnswerIndex]; final chosenIndex = widgets.indexOf(chosen); widgets.last = chosen; widgets[chosenIndex] = last; return Container( child: Stack( children: widgets, ), ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/widgets/summaryanswer_widget.dart
import 'package:flutter/material.dart'; import '../styles.dart'; import '../models/question.dart'; class SummaryAnswers extends StatelessWidget { const SummaryAnswers({Key key, this.index, this.question}) : super(key: key); final int index; final Question question; List<Widget> _buildAnswers(Question question) { final widgets = List<Widget>() ..addAll( question.answers.map((answer) { return Text( answer, style: question.isCorrect(answer) ? correctAnswerStyle : question.isChosen(answer) ? wrongAnswerStyle : notChosenStyle, ); }), ); return widgets; } @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric(vertical: 18), child: Column( children: <Widget>[ Row( children: <Widget>[ Padding( padding: const EdgeInsets.only(left: 8.0, right: 4.0), child: CircleAvatar( backgroundColor: circleAvatarBackground, radius: circleAvatarRadius, child: Text( '$index', style: questionStyle, ), ), ), Expanded( flex: 4, child: Padding( padding: const EdgeInsets.all(8.0), child: Text('${question.question}', style: questionStyle, textAlign: TextAlign.center), )), ], ), Column(children: _buildAnswers(question)), ], ), ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/blocs/trivia_bloc.dart
import 'dart:async'; import 'package:frideos_core/frideos_core.dart'; import '../models/models.dart'; import '../models/question.dart'; import '../models/trivia_stats.dart'; const refreshTime = 100; class TriviaBloc { TriviaBloc({this.countdownStream, this.questions, this.tabController}) { // Getting the questions from the API questions.onChange((data) { if (data.isNotEmpty) { final questions = data..shuffle(); _startTrivia(questions); } }); countdownStream.outTransformed.listen((data) { countdown = int.parse(data) * 1000; }); } // STREAMS final StreamedValue<AppTab> tabController; final triviaState = StreamedValue<TriviaState>(initialData: TriviaState()); final StreamedList<Question> questions; final currentQuestion = StreamedValue<Question>(); final currentTime = StreamedValue<int>(initialData: 0); final countdownBar = StreamedValue<double>(); final answersAnimation = StreamedValue<AnswerAnimation>( initialData: AnswerAnimation(chosenAnswerIndex: 0, startPlaying: false)); // QUESTIONS, ANSWERS, STATS int index = 0; String chosenAnswer; final stats = TriviaStats(); // TIMER, COUNTDOWN final StreamedTransformed<String, String> countdownStream; int countdown; // Milliseconds Timer timer; void _startTrivia(List<Question> data) { index = 0; triviaState.value.questionIndex = 1; // To show the main page and summary buttons triviaState.value.isTriviaEnd = false; // Reset the stats stats.reset(); // To set the initial question (in this case the countdown // bar animation won't start). currentQuestion.value = data.first; Timer(Duration(milliseconds: 1000), () { // Setting this flag to true on changing the question // the countdown bar animation starts. triviaState.value.isTriviaPlaying = true; // Stream the first question again with the countdown bar // animation. currentQuestion.value = data[index]; playTrivia(); }); } void playTrivia() { timer = Timer.periodic(Duration(milliseconds: refreshTime), (Timer t) { currentTime.value = refreshTime * t.tick; if (currentTime.value > countdown) { currentTime.value = 0; timer.cancel(); notAnswered(currentQuestion.value); _nextQuestion(); } }); } void _endTrivia() { // RESET timer.cancel(); currentTime.value = 0; triviaState.value.isTriviaEnd = true; triviaState.refresh(); stopTimer(); Timer(Duration(milliseconds: 1500), () { // this is reset here to not trigger the start of the // countdown animation while waiting for the summary page. triviaState.value.isAnswerChosen = false; // Show the summary page after 1.5s tabController.value = AppTab.summary; // Clear the last question so that it doesn't appear // in the next game currentQuestion.value = null; }); } void notAnswered(Question question) { stats.addNoAnswer(question); } void checkAnswer(Question question, String answer) { if (!triviaState.value.isTriviaEnd) { question.chosenAnswerIndex = question.answers.indexOf(answer); if (question.isCorrect(answer)) { stats.addCorrect(question); } else { stats.addWrong(question); } timer.cancel(); currentTime.value = 0; _nextQuestion(); } } void _nextQuestion() { index++; if (index < questions.length) { triviaState.value.questionIndex++; currentQuestion.value = questions.value[index]; playTrivia(); } else { _endTrivia(); } } void stopTimer() { // Stop the timer timer.cancel(); // By setting this flag to true the countdown animation will stop triviaState.value.isAnswerChosen = true; triviaState.refresh(); } void onChosenAnswer(String answer) { chosenAnswer = answer; stopTimer(); // Set the chosenAnswer so that the answer widget can put it last on the // stack. answersAnimation.value.chosenAnswerIndex = currentQuestion.value.answers.indexOf(answer); answersAnimation.refresh(); } void onChosenAnwserAnimationEnd() { // Reset the flag so that the countdown animation can start triviaState.value.isAnswerChosen = false; triviaState.refresh(); checkAnswer(currentQuestion.value, chosenAnswer); } void dispose() { answersAnimation.dispose(); countdownBar.dispose(); countdownStream.dispose(); currentQuestion.dispose(); currentTime.dispose(); questions.dispose(); tabController.dispose(); triviaState.dispose(); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/models/question.dart
enum QuestionDifficulty { easy, medium, hard } enum QuestionType { boolean, multiple } class QuestionModel { QuestionModel({this.question, this.correctAnswer, this.incorrectAnswers}); factory QuestionModel.fromJson(Map<String, dynamic> json) { return QuestionModel( question: json['question'], correctAnswer: json['correct_answer'], incorrectAnswers: (json['incorrect_answers'] as List) .map((answer) => answer.toString()) .toList()); } String question; String correctAnswer; List<String> incorrectAnswers; } class Question { Question({this.question, this.answers, this.correctAnswerIndex}); factory Question.fromQuestionModel(QuestionModel model) { final List<String> answers = [] ..add(model.correctAnswer) ..addAll(model.incorrectAnswers) ..shuffle(); final index = answers.indexOf(model.correctAnswer); return Question( question: model.question, answers: answers, correctAnswerIndex: index); } String question; List<String> answers; int correctAnswerIndex; int chosenAnswerIndex; bool isCorrect(String answer) { return answers.indexOf(answer) == correctAnswerIndex; } bool isChosen(String answer) { return answers.indexOf(answer) == chosenAnswerIndex; } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/models/appstate.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:frideos_core/frideos_core.dart'; import 'package:frideos/frideos.dart'; import '../API/api_interface.dart'; import '../API/mock_api.dart'; import '../API/trivia_api.dart'; import '../blocs/trivia_bloc.dart'; import '../models/category.dart'; import '../models/models.dart'; import '../models/question.dart'; import '../models/theme.dart'; class AppState extends AppStateModel { factory AppState() => _singletonAppState; AppState._internal() { print('-------APP STATE INIT--------'); _createThemes(themes); _loadCategories(); countdown.value = 10.toString(); countdown.setTransformer(validateCountdown); questionsAmount.value = 5.toString(); questionsAmount.setTransformer(validateAmount); triviaBloc = TriviaBloc( countdownStream: countdown, questions: questions, tabController: tabController); } static final AppState _singletonAppState = AppState._internal(); // THEMES final themes = List<MyTheme>(); final currentTheme = StreamedValue<MyTheme>(); // API QuestionsAPI api = MockAPI(); final apiType = StreamedValue<ApiType>(initialData: ApiType.mock); // TABS final tabController = StreamedValue<AppTab>(initialData: AppTab.main); // TRIVIA final categoriesStream = StreamedList<Category>(); final categoryChosen = StreamedValue<Category>(); final questions = StreamedList<Question>(); final questionsDifficulty = StreamedValue<QuestionDifficulty>(initialData: QuestionDifficulty.medium); final questionsAmount = StreamedTransformed<String, String>(); final validateAmount = StreamTransformer<String, String>.fromHandlers(handleData: (str, sink) { if (str.isNotEmpty) { final amount = int.tryParse(str); if (amount > 1 && amount <= 15) { sink.add(str); } else { sink.addError('Insert a value from 2 to 15..'); } } else { sink.addError('Insert a value.'); } }); // BLOC TriviaBloc triviaBloc; // COUNTDOWN final countdown = StreamedTransformed<String, String>(); final validateCountdown = StreamTransformer<String, String>.fromHandlers(handleData: (str, sink) { if (str.isNotEmpty) { final time = int.tryParse(str); if (time >= 3 && time <= 90) { sink.add(str); } else { sink.addError('Insert a value from 3 to 90 seconds.'); } } else { sink.addError('Insert a value.'); } }); @override Future<void> init() async { final String lastTheme = await Prefs.getPref('apptheme'); if (lastTheme != null) { currentTheme.value = themes.firstWhere((theme) => theme.name == lastTheme, orElse: () => themes[0]); } else { currentTheme.value = themes[0]; } } Future _loadCategories() async { final isLoaded = await api.getCategories(categoriesStream); if (isLoaded) { categoryChosen.value = categoriesStream.value.last; } } Future _loadQuestions() async { await api.getQuestions( questions: questions, number: int.parse(questionsAmount.value), category: categoryChosen.value, difficulty: questionsDifficulty.value, type: QuestionType.multiple); } void setCategory(Category category) => categoryChosen.value = category; void setDifficulty(QuestionDifficulty difficulty) => questionsDifficulty.value = difficulty; void setApiType(ApiType type) { if (apiType.value != type) { apiType.value = type; if (type == ApiType.mock) { api = MockAPI(); } else { api = TriviaAPI(); } _loadCategories(); } } void _createThemes(List<MyTheme> themes) { themes.addAll([ MyTheme( name: 'Default', brightness: Brightness.dark, backgroundColor: const Color(0xff111740), scaffoldBackgroundColor: const Color(0xff111740), primaryColor: const Color(0xff283593), primaryColorBrightness: Brightness.dark, accentColor: Colors.blue[300], ), MyTheme( name: 'Dark', brightness: Brightness.dark, backgroundColor: Colors.black, scaffoldBackgroundColor: Colors.black, primaryColor: Colors.blueGrey[900], primaryColorBrightness: Brightness.dark, accentColor: Colors.blue[900], ), ]); } void setTheme(MyTheme theme) { currentTheme.value = theme; Prefs.savePref<String>('apptheme', theme.name); } set _changeTab(AppTab appTab) => tabController.value = appTab; void startTrivia() { _loadQuestions(); _changeTab = AppTab.trivia; } void endTrivia() => tabController.value = AppTab.main; void showSummary() => tabController.value = AppTab.summary; @override void dispose() { print('---------APP STATE DISPOSE-----------'); apiType.dispose(); categoryChosen.dispose(); countdown.dispose(); currentTheme.dispose(); questions.dispose(); questionsAmount.dispose(); questionsDifficulty.dispose(); tabController.dispose(); triviaBloc.dispose(); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/models/category.dart
class Category { Category({this.id, this.name}); factory Category.fromJson(Map<String, dynamic> json) { return Category(id: json['id'], name: json['name']); } int id; String name; }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/models/theme.dart
import 'package:flutter/material.dart'; class MyTheme { MyTheme( {this.name, this.brightness, this.backgroundColor, this.scaffoldBackgroundColor, this.primaryColor, this.primaryColorBrightness, this.accentColor}); String name; Brightness brightness; Color backgroundColor; Color scaffoldBackgroundColor; Color primaryColor; Brightness primaryColorBrightness; Color accentColor; }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/models/models.dart
enum AppTab { main, trivia, summary, stats } enum ApiType { mock, remote } class TriviaState { bool isTriviaPlaying = false; bool isTriviaEnd = false; bool isAnswerChosen = false; int questionIndex = 1; } class AnswerAnimation { AnswerAnimation({this.chosenAnswerIndex, this.startPlaying}); int chosenAnswerIndex; bool startPlaying = false; }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/models/trivia_stats.dart
import 'question.dart'; class TriviaStats { TriviaStats() { corrects = []; wrongs = []; noAnswered = []; score = 0; } List<Question> corrects; List<Question> wrongs; List<Question> noAnswered; int score; void addCorrect(Question question) { corrects.add(question); score += 10; } void addWrong(Question question) { wrongs.add(question); score -= 4; } void addNoAnswer(Question question) { noAnswered.add(question); score -= 2; } void reset() { corrects = []; wrongs = []; noAnswered = []; score = 0; } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/API/trivia_api.dart
import 'dart:async'; import 'dart:convert' as convert; import 'package:http/http.dart' as http; import 'package:frideos_core/frideos_core.dart'; import '../models/category.dart'; import '../models/question.dart'; import 'api_interface.dart'; class TriviaAPI implements QuestionsAPI { @override Future<bool> getCategories(StreamedList<Category> categories) async { const categoriesURL = 'https://opentdb.com/api_category.php'; final response = await http.get(categoriesURL); if (response.statusCode == 200) { final jsonResponse = convert.jsonDecode(response.body); final result = (jsonResponse['trivia_categories'] as List) .map((category) => Category.fromJson(category)); categories.value = []; categories ..addAll(result) ..addElement(Category(id: 0, name: 'Any category')); return true; } else { print('Request failed with status: ${response.statusCode}.'); return false; } } @override Future<bool> getQuestions( {StreamedList<Question> questions, int number, Category category, QuestionDifficulty difficulty, QuestionType type}) async { var qdifficulty; var qtype; switch (difficulty) { case QuestionDifficulty.easy: qdifficulty = 'easy'; break; case QuestionDifficulty.medium: qdifficulty = 'medium'; break; case QuestionDifficulty.hard: qdifficulty = 'hard'; break; default: qdifficulty = 'medium'; break; } switch (type) { case QuestionType.boolean: qtype = 'boolean'; break; case QuestionType.multiple: qtype = 'multiple'; break; default: qtype = 'multiple'; break; } final url = 'https://opentdb.com/api.php?amount=$number&difficulty=$qdifficulty&type=$qtype&category=${category.id}'; final response = await http.get(url); if (response.statusCode == 200) { final jsonResponse = convert.jsonDecode(response.body); final result = (jsonResponse['results'] as List) .map((question) => QuestionModel.fromJson(question)); questions.value = result .map((question) => Question.fromQuestionModel(question)) .toList(); return true; } else { print('Request failed with status: ${response.statusCode}.'); return false; } } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/API/api_interface.dart
import 'package:frideos_core/frideos_core.dart'; import '../models/category.dart'; import '../models/question.dart'; abstract class QuestionsAPI { Future<bool> getCategories(StreamedList<Category> categories); Future<bool> getQuestions( {StreamedList<Question> questions, int number, Category category, QuestionDifficulty difficulty, QuestionType type}); }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/API/mock_api.dart
import 'dart:async'; import 'dart:convert' as convert; import 'package:frideos_core/frideos_core.dart'; import '../models/category.dart'; import '../models/question.dart'; import 'api_interface.dart'; class MockAPI implements QuestionsAPI { @override Future<bool> getCategories(StreamedList<Category> categories) async { categories.value = []; categories.addElement( Category(id: 1, name: 'Category demo'), ); return true; } @override Future<bool> getQuestions( {StreamedList<Question> questions, int number, Category category, QuestionDifficulty difficulty, QuestionType type}) async { const json = "{\"response_code\":0,\"results\":[{\"category\":\"General Knowledge\",\"type\":\"multiple\",\"difficulty\":\"easy\",\"question\":\"What is the largest organ of the human body?\",\"correct_answer\":\"Skin\",\"incorrect_answers\":[\"Heart\",\"large Intestine\",\"Liver\"]},{\"category\":\"Science: Mathematics\",\"type\":\"multiple\",\"difficulty\":\"easy\",\"question\":\"In Roman Numerals, what does XL equate to?\",\"correct_answer\":\"40\",\"incorrect_answers\":[\"60\",\"15\",\"90\"]},{\"category\":\"Entertainment: Television\",\"type\":\"multiple\",\"difficulty\":\"easy\",\"question\":\"Grant Gustin plays which superhero on the CW show of the same name?\",\"correct_answer\":\"The Flash\",\"incorrect_answers\":[\"The Arrow\",\"Black Canary\",\"Daredevil\"]},{\"category\":\"Entertainment: Cartoon & Animations\",\"type\":\"multiple\",\"difficulty\":\"easy\",\"question\":\"In the 1993 Disney animated series, what is the name of Bonker\'s second partner?\",\"correct_answer\":\"Miranda Wright\",\"incorrect_answers\":[\"Dick Tracy\",\"Eddie Valiant\",\"Dr. Ludwig von Drake\"]},{\"category\":\"Geography\",\"type\":\"multiple\",\"difficulty\":\"easy\",\"question\":\"How many countries does Mexico border?\",\"correct_answer\":\"3\",\"incorrect_answers\":[\"2\",\"4\",\"1\"]}]}"; final jsonResponse = convert.jsonDecode(json); final result = (jsonResponse['results'] as List) .map((question) => QuestionModel.fromJson(question)); questions.value = result.map((question) => Question.fromQuestionModel(question)).toList(); return true; } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/screens/summary_page.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import '../models/appstate.dart'; import '../models/models.dart'; import '../models/trivia_stats.dart'; import '../widgets/summaryanswer_widget.dart'; import '../styles.dart'; class SummaryPage extends StatelessWidget { const SummaryPage({this.stats}); final TriviaStats stats; List<Widget> _buildQuestions() { var index = 0; final widgets = List<Widget>() ..add( Container( alignment: Alignment.center, padding: const EdgeInsets.all(24), child: Text( 'Final score: ${stats.score}', style: summaryScoreStyle, ), ), ); if (stats.corrects.isNotEmpty) { widgets ..add( Container( padding: const EdgeInsets.all(8.0), height: 32, color: Colors.indigo[700], child: Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Text( 'CORRECTS: ${stats.corrects.length}', style: correctsHeaderStyle, ), ], ), ), ) ..addAll( stats.corrects.map((question) { index++; return SummaryAnswers( index: index, question: question, ); }), ); } if (stats.wrongs.isNotEmpty) { widgets ..add( Container( padding: const EdgeInsets.all(8.0), height: 32, color: Colors.indigo[700], child: Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Text( 'WRONGS: ${stats.wrongs.length}', style: wrongsHeaderStyle, ), ], ), ), ) ..addAll( stats.wrongs.map((question) { index++; return SummaryAnswers( index: index, question: question, ); }), ); } if (stats.noAnswered.isNotEmpty) { widgets ..add( Container( padding: const EdgeInsets.all(8.0), height: 32, color: Colors.indigo[700], child: Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Text( 'NOT GIVEN: ${stats.noAnswered.length}', style: notAnsweredHeaderStyle, ), ], ), ), ) ..addAll( stats.noAnswered.map((question) { index++; return SummaryAnswers( index: index, question: question, ); }), ); } return widgets; } @override Widget build(BuildContext context) { final appState = AppStateProvider.of<AppState>(context); final List<Widget> widgets = _buildQuestions() ..add(Container( height: 24, )) ..add(Container( width: 90, child: RaisedButton( child: const Text('Home'), onPressed: () => appState.tabController.value = AppTab.main, ), )); return FadeInWidget( duration: 750, child: Container( child: ListView( shrinkWrap: true, children: widgets, ), ), ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/screens/trivia_page.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import '../styles.dart'; import '../models/appstate.dart'; import '../models/models.dart'; import '../models/question.dart'; import '../widgets/answers_widget.dart'; import '../widgets/countdown_widget.dart'; import '../widgets/question_widget.dart'; class TriviaPage extends StatelessWidget { @override Widget build(BuildContext context) { final bloc = AppStateProvider.of<AppState>(context).triviaBloc; return ValueBuilder<TriviaState>( streamed: bloc.triviaState, builder: (context, snapshotTrivia) { return ValueBuilder<Question>( streamed: bloc.currentQuestion, builder: (context, snapshotQuestion) { return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, padding: const EdgeInsets.only(top: 22), child: TriviaMain( triviaState: snapshotTrivia.data, question: snapshotQuestion.data), ); }); }); } } class TriviaMain extends StatelessWidget { const TriviaMain({this.triviaState, this.question}); final TriviaState triviaState; final Question question; @override Widget build(BuildContext context) { final bloc = AppStateProvider.of<AppState>(context).triviaBloc; return Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Container( padding: const EdgeInsets.symmetric(horizontal: 22), decoration: BoxDecoration( color: const Color(0xff283593), borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(25), bottomRight: Radius.circular(25)), boxShadow: [ BoxShadow(color: Colors.blue, blurRadius: 3.0, spreadRadius: 1.5), ], ), child: Column( children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.all(16), child: Text( 'SCORE: ${bloc.stats.score}', style: scoreHeaderStyle, ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( 'Corrects: ${bloc.stats.corrects.length}', style: questionsHeaderStyle, ), Text( 'Wrongs: ${bloc.stats.wrongs.length}', style: questionsHeaderStyle, ), Text( 'Not answered: ${bloc.stats.noAnswered.length}', style: questionsHeaderStyle, ), ], ), const SizedBox( height: 12, ) ], ), ), Container( height: 12, ), Container( padding: const EdgeInsets.all(8), child: QuestionWidget( bloc: bloc, question: question, ), ), Container( height: 32, ), Expanded( child: ValueBuilder<AnswerAnimation>( streamed: bloc.answersAnimation, builder: (context, snapshot) { return Container( padding: const EdgeInsets.symmetric(horizontal: 22), child: AnswersWidget( bloc: bloc, question: question, answerAnimation: snapshot.data, isTriviaEnd: triviaState.isTriviaEnd, )); }), ), ValueBuilder<int>( streamed: bloc.currentTime, builder: (context, snapshot) { return Column( children: <Widget>[ Container( height: 24, padding: const EdgeInsets.all(22), child: Text( 'Time left: ${((bloc.countdown - snapshot.data) / 1000)}', style: const TextStyle( color: Colors.white, fontSize: 12, fontStyle: FontStyle.italic), ), ), ], ); }), Container( height: 18, ), CountdownWidget( width: MediaQuery.of(context).size.width, duration: bloc.countdown, triviaState: triviaState, ), ], ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/screens/main_page.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import '../models/appstate.dart'; import '../models/category.dart'; class MainPage extends StatelessWidget { @override Widget build(BuildContext context) { final appState = AppStateProvider.of<AppState>(context); return FadeInWidget( duration: 750, child: Container( padding: const EdgeInsets.symmetric(horizontal: 36.0), child: ValueBuilder<List<Category>>( streamed: appState.categoriesStream, noDataChild: const CircularProgressIndicator(), builder: (context, snapshot) { final categories = snapshot.data; return Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Container( padding: const EdgeInsets.symmetric( horizontal: 28.0, vertical: 56.0), child: const Text( 'TRIVIA', style: TextStyle( fontSize: 46.0, fontWeight: FontWeight.w700, color: Colors.white, letterSpacing: 4.0, shadows: [ Shadow( blurRadius: 8.0, color: Colors.lightBlueAccent, offset: Offset(3.0, 4.5), ), ], ), ), ), const Text( 'Choose a category:', style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.w600, color: Colors.white, shadows: [ Shadow( blurRadius: 14.0, color: Colors.lightBlueAccent, ), ], ), ), ValueBuilder<Category>( streamed: appState.categoryChosen, builder: (context, snapshotCategory) => DropdownButton<Category>( isExpanded: true, value: snapshotCategory.data, onChanged: appState.setCategory, items: categories .map<DropdownMenuItem<Category>>( (value) => DropdownMenuItem<Category>( value: value, child: Text( value.name, style: const TextStyle( fontSize: 16.0, fontWeight: FontWeight.w600, color: Colors.orange, ), ), ), ) .toList(), ), ), ], ), GestureDetector( child: Container( alignment: Alignment.center, height: 36, width: 90, decoration: BoxDecoration( color: Theme.of(context).primaryColor, borderRadius: const BorderRadius.all( Radius.circular(35), ), boxShadow: [ BoxShadow( color: Colors.blue, blurRadius: 2.0, spreadRadius: 2.5), ]), child: const Text( 'Play trivia', style: TextStyle(fontWeight: FontWeight.w500), ), ), onTap: appState.startTrivia, ), ], ); }, ), ), ); } }
0
mirrored_repositories/trivia_example/lib/src
mirrored_repositories/trivia_example/lib/src/screens/settings_page.dart
import 'package:flutter/material.dart'; import 'package:frideos/frideos.dart'; import '../models/appstate.dart'; import '../models/models.dart'; import '../models/question.dart'; import '../models/theme.dart'; class SettingsPage extends StatefulWidget { @override _SettingsPageState createState() => _SettingsPageState(); } class _SettingsPageState extends State<SettingsPage> { final countdownController = TextEditingController(); final amountController = TextEditingController(); @override Widget build(BuildContext context) { final appState = AppStateProvider.of<AppState>(context); countdownController.text = (appState.triviaBloc.countdown / 1000).toStringAsFixed(0); amountController.text = (appState.questionsAmount.value); List<Widget> _buildThemesList() { return appState.themes.map((MyTheme appTheme) { return DropdownMenuItem<MyTheme>( value: appTheme, child: Text(appTheme.name, style: const TextStyle(fontSize: 14.0)), ); }).toList(); } return Scaffold( resizeToAvoidBottomPadding: true, appBar: AppBar( centerTitle: true, title: const Text( 'Settings', ), ), body: Container( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ const Padding( padding: EdgeInsets.all(8.0), child: Text( 'Choose a theme:', style: TextStyle(fontWeight: FontWeight.w500), ), ), ValueBuilder<MyTheme>( streamed: appState.currentTheme, builder: (context, snapshot) { return DropdownButton<MyTheme>( hint: const Text('Status'), value: snapshot.data, items: _buildThemesList(), onChanged: appState.setTheme, ); }), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ const Padding( padding: EdgeInsets.all(8.0), child: Text( 'Quiz database:', style: TextStyle(fontWeight: FontWeight.w500), ), ), ValueBuilder<ApiType>( streamed: appState.apiType, builder: (context, snapshot) { return DropdownButton<ApiType>( value: snapshot.data, onChanged: appState.setApiType, items: [ const DropdownMenuItem<ApiType>( value: ApiType.mock, child: Text('Demo'), ), const DropdownMenuItem<ApiType>( value: ApiType.remote, child: Text('opentdb.com'), ), ]); }), ], ), ValueBuilder<ApiType>( streamed: appState.apiType, builder: (context, snapshot) { return snapshot.data == ApiType.mock ? Container() : Column( children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ const Padding( padding: EdgeInsets.all(8.0), child: Text( 'N. of questions:', style: TextStyle(fontWeight: FontWeight.w500), ), ), Container( child: StreamBuilder<String>( stream: appState .questionsAmount.outTransformed, builder: (context, snapshot) { return Expanded( child: TextField( controller: amountController, onChanged: appState .questionsAmount.inStream, decoration: InputDecoration( border: InputBorder.none, hintText: 'Enter a value between 2 and 15.', errorText: snapshot.error, ), keyboardType: TextInputType.number, ), ); }), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ const Padding( padding: EdgeInsets.all(8.0), child: Text( 'Difficulty:', style: TextStyle(fontWeight: FontWeight.w500), ), ), ValueBuilder<QuestionDifficulty>( streamed: appState.questionsDifficulty, builder: (context, snapshot) { return DropdownButton<QuestionDifficulty>( value: snapshot.data, onChanged: appState.setDifficulty, items: [ const DropdownMenuItem< QuestionDifficulty>( value: QuestionDifficulty.easy, child: Text('Easy'), ), const DropdownMenuItem< QuestionDifficulty>( value: QuestionDifficulty.medium, child: Text('Medium'), ), const DropdownMenuItem< QuestionDifficulty>( value: QuestionDifficulty.hard, child: Text('Hard'), ), ]); }), ], ), ], ); }), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ const Padding( padding: EdgeInsets.all(8.0), child: Text( 'Countdown:', style: TextStyle(fontWeight: FontWeight.w500), ), ), Container( child: StreamBuilder<String>( stream: appState.countdown.outTransformed, builder: (context, snapshot) { return Expanded( child: TextField( controller: countdownController, onChanged: appState.countdown.inStream, decoration: InputDecoration( border: InputBorder.none, hintText: 'Enter a value in seconds (max 60).', errorText: snapshot.error, ), keyboardType: TextInputType.number, ), ); }), ), ], ), ], ), ), ); } }
0
mirrored_repositories/trivia_example
mirrored_repositories/trivia_example/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:trivia_ex/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter-bloc-introduction
mirrored_repositories/flutter-bloc-introduction/lib/main.dart
import 'package:flutter/material.dart'; import 'pages/home_single_page.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const HomeSinglePage(), ); } }
0
mirrored_repositories/flutter-bloc-introduction/lib
mirrored_repositories/flutter-bloc-introduction/lib/pages/home_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc_introduction/pages/state_subclass/home_controller.dart'; import 'package:flutter_bloc_introduction/pages/state_subclass/home_state.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { final homeController = HomeController(); final formkey = GlobalKey<FormState>(); final cepEC = TextEditingController(); @override void dispose() { cepEC.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return BlocListener<HomeController, HomeState>( bloc: homeController, listener: (context, state) { if (state is HomeFailure) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text("Erro ao buscar Endereço")), ); } }, child: Scaffold( appBar: AppBar( title: const Text("Buscar CEP"), ), body: SingleChildScrollView( child: Form( key: formkey, child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ TextFormField( controller: cepEC, validator: (value) { if (value == null || value.isEmpty) { return "CEP Obrigatório"; } return null; }, ), ElevatedButton( onPressed: () async { final valid = formkey.currentState?.validate() ?? false; if (valid) { homeController.findCep(cepEC.text); } }, child: const Text("Buscar"), ), BlocBuilder<HomeController, HomeState>( bloc: homeController, builder: (context, state) { return Visibility( visible: state is HomeLoading, child: const CircularProgressIndicator(), ); }, ), BlocBuilder<HomeController, HomeState>( bloc: homeController, builder: (context, state) { if (state is HomeLoaded) { return Text( "Logradouro:${state.enderecoModel.logradouro} \nComplemento: ${state.enderecoModel.complemento} \nCEP:${state.enderecoModel.cep}", ); } return const SizedBox.shrink(); }, ) ], ), )), ), ), ); } }
0
mirrored_repositories/flutter-bloc-introduction/lib
mirrored_repositories/flutter-bloc-introduction/lib/pages/home_single_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc_introduction/pages/state_single_class/home_single_class_controller.dart'; import 'package:flutter_bloc_introduction/pages/state_single_class/home_state.dart'; class HomeSinglePage extends StatefulWidget { const HomeSinglePage({super.key}); @override State<HomeSinglePage> createState() => _HomeSinglePageState(); } class _HomeSinglePageState extends State<HomeSinglePage> { final homeController = HomeSingleClassController(); final formkey = GlobalKey<FormState>(); final cepEC = TextEditingController(); @override void dispose() { cepEC.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return BlocListener<HomeSingleClassController, HomeState>( bloc: homeController, listener: (context, state) { if (state.status == HomeStatus.failure) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text("Erro ao buscar Endereço")), ); } }, child: Scaffold( appBar: AppBar( title: const Text("Buscar CEP"), ), body: SingleChildScrollView( child: Form( key: formkey, child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ TextFormField( controller: cepEC, validator: (value) { if (value == null || value.isEmpty) { return "CEP Obrigatório"; } return null; }, ), ElevatedButton( onPressed: () async { final valid = formkey.currentState?.validate() ?? false; if (valid) { homeController.findCep(cepEC.text); } }, child: const Text("Buscar"), ), BlocBuilder<HomeSingleClassController, HomeState>( bloc: homeController, builder: (context, state) { return Visibility( visible: state.status == HomeStatus.loading, child: const CircularProgressIndicator(), ); }, ), BlocBuilder<HomeSingleClassController, HomeState>( bloc: homeController, builder: (context, state) { if (state.status == HomeStatus.loaded) { return Text( "Logradouro:${state.enderecoModel?.logradouro} \nComplemento: ${state.enderecoModel?.complemento} \nCEP:${state.enderecoModel?.cep}", ); } return const SizedBox.shrink(); }, ) ], ), )), ), ), ); } }
0
mirrored_repositories/flutter-bloc-introduction/lib/pages
mirrored_repositories/flutter-bloc-introduction/lib/pages/state_subclass/home_state.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:flutter_bloc_introduction/models/endereco_model.dart'; abstract class HomeState {} class HomeInitial extends HomeState {} class HomeLoading extends HomeState {} class HomeFailure extends HomeState {} class HomeLoaded extends HomeState { final EnderecoModel enderecoModel; HomeLoaded({ required this.enderecoModel, }); }
0
mirrored_repositories/flutter-bloc-introduction/lib/pages
mirrored_repositories/flutter-bloc-introduction/lib/pages/state_subclass/home_controller.dart
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc_introduction/pages/state_subclass/home_state.dart'; import 'package:flutter_bloc_introduction/repositories/cep_repository.dart'; import 'package:flutter_bloc_introduction/repositories/cep_repository_impl.dart'; class HomeController extends Cubit<HomeState> { final CepRepository cepRepository = CepRepositoryImpl(); HomeController() : super(HomeInitial()); Future<void> findCep(String cep) async { try { emit(HomeLoading()); final enderecoModel = await cepRepository.getCep(cep); emit(HomeLoaded(enderecoModel: enderecoModel)); } catch (e) { emit(HomeFailure()); } } }
0
mirrored_repositories/flutter-bloc-introduction/lib/pages
mirrored_repositories/flutter-bloc-introduction/lib/pages/state_single_class/home_state.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:flutter_bloc_introduction/models/endereco_model.dart'; enum HomeStatus { initial, loading, loaded, failure, } class HomeState { final EnderecoModel? enderecoModel; final HomeStatus status; HomeState({ this.status = HomeStatus.initial, this.enderecoModel, }); HomeState copyWith({ EnderecoModel? enderecoModel, HomeStatus? status, }) { return HomeState( enderecoModel: enderecoModel ?? this.enderecoModel, status: status ?? this.status, ); } }
0
mirrored_repositories/flutter-bloc-introduction/lib/pages
mirrored_repositories/flutter-bloc-introduction/lib/pages/state_single_class/home_single_class_controller.dart
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc_introduction/pages/state_single_class/home_state.dart'; import 'package:flutter_bloc_introduction/repositories/cep_repository.dart'; import 'package:flutter_bloc_introduction/repositories/cep_repository_impl.dart'; class HomeSingleClassController extends Cubit<HomeState> { final CepRepository cepRepository = CepRepositoryImpl(); HomeSingleClassController() : super(HomeState()); Future<void> findCep(String cep) async { try { emit(state.copyWith(status: HomeStatus.loading)); final enderecoModel = await cepRepository.getCep(cep); emit(state.copyWith( enderecoModel: enderecoModel, status: HomeStatus.loaded)); } catch (e) { emit(state.copyWith(status: HomeStatus.failure)); } } }
0
mirrored_repositories/flutter-bloc-introduction/lib
mirrored_repositories/flutter-bloc-introduction/lib/models/endereco_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; class EnderecoModel { final String cep; final String logradouro; final String complemento; EnderecoModel({ required this.cep, required this.logradouro, required this.complemento, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'cep': cep, 'logradouro': logradouro, 'complemento': complemento, }; } factory EnderecoModel.fromMap(Map<String, dynamic> map) { return EnderecoModel( cep: map['cep'], logradouro: map['logradouro'], complemento: map['complemento'], ); } String toJson() => json.encode(toMap()); factory EnderecoModel.fromJson(String json) => EnderecoModel.fromMap(jsonDecode(json)); }
0
mirrored_repositories/flutter-bloc-introduction/lib
mirrored_repositories/flutter-bloc-introduction/lib/repositories/cep_repository_impl.dart
import 'dart:developer'; import 'package:dio/dio.dart'; import './cep_repository.dart'; import '../models/endereco_model.dart'; class CepRepositoryImpl implements CepRepository { @override Future<EnderecoModel> getCep(String cep) async { try { final result = await Dio().get('https://viacep.com.br/ws/$cep/json/'); return EnderecoModel.fromMap(result.data); } on DioError catch (e) { log('Erro ao buscar CEP', error: e); throw Exception('Erro ao buscar CEP'); } } }
0
mirrored_repositories/flutter-bloc-introduction/lib
mirrored_repositories/flutter-bloc-introduction/lib/repositories/cep_repository.dart
import '../models/endereco_model.dart'; abstract class CepRepository { Future<EnderecoModel> getCep(String cep); }
0
mirrored_repositories/flutter-bloc-introduction
mirrored_repositories/flutter-bloc-introduction/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:flutter_bloc_introduction/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/Walkthrough-Flutter
mirrored_repositories/Walkthrough-Flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:walkthrough_flutter/Screen/Home.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: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( body: HomePage(), ); } }
0
mirrored_repositories/Walkthrough-Flutter/lib
mirrored_repositories/Walkthrough-Flutter/lib/Screen/Home.dart
import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:walkthrough_flutter/Model/Slider.dart'; Future<void> main() async { runApp(HomePage()); } class HomePage extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( home: MyHomePage(), theme: new ThemeData( pageTransitionsTheme: PageTransitionsTheme(builders: {TargetPlatform.android: ZoomPageTransitionsBuilder(),}), ), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { List<SliderModel> mySLides = new List<SliderModel>(); int slideIndex = 0; PageController controller; Widget _buildPageIndicator(bool isCurrentPage){ return Container( margin: EdgeInsets.symmetric(horizontal: 2.0), height: isCurrentPage ? 10.0 : 6.0, width: isCurrentPage ? 10.0 : 6.0, decoration: BoxDecoration( color: isCurrentPage ? Colors.grey : Colors.grey[300], borderRadius: BorderRadius.circular(12), ), ); } @override void initState() { // TODO: implement initState super.initState(); mySLides = getSlides(); controller = new PageController(); } @override Widget build(BuildContext context) { return Container( color: Colors.white, child: Scaffold( backgroundColor: Colors.white, body: Container( height: MediaQuery.of(context).size.height - 100, child: PageView( controller: controller, onPageChanged: (index) { setState(() { slideIndex = index; }); }, children: <Widget>[ SlideTile( imagePath: mySLides[0].getImageAssetPath(), title: mySLides[0].getTitle(), desc: mySLides[0].getDesc(), ), SlideTile( imagePath: mySLides[1].getImageAssetPath(), title: mySLides[1].getTitle(), desc: mySLides[1].getDesc(), ), SlideTile( imagePath: mySLides[2].getImageAssetPath(), title: mySLides[2].getTitle(), desc: mySLides[2].getDesc(), ), ], ), ), bottomSheet: slideIndex != 2 ? Container( margin: EdgeInsets.symmetric(vertical: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ FlatButton( onPressed: (){ controller.animateToPage(2, duration: Duration(milliseconds: 400), curve: Curves.linear); }, splashColor: Colors.blue[50], child: Text( "SKIP", style: TextStyle(color: Color(0xFF0074E4), fontWeight: FontWeight.w600), ), ), Container( child: Row( children: [ for (int i = 0; i < 3 ; i++) i == slideIndex ? _buildPageIndicator(true): _buildPageIndicator(false), ],), ), FlatButton( onPressed: (){ print("this is slideIndex: $slideIndex"); controller.animateToPage(slideIndex + 1, duration: Duration(milliseconds: 500), curve: Curves.linear); }, splashColor: Colors.blue[50], child: Text( "NEXT", style: TextStyle(color: Color(0xFF0074E4), fontWeight: FontWeight.w600), ), ), ], ), ): InkWell( onTap: (){ print('Push your next page'); }, child: Container( height: Platform.isIOS ? 70 : 60, color: Colors.blue, alignment: Alignment.center, child: Text( "GET STARTED NOW", style: TextStyle(color: Colors.white, fontWeight: FontWeight.w600), ), ), ), ), ); } } class SlideTile extends StatelessWidget { String imagePath, title, desc; SlideTile({this.imagePath, this.title, this.desc}); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 20), alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Image.asset(imagePath), SizedBox( height: 40, ), Text(title, textAlign: TextAlign.center,style: TextStyle( fontWeight: FontWeight.w500, fontSize: 20 ),), SizedBox( height: 20, ), Text(desc, textAlign: TextAlign.center,style: TextStyle( fontWeight: FontWeight.w500, fontSize: 14)) ], ), ); } }
0
mirrored_repositories/Walkthrough-Flutter/lib
mirrored_repositories/Walkthrough-Flutter/lib/Model/Slider.dart
class SliderModel{ String imageAssetPath; String title; String desc; SliderModel({this.imageAssetPath,this.title,this.desc}); void setImageAssetPath(String getImageAssetPath){ imageAssetPath = getImageAssetPath; } void setTitle(String getTitle){ title = getTitle; } void setDesc(String getDesc){ desc = getDesc; } String getImageAssetPath(){ return imageAssetPath; } String getTitle(){ return title; } String getDesc(){ return desc; } } List<SliderModel> getSlides(){ List<SliderModel> slides = new List<SliderModel>(); SliderModel sliderModel = new SliderModel(); sliderModel.setDesc("Get instand Designs at your door step with our easy to use platform"); sliderModel.setTitle("Design"); sliderModel.setImageAssetPath("Assets/image1.jpg"); slides.add(sliderModel); sliderModel = new SliderModel(); sliderModel.setDesc("Upload any type of projects to our server. Advantage over other platform is that it allows any type of file format and any file size"); sliderModel.setTitle("Upload"); sliderModel.setImageAssetPath("Assets/image2.jpg"); slides.add(sliderModel); sliderModel = new SliderModel(); sliderModel.setDesc("Create you own private chat rooms to make constructive conversations and this is some thing build to replace Email"); sliderModel.setTitle("Communicate"); sliderModel.setImageAssetPath("Assets/image3.jpg"); slides.add(sliderModel); sliderModel = new SliderModel(); return slides; }
0
mirrored_repositories/Walkthrough-Flutter
mirrored_repositories/Walkthrough-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:walkthrough_flutter/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/FiverrClone
mirrored_repositories/FiverrClone/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fiverr_clone/pages/main_tabs.dart'; void main() { runApp(FiverrClone()); } class FiverrClone extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle(statusBarColor: Colors.white)); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: Colors.white, accentColor: Color(0xFF1DBF73), ), home: MainTabs(), ); } }
0
mirrored_repositories/FiverrClone/lib
mirrored_repositories/FiverrClone/lib/pages/manage_account.dart
import 'package:flutter/material.dart'; import 'package:fiverr_clone/pages/earnings.dart'; import 'package:fiverr_clone/pages/settings.dart'; import 'package:fiverr_clone/pages/profile/profile.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class ManageAccount extends StatefulWidget { @override _ManageAccountState createState() => _ManageAccountState(); } class _ManageAccountState extends State<ManageAccount> { bool isSeller = true; bool isOnline = true; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( actions: <Widget>[ IconButton( icon: Icon( FontAwesomeIcons.cog, color: Colors.grey, ), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => SettingsPage()), ); }, ), ], ), body: Column( children: <Widget>[ Stack( alignment: Alignment.bottomCenter, children: <Widget>[ Column( children: <Widget>[ Container( color: Color(0xFF313131), height: 200.0, width: MediaQuery.of(context).size.width, child: Padding( padding: const EdgeInsets.only( left: 20.0, right: 20.0, bottom: 40.0), child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Stack( alignment: Alignment.bottomRight, children: <Widget>[ CircleAvatar( radius: 30.0, backgroundImage: AssetImage( "assets/images/fiverr_logo.png"), ), Container( child: CircleAvatar( radius: 6.0, backgroundColor: Color(0xFF1DBF73), ), decoration: new BoxDecoration( shape: BoxShape.circle, color: const Color(0xFFFFFFFF), // border color border: Border.all( color: Colors.black87, width: 2), ), ), ], ), ), Text( "bruce", style: TextStyle( color: Colors.white, fontSize: 18.0, ), ), SizedBox( height: 6.0, ), Text( "My personal balance: US\$36.90", style: TextStyle( color: Colors.white, fontSize: 14.0, ), ), ], ), ), ), Container( height: 50.0, width: MediaQuery.of(context).size.width, ), ], ), Card( elevation: 8.0, child: Container( height: 60.0, width: MediaQuery.of(context).size.width * 0.9, child: ListTile( leading: Icon( Icons.credit_card, color: Theme.of(context).accentColor, ), title: Text( "Seller mode", style: TextStyle( fontWeight: FontWeight.bold, ), ), trailing: Switch( value: isSeller, onChanged: (value) { setState(() { isSeller = value; }); }, activeTrackColor: Color(0xFF8bd9ad), activeColor: Theme.of(context).accentColor, ), ), ), ), ], ), Expanded( child: ListView( children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 20.0, left: 20.0, bottom: 5.0), child: Text( "My Fiverr", style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => EarningsPage(), ), ); }, child: ListTile( leading: Icon(Icons.monetization_on), title: Text( "Earnings", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.solidStickyNote), title: Text( "Buyers requests", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.fileMedicalAlt), title: Text( "Offer templates", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.bullhorn), title: Text( "Promote my gigs", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.windowMaximize), title: Text( "My gigs", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), Divider(), Padding( padding: const EdgeInsets.only(top: 10.0, left: 20.0, bottom: 5.0), child: Text( "General", style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => ProfilePage())); }, child: ListTile( leading: Icon(FontAwesomeIcons.user), title: Text( "My profile", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.circleNotch), title: Text( "Online status", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), trailing: Switch( value: isOnline, onChanged: (value) { setState(() { isOnline = value; }); }, activeTrackColor: Color(0xFF8bd9ad), activeColor: Theme.of(context).accentColor, ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.paperPlane), title: Text( "Invite friends", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), InkWell( onTap: () {}, child: ListTile( leading: Icon(FontAwesomeIcons.lifeRing), title: Text( "Support", style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, ), ), ), ), ], ), ), ], ), ); } }
0
mirrored_repositories/FiverrClone/lib
mirrored_repositories/FiverrClone/lib/pages/notifications.dart
import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class Notifications extends StatefulWidget { @override _NotificationsState createState() => _NotificationsState(); } class _NotificationsState extends State<Notifications> { Future<void> _refreshNotifications() async {} Map<String, IconData> _iconMapping = { "complete": FontAwesomeIcons.clipboardCheck, "buyerTip": Icons.monetization_on, "congrats": FontAwesomeIcons.award, "delivery": FontAwesomeIcons.envelopeOpenText }; var _notifications = [ { "icon": "delivery", "notification": "brad left a 5 star review. 3d ago", "hasRead": false }, { "icon": "delivery", "notification": "chad left a 5 star review. 3d ago", "hasRead": false }, { "icon": "complete", "notification": "fedminz's order was automatically marked as complete. 6d ago", "hasRead": true }, { "icon": "buyerTip", "notification": "ninny left you a Tip. 1w ago", "hasRead": false }, { "icon": "buyerTip", "notification": "ninny left you a Tip. 1w ago", "hasRead": true }, { "icon": "buyerTip", "notification": "ninny left you a Tip. 1w ago", "hasRead": true }, { "icon": "congrats", "notification": "Congrats! You're now a Level One Seller!", "hasRead": true }, { "icon": "complete", "notification": "fedminz's order was automatically marked as complete. 6d ago", "hasRead": true }, { "icon": "buyerTip", "notification": "ninny left you a Tip. 1w ago", "hasRead": true }, { "icon": "delivery", "notification": "brad left a 5 star review. 3d ago", "hasRead": true }, { "icon": "buyerTip", "notification": "adam left you a Tip. 1w ago", "hasRead": true }, { "icon": "complete", "notification": "gina's order was automatically marked as complete. 6d ago", "hasRead": true }, { "icon": "complete", "notification": "lamdz's order was automatically marked as complete. 6d ago", "hasRead": true }, { "icon": "buyerTip", "notification": "ninny left you a Tip. 1w ago", "hasRead": true }, { "icon": "complete", "notification": "sasha's order was automatically marked as complete. 6d ago", "hasRead": true }, { "icon": "complete", "notification": "kitty's order was automatically marked as complete. 6d ago", "hasRead": true }, ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Notifications"), ), body: RefreshIndicator( onRefresh: _refreshNotifications, color: Colors.black87, child: ListView.builder( itemCount: _notifications.length, itemBuilder: (context, int index) { return InkWell( onTap: () {}, splashColor: Colors.transparent, highlightColor: Colors.transparent, child: Container( color: _notifications[index]['hasRead'] ? Colors.white : Colors.white12, child: Padding( padding: const EdgeInsets.only( left: 8.0, right: 8.0, bottom: 8.0), child: ListTile( leading: Icon(_iconMapping[_notifications[index]['icon']], size: 25.0, color: _notifications[index]['hasRead'] ? Colors.grey : Theme.of(context).accentColor), title: Text( _notifications[index]['notification'], style: TextStyle( color: _notifications[index]['hasRead'] ? Colors.grey : Colors.black87, fontSize: 16.0, fontWeight: _notifications[index]['hasRead'] ? FontWeight.normal : FontWeight.bold, ), ), ), ), ), ); }), ), ); } }
0
mirrored_repositories/FiverrClone/lib
mirrored_repositories/FiverrClone/lib/pages/main_tabs.dart
import 'package:flutter/material.dart'; import 'package:flutter_icons/flutter_icons.dart'; import 'package:fiverr_clone/pages/home.dart'; import 'package:fiverr_clone/pages/manage_account.dart'; import 'package:fiverr_clone/pages/manage_sales.dart'; import 'package:fiverr_clone/pages/message_inbox.dart'; import 'package:fiverr_clone/pages/notifications.dart'; class MainTabs extends StatefulWidget { @override _MainTabsState createState() => _MainTabsState(); } class _MainTabsState extends State<MainTabs> with SingleTickerProviderStateMixin { TabController controller; int _selectedIndexForBottomNavigationBar; @override void initState() { super.initState(); _selectedIndexForBottomNavigationBar = 0; controller = TabController( vsync: this, length: _listOfPagesForBottomNavigationBar.length, initialIndex: 1); } @override void dispose() { super.dispose(); controller.dispose(); } void _onItemTappedForBottomNavigationBar(int index) { setState(() { _selectedIndexForBottomNavigationBar = index; }); } static List<Widget> _listOfPagesForBottomNavigationBar = <Widget>[ HomePage(), MessageInboxPage(), ManageSales(), Notifications(), ManageAccount(), ]; @override Widget build(BuildContext context) { return Scaffold( body: _listOfPagesForBottomNavigationBar[ _selectedIndexForBottomNavigationBar], bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, onTap: _onItemTappedForBottomNavigationBar, // this will be set when a new tab is tapped items: [ BottomNavigationBarItem( icon: Icon(Feather.home), title: Text('Home'), ), BottomNavigationBarItem( icon: Icon(Feather.mail), title: Text('Messages'), ), BottomNavigationBarItem( icon: Icon(Feather.clipboard), title: Text('Sales'), ), BottomNavigationBarItem( icon: Icon(Feather.bell), title: Text('Notifications'), ), BottomNavigationBarItem( icon: Icon(Feather.user), title: Text('Profile'), ), ], currentIndex: _selectedIndexForBottomNavigationBar, selectedItemColor: Theme.of(context).accentColor, unselectedItemColor: Color(0xFF404040), showSelectedLabels: false, showUnselectedLabels: false, ), ); } }
0