repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/widgets/movie_card.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:show_bitz/screens/movie_detail_screen.dart'; import 'package:show_bitz/utils/type.dart'; import 'package:show_bitz/utils/video.dart'; class MovieCard extends StatelessWidget { // final String title; // final String img; final int index; final Video video; final bool now; const MovieCard({ super.key, required this.video, required this.index, required this.now, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.of(context).push(MaterialPageRoute(builder: (context) { switch (video.type) { case Types.movie: return MovieDetailsScreen( movie: video, ); case Types.series: return MovieDetailsScreen( movie: video, ); default: return showAlertDialog(context); } })); }, child: SizedBox( width: MediaQuery.of(context).size.width / 2, child: Padding( padding: index == 0 ? const EdgeInsets.only( left: 0, top: 10, bottom: 10, right: 5, ) : const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ CachedNetworkImage( width: 170, fit: BoxFit.fill, imageUrl: video.imgUrl, progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors.greenAccent, value: downloadProgress.progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), ), Padding( padding: const EdgeInsets.only( top: 5, ), child: Text( video.title, textAlign: TextAlign.start, style: const TextStyle( overflow: TextOverflow.ellipsis, color: Colors.white, letterSpacing: 1, fontWeight: FontWeight.w500, ), maxLines: 2, ), ), ], ), ), ), ); } } AlertDialog showAlertDialog(BuildContext context) { return (AlertDialog( alignment: Alignment.center, content: const Text( "we are currently in uder development proccess of this action please check for the updates regularly!"), iconColor: Colors.red, surfaceTintColor: Colors.grey[400], icon: const Row(mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.info_sharp, size: 26, ) ]), title: const Text( "Under Development", textAlign: TextAlign.start, ), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text("Ok"), ), ], actionsPadding: const EdgeInsets.all(10), elevation: 10, )); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/widgets/bottom_appbar.dart
import 'package:flutter/material.dart'; Widget bottomNavBar({required int index, required Function tap}) { const activeColor = Colors.green; return BottomNavigationBar( backgroundColor: Colors.transparent, type: BottomNavigationBarType.fixed, selectedItemColor: Colors.white, unselectedItemColor: Colors.white54, onTap: (value) { tap(value); }, currentIndex: index, items: [ BottomNavigationBarItem( icon: const Icon(Icons.home), label: '', activeIcon: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: activeColor, ), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), child: const Icon( Icons.home_filled, color: Colors.white, ), ), ), BottomNavigationBarItem( icon: const Icon(Icons.star), label: '', activeIcon: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: activeColor, ), padding: const EdgeInsets.all(10), child: const Icon( Icons.star, ), ), ), BottomNavigationBarItem( icon: const Icon(Icons.video_collection), label: '', activeIcon: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: activeColor, ), padding: const EdgeInsets.all(10), child: const Icon( Icons.video_collection, ), ), ), BottomNavigationBarItem( icon: const Icon(Icons.people_alt_outlined), label: '', activeIcon: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: activeColor, ), padding: const EdgeInsets.all(10), child: const Icon( Icons.people, ), ), ), ], ); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/widgets/actor_card.dart
import 'package:flutter/material.dart'; class Actor extends StatelessWidget { const Actor({super.key}); @override Widget build(BuildContext context) { return SizedBox( width: MediaQuery.of(context).size.width / 2 - 5, child: const Column( children: [ Text("Actor"), Text("Actor"), ], ), ); } }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/utils/series.dart
import 'package:show_bitz/utils/type.dart'; import 'package:show_bitz/utils/video.dart'; class Series extends Video { const Series({ required super.title, required super.imgUrl, required super.id, required super.type, super.genres, }); factory Series.fromMap(Map<String, dynamic> map) { String url = "https://image.tmdb.org/t/p/original${map['poster_path']}"; return Series( title: map['name'], imgUrl: url, id: map['id'], type: Types.series, genres: map['genre_ids'], ); } }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/utils/styles.dart
import 'package:flutter/material.dart'; import 'package:show_bitz/utils/colors.dart'; final TextStyle headerStyle = TextStyle( fontSize: 22, color: primaryTextColor, fontWeight: FontWeight.w500, );
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/utils/movie.dart
import 'package:show_bitz/utils/type.dart'; import 'package:show_bitz/utils/video.dart'; final class Movie extends Video { Movie({ required super.title, required super.imgUrl, required super.id, required super.type, super.genres, }); factory Movie.fromMap(Map<String, dynamic> map) { String url = "https://image.tmdb.org/t/p/original${map['poster_path']}"; return Movie( title: map['title'], imgUrl: url, id: map['id'], type: Types.movie, genres: map['genre_ids']); } }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/utils/colors.dart
import 'package:flutter/material.dart'; Color primaryTextColor = Colors.white; Color backgroundColor = Colors.black;
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/utils/type.dart
enum Types { movie, series, actor }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/utils/actor.dart
class Actor { final String name; final int id; final String type; final String img; // final List<Map<String, dynamic>> knownFor; const Actor(this.name, this.id, this.type, this.img); factory Actor.fromMap(Map<String, dynamic> map) { String url = "https://image.tmdb.org/t/p/original${map['profile_path']}"; return Actor( map['original_name'], map['id'], map['known_for_department'], url, ); } }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/services/series_service.dart
import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; import 'package:show_bitz/utils/constants.dart'; abstract class SeriesService { static Future<List?> loadPopularSeries() async { const url = "https://api.themoviedb.org/3/tv/popular?language=en-US&page=1"; try { var response = await http.get(Uri.parse(url), headers: <String, String>{ HttpHeaders.acceptHeader: 'application/json', HttpHeaders.authorizationHeader: authToken, }); if (response.statusCode != 200) { return null; } List<dynamic> resp = jsonDecode(response.body)['results']; return resp; } catch (error) { return null; } } static Future<List?> loadThisWeekThreanding() async { const url = "https://api.themoviedb.org/3/trending/tv/week?language=en-US"; try { var response = await http.get(Uri.parse(url), headers: <String, String>{ HttpHeaders.acceptHeader: 'application/json', HttpHeaders.authorizationHeader: authToken, }); if (response.statusCode != 200) { return null; } List<dynamic> resp = jsonDecode(response.body)['results']; // print(resp); return resp; } catch (error) { return null; } } static Future<List?> loadToday() async { const url = "https://api.themoviedb.org/3/tv/airing_today?language=en-US&page=1"; try { var response = await http.get(Uri.parse(url), headers: <String, String>{ HttpHeaders.acceptHeader: 'application/json', HttpHeaders.authorizationHeader: authToken, }); if (response.statusCode != 200) { return null; } List<dynamic> resp = jsonDecode(response.body)['results']; // print(resp); return resp; } catch (error) { return null; } } static Future<List?> loadTopRated() async { const url = "https://api.themoviedb.org/3/tv/top_rated?language=en-US&page=1"; try { var response = await http.get(Uri.parse(url), headers: <String, String>{ HttpHeaders.acceptHeader: 'application/json', HttpHeaders.authorizationHeader: authToken, }); if (response.statusCode != 200) { return null; } List<dynamic> resp = jsonDecode(response.body)['results']; // print(resp); return resp; } catch (error) { return null; } } }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; import 'package:show_bitz/services/movie_service.dart'; import 'package:show_bitz/utils/movie.dart'; import 'package:show_bitz/utils/styles.dart'; import 'package:show_bitz/widgets/movie_card.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { @override Widget build(BuildContext context) { return SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric( horizontal: 15, vertical: 20, ), child: Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Movies", style: TextStyle( color: Colors.white, fontSize: 26, fontWeight: FontWeight.w300, letterSpacing: 3, ), ), ], ), Text( "Now Playing", style: headerStyle, ), FutureBuilder( future: MovieService.loadMovies(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Text( "Opps! loading failed\nPlease make sure your connection is up", style: TextStyle(color: Colors.white60), ), ), ) ], ); } return SizedBox( height: 330, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Movie m = Movie.fromMap(snapshot.data?[index]); return MovieCard( video: m, index: index, now: true, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), Text( "Upcoming", style: headerStyle, ), FutureBuilder( future: MovieService.loadUpCommingMovie(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Text( "Opps! loading failed", style: TextStyle(color: Colors.white60), ), ), ) ], ); } return SizedBox( height: 330, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Movie m = Movie.fromMap(snapshot.data?[index]); return MovieCard( video: m, index: index, now: false, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), Text( "Popular", style: headerStyle, ), FutureBuilder( future: MovieService.loadPopularMovies(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Text( "Opps! loading failed", style: TextStyle(color: Colors.white60), ), ), ) ], ); } return SizedBox( height: 330, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Movie m = Movie.fromMap(snapshot.data?[index]); return MovieCard( video: m, index: index, now: false, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), ], ), )), ); } } Widget showProgressIndicator() { return const SizedBox( height: 300, child: Center( child: Padding( padding: EdgeInsets.only( top: 40, ), child: CircularProgressIndicator( color: Colors.white, strokeWidth: 2, ), ), ), ); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/actors_screen.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:show_bitz/screens/person_details_screen.dart'; import 'package:show_bitz/services/actor_service.dart'; import 'package:show_bitz/utils/actor.dart'; import 'package:show_bitz/utils/styles.dart'; class ActorsScreen extends StatefulWidget { const ActorsScreen({super.key}); @override State<ActorsScreen> createState() => _ActorsScreenState(); } class _ActorsScreenState extends State<ActorsScreen> { @override Widget build(BuildContext context) { return SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(10), child: Expanded( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 10), child: Text( "Popular Now", style: headerStyle, ), ) ], ), FutureBuilder( future: ActorService.loadActors(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: return SizedBox( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, child: GridView.builder( itemCount: snapshot.data?.length, padding: const EdgeInsets.all(10), physics: const BouncingScrollPhysics( decelerationRate: ScrollDecelerationRate.fast, ), cacheExtent: 10, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 20, mainAxisSpacing: 20, ), itemBuilder: (context, index) { Actor actor = Actor.fromMap(snapshot.data![index]); return GestureDetector( onTap: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => PersonDetailsScreen( id: actor.id, ), ), ), child: CachedNetworkImage( imageUrl: actor.img, fit: BoxFit.cover, progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: Center( child: CircularProgressIndicator( strokeWidth: 2, color: Colors.greenAccent, value: downloadProgress.progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), ), ); }, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ) ], )), )); } } Widget showProgressIndicator() { return const SizedBox( height: 300, child: Center( child: Padding( padding: EdgeInsets.only( top: 40, ), child: CircularProgressIndicator( color: Colors.white, strokeWidth: 2, ), ), ), ); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/threanding_screen.dart
import 'dart:convert'; import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:show_bitz/utils/constants.dart'; import 'package:show_bitz/utils/styles.dart'; import 'package:http/http.dart' as http; class ThreandingScreen extends StatefulWidget { const ThreandingScreen({super.key}); @override State<ThreandingScreen> createState() => _ThreandingScreenState(); } class _ThreandingScreenState extends State<ThreandingScreen> { Future<List?> getThreandingThisWeek() async { const url = "https://api.themoviedb.org/3/trending/all/week?language=en-US"; try { var response = await http.get(Uri.parse(url), headers: <String, String>{ HttpHeaders.acceptHeader: 'application/json', HttpHeaders.authorizationHeader: authToken, }); if (response.statusCode != 200) { return null; } List<dynamic> resp = jsonDecode(response.body)['results']; // print(resp); return resp; } catch (error) { return null; } } @override Widget build(BuildContext context) { return SingleChildScrollView( physics: const ScrollPhysics(parent: AlwaysScrollableScrollPhysics()), child: Padding( padding: const EdgeInsets.symmetric( horizontal: 15, vertical: 20, ), child: Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "TRENDING".capitalize(), style: headerStyle, ), FutureBuilder( future: getThreandingThisWeek(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text("Opps! loading failed", style: TextStyle(color: Colors.white60)) ], ); } return SizedBox( // height: MediaQuery.of(context).size.height, height: 600, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { var item = snapshot.data; try { String title; String type = item![index]['media_type']; if (type == 'movie') { title = item[index]['title']; } else { title = item[index]['name']; } int id = item[index]['id']; double rate = item[index]['vote_average']; String imgpath = item[index]['poster_path']; return ThreandingItem( title: title, type: type, id: id, imgpath: imgpath, rate: rate, ); } catch (er) { return const Center( child: Icon( Icons.error, color: Colors.white, ), ); } }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), ], ), )), ); } } Widget showProgressIndicator() { return const SizedBox( height: 300, child: Center( child: Padding( padding: EdgeInsets.only( top: 40, ), child: CircularProgressIndicator( color: Colors.white, strokeWidth: 2, ), ), ), ); } class ThreandingItem extends StatelessWidget { final String title; final String type; final int id; final String imgpath; final double rate; const ThreandingItem({ super.key, required this.title, required this.type, required this.id, required this.imgpath, required this.rate, }); @override Widget build(BuildContext context) { double width = MediaQuery.of(context).size.width; String url = 'https://image.tmdb.org/t/p/original$imgpath'; return GestureDetector( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: SizedBox( width: width - 60, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Stack( children: [ CachedNetworkImage( width: 400, fit: BoxFit.fill, imageUrl: url, progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors.greenAccent, value: downloadProgress.progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), ), Positioned( left: 10, top: 10, child: Expanded( child: Padding( padding: const EdgeInsets.symmetric( horizontal: 10, vertical: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( type.capitalize(), style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w500, letterSpacing: 2, fontSize: 20, ), ), Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Padding( padding: EdgeInsets.only(left: 10), child: Icon( Icons.star_rate, color: Colors.yellow, size: 25, ), ), Text( double.parse(rate.toString()) .toStringAsFixed(1), style: const TextStyle(color: Colors.white), ), ], ), ], ), ), )), ], ) ], ), ), ), ); } } extension StringExtension on String { String capitalize() { return "${this[0].toUpperCase()}${substring(1).toLowerCase()}"; } }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/person_details_screen.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:show_bitz/services/actor_service.dart'; import 'package:show_bitz/utils/colors.dart'; class PersonDetailsScreen extends StatelessWidget { final int id; const PersonDetailsScreen({super.key, required this.id}); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, body: FutureBuilder( future: ActorService.loadActorDetails(id: id), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: var item = snapshot.data; if (item == null) { return const Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon( Icons.error, color: Colors.white, size: 20, ), Text("Opps!"), ], ), ); } return SingleChildScrollView( child: Center( child: Column( children: [ Stack(children: [ CachedNetworkImage( alignment: Alignment.center, width: MediaQuery.of(context).size.width, imageUrl: "https://image.tmdb.org/t/p/original${item['profile_path']}", progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors.greenAccent, value: downloadProgress.progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), fit: BoxFit.cover, ), Positioned( top: 40, left: 0, child: Padding( padding: const EdgeInsets.all(10), child: IconButton( onPressed: () { Navigator.pop(context); }, icon: Container( decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(10)), child: const Icon( Icons.arrow_back, color: Colors.green, size: 27, ), )), ), ), ]), const SizedBox( height: 10, ), Padding( padding: const EdgeInsets.all(10), child: Column( children: [ Text( item['name'], style: const TextStyle( color: Colors.white, fontSize: 17, ), ), Text( item['known_for_department'], style: const TextStyle( color: Colors.white70, fontSize: 15, ), ), Text( item['birthday'], style: const TextStyle( color: Colors.white70, fontSize: 15, ), ), Text( item['place_of_birth'], style: const TextStyle( color: Colors.white70, fontSize: 15, ), ), const SizedBox( height: 20, ), Text( item['biography'], maxLines: 25, overflow: TextOverflow.clip, style: const TextStyle( color: Colors.white60, fontSize: 15, ), ) ], ), ), const SizedBox( height: 15, ), Padding( padding: const EdgeInsets.all(10), child: FutureBuilder( future: ActorService.getImages(id: id), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: var data = snapshot.data; // print(snapshot.data); if (data == null) { return const Center( child: Icon( Icons.error, size: 25, ), ); } return SizedBox( height: 250, child: ListView.builder( itemCount: data?.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { var item = data[index]; return Padding( padding: const EdgeInsets.only(right: 10), child: CachedNetworkImage( fit: BoxFit.contain, imageUrl: "https://image.tmdb.org/t/p/original${item['file_path']}", progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors .greenAccent, value: downloadProgress .progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), ), ); }, ), ); case ConnectionState.waiting: return showProgress(); default: return showProgress(); } }, ), ) ], ), ), ); case ConnectionState.waiting: return showProgress(); default: return showProgress(); } }, )); } } showProgress() { return const Center( child: CircularProgressIndicator( color: Colors.green, ), ); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/series_screen.dart
import 'package:flutter/material.dart'; import 'package:show_bitz/services/series_service.dart'; import 'package:show_bitz/utils/series.dart'; import 'package:show_bitz/utils/styles.dart'; import 'package:show_bitz/utils/video.dart'; import 'package:show_bitz/widgets/movie_card.dart'; class SeriesScreen extends StatefulWidget { const SeriesScreen({super.key}); @override State<SeriesScreen> createState() => _SeriesScreenState(); } class _SeriesScreenState extends State<SeriesScreen> { @override Widget build(BuildContext context) { return SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric( horizontal: 15, vertical: 20, ), child: Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Tv shows", style: TextStyle( color: Colors.white, fontSize: 26, fontWeight: FontWeight.w300, letterSpacing: 3, ), ), ], ), const SizedBox( height: 15, ), Text( "On Air Today", style: headerStyle, ), FutureBuilder( future: SeriesService.loadToday(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Padding( padding: EdgeInsets.only(top: 10), child: Text( "Opps! loading failed\nPlease make sure your connection is up", style: TextStyle(color: Colors.white60), ), ), ), ) ], ); } return SizedBox( height: 330, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Video s = Series.fromMap(snapshot.data?[index]); return MovieCard( video: s, index: index, now: false, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), Text( "This Week", style: headerStyle, ), FutureBuilder( future: SeriesService.loadThisWeekThreanding(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Text( "Opps! loading failed", style: TextStyle(color: Colors.white60), ), ), ) ], ); } return SizedBox( height: 330, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Series s = Series.fromMap(snapshot.data?[index]); return MovieCard( video: s, index: index, now: true, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), Text( "Popular", style: headerStyle, ), FutureBuilder( future: SeriesService.loadPopularSeries(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Text( "Opps! loading failed", style: TextStyle(color: Colors.white60), ), ), ) ], ); } return SizedBox( height: 330, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Video s = Series.fromMap(snapshot.data?[index]); return MovieCard( video: s, index: index, now: false, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), Text( "Top Rated", style: headerStyle, ), FutureBuilder( future: SeriesService.loadTopRated(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: if (snapshot.data == null) { return const Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 250, child: Center( child: Text( "Opps! loading failed", style: TextStyle(color: Colors.white60), ), ), ) ], ); } return SizedBox( height: 340, child: ListView.builder( itemCount: snapshot.data?.length, itemBuilder: (context, index) { Series m = Series.fromMap(snapshot.data?[index]); return MovieCard( video: m, index: index, now: false, ); }, scrollDirection: Axis.horizontal, ), ); case ConnectionState.waiting: return showProgressIndicator(); default: return showProgressIndicator(); } }, ), ], ), )), ); } } Widget showProgressIndicator() { return const SizedBox( height: 300, child: Center( child: Padding( padding: EdgeInsets.only( top: 40, ), child: CircularProgressIndicator( color: Colors.white, strokeWidth: 2, ), ), ), ); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/movie_detail_screen.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:share_plus/share_plus.dart'; import 'package:show_bitz/services/movie_service.dart'; import 'package:show_bitz/utils/colors.dart'; import 'package:show_bitz/utils/type.dart'; import 'package:show_bitz/utils/video.dart'; import 'package:url_launcher/url_launcher.dart'; class MovieDetailsScreen extends StatelessWidget { final Video movie; const MovieDetailsScreen({super.key, required this.movie}); void lunchWeb(String u, BuildContext context) async { try { Uri url = Uri.parse(u); bool canlunch = await canLaunchUrl(url); if (canlunch) { await launchUrl(url, mode: LaunchMode.externalApplication); } else { AlertDialog( title: const Text("Failed to open url"), icon: const Icon( Icons.error_outline, size: 27, ), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text("Cancel")) ], ); } } catch (er) { AlertDialog( title: const Text("Failed to open url"), content: Text(er.toString()), icon: const Icon( Icons.error_outline, size: 27, ), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text("Cancel")) ], ); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, body: FutureBuilder( future: MovieService.loadMovieDetails(movie: movie), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.done: var item = snapshot.data; if (item == null) { return const Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon( Icons.error, color: Colors.white, size: 20, ), Text("Opps!"), ], ), ); } double rate = item['vote_average']; return SingleChildScrollView( child: Center( child: Column( children: [ Stack(children: [ CachedNetworkImage( alignment: Alignment.center, width: MediaQuery.of(context).size.width, imageUrl: movie.imgUrl, progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors.greenAccent, value: downloadProgress.progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), fit: BoxFit.cover, ), Positioned( top: 40, left: 0, child: Padding( padding: const EdgeInsets.all(10), child: IconButton( onPressed: () { Navigator.pop(context); }, icon: Container( decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(10)), child: const Icon( Icons.arrow_back, color: Colors.green, size: 27, ), )), ), ), Positioned( top: 40, right: 0, child: Padding( padding: const EdgeInsets.all(10), child: IconButton( onPressed: () async { await Share.share( movie.title, subject: item['homepage'], ); }, icon: Container( decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(10)), child: const Icon( Icons.share, color: Colors.green, size: 27, ), )), ), ), ]), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Padding( padding: EdgeInsets.only(left: 10), child: Icon( Icons.star_rate, color: Colors.yellow, size: 25, ), ), Text( double.parse(rate.toString()).toStringAsFixed(1), style: const TextStyle(color: Colors.white54), ), Padding( padding: const EdgeInsets.all(8), child: Container( decoration: const BoxDecoration(color: Colors.white30), child: Padding( padding: const EdgeInsets.symmetric( horizontal: 10), child: Text( item['original_language'], style: const TextStyle(color: Colors.white70), ), ), ), ) ], ), Padding( padding: const EdgeInsets.only(right: 5.0), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( onPressed: () => lunchWeb(item['homepage'], context), child: const Text( "Visit ", style: TextStyle( color: Colors.lightGreen, ), )), const SizedBox( width: 4, ), Text( movie.type == Types.movie ? item['release_date'] : item['first_air_date'], style: const TextStyle( color: Colors.white60, )), ], ), ), Padding( padding: const EdgeInsets.all(10), child: Text( item['overview'], style: const TextStyle( color: Colors.white54, fontSize: 16, ), ), ), const SizedBox( height: 10, ), SizedBox( height: 50, child: ListView( scrollDirection: Axis.horizontal, children: item['genres']!.map<Widget>((item) { return Padding( padding: const EdgeInsets.all(10), child: Container( decoration: BoxDecoration( color: const Color.fromARGB(255, 77, 77, 77), borderRadius: BorderRadius.circular(10)), child: Padding( padding: const EdgeInsets.all(5), child: Text( item['name'] as String, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w400, ), ), ), ), ); }).toList(), ), ), const SizedBox( height: 10, ), item['vurl'] != null ? Padding( padding: const EdgeInsets.all(20), child: GestureDetector( onTap: () => lunchWeb(item['vurl'], context), child: Stack(children: [ CachedNetworkImage( alignment: Alignment.center, width: MediaQuery.of(context).size.width, imageUrl: item['tumbnail'], progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: Column( children: [ SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors .greenAccent, value: downloadProgress .progress), ), const Text( "Loading.", style: TextStyle( color: Colors.white60), ), ], ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), fit: BoxFit.cover, ), Positioned( top: 5, right: 5, child: SizedBox( width: 60, height: 50, child: Image.asset( 'assets/ylogo.png', fit: BoxFit.contain, ), ), ), ]), ), ) : const SizedBox( height: 2, ), movie.type == Types.series ? Padding( padding: const EdgeInsets.all(10), child: Row( children: [ Text( "Seasons ${List.of(item['seasons']).length}", style: const TextStyle( color: Colors.white54, fontSize: 16, ), ), ], ), ) : const SizedBox( height: 2, ), movie.type == Types.series ? Padding( padding: const EdgeInsets.only( left: 10, right: 10, top: 5, bottom: 40), child: SizedBox( height: 300, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: List.of(item['seasons']).length, itemBuilder: (context, index) { var season = item['seasons'][index]; String url; if (season['poster_path'] != null) { url = "https://image.tmdb.org/t/p/original${season['poster_path']}"; } else { url = 'https://www.movienewz.com/img/films/poster-holder.jpg'; } return Padding( padding: const EdgeInsets.only(right: 16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ CachedNetworkImage( width: 150, fit: BoxFit.fill, imageUrl: url, progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: Padding( padding: const EdgeInsets.all(5), child: SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, color: Colors .greenAccent, value: downloadProgress .progress), ), ), ); }, errorWidget: (context, url, error) => const Icon(Icons.error), ), Padding( padding: const EdgeInsets.only( top: 5.0), child: Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( season['name'], style: const TextStyle( color: Colors.white, ), ), Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment .center, children: [ const Padding( padding: EdgeInsets.only( left: 10), child: Icon( Icons.star_rate, color: Colors.yellow, size: 20, ), ), Text( double.parse(season[ 'vote_average'] .toString()) .toStringAsFixed( 1), style: const TextStyle( color: Colors .white), ), ]), ], ), ), ], ), ); }, ), ), ) : const SizedBox( height: 2, ) ], ), ), ); case ConnectionState.waiting: return showProgress(); default: return showProgress(); } }, )); } } showProgress() { return const Center( child: CircularProgressIndicator( color: Colors.green, ), ); }
0
mirrored_repositories/show-bitz-mobile-app/lib
mirrored_repositories/show-bitz-mobile-app/lib/screens/search_screen.dart
import 'package:flutter/material.dart'; class SearchScreen extends StatefulWidget { const SearchScreen({super.key}); @override State<SearchScreen> createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { @override Widget build(BuildContext context) { return const Center( child: Text( "Search Page!", ), ); } }
0
mirrored_repositories/show-bitz-mobile-app
mirrored_repositories/show-bitz-mobile-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:show_bitz/my_app.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/samachar
mirrored_repositories/samachar/lib/main.dart
import 'package:flutter/material.dart'; import 'package:samachar/Views/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: 'samachar', debugShowCheckedModeBanner: false, // theme: ThemeData( // the // primaryColor: Colors.white, //), theme: ThemeData.dark(), home: Home(), ); } }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/Model/article_model.dart
class ArticleModel { String authorName; String title; String description; String url; String urlToImage; String content; ArticleModel( {this.authorName, this.title, this.description, this.url, this.urlToImage, this.content}); }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/Model/category_model.dart
class CategoryModel { String categoryName; String imageURL; }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/Views/Home.dart
//HOME PAGE FOR SAMACHAR import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:samachar/App%20info/app_info.dart'; import 'package:samachar/Model/article_model.dart'; import 'package:samachar/Model/category_model.dart'; import 'package:samachar/Views/article_View.dart'; import 'package:samachar/Views/category_news.dart'; import 'package:samachar/helper/data.dart'; import 'package:samachar/helper/news_fetch.dart'; class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { final ScrollController controller = ScrollController(); final ScrollController mainScrollController = ScrollController(); //bool noScrollMoreIcon = false; List<CategoryModel> categories = new List<CategoryModel>(); List<ArticleModel> newsArticles = new List<ArticleModel>(); bool _loading = true; @override void initState() { super.initState(); categories = getCategories(); getNews(); // controller.addListener(() { // if (controller.position.pixels == controller.position.maxScrollExtent) { // setState(() { // noScrollMoreIcon = true; // }); // } else { // setState(() { // noScrollMoreIcon = false; // }); // } // }); } getNews() async { NewsFetch newsClass = NewsFetch(); await newsClass.getNews(); newsArticles = newsClass.news; setState(() { _loading = false; }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[900], appBar: AppBar( title: GestureDetector( //for scrolling news back to initial stage onTap: () { mainScrollController.animateTo(0, duration: Duration(milliseconds: 300), curve: Curves.easeInOut); }, //for opening the app info page onLongPress: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return AppInfo(); })); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'sama', style: TextStyle(fontWeight: FontWeight.w800, fontSize: 20), ), Text( 'char', style: TextStyle( color: Colors.blue, fontSize: 20.0, fontWeight: FontWeight.bold), ), ], ), ), elevation: 0.0, centerTitle: true, ), body: _loading ? Center( child: Container( child: CircularProgressIndicator( valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue), ), )) : Container( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Column( children: [ Expanded( child: Container( //padding for the container Containing categories height: 70.0, child: Row( children: [ Expanded( flex: 25, child: ListView.builder( controller: controller, itemCount: categories.length, shrinkWrap: true, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { return CardTile( //fetching the image url form and Category Namedata.dart file imageURL: categories[index].imageURL, categoryName: categories[index].categoryName, ); }, ), ), //Side scrolling icon //SCROLLING ICON TOOGLE Expanded( child: Container( alignment: Alignment.centerRight, child: Icon( Icons.navigate_next, color: Colors.blue, size: 23.0, ), ), ), ], ), ), ), //container for News Articles //Main Content for news area Expanded( flex: 10, child: Container( margin: EdgeInsets.only(top: 15.0), child: ListView.builder( controller: mainScrollController, itemCount: newsArticles.length, shrinkWrap: true, physics: ClampingScrollPhysics(), itemBuilder: (context, index) { return BottomBlogTile( articleUrl: newsArticles[index].url, imageURL: newsArticles[index].urlToImage, title: newsArticles[index].title, description: newsArticles[index].description); }), ), ), ], ), ), ); } } // Tile/Card frame for the the scrollable category section class CardTile extends StatelessWidget { final imageURL, categoryName; CardTile({ this.imageURL, this.categoryName, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return CategoryView(category: categoryName.toString().toLowerCase()); })); }, child: Container( margin: EdgeInsets.only(right: 12.0), child: Stack( children: [ ClipRRect( borderRadius: BorderRadius.circular(10), child: CachedNetworkImage( //Passing the image Url imageUrl: imageURL, width: 130.0, height: 70.0, fit: BoxFit.cover, ), ), Container( alignment: Alignment.center, width: 130.0, height: 70.0, decoration: BoxDecoration( color: Colors.black26, borderRadius: BorderRadius.circular(10), ), child: Text( //passing the Category Name categoryName, style: TextStyle( color: Colors.white, fontSize: 15.0, ), ), ) ], ), ), ); } } //Tile for news section of the sama4 app class BottomBlogTile extends StatelessWidget { final String imageURL, title, description, articleUrl; BottomBlogTile( {@required this.imageURL, @required this.title, @required this.description, @required this.articleUrl}); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return ArticleView( articleUrl: articleUrl, ); })); }, child: Container( child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(6), child: Image.network(imageURL)), SizedBox( height: 8.0, ), Text( title, style: TextStyle( fontSize: 17, color: Colors.white, fontWeight: FontWeight.bold), ), SizedBox( height: 4.0, ), Text( description, style: TextStyle(fontSize: 14, color: Colors.grey[500]), ), SizedBox( height: 24.0, ), ], ), ), ); } }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/Views/article_View.dart
//This is for the detailed news in the webview import 'dart:async'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class ArticleView extends StatefulWidget { final String articleUrl; final ScrollController mainScrollController = ScrollController(); ArticleView({this.articleUrl}); @override _ArticleViewState createState() => _ArticleViewState(); } class _ArticleViewState extends State<ArticleView> { final Completer<WebViewController> _completer = Completer<WebViewController>(); //Controller for the auto scroll on tap(currently not in working state) // final ScrollController mainScrollController = ScrollController(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: GestureDetector( //for scrolling news back to initial stage //NOT IN WORKING STATE // onTap: () { // mainScrollController.animateTo(0, // duration: Duration(milliseconds: 300), curve: Curves.easeInOut); // }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'sama', style: TextStyle(fontWeight: FontWeight.w800, fontSize: 20), ), Text( 'char', style: TextStyle( color: Colors.blue, fontSize: 20.0, fontWeight: FontWeight.bold), ), ], ), ), actions: [ Opacity( opacity: 0, child: Container( padding: EdgeInsets.symmetric(horizontal: 16), child: Icon(Icons.ac_unit_rounded)), ), ], elevation: 0.0, centerTitle: true, ), body: Container( child: WebView( initialUrl: widget.articleUrl, onWebViewCreated: (WebViewController webViewController) { _completer.complete(webViewController); }, ), ), ); } }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/Views/category_news.dart
//This is for the categorical headline for the news: openned when selected by tapping on some category import 'package:flutter/material.dart'; import 'package:samachar/Model/article_model.dart'; import 'package:samachar/Views/article_View.dart'; import 'package:samachar/helper/news_fetch.dart'; class CategoryView extends StatefulWidget { final String category; CategoryView({@required this.category}); @override _CategoryViewState createState() => _CategoryViewState(); } class _CategoryViewState extends State<CategoryView> { final ScrollController mainScrollController = ScrollController(); List<ArticleModel> newsArticles = new List<ArticleModel>(); bool _loading = true; @override void initState() { super.initState(); getCategoryNews(); } getCategoryNews() async { CategoryNewsClass newsClass = CategoryNewsClass(); await newsClass.getNews(widget.category); newsArticles = newsClass.news; setState(() { _loading = false; }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[900], appBar: AppBar( title: GestureDetector( //for scrolling news back to initial stage //NOT IN WORKING STATE onTap: () { mainScrollController.animateTo(0, duration: Duration(milliseconds: 300), curve: Curves.easeInOut); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '${widget.category.toUpperCase()}', style: TextStyle( color: Colors.blue, fontWeight: FontWeight.w800, fontSize: 20), ), ], ), ), actions: [ Opacity( opacity: 0, child: Container( padding: EdgeInsets.symmetric(horizontal: 16), child: Icon(Icons.ac_unit_rounded)), ), ], elevation: 0.0, centerTitle: true, ), //BODY body: _loading ? Center( child: Container( child: CircularProgressIndicator( valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue), ), ), ) : Container( padding: EdgeInsets.symmetric(horizontal: 10.0), margin: EdgeInsets.only(top: 8.0), child: ListView.builder( controller: mainScrollController, itemCount: newsArticles.length, shrinkWrap: true, physics: ClampingScrollPhysics(), itemBuilder: (context, index) { return BottomBlogTile( articleUrl: newsArticles[index].url, imageURL: newsArticles[index].urlToImage, title: newsArticles[index].title, description: newsArticles[index].description); }), ), ); } } //Tile for news section of the sama4 app class BottomBlogTile extends StatelessWidget { final String imageURL, title, description, articleUrl; BottomBlogTile( {@required this.imageURL, @required this.title, @required this.description, @required this.articleUrl}); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return ArticleView( articleUrl: articleUrl, ); })); }, child: Container( child: Column( children: [ ClipRRect( borderRadius: BorderRadius.circular(6), child: Image.network(imageURL)), SizedBox( height: 8.0, ), Text( title, style: TextStyle( fontSize: 17, color: Colors.white, fontWeight: FontWeight.bold), ), SizedBox( height: 4.0, ), Text( description, style: TextStyle(fontSize: 14, color: Colors.grey[500]), ), SizedBox( height: 24.0, ), ], ), ), ); } }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/App info/app_info.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:samachar/Views/article_View.dart'; class AppInfo extends StatefulWidget { @override _AppInfoState createState() => _AppInfoState(); } class _AppInfoState extends State<AppInfo> { final ScrollController mainScrollController = ScrollController(); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[900], appBar: AppBar( title: GestureDetector( //for scrolling news back to initial stage onTap: () { mainScrollController.animateTo(0, duration: Duration(milliseconds: 300), curve: Curves.easeInOut); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'About ', style: TextStyle( color: Colors.blue, fontSize: 20.0, fontWeight: FontWeight.bold), ), Text( 'sama', style: TextStyle(fontWeight: FontWeight.w800, fontSize: 20), ), Text( 'char', style: TextStyle( color: Colors.blue, fontSize: 20.0, fontWeight: FontWeight.bold), ), ], ), ), actions: [ Opacity( opacity: 0, child: Container( padding: EdgeInsets.symmetric(horizontal: 16), child: Icon(Icons.ac_unit_rounded)), ), ], elevation: 0.0, centerTitle: true, ), body: ListView( controller: mainScrollController, padding: const EdgeInsets.all(8), children: <Widget>[ Container( alignment: Alignment.center, child: Column( children: [ Container( padding: EdgeInsets.all(20.0), margin: EdgeInsetsDirectional.only(top: 20.0), child: CachedNetworkImage( imageUrl: "https://raw.githubusercontent.com/rohitsinghkcodes/RESOURCES/master/samachar/samachar_logo_2mb.png"), ), Container( alignment: Alignment.center, padding: EdgeInsets.all(14.0), child: Column( children: [ Text( 'Samachar is an application which will enhance your news reading experience.', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 10.0, ), Text( 'This application contains the best and top news form multiple news sources, and by clicking on the desired news you will be redirected to the official news article from where you can read the whole news in detail.', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 10.0, ), Text( 'The news in this application is provided in a categorized manner which enhances the user experience.', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 80.0, ), Text('CATEGORIES AVAILABLE :', style: TextStyle( fontSize: 25.0, color: Colors.grey[700], fontWeight: FontWeight.w900)), SizedBox( height: 12.0, ), Text( '🔹 Sports', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Science', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Technology', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Entertainment', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Health business', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), SizedBox( height: 70.0, ), Text('TOP HIGHLIGHTS :', style: TextStyle( fontSize: 25.0, color: Colors.grey[700], fontWeight: FontWeight.w900)), SizedBox( height: 12.0, ), Text( '🔹 Easy to use', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Engaging news content', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Simple and minimal UI', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Beautiful Dark Theme', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Categorized Section For Use', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 5.0, ), Text( '🔹 Top news from multiple news sources', style: TextStyle( fontSize: 24.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 80.0, ), Text('GET IN TOUCH :', style: TextStyle( fontSize: 20.0, color: Colors.grey[700], fontWeight: FontWeight.w900)), Container( margin: EdgeInsets.symmetric(horizontal: 160.0), padding: EdgeInsets.all(10.0), child: GestureDetector( onTap: () { //open github in web view Navigator.push(context, MaterialPageRoute(builder: (context) { return ArticleView( articleUrl: 'https://github.com/rohitsinghkcodes', ); })); }, child: CachedNetworkImage( imageUrl: "https://raw.githubusercontent.com/paulrobertlloyd/socialmediaicons/main/github-48x48.png"), ), ), SizedBox( height: 20.0, ), Text('ABOUT THE DEVELOPER :', style: TextStyle( fontSize: 22.0, color: Colors.grey[700], fontWeight: FontWeight.w900)), SizedBox( height: 8.0, ), Text( 'I am Rohit Kumar Singh and i am the developer of samachar. I hope you all will love this application and find it useful.', style: TextStyle( fontSize: 22.0, color: Colors.grey[500], fontWeight: FontWeight.w300), textAlign: TextAlign.center, ), SizedBox( height: 2.0, ), Text( 'You can check more of my work on GitHub.', style: TextStyle( fontSize: 22.0, color: Colors.grey[500], fontWeight: FontWeight.w500), textAlign: TextAlign.center, ), SizedBox( height: 60.0, ), Text( '© R O H I T K U M A R S I N G H', style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.w200), ), ], ), ), ], ), ), ], )); } } /**/
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/helper/data.dart
import 'package:samachar/Model/category_model.dart'; List<CategoryModel> getCategories() { List<CategoryModel> category = new List<CategoryModel>(); CategoryModel categoryModel = new CategoryModel(); //First model data // categoryModel.categoryName = 'General'; // categoryModel.imageURL = // 'https://images.unsplash.com/photo-1457369804613-52c61a468e7d?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80'; // category.add(categoryModel); // categoryModel = new CategoryModel(); //Second model data categoryModel.categoryName = 'Technology'; categoryModel.imageURL = 'https://images.unsplash.com/photo-1515879218367-8466d910aaa4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'; category.add(categoryModel); categoryModel = new CategoryModel(); //third model data categoryModel.categoryName = 'Entertainment'; categoryModel.imageURL = 'https://images.unsplash.com/photo-1470229722913-7c0e2dbbafd3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80'; category.add(categoryModel); categoryModel = new CategoryModel(); //forth model data categoryModel.categoryName = 'Health'; categoryModel.imageURL = 'https://images.unsplash.com/photo-1476480862126-209bfaa8edc8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'; category.add(categoryModel); categoryModel = new CategoryModel(); //fifth model data categoryModel.categoryName = 'Business'; categoryModel.imageURL = 'https://images.unsplash.com/photo-1480944657103-7fed22359e1d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=889&q=80'; category.add(categoryModel); categoryModel = new CategoryModel(); //sixth model data categoryModel.categoryName = 'Sports'; categoryModel.imageURL = 'https://images.unsplash.com/photo-1461896836934-ffe607ba8211?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'; category.add(categoryModel); categoryModel = new CategoryModel(); //seventh model data categoryModel.categoryName = 'Science'; categoryModel.imageURL = 'https://images.unsplash.com/photo-1507413245164-6160d8298b31?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'; category.add(categoryModel); categoryModel = new CategoryModel(); return category; }
0
mirrored_repositories/samachar/lib
mirrored_repositories/samachar/lib/helper/news_fetch.dart
import 'package:http/http.dart' as http; import 'dart:convert'; import 'package:samachar/Model/article_model.dart'; //SECTION FOR HOME NEWS class NewsFetch { List<ArticleModel> news = []; Future<void> getNews() async { String url = 'http://newsapi.org/v2/top-headlines?country=in&apiKey=10ccf053cfb143159c6285de1397e4a3'; var response = await http.get(url); var jsonData = jsonDecode(response.body); if (jsonData['status'] == "ok") { jsonData['articles'].forEach((element) { if (element['urlToImage'] != null && element['description'] != null) { ArticleModel articleModel = new ArticleModel( authorName: element['author'], title: element['title'], description: element['description'], url: element['url'], urlToImage: element['urlToImage'], content: element['content']); news.add(articleModel); } }); } } } //SECTION FOR CATEGORY NEWS class CategoryNewsClass { List<ArticleModel> news = []; Future<void> getNews(String category) async { String url = 'http://newsapi.org/v2/top-headlines?country=in&category=$category&apiKey=10ccf053cfb143159c6285de1397e4a3'; var response = await http.get(url); var jsonData = jsonDecode(response.body); if (jsonData['status'] == "ok") { jsonData['articles'].forEach((element) { if (element['urlToImage'] != null && element['description'] != null) { ArticleModel articleModel = new ArticleModel( authorName: element['author'], title: element['title'], description: element['description'], url: element['url'], urlToImage: element['urlToImage'], content: element['content']); news.add(articleModel); } }); } } }
0
mirrored_repositories/samachar
mirrored_repositories/samachar/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:samachar/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_click_more_counter
mirrored_repositories/flutter_click_more_counter/lib/flutter_click_more_counter.dart
library flutter_click_more_counter; import 'dart:async'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; /// A click counter that show message to tell the users that they need to click more to continue. /// The feature of this lib is the same as active the developer mode in Android devices. class ClickMoreCounter { /// reset value after [milliseconds] /// Default: 2000 milliseconds (2 seconds) final int resetCounterMilliseconds; /// total number of times needed to click /// Default: 10 final int totalClick; /// Number of times the message will be displayed /// Default: 5 final int displayMessageClick; /// counter click int counter = 0; Timer? _timer; ClickMoreCounter({ this.resetCounterMilliseconds = 2000, this.displayMessageClick = 5, this.totalClick = 10, }) : assert(totalClick > displayMessageClick, "totalClick must greater than displayMessageClick"); /// Increase [counter] every times user press. /// if [counter] is greater than [displayMessageClick], toast message will be shown. /// When [counter] = [totalClick], [action] will be call /// After [resetCounterMilliseconds], if no more press, [counter] will reset to 0 run(VoidCallback action, {ToastMessageText? messageText, bool showMessage = true}) { counter++; if (counter >= displayMessageClick) { if (counter == totalClick) { counter = 0; action(); return; } if (counter < totalClick) { int remainTimes = totalClick - counter; Fluttertoast.cancel(); Fluttertoast.showToast( msg: messageText != null ? messageText(remainTimes) : "Press more $remainTimes times to open developer menu", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, backgroundColor: const Color(0xFF818181), textColor: Colors.white, fontSize: 14); } } if (_timer?.isActive ?? false) _timer?.cancel(); _timer = Timer(Duration(milliseconds: resetCounterMilliseconds), () async { counter = 0; }); } } typedef ToastMessageText = String Function(int remainTimes);
0
mirrored_repositories/flutter_click_more_counter
mirrored_repositories/flutter_click_more_counter/test/flutter_click_more_counter_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_click_more_counter/flutter_click_more_counter.dart'; void main() { test('ClickMoreCounter test', () { final clickMoreCouter = ClickMoreCounter(); clickMoreCouter.run(() {}); expect(clickMoreCouter.counter, 1); }); }
0
mirrored_repositories/flutter_click_more_counter/example
mirrored_repositories/flutter_click_more_counter/example/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_click_more_counter/flutter_click_more_counter.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( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage(title: 'Flutter Click More Counter'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { final _clickCounter = ClickMoreCounter(); void onClick() { _clickCounter.run(() { showDialog( useSafeArea: false, context: context, builder: (BuildContext context) => const AlertDialog( title: Text("Flutter Click More Counter"), content: Text("Hello there"), )); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: const Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'Click the button more than 5 times', ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: onClick, tooltip: 'Click', child: const Icon(Icons.add), ), ); } }
0
mirrored_repositories/flutter_click_more_counter/example
mirrored_repositories/flutter_click_more_counter/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 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:example/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/encrypt_local_storage
mirrored_repositories/encrypt_local_storage/lib/encrypt_db.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ library encrypt_db; export 'src/core/encrypt_db_plugin.dart'; export 'src/model/encrypt_information_model.dart';
0
mirrored_repositories/encrypt_local_storage/lib/src
mirrored_repositories/encrypt_local_storage/lib/src/constants/app_constants.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ mixin AppConstants { static const CHANNEL_NAME = "com.swing.deb.encrypt_db"; // Method names static const METHOD_INITIATE = "METHOD_INITIATE"; static const METHOD_WRITE_DATA = "METHOD_WRITE_DATA"; static const METHOD_READ_DATA = "METHOD_READ_DATA"; static const METHOD_READ_ALL = "METHOD_READ_ALL"; static const METHOD_DELETE = "METHOD_DELETE"; static const METHOD_CLEAR_ALL = "METHOD_CLEAR_ALL"; }
0
mirrored_repositories/encrypt_local_storage/lib/src
mirrored_repositories/encrypt_local_storage/lib/src/model/encrypt_information_model.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ enum EncryptType { AES, RSA, DES } enum EncryptDbMode { SHARED_PREF, FILE_PREF } class EncryptInformationModel { final String? fileName; final int? version; final EncryptType? encryptType; final EncryptDbMode? encryptDbMode; EncryptInformationModel({ this.fileName, this.version, this.encryptType, this.encryptDbMode, }); Map<String, dynamic> toMap() { return { 'fileName': fileName, 'version': version, 'encryptType': encryptType?.name, 'encryptDbMode': encryptDbMode?.name, }; } factory EncryptInformationModel.fromMap( Map<String, dynamic> map) { return EncryptInformationModel( fileName: map['fileName'], version: map['version'], encryptType: EncryptType.values.firstWhere( (element) => element.name == map['encryptType']), encryptDbMode: EncryptDbMode.values.firstWhere( (element) => element.name == map['encryptDbMode']), ); } }
0
mirrored_repositories/encrypt_local_storage/lib/src
mirrored_repositories/encrypt_local_storage/lib/src/core/encrypt_db_plugin.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ import '../../encrypt_db.dart'; import 'encrypt_db_platform_interface.dart'; class EncryptDb { void initializeEncryptDb({ EncryptInformationModel? encryptInformationModel, }) async { EncryptDbPlatform.instance.initializeEncryptDb( encryptInformationModel: encryptInformationModel, ); } void write<T>({ required String key, required T value, }) { return EncryptDbPlatform.instance .write(key: key, value: value); } Future<dynamic> read<T>({ required String key, required T defaultValue, }) { return EncryptDbPlatform.instance .read(key: key, defaultValue: defaultValue); } Future<dynamic> readAll() { return EncryptDbPlatform.instance.readAll(); } Future<dynamic> clear({ required String key, }) { return EncryptDbPlatform.instance.clear(key: key); } Future<dynamic> clearAll() { return EncryptDbPlatform.instance.clearAll(); } }
0
mirrored_repositories/encrypt_local_storage/lib/src
mirrored_repositories/encrypt_local_storage/lib/src/core/encrypt_db_method_channel.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ import 'package:encrypt_db/src/constants/app_constants.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import '../../encrypt_db.dart'; import 'encrypt_db_platform_interface.dart'; class MethodChannelEncryptDb extends EncryptDbPlatform { @visibleForTesting final methodChannel = const MethodChannel(AppConstants.CHANNEL_NAME); @override Future<void> initializeEncryptDb({ EncryptInformationModel? encryptInformationModel, }) { final result = methodChannel.invokeMethod<void>( AppConstants.METHOD_INITIATE, { AppConstants.METHOD_INITIATE: encryptInformationModel?.toMap(), }, ); return result; } @override void write<T>({ required String key, required T value, }) async { await methodChannel.invokeMapMethod( AppConstants.METHOD_WRITE_DATA, { AppConstants.METHOD_WRITE_DATA: { 'key': key, 'value': value, } }, ); } @override Future<dynamic> read<T>({ required String key, required T defaultValue, }) async { final value = await methodChannel.invokeMethod( AppConstants.METHOD_READ_DATA, { AppConstants.METHOD_READ_DATA: { 'key': key, 'defaultValue': defaultValue, } }, ); return value; } @override Future<dynamic> readAll() { final result = methodChannel.invokeMethod( AppConstants.METHOD_READ_ALL, ); return result; } @override Future<dynamic> clear({required String key}) { final result = methodChannel.invokeMethod( AppConstants.METHOD_DELETE, { AppConstants.METHOD_DELETE: { 'key': key, } }, ); return result; } @override Future<dynamic> clearAll() { final result = methodChannel.invokeMethod( AppConstants.METHOD_CLEAR_ALL, ); return result; } }
0
mirrored_repositories/encrypt_local_storage/lib/src
mirrored_repositories/encrypt_local_storage/lib/src/core/encrypt_db_platform_interface.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ import 'package:encrypt_db/encrypt_db.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'encrypt_db_method_channel.dart'; abstract class EncryptDbPlatform extends PlatformInterface { /// Constructs a EncryptDbPlatform. EncryptDbPlatform() : super(token: _token); static final Object _token = Object(); static EncryptDbPlatform _instance = MethodChannelEncryptDb(); static EncryptDbPlatform get instance => _instance; static set instance(EncryptDbPlatform instance) { PlatformInterface.verifyToken(instance, _token); _instance = instance; } void initializeEncryptDb({ EncryptInformationModel? encryptInformationModel, }) async { throw UnimplementedError( 'initializeEncryptDb() has not been implemented.'); } void write<T>({ required String key, required T value, }) { throw UnimplementedError( 'writeData() has not been implemented.'); } Future<dynamic> read<T>({ required String key, required T defaultValue, }) { throw UnimplementedError( 'readData() has not been implemented.'); } Future<dynamic> readAll() { throw UnimplementedError( 'readAll() has not been implemented.'); } Future<dynamic> clear({ required String key, }) { throw UnimplementedError( 'delete() has not been implemented.'); } Future<dynamic> clearAll() { throw UnimplementedError( 'clearAll() has not been implemented.'); } }
0
mirrored_repositories/encrypt_local_storage/lib/src
mirrored_repositories/encrypt_local_storage/lib/src/utils/extensions.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ /// enum to string extension EnumToString on Enum { String get toName => toString().split('.').last; }
0
mirrored_repositories/encrypt_local_storage
mirrored_repositories/encrypt_local_storage/test/encrypt_db_method_channel_test.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ import 'package:dart_std/dart_std.dart'; import 'package:encrypt_db/src/constants/app_constants.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'encrypt_db_test.dart'; void main() { MockEncryptDbPlatform platform = MockEncryptDbPlatform(); const MethodChannel channel = MethodChannel(AppConstants.CHANNEL_NAME); TestWidgetsFlutterBinding.ensureInitialized(); setUp(() { channel.setMockMethodCallHandler( (MethodCall methodCall) async { switch (methodCall.method) { case AppConstants.METHOD_READ_ALL: return platform.readAll(); case AppConstants.METHOD_READ_DATA: return platform.read( key: methodCall.arguments['key'], defaultValue: methodCall.arguments['defaultValue']); case AppConstants.METHOD_WRITE_DATA: return platform.write( key: methodCall.arguments['key'], value: methodCall.arguments['value']); case AppConstants.METHOD_DELETE: return platform.clear( key: methodCall.arguments['key']); case AppConstants.METHOD_CLEAR_ALL: return platform.clearAll(); default: return; } }); }); test('positive read all data', () async { platform.write(key: 'key1', value: 'value1'); expect(await platform.readAll(), const Pair<String, dynamic>('key1', 'value1')); }); test('negative read all data', () async { platform.clearAll(); expect(await platform.readAll(), null); }); test('write data tests', () async { platform.write(key: 'key1', value: 'value1'); expect( await platform.read(key: 'key1', defaultValue: ''), 'value1'); }); test('clear specific key', () async { platform.write(key: 'key2', value: 'value2'); expect( await platform.read( key: 'key2', defaultValue: 'default'), 'value2'); await platform.clear(key: 'key2'); expect( await platform.read( key: 'key2', defaultValue: null), null); }); tearDown(() { channel.setMockMethodCallHandler(null); }); }
0
mirrored_repositories/encrypt_local_storage
mirrored_repositories/encrypt_local_storage/test/encrypt_db_test.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ import 'package:dart_std/dart_std.dart'; import 'package:encrypt_db/encrypt_db.dart'; import 'package:encrypt_db/src/core/encrypt_db_method_channel.dart'; import 'package:encrypt_db/src/core/encrypt_db_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; class MockEncryptDbPlatform with MockPlatformInterfaceMixin implements EncryptDbPlatform { Pair<String, dynamic>? _pairData = const Pair<String, dynamic>('', ''); @override void initializeEncryptDb({ EncryptInformationModel? encryptInformationModel, }) {} @override Future read<T>({ required String key, required T defaultValue, }) { return Future.value(_pairData?.second); } @override void write<T>({ required String key, required T value, }) { if (T == String) { _pairData = Pair(key, value as String); } else if (T == int) { _pairData = Pair(key, value as int); } else if (T == double) { _pairData = Pair(key, value as double); } else if (T == bool) { _pairData = Pair(key, value as bool); } } @override Future<dynamic> clearAll() { _pairData = null; return Future.value(_pairData); } @override Future<dynamic> clear({required String key}) { if (_pairData?.first == key) { _pairData = null; return Future.value(_pairData); } return Future.value(_pairData); } @override Future<dynamic> readAll() { if (_pairData?.first.isEmpty ?? false) { return Future.value(null); } return Future.value(_pairData); } } void main() { final EncryptDbPlatform initialPlatform = EncryptDbPlatform.instance; test('$MethodChannelEncryptDb is the default instance', () { expect(initialPlatform, isInstanceOf<MethodChannelEncryptDb>()); }); test('positive write test', () async { EncryptDb encryptDbPlugin = EncryptDb(); MockEncryptDbPlatform fakePlatform = MockEncryptDbPlatform(); EncryptDbPlatform.instance = fakePlatform; encryptDbPlugin.write(key: 'key', value: 'value1'); var data = await encryptDbPlugin.read( key: 'key', defaultValue: 'value'); expect(data, 'value1'); }); test('negative write test', () async {}); }
0
mirrored_repositories/encrypt_local_storage/example
mirrored_repositories/encrypt_local_storage/example/lib/main.dart
/* * * * * * MIT License * * ******************************************************************************************* * * * Created By Debojyoti Singha * * * Copyright (c) 2023. * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * * of this software and associated documentation files (the "Software"), to deal * * * in the Software without restriction, including without limitation the rights * * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * * copies of the Software, and to permit persons to whom the Software is * * * furnished to do so, subject to the following conditions: * * * * * * The above copyright notice and this permission notice shall be included in all * * * copies or substantial portions of the Software. * * * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * * * SOFTWARE. * * * Contact Email: [email protected] * * ****************************************************************************************** * */ import 'dart:async'; import 'package:encrypt_db/encrypt_db.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State<MyApp> createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { final _encryptDbPlugin = EncryptDb(); final Map<String, dynamic> _testPrintMap = <String, dynamic>{}; @override void initState() { super.initState(); initialDb(); } Future<void> initialDb() async { try { _encryptDbPlugin.initializeEncryptDb(); _encryptDbPlugin.write(key: 'key0', value: 452); } catch (e) { debugPrint('Error: $e'); } } void _runManualTest() async { try { var result = await _encryptDbPlugin.readAll(); debugPrint('result0: $result'); _testPrintMap['result0'] = result; await _encryptDbPlugin.clearAll(); debugPrint('Clear all'); result = await _encryptDbPlugin.readAll(); debugPrint('result1: $result'); _testPrintMap['result1'] = result; _encryptDbPlugin.write(key: 'key1', value: 'value1'); debugPrint('Write key1'); _testPrintMap['Write key1'] = 'Write key1'; result = await _encryptDbPlugin.read( key: 'key1', defaultValue: 'default_value'); debugPrint('result2: $result'); _testPrintMap['result2'] = result; _encryptDbPlugin.write(key: 'key2', value: 'value2'); debugPrint('Write key2'); _testPrintMap['Write key2'] = 'Write key2'; result = await _encryptDbPlugin.readAll(); debugPrint('result3: $result'); _testPrintMap['result3'] = result; _encryptDbPlugin.clear(key: 'key1'); debugPrint('Delete key1'); _testPrintMap['Delete key1'] = 'Delete key1'; result = await _encryptDbPlugin.readAll(); debugPrint('result4: $result'); _testPrintMap['result4'] = result; _encryptDbPlugin.clearAll(); debugPrint('Clear all'); _testPrintMap['Clear all'] = 'Clear all'; } catch (e) { debugPrint('Error: $e'); } finally { debugPrint('Test print map: $_testPrintMap'); setState(() {}); } } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Encrypt DB example app'), ), body: SafeArea( child: Column( children: [ ListView.builder( shrinkWrap: true, itemCount: _testPrintMap.length, itemBuilder: (BuildContext context, int index) { final key = _testPrintMap.keys.elementAt(index); final value = _testPrintMap[key]; return Container( margin: const EdgeInsets.all(8), child: Text('log: $key: $value'), ); }, ), ElevatedButton( onPressed: () async { _runManualTest(); }, child: const Text('Run Test'), ), ], ), ), ), ); } }
0
mirrored_repositories/flutter_isolate_example
mirrored_repositories/flutter_isolate_example/lib/flutter_isolate.dart
import 'dart:isolate'; import 'package:flutter/foundation.dart'; class FlutterIsolate { FlutterIsolate._internal(); static final FlutterIsolate _flutterIsolate = FlutterIsolate._internal(); factory FlutterIsolate() { return _flutterIsolate; } ///Receiver port on main isolate final receivePort = ReceivePort(); SendPort? sendPort; createIsolate() async { ///sending sendPort to new isolate to send messages back var sendData = <String, dynamic>{ 'send_port': receivePort.sendPort, }; ///creating isolate await Isolate.spawn<Map<String, dynamic>>(expensiveTask, sendData); ///listening to messages from new isolate receivePort.listen((message) { ///checking if the message is sendPort data if (message['is_port_data'] as bool) { sendPort = message['send_port'] as SendPort; } else { var taskName = message['task_name']; debugPrint('$taskName completed'); } }); } /// function that will send message to new isolate and do our task(printing the task name in our case) doExpensiveTask(String taskName) { if (sendPort != null) { var sendData = {'task_name': taskName}; sendPort!.send(sendData); } } } ///isolate entry point expensiveTask(Map<String, dynamic> data) { ///Receiver port of new isolate final receivePort = ReceivePort(); var sendProt = data['send_port'] as SendPort; var sendData = {'send_port': receivePort.sendPort, 'is_port_data': true}; ///sending sendPort to main isolate to send messages back sendProt.send(sendData); ///Listening to messages from main isolate receivePort.listen((message) { var taskName = message['task_name']; ///prints the task name debugPrint('$taskName printing in new isolate'); var sendData = {'is_port_data': false, 'task_name': taskName}; sendProt.send(sendData); }); }
0
mirrored_repositories/flutter_isolate_example
mirrored_repositories/flutter_isolate_example/lib/main.dart
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:isolate_example/flutter_isolate.dart'; void main() { FlutterIsolate().createIsolate(); 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( title: 'Flutter Isolate Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Isolate Demo'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton( onPressed: () { FlutterIsolate() .doExpensiveTask('taskName ${Random().nextInt(100)}'); }, child: const Text('Do expensive task')) ], ), ), ); } }
0
mirrored_repositories/flutter_isolate_example
mirrored_repositories/flutter_isolate_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 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:isolate_example/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/questionnaires
mirrored_repositories/questionnaires/lib/main.dart
import 'package:flutter/material.dart'; import 'package:questionnaires/configs/app_colors.dart'; import 'package:questionnaires/screens/home_screen.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( appBarTheme: AppBarTheme( elevation: 0, color: AppColors.green, ), scaffoldBackgroundColor: AppColors.green, cardColor: Colors.white, primaryColor: AppColors.green, accentColor: Colors.white, primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith(color: Colors.white), primaryTextTheme: TextTheme( title: TextStyle(color: Colors.white), body1: TextStyle(color: AppColors.darkgray), ), disabledColor: AppColors.lightgray, ), home: HomeScreen(), ); } }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/widgets/button.dart
import 'package:flutter/material.dart'; class Button extends StatelessWidget { final String buttonLabel; final Function onPressed; final bool isPrimary; Button.primary({ @required this.buttonLabel, @required this.onPressed, }) : isPrimary = true; Button.accent({ @required this.buttonLabel, @required this.onPressed, }) : isPrimary = false; @override Widget build(BuildContext context) { return RaisedButton( color: isPrimary ? Theme.of(context).primaryColor : Theme.of(context).accentColor, shape: isPrimary ? null : RoundedRectangleBorder( side: BorderSide( color: Theme.of(context).disabledColor, ), ), child: Text( buttonLabel, style: isPrimary ? TextStyle( fontWeight: FontWeight.w700, color: Theme.of(context).accentColor, ) : TextStyle( fontWeight: FontWeight.w700, ), ), onPressed: onPressed, ); } }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/models/interpretation.dart
import 'package:meta/meta.dart'; class Interpretation { final int score; final String text; Interpretation({ @required this.score, @required this.text, }); factory Interpretation.fromJson(Map<String, dynamic> json) => Interpretation( score: json['score'], text: json['text'], ); Map<String, dynamic> toJson() => { 'score': score, 'text': text, }; @override String toString() => toJson().toString(); }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/models/question.dart
import 'package:questionnaires/models/answer.dart'; import 'package:meta/meta.dart'; class Question { final String text; final List<Answer> answers; Question({ @required this.text, @required this.answers, }); factory Question.fromJson(Map<String, dynamic> json) => Question( text: json['text'], answers: List<Answer>.from(json['answers'].map((x) => Answer.fromJson(x))), ); Map<String, dynamic> toJson() => { 'text': text, 'answers': List<dynamic>.from(answers.map((x) => x.toJson())), }; @override String toString() => toJson().toString(); }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/models/answer.dart
import 'package:meta/meta.dart'; class Answer { final int score; final String text; Answer({ @required this.score, @required this.text, }); factory Answer.fromJson(Map<String, dynamic> json) => Answer( score: json['score'], text: json['text'], ); Map<String, dynamic> toJson() => { 'score': score, 'text': text, }; @override String toString() => toJson().toString(); }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/models/questionnaire.dart
import 'package:meta/meta.dart'; import 'package:questionnaires/models/interpretation.dart'; import 'package:questionnaires/models/question.dart'; class Questionnaire { final String name; final String instructions; final List<Question> questions; final List<Interpretation> interpretations; Questionnaire({ @required this.name, @required this.instructions, @required this.questions, @required this.interpretations, }); factory Questionnaire.fromJson(Map<String, dynamic> json) => Questionnaire( name: json['name'], instructions: json['instructions'], questions: List<Question>.from(json['questions'].map((x) => Question.fromJson(x))), interpretations: List<Interpretation>.from(json['interpretations'].map((x) => Interpretation.fromJson(x))), ); Map<String, dynamic> toJson() => { 'name': name, 'instructions': instructions, 'questions': List<dynamic>.from(questions.map((x) => x.toJson())), 'interpretations': List<dynamic>.from(interpretations.map((x) => x.toJson())), }; @override String toString() => toJson().toString(); }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/enums/questionnaire_type.dart
enum QuestionnaireType { satisfaction, }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/configs/app_colors.dart
import 'dart:ui'; class AppColors { static const green = const Color(0xff3ab098); static const lightgray = const Color(0xffcecfd1); static const darkgray = const Color(0xffadaeb0); }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/services/questionnaire_service.dart
import 'dart:convert'; import 'package:flutter/services.dart' show rootBundle; import 'package:questionnaires/enums/questionnaire_type.dart'; import 'package:questionnaires/models/questionnaire.dart'; class QuestionnaireService { String _getQuestionnaireAssetPath(QuestionnaireType questionnaireType) { switch (questionnaireType) { case QuestionnaireType.satisfaction: return 'assets/questionnaires/satisfaction_with_life_scale.json'; default: return null; } } Future<Questionnaire> getQuestionnaire(QuestionnaireType questionnaireType) async { final assetPath = _getQuestionnaireAssetPath(questionnaireType); final jsonData = await rootBundle.loadString(assetPath); final jsonDataDecoded = jsonDecode(jsonData); return Questionnaire.fromJson(jsonDataDecoded); } }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; import 'package:questionnaires/enums/questionnaire_type.dart'; import 'package:questionnaires/models/questionnaire.dart'; import 'package:questionnaires/screens/questionnaire_screen.dart'; import 'package:questionnaires/services/questionnaire_service.dart'; import 'package:questionnaires/widgets/button.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({Key key}) : super(key: key); @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { List<Questionnaire> questionnaires; Future<bool> loadAllQuestionnairesFuture; @override void initState() { super.initState(); loadAllQuestionnairesFuture = loadAllQuestionnaires(); } Future<bool> loadAllQuestionnaires() async { final questionnaireService = QuestionnaireService(); questionnaires = []; for (QuestionnaireType questionnaireType in QuestionnaireType.values) { final questionnaire = await questionnaireService.getQuestionnaire(questionnaireType); // if something went wrong, stop loading questionnaires if (questionnaire == null) { return false; } questionnaires.add(questionnaire); } return true; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( 'Questionnaires', ), ), body: FutureBuilder( future: loadAllQuestionnairesFuture, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData && snapshot.data == true) { return Center( child: Column( children: <Widget>[ for (Questionnaire questionnaire in questionnaires) Button.accent( buttonLabel: questionnaire.name, onPressed: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => QuestionnaireScreen( questionnaire: questionnaire, ), ), ), ) ], ), ); } else if (snapshot.hasError || (snapshot.connectionState == ConnectionState.done && snapshot.data == false)) { return AlertDialog( title: Text('Ooops something went wrong!'), actions: <Widget>[ FlatButton( child: Text('Try Again'), onPressed: () => setState(() { loadAllQuestionnairesFuture = loadAllQuestionnaires(); }), ) ], ); } else { return Center( child: CircularProgressIndicator(), ); } }, ), ); } }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/screens/result_screen.dart
import 'package:flutter/material.dart'; import 'package:questionnaires/widgets/button.dart'; class ResultScreen extends StatelessWidget { final String questionnaireName; final String interpretation; ResultScreen({@required this.questionnaireName, this.interpretation}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(questionnaireName), ), body: SafeArea( child: Center( child: LayoutBuilder( builder: (context, constraints) { return Container( width: constraints.maxWidth * 0.75, height: constraints.maxHeight * 0.5, child: Card( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 40.0, bottom: 20), child: Text( 'Your Result:', textAlign: TextAlign.center, style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal), ), ), Text( interpretation, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700), ), SizedBox(height: 20), Padding( padding: const EdgeInsets.only(bottom: 16.0), child: Button.primary( buttonLabel: 'Main Menu', onPressed: () => Navigator.of(context).pop(), ), ), ], // ), ), ); }, ), ), ), ); } }
0
mirrored_repositories/questionnaires/lib
mirrored_repositories/questionnaires/lib/screens/questionnaire_screen.dart
import 'package:dots_indicator/dots_indicator.dart'; import 'package:flutter/material.dart'; import 'package:grouped_buttons/grouped_buttons.dart'; import 'package:questionnaires/models/answer.dart'; import 'package:questionnaires/models/interpretation.dart'; import 'package:questionnaires/models/question.dart'; import 'package:questionnaires/models/questionnaire.dart'; import 'package:questionnaires/screens/result_screen.dart'; import 'package:questionnaires/widgets/button.dart'; class QuestionnaireScreen extends StatefulWidget { final Questionnaire questionnaire; QuestionnaireScreen({@required this.questionnaire}); @override _QuestionnaireScreenState createState() => _QuestionnaireScreenState(); } class _QuestionnaireScreenState extends State<QuestionnaireScreen> { List<Question> get questions => widget.questionnaire.questions; int questionIndex; Question get currentQuestion => questions[questionIndex]; int get numberOfQuestions => questions.length; List<int> chosenAnswers; bool get userHasAnsweredCurrentQuestion => chosenAnswers[questionIndex] != null; String get instructions => widget.questionnaire.instructions; String getResultInterpretation() { // calculate user's total score int result = 0; for (int index = 0; index < numberOfQuestions; index++) { Question question = questions[index]; int answerIndex = chosenAnswers[index]; Answer answer = question.answers[answerIndex]; int score = answer.score; result += score; } // determine interpretation for result List<Interpretation> interpretations = widget.questionnaire.interpretations; for (Interpretation interpretation in interpretations) { if (result >= interpretation.score) { return interpretation.text; } } // if something went wrong, return the worst interpretation return interpretations.last.text; } @override void initState() { super.initState(); questionIndex = 0; chosenAnswers = List<int>(numberOfQuestions); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.questionnaire.name), ), body: SafeArea( child: SingleChildScrollView( child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 20.0), child: Text( instructions, textAlign: TextAlign.justify, style: TextStyle( fontSize: 15, fontWeight: FontWeight.w500, color: Theme.of(context).accentColor, ), ), ), Padding( padding: const EdgeInsets.all(15.0), child: Card( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 16, ), Center( child: DotsIndicator( dotsCount: numberOfQuestions, position: questionIndex.toDouble(), decorator: DotsDecorator( size: Size.square(15), activeSize: Size(18, 18), activeColor: Theme.of(context).primaryColor, color: Theme.of(context).disabledColor, ), ), ), SizedBox( height: 24, ), Padding( padding: const EdgeInsets.only(left: 30.0, right: 8.0), child: Text( currentQuestion.text, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700), textAlign: TextAlign.left, ), ), SizedBox( height: 24, ), RadioButtonGroup( activeColor: Theme.of(context).primaryColor, labels: currentQuestion.answers.map((answer) => answer.text).toList(), onChange: (_, answerIndex) => setState(() { chosenAnswers[questionIndex] = answerIndex; }), picked: !userHasAnsweredCurrentQuestion ? "" : currentQuestion.answers[chosenAnswers[questionIndex]].text, ), SizedBox( height: 20, ), Padding( padding: const EdgeInsets.only(bottom: 20.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Visibility( visible: questionIndex != 0, child: Button.accent( buttonLabel: 'Back', onPressed: onBackButtonPressed, ), ), Button.primary( buttonLabel: 'Next', onPressed: userHasAnsweredCurrentQuestion ? onNextButtonPressed : null, ) ], ), ), ], ), ), ), ], ), ), ), ); } void onNextButtonPressed() { if (questionIndex < numberOfQuestions - 1) { setState(() { questionIndex++; }); } else { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => ResultScreen( questionnaireName: widget.questionnaire.name, interpretation: getResultInterpretation(), ), ), ); } } void onBackButtonPressed() { if (questionIndex > 0) { setState(() { questionIndex--; }); } } }
0
mirrored_repositories/flutterflow_ecommerce_app
mirrored_repositories/flutterflow_ecommerce_app/lib/app_state.dart
import 'package:flutter/material.dart'; import '/backend/backend.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'flutter_flow/flutter_flow_util.dart'; class FFAppState extends ChangeNotifier { static FFAppState _instance = FFAppState._internal(); factory FFAppState() { return _instance; } FFAppState._internal(); static void reset() { _instance = FFAppState._internal(); } Future initializePersistedState() async {} void update(VoidCallback callback) { callback(); notifyListeners(); } String _phoneNumber = ''; String get phoneNumber => _phoneNumber; set phoneNumber(String _value) { _phoneNumber = _value; } int _pageNumber = 1; int get pageNumber => _pageNumber; set pageNumber(int _value) { _pageNumber = _value; } bool _cartOpened = false; bool get cartOpened => _cartOpened; set cartOpened(bool _value) { _cartOpened = _value; } int _filterPriceLower = 0; int get filterPriceLower => _filterPriceLower; set filterPriceLower(int _value) { _filterPriceLower = _value; } int _filterPriceHigher = 8000; int get filterPriceHigher => _filterPriceHigher; set filterPriceHigher(int _value) { _filterPriceHigher = _value; } String _firterProductTypeId = '3IsjNApvCaUKWQyC0fl0'; String get firterProductTypeId => _firterProductTypeId; set firterProductTypeId(String _value) { _firterProductTypeId = _value; } List<String> _filterSizes = ['XS', 'M']; List<String> get filterSizes => _filterSizes; set filterSizes(List<String> _value) { _filterSizes = _value; } void addToFilterSizes(String _value) { _filterSizes.add(_value); } void removeFromFilterSizes(String _value) { _filterSizes.remove(_value); } void removeAtIndexFromFilterSizes(int _index) { _filterSizes.removeAt(_index); } void updateFilterSizesAtIndex( int _index, String Function(String) updateFn, ) { _filterSizes[_index] = updateFn(_filterSizes[_index]); } void insertAtIndexInFilterSizes(int _index, String _value) { _filterSizes.insert(_index, _value); } String _filterSortBy = ''; String get filterSortBy => _filterSortBy; set filterSortBy(String _value) { _filterSortBy = _value; } List<String> _filterBrands = []; List<String> get filterBrands => _filterBrands; set filterBrands(List<String> _value) { _filterBrands = _value; } void addToFilterBrands(String _value) { _filterBrands.add(_value); } void removeFromFilterBrands(String _value) { _filterBrands.remove(_value); } void removeAtIndexFromFilterBrands(int _index) { _filterBrands.removeAt(_index); } void updateFilterBrandsAtIndex( int _index, String Function(String) updateFn, ) { _filterBrands[_index] = updateFn(_filterBrands[_index]); } void insertAtIndexInFilterBrands(int _index, String _value) { _filterBrands.insert(_index, _value); } List<Color> _filterColors = []; List<Color> get filterColors => _filterColors; set filterColors(List<Color> _value) { _filterColors = _value; } void addToFilterColors(Color _value) { _filterColors.add(_value); } void removeFromFilterColors(Color _value) { _filterColors.remove(_value); } void removeAtIndexFromFilterColors(int _index) { _filterColors.removeAt(_index); } void updateFilterColorsAtIndex( int _index, Color Function(Color) updateFn, ) { _filterColors[_index] = updateFn(_filterColors[_index]); } void insertAtIndexInFilterColors(int _index, Color _value) { _filterColors.insert(_index, _value); } List<DocumentReference> _filterColorIds = []; List<DocumentReference> get filterColorIds => _filterColorIds; set filterColorIds(List<DocumentReference> _value) { _filterColorIds = _value; } void addToFilterColorIds(DocumentReference _value) { _filterColorIds.add(_value); } void removeFromFilterColorIds(DocumentReference _value) { _filterColorIds.remove(_value); } void removeAtIndexFromFilterColorIds(int _index) { _filterColorIds.removeAt(_index); } void updateFilterColorIdsAtIndex( int _index, DocumentReference Function(DocumentReference) updateFn, ) { _filterColorIds[_index] = updateFn(_filterColorIds[_index]); } void insertAtIndexInFilterColorIds(int _index, DocumentReference _value) { _filterColorIds.insert(_index, _value); } List<DocumentReference> _filterBrandIds = []; List<DocumentReference> get filterBrandIds => _filterBrandIds; set filterBrandIds(List<DocumentReference> _value) { _filterBrandIds = _value; } void addToFilterBrandIds(DocumentReference _value) { _filterBrandIds.add(_value); } void removeFromFilterBrandIds(DocumentReference _value) { _filterBrandIds.remove(_value); } void removeAtIndexFromFilterBrandIds(int _index) { _filterBrandIds.removeAt(_index); } void updateFilterBrandIdsAtIndex( int _index, DocumentReference Function(DocumentReference) updateFn, ) { _filterBrandIds[_index] = updateFn(_filterBrandIds[_index]); } void insertAtIndexInFilterBrandIds(int _index, DocumentReference _value) { _filterBrandIds.insert(_index, _value); } List<DocumentReference> _filterSizesIds = []; List<DocumentReference> get filterSizesIds => _filterSizesIds; set filterSizesIds(List<DocumentReference> _value) { _filterSizesIds = _value; } void addToFilterSizesIds(DocumentReference _value) { _filterSizesIds.add(_value); } void removeFromFilterSizesIds(DocumentReference _value) { _filterSizesIds.remove(_value); } void removeAtIndexFromFilterSizesIds(int _index) { _filterSizesIds.removeAt(_index); } void updateFilterSizesIdsAtIndex( int _index, DocumentReference Function(DocumentReference) updateFn, ) { _filterSizesIds[_index] = updateFn(_filterSizesIds[_index]); } void insertAtIndexInFilterSizesIds(int _index, DocumentReference _value) { _filterSizesIds.insert(_index, _value); } } LatLng? _latLngFromString(String? val) { if (val == null) { return null; } final split = val.split(','); final lat = double.parse(split.first); final lng = double.parse(split.last); return LatLng(lat, lng); } void _safeInit(Function() initializeField) { try { initializeField(); } catch (_) {} } Future _safeInitAsync(Function() initializeField) async { try { await initializeField(); } catch (_) {} } Color? _colorFromIntValue(int? val) { if (val == null) { return null; } return Color(val); }
0
mirrored_repositories/flutterflow_ecommerce_app
mirrored_repositories/flutterflow_ecommerce_app/lib/index.dart
// Export pages export '/login/get_started/get_started_widget.dart' show GetStartedWidget; export '/navigation/navigation/navigation_widget.dart' show NavigationWidget; export '/login/enter_phone/enter_phone_widget.dart' show EnterPhoneWidget; export '/login/o_t_p_code/o_t_p_code_widget.dart' show OTPCodeWidget; export '/category/category_page/category_page_widget.dart' show CategoryPageWidget; export '/category/filters/filters_widget.dart' show FiltersWidget; export '/product/porduct_page/porduct_page_widget.dart' show PorductPageWidget; export '/cart/cart_page/cart_page_widget.dart' show CartPageWidget; export '/check_out/check_out_page/check_out_page_widget.dart' show CheckOutPageWidget;
0
mirrored_repositories/flutterflow_ecommerce_app
mirrored_repositories/flutterflow_ecommerce_app/lib/main.dart
import 'package:provider/provider.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:firebase_core/firebase_core.dart'; import 'auth/firebase_auth/firebase_user_provider.dart'; import 'auth/firebase_auth/auth_util.dart'; import 'backend/firebase/firebase_config.dart'; import 'flutter_flow/flutter_flow_theme.dart'; import 'flutter_flow/flutter_flow_util.dart'; import 'flutter_flow/internationalization.dart'; import 'flutter_flow/nav/nav.dart'; import 'index.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); usePathUrlStrategy(); await initFirebase(); final appState = FFAppState(); // Initialize FFAppState await appState.initializePersistedState(); runApp(ChangeNotifierProvider( create: (context) => appState, child: MyApp(), )); } class MyApp extends StatefulWidget { // This widget is the root of your application. @override State<MyApp> createState() => _MyAppState(); static _MyAppState of(BuildContext context) => context.findAncestorStateOfType<_MyAppState>()!; } class _MyAppState extends State<MyApp> { Locale? _locale; ThemeMode _themeMode = ThemeMode.system; late Stream<BaseAuthUser> userStream; late AppStateNotifier _appStateNotifier; late GoRouter _router; final authUserSub = authenticatedUserStream.listen((_) {}); @override void initState() { super.initState(); _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); userStream = myShopFlutterFlowFirebaseUserStream() ..listen((user) => _appStateNotifier.update(user)); jwtTokenStream.listen((_) {}); Future.delayed( Duration(milliseconds: 1000), () => _appStateNotifier.stopShowingSplashImage(), ); } @override void dispose() { authUserSub.cancel(); super.dispose(); } void setLocale(String language) { setState(() => _locale = createLocale(language)); } void setThemeMode(ThemeMode mode) => setState(() { _themeMode = mode; }); @override Widget build(BuildContext context) { return MaterialApp.router( title: 'MyShop FlutterFlow', localizationsDelegates: [ FFLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], locale: _locale, supportedLocales: const [Locale('en', '')], theme: ThemeData( brightness: Brightness.light, scrollbarTheme: ScrollbarThemeData(), ), themeMode: _themeMode, routerConfig: _router, ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_item/cart_item_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/instant_timer.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'cart_item_model.dart'; export 'cart_item_model.dart'; class CartItemWidget extends StatefulWidget { const CartItemWidget({ Key? key, required this.isLast, required this.image, required this.text, required this.price, required this.onAddTap, required this.onRemoveTap, }) : super(key: key); final bool? isLast; final String? image; final String? text; final double? price; final Future<dynamic> Function()? onAddTap; final Future<dynamic> Function()? onRemoveTap; @override _CartItemWidgetState createState() => _CartItemWidgetState(); } class _CartItemWidgetState extends State<CartItemWidget> { late CartItemModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CartItemModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Builder( builder: (context) { if (widget.isLast ?? false) { return Container( width: double.infinity, height: 120.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 12.0, 0.0), child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.network( widget.image!, width: 80.0, height: 80.0, fit: BoxFit.contain, ), ), ), Container( width: 200.0, decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 16.0, 0.0, 16.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( flex: 1, child: Text( widget.text!, maxLines: 3, style: FlutterFlowTheme.of(context).bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 6.0, 0.0, 0.0), child: Text( '\$${widget.price?.toString()}', style: FlutterFlowTheme.of(context).bodyMedium, ), ), ], ), ), ), Align( alignment: AlignmentDirectional(1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { _model.instantTimer = InstantTimer.periodic( duration: Duration(milliseconds: 1000), callback: (timer) async {}, startImmediately: true, ); }, child: Icon( Icons.add_circle_outline_sharp, color: FlutterFlowTheme.of(context) .primaryBackground, size: 26.0, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 4.0, 0.0, 4.0), child: Text( '1', style: FlutterFlowTheme.of(context).bodyMedium, ), ), Icon( Icons.remove_circle_outline_outlined, color: FlutterFlowTheme.of(context).primaryBackground, size: 26.0, ), ], ), ), ), ], ), ), ); } else { return Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 1.0), child: Container( width: double.infinity, height: 120.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 12.0, 0.0), child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.network( widget.image!, width: 80.0, height: 80.0, fit: BoxFit.contain, ), ), ), Container( width: 200.0, decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 16.0, 0.0, 16.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( flex: 1, child: Text( widget.text!, maxLines: 3, style: FlutterFlowTheme.of(context).bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 6.0, 0.0, 0.0), child: Text( '\$${widget.price?.toString()}', style: FlutterFlowTheme.of(context).bodyMedium, ), ), ], ), ), ), Align( alignment: AlignmentDirectional(1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.add_circle_outline_sharp, color: FlutterFlowTheme.of(context) .primaryBackground, size: 26.0, ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 4.0, 0.0, 4.0), child: Text( '1', style: FlutterFlowTheme.of(context).bodyMedium, ), ), Icon( Icons.remove_circle_outline_outlined, color: FlutterFlowTheme.of(context) .primaryBackground, size: 26.0, ), ], ), ), ), ], ), ), ), ); } }, ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_item/cart_item_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/instant_timer.dart'; import 'cart_item_widget.dart' show CartItemWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CartItemModel extends FlutterFlowModel<CartItemWidget> { /// State fields for stateful widgets in this component. InstantTimer? instantTimer; /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() { instantTimer?.cancel(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_app_bar/cart_app_bar_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'cart_app_bar_model.dart'; export 'cart_app_bar_model.dart'; class CartAppBarWidget extends StatefulWidget { const CartAppBarWidget({ Key? key, required this.cartDoc, }) : super(key: key); final CartRecord? cartDoc; @override _CartAppBarWidgetState createState() => _CartAppBarWidgetState(); } class _CartAppBarWidgetState extends State<CartAppBarWidget> { late CartAppBarModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CartAppBarModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Align( alignment: AlignmentDirectional(0.0, -1.0), child: Container( width: double.infinity, height: 44.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).primary, FlutterFlowTheme.of(context).secondary ], stops: [0.0, 1.0], begin: AlignmentDirectional(-1.0, 0.0), end: AlignmentDirectional(1.0, 0), ), ), child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { context.safePop(); }, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: SvgPicture.asset( 'assets/images/back.svg', width: 24.0, height: 24.0, fit: BoxFit.scaleDown, ), ), ), Expanded( child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0), child: Text( 'Cart', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 19.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ), InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { setState(() { _model.cartItemsAmmount = widget.cartDoc?.content?.length; }); await widget.cartDoc!.reference.update({ ...createCartRecordData( price: 0.0, ), ...mapToFirestore( { 'content': FieldValue.delete(), }, ), }); _model.cartItems = await queryCartContentRecordOnce( queryBuilder: (cartContentRecord) => cartContentRecord.where( 'cart_id', isEqualTo: widget.cartDoc?.reference.id, ), ); while ( _model.currentIteration! < _model.cartItemsAmmount!) { await _model .cartItems![_model.currentIteration!].reference .delete(); setState(() { _model.currentIteration = _model.currentIteration! + 1; }); } setState(() {}); }, child: Text( 'Delete', style: FlutterFlowTheme.of(context).titleSmall, ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_app_bar/cart_app_bar_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'cart_app_bar_widget.dart' show CartAppBarWidget; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CartAppBarModel extends FlutterFlowModel<CartAppBarWidget> { /// Local state fields for this component. int? cartItemsAmmount; int? currentIteration = 0; /// State fields for stateful widgets in this component. // Stores action output result for [Firestore Query - Query a collection] action in Text widget. List<CartContentRecord>? cartItems; /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_bottom_bar/cart_bottom_bar_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'cart_bottom_bar_widget.dart' show CartBottomBarWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CartBottomBarModel extends FlutterFlowModel<CartBottomBarWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_bottom_bar/cart_bottom_bar_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'cart_bottom_bar_model.dart'; export 'cart_bottom_bar_model.dart'; class CartBottomBarWidget extends StatefulWidget { const CartBottomBarWidget({ Key? key, required this.totalPrice, }) : super(key: key); final double? totalPrice; @override _CartBottomBarWidgetState createState() => _CartBottomBarWidgetState(); } class _CartBottomBarWidgetState extends State<CartBottomBarWidget> { late CartBottomBarModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CartBottomBarModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Material( color: Colors.transparent, elevation: 3.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Container( width: double.infinity, height: 131.0, constraints: BoxConstraints( maxHeight: 131.0, ), decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: 40.0, constraints: BoxConstraints( maxHeight: 110.0, ), decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Text( 'Total price', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17.0, ), ), ), Flexible( child: Text( '\$${formatNumber( widget.totalPrice, formatType: FormatType.custom, format: '##0.00', locale: '', )}', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17.0, ), ), ), ], ), ), ), ), Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 0.0), child: FFButtonWidget( onPressed: () async { context.pushNamed('CheckOutPage'); }, text: 'Check Out ', options: FFButtonOptions( width: double.infinity, height: 40.0, padding: EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'SF Pro Display', color: Colors.white, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_page/cart_page_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/cart/cart_app_bar/cart_app_bar_widget.dart'; import '/cart/cart_bottom_bar/cart_bottom_bar_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'cart_page_model.dart'; export 'cart_page_model.dart'; class CartPageWidget extends StatefulWidget { const CartPageWidget({Key? key}) : super(key: key); @override _CartPageWidgetState createState() => _CartPageWidgetState(); } class _CartPageWidgetState extends State<CartPageWidget> { late CartPageModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => CartPageModel()); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: Color(0xFFF4F3F4), appBar: FFAppState().pageNumber != 4 ? AppBar( automaticallyImplyLeading: false, actions: [], flexibleSpace: FlexibleSpaceBar( background: Container( width: 100.0, height: 100.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).primary, FlutterFlowTheme.of(context).secondary ], stops: [0.0, 1.0], begin: AlignmentDirectional(-1.0, 0.0), end: AlignmentDirectional(1.0, 0), ), ), ), ), centerTitle: false, elevation: 0.0, ) : null, body: Container( decoration: BoxDecoration(), child: Stack( children: [ Column( mainAxisSize: MainAxisSize.max, children: [ StreamBuilder<List<CartRecord>>( stream: queryCartRecord( queryBuilder: (cartRecord) => cartRecord.where( 'user_id', isEqualTo: currentUserUid, ), singleRecord: true, ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<CartRecord> cartAppBarCartRecordList = snapshot.data!; // Return an empty Container when the item does not exist. if (snapshot.data!.isEmpty) { return Container(); } final cartAppBarCartRecord = cartAppBarCartRecordList.isNotEmpty ? cartAppBarCartRecordList.first : null; return wrapWithModel( model: _model.cartAppBarModel, updateCallback: () => setState(() {}), child: CartAppBarWidget( cartDoc: cartAppBarCartRecord!, ), ); }, ), StreamBuilder<List<CartRecord>>( stream: queryCartRecord( queryBuilder: (cartRecord) => cartRecord.where( 'user_id', isEqualTo: currentUserUid, ), singleRecord: true, ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<CartRecord> containerCartRecordList = snapshot.data!; // Return an empty Container when the item does not exist. if (snapshot.data!.isEmpty) { return Container(); } final containerCartRecord = containerCartRecordList.isNotEmpty ? containerCartRecordList.first : null; return Container( height: 700.0, decoration: BoxDecoration(), child: StreamBuilder<List<CartContentRecord>>( stream: queryCartContentRecord( queryBuilder: (cartContentRecord) => cartContentRecord.where( 'cart_id', isEqualTo: containerCartRecord?.reference.id, ), ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<CartContentRecord> listViewCartContentRecordList = snapshot.data!; return ListView.builder( padding: EdgeInsets.fromLTRB( 0, 0, 0, 200.0, ), shrinkWrap: true, scrollDirection: Axis.vertical, itemCount: listViewCartContentRecordList.length, itemBuilder: (context, listViewIndex) { final listViewCartContentRecord = listViewCartContentRecordList[ listViewIndex]; return Builder( builder: (context) { if (listViewIndex > listViewCartContentRecord.ammount) { return Container( width: double.infinity, height: 120.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context) .secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 0.0, 12.0, 0.0), child: ClipRRect( borderRadius: BorderRadius.circular( 8.0), child: Image.network( listViewCartContentRecord .image, width: 80.0, height: 80.0, fit: BoxFit.contain, ), ), ), Container( width: 200.0, decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 16.0, 0.0, 16.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment .center, crossAxisAlignment: CrossAxisAlignment .start, children: [ Flexible( flex: 1, child: Text( listViewCartContentRecord .text, maxLines: 3, style: FlutterFlowTheme .of(context) .bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 6.0, 0.0, 0.0), child: Text( '\$${listViewCartContentRecord.price.toString()}', style: FlutterFlowTheme .of(context) .bodyMedium, ), ), ], ), ), ), Align( alignment: AlignmentDirectional( 1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional .fromSTEB( 12.0, 0.0, 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment .center, children: [ InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { await listViewCartContentRecord .reference .update({ ...mapToFirestore( { 'ammount': FieldValue .increment( 1), }, ), }); await containerCartRecord! .reference .update({ ...mapToFirestore( { 'price': FieldValue .increment( listViewCartContentRecord .price), }, ), }); }, child: Icon( Icons .add_circle_outline_sharp, color: FlutterFlowTheme .of(context) .primaryBackground, size: 26.0, ), ), Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 4.0, 0.0, 4.0), child: Text( listViewCartContentRecord .ammount .toString(), style: FlutterFlowTheme .of(context) .bodyMedium, ), ), InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { if (listViewCartContentRecord .ammount == 1) { await containerCartRecord! .reference .update({ ...mapToFirestore( { 'price': FieldValue .increment( -(listViewCartContentRecord .price)), 'content': FieldValue .arrayRemove([ listViewCartContentRecord .reference ]), }, ), }); await listViewCartContentRecord .reference .delete(); } else { await containerCartRecord! .reference .update({ ...mapToFirestore( { 'price': FieldValue .increment( -(listViewCartContentRecord .price)), }, ), }); await listViewCartContentRecord .reference .update({ ...mapToFirestore( { 'ammount': FieldValue .increment( -(1)), }, ), }); } }, child: Icon( Icons .remove_circle_outline_outlined, color: FlutterFlowTheme .of(context) .primaryBackground, size: 26.0, ), ), ], ), ), ), ], ), ), ); } else { return Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 1.0), child: Container( width: double.infinity, height: 120.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context) .secondaryBackground, ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 0.0, 12.0, 0.0), child: ClipRRect( borderRadius: BorderRadius.circular( 8.0), child: Image.network( listViewCartContentRecord .image, width: 80.0, height: 80.0, fit: BoxFit.contain, ), ), ), Container( width: 200.0, decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional .fromSTEB(0.0, 16.0, 0.0, 16.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment .center, crossAxisAlignment: CrossAxisAlignment .start, children: [ Flexible( flex: 1, child: Text( listViewCartContentRecord .text, maxLines: 3, style: FlutterFlowTheme .of(context) .bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 6.0, 0.0, 0.0), child: Text( '\$${listViewCartContentRecord.price.toString()}', style: FlutterFlowTheme .of(context) .bodyMedium, ), ), ], ), ), ), Align( alignment: AlignmentDirectional( 1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional .fromSTEB(12.0, 0.0, 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment .center, children: [ InkWell( splashColor: Colors .transparent, focusColor: Colors .transparent, hoverColor: Colors .transparent, highlightColor: Colors .transparent, onTap: () async { await listViewCartContentRecord .reference .update({ ...mapToFirestore( { 'ammount': FieldValue .increment( 1), }, ), }); await containerCartRecord! .reference .update({ ...mapToFirestore( { 'price': FieldValue .increment( listViewCartContentRecord .price), }, ), }); }, child: Icon( Icons .add_circle_outline_sharp, color: FlutterFlowTheme .of(context) .primaryBackground, size: 26.0, ), ), Padding( padding: EdgeInsetsDirectional .fromSTEB( 0.0, 4.0, 0.0, 4.0), child: Text( listViewCartContentRecord .ammount .toString(), style: FlutterFlowTheme .of(context) .bodyMedium, ), ), InkWell( splashColor: Colors .transparent, focusColor: Colors .transparent, hoverColor: Colors .transparent, highlightColor: Colors .transparent, onTap: () async { if (listViewCartContentRecord .ammount == 1) { await containerCartRecord! .reference .update({ ...mapToFirestore( { 'price': FieldValue.increment( -(listViewCartContentRecord .price)), 'content': FieldValue .arrayRemove([ listViewCartContentRecord .reference ]), }, ), }); await listViewCartContentRecord .reference .delete(); } else { await containerCartRecord! .reference .update({ ...mapToFirestore( { 'price': FieldValue.increment( -(listViewCartContentRecord .price)), }, ), }); await listViewCartContentRecord .reference .update({ ...mapToFirestore( { 'ammount': FieldValue .increment( -(1)), }, ), }); } }, child: Icon( Icons .remove_circle_outline_outlined, color: FlutterFlowTheme .of(context) .primaryBackground, size: 26.0, ), ), ], ), ), ), ], ), ), ), ); } }, ); }, ); }, ), ); }, ), ], ), Align( alignment: AlignmentDirectional(0.0, 1.0), child: StreamBuilder<List<CartRecord>>( stream: queryCartRecord( queryBuilder: (cartRecord) => cartRecord.where( 'user_id', isEqualTo: currentUserUid, ), singleRecord: true, ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<CartRecord> cartBottomBarCartRecordList = snapshot.data!; // Return an empty Container when the item does not exist. if (snapshot.data!.isEmpty) { return Container(); } final cartBottomBarCartRecord = cartBottomBarCartRecordList.isNotEmpty ? cartBottomBarCartRecordList.first : null; return wrapWithModel( model: _model.cartBottomBarModel, updateCallback: () => setState(() {}), child: CartBottomBarWidget( totalPrice: cartBottomBarCartRecord!.price, ), ); }, ), ), ], ), ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/cart
mirrored_repositories/flutterflow_ecommerce_app/lib/cart/cart_page/cart_page_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/cart/cart_app_bar/cart_app_bar_widget.dart'; import '/cart/cart_bottom_bar/cart_bottom_bar_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'cart_page_widget.dart' show CartPageWidget; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CartPageModel extends FlutterFlowModel<CartPageWidget> { /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); // Model for CartAppBar component. late CartAppBarModel cartAppBarModel; // Model for CartBottomBar component. late CartBottomBarModel cartBottomBarModel; /// Initialization and disposal methods. void initState(BuildContext context) { cartAppBarModel = createModel(context, () => CartAppBarModel()); cartBottomBarModel = createModel(context, () => CartBottomBarModel()); } void dispose() { unfocusNode.dispose(); cartAppBarModel.dispose(); cartBottomBarModel.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib
mirrored_repositories/flutterflow_ecommerce_app/lib/components/product_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'product_widget.dart' show ProductWidget; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class ProductModel extends FlutterFlowModel<ProductWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib
mirrored_repositories/flutterflow_ecommerce_app/lib/components/product_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'product_model.dart'; export 'product_model.dart'; class ProductWidget extends StatefulWidget { const ProductWidget({ Key? key, int? discount, required this.image, this.raiting, required this.title, required this.price, double? discountPrice, required this.isFavorite, required this.docRef, required this.doc, }) : this.discount = discount ?? 0, this.discountPrice = discountPrice ?? 0.0, super(key: key); final int discount; final String? image; final int? raiting; final String? title; final double? price; final double discountPrice; final bool? isFavorite; final DocumentReference? docRef; final ProductsRecord? doc; @override _ProductWidgetState createState() => _ProductWidgetState(); } class _ProductWidgetState extends State<ProductWidget> { late ProductModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => ProductModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { context.pushNamed( 'PorductPage', queryParameters: { 'product': serializeParam( widget.doc, ParamType.Document, ), }.withoutNulls, extra: <String, dynamic>{ 'product': widget.doc, }, ); }, child: Container( decoration: BoxDecoration(), child: Column( mainAxisSize: MainAxisSize.min, children: [ Stack( alignment: AlignmentDirectional(0.0, 1.0), children: [ Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 163.0, height: 163.0, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: Image.network( widget.image!, ).image, ), borderRadius: BorderRadius.circular(8.0), ), child: Visibility( visible: widget.discount > 0, child: Align( alignment: AlignmentDirectional(-1.0, -1.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 8.0, 0.0, 0.0), child: Container( width: 47.0, height: 20.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color(0xFFD23A3A), Color(0xFFF49763) ], stops: [0.0, 1.0], begin: AlignmentDirectional(-1.0, 0.0), end: AlignmentDirectional(1.0, 0), ), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(40.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(40.0), ), shape: BoxShape.rectangle, ), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Text( '-${widget.discount.toString()}%', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 11.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 8.0, 0.0, 0.0), child: RatingBarIndicator( itemBuilder: (context, index) => Icon( Icons.star_rounded, color: FlutterFlowTheme.of(context).accent2, ), direction: Axis.horizontal, rating: widget.raiting!.toDouble(), unratedColor: FlutterFlowTheme.of(context).alternate, itemCount: 5, itemSize: 9.0, ), ), ], ), Align( alignment: AlignmentDirectional(1.0, 1.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 8.0, 0.0), child: Container( width: 36.0, height: 36.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, boxShadow: [ BoxShadow( blurRadius: 12.0, color: Color(0x1434283E), offset: Offset(0.0, 4.0), ) ], shape: BoxShape.circle, ), child: Builder( builder: (context) { if (widget.isFavorite ?? false) { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { await widget.docRef!.update({ ...mapToFirestore( { 'in_favorites': FieldValue.arrayRemove( [currentUserUid]), }, ), }); }, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: SvgPicture.asset( 'assets/images/favorite_on.svg', width: 20.0, height: 20.0, fit: BoxFit.scaleDown, ), ), ); } else { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { await widget.docRef!.update({ ...mapToFirestore( { 'in_favorites': FieldValue.arrayUnion( [currentUserUid]), }, ), }); }, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: SvgPicture.asset( 'assets/images/favorite_off.svg', width: 20.0, height: 20.0, fit: BoxFit.scaleDown, ), ), ); } }, ), ), ), ), ], ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 8.0, 0.0, 0.0), child: Text( widget.title!, maxLines: 2, style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Text', useGoogleFonts: false, ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 8.0, 0.0, 0.0), child: Builder( builder: (context) { if (widget.discountPrice == 0) { return Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Text( '\$${widget.price?.toString()}', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Text', fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ); } else { return Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( '\$${widget.discountPrice.toString()}', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context).accent3, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 4.0, 0.0, 0.0, 0.0), child: Text( '\$${widget.price?.toString()}', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .primaryBackground, decoration: TextDecoration.lineThrough, useGoogleFonts: false, ), ), ), ], ); } }, ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/login
mirrored_repositories/flutterflow_ecommerce_app/lib/login/o_t_p_code/o_t_p_code_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'o_t_p_code_model.dart'; export 'o_t_p_code_model.dart'; class OTPCodeWidget extends StatefulWidget { const OTPCodeWidget({Key? key}) : super(key: key); @override _OTPCodeWidgetState createState() => _OTPCodeWidgetState(); } class _OTPCodeWidgetState extends State<OTPCodeWidget> { late OTPCodeModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => OTPCodeModel()); authManager.handlePhoneAuthStateChanges(context); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).secondaryBackground, body: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: double.infinity, height: 197.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).secondary, FlutterFlowTheme.of(context).primary ], stops: [0.0, 1.0], begin: AlignmentDirectional(1.0, 0.0), end: AlignmentDirectional(-1.0, 0), ), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(300.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), ), child: Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 32.0, 0.0), child: Text( 'Verification Code', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 25.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(24.0, 33.0, 24.0, 0.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Text( 'Please enter Code sent to', textAlign: TextAlign.start, style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context).secondaryText, fontSize: 17.0, useGoogleFonts: false, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 8.0, 0.0, 36.0), child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( child: Text( FFAppState().phoneNumber, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .primaryText, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { context.goNamed('EnterPhone'); }, child: Text( 'Change Phone Number', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .primaryText, fontSize: 12.0, decoration: TextDecoration.underline, useGoogleFonts: false, ), ), ), ], ), ), PinCodeTextField( autoDisposeControllers: false, appContext: context, length: 6, textStyle: FlutterFlowTheme.of(context) .bodyLarge .override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context).secondaryText, fontSize: 25.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), mainAxisAlignment: MainAxisAlignment.spaceEvenly, enableActiveFill: false, autoFocus: false, enablePinAutofill: false, errorTextSpace: 16.0, showCursor: true, cursorColor: FlutterFlowTheme.of(context).primary, obscureText: false, keyboardType: TextInputType.number, pinTheme: PinTheme( fieldHeight: 42.0, fieldWidth: 48.0, borderWidth: 2.0, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), shape: PinCodeFieldShape.underline, activeColor: Color(0xFF46AB62), inactiveColor: FlutterFlowTheme.of(context).alternate, selectedColor: FlutterFlowTheme.of(context).primary, activeFillColor: Color(0xFF46AB62), inactiveFillColor: FlutterFlowTheme.of(context).alternate, selectedFillColor: FlutterFlowTheme.of(context).primary, ), controller: _model.pinCodeController, onChanged: (_) {}, autovalidateMode: AutovalidateMode.onUserInteraction, validator: _model.pinCodeControllerValidator .asValidator(context), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 26.0, 0.0, 8.0), child: FFButtonWidget( onPressed: () async { GoRouter.of(context).prepareAuthEvent(); final smsCodeVal = _model.pinCodeController!.text; if (smsCodeVal == null || smsCodeVal.isEmpty) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('Enter SMS verification code.'), ), ); return; } final phoneVerifiedUser = await authManager.verifySmsCode( context: context, smsCode: smsCodeVal, ); if (phoneVerifiedUser == null) { return; } context.pushNamedAuth('Navigation', context.mounted); }, text: 'Verify Code', options: FFButtonOptions( width: double.infinity, height: 64.0, padding: EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), Padding( padding: EdgeInsets.all(16.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { final phoneNumberVal = FFAppState().phoneNumber; if (phoneNumberVal == null || phoneNumberVal.isEmpty || !phoneNumberVal.startsWith('+')) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( 'Phone Number is required and has to start with +.'), ), ); return; } await authManager.beginPhoneAuth( context: context, phoneNumber: phoneNumberVal, onCodeSent: (context) async { context.goNamedAuth( 'OTPCode', context.mounted, ignoreRedirect: true, ); }, ); }, child: Text( 'Resend Code', textAlign: TextAlign.center, style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .primaryBackground, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ], ), ), ], ), ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/login
mirrored_repositories/flutterflow_ecommerce_app/lib/login/o_t_p_code/o_t_p_code_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'o_t_p_code_widget.dart' show OTPCodeWidget; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class OTPCodeModel extends FlutterFlowModel<OTPCodeWidget> { /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); // State field(s) for PinCode widget. TextEditingController? pinCodeController; String? Function(BuildContext, String?)? pinCodeControllerValidator; /// Initialization and disposal methods. void initState(BuildContext context) { pinCodeController = TextEditingController(); } void dispose() { unfocusNode.dispose(); pinCodeController?.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/login
mirrored_repositories/flutterflow_ecommerce_app/lib/login/get_started/get_started_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'get_started_model.dart'; export 'get_started_model.dart'; class GetStartedWidget extends StatefulWidget { const GetStartedWidget({Key? key}) : super(key: key); @override _GetStartedWidgetState createState() => _GetStartedWidgetState(); } class _GetStartedWidgetState extends State<GetStartedWidget> { late GetStartedModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => GetStartedModel()); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, body: Stack( children: [ Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.7, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: Image.asset( 'assets/images/get_started_background_animated.gif', ).image, ), ), child: Container( width: 100.0, height: 100.0, decoration: BoxDecoration( color: Color(0x4D2A034B), ), ), ), Align( alignment: AlignmentDirectional(0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.end, children: [ Align( alignment: AlignmentDirectional(1.0, 0.0), child: Container( width: MediaQuery.sizeOf(context).width * 0.7, height: 146.0, decoration: BoxDecoration( color: Color(0xB2E7B944), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(300.0), topRight: Radius.circular(0.0), ), ), ), ), Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.25, decoration: BoxDecoration(), ), ], ), ), Align( alignment: AlignmentDirectional(0.0, 1.0), child: Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.35, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).secondary, FlutterFlowTheme.of(context).primary ], stops: [0.0, 1.0], begin: AlignmentDirectional(1.0, 0.0), end: AlignmentDirectional(-1.0, 0), ), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(40.0), topRight: Radius.circular(40.0), ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(32.0, 28.0, 32.0, 32.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ RichText( textScaleFactor: MediaQuery.of(context).textScaleFactor, text: TextSpan( children: [ TextSpan( text: 'My', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Montserrat', color: FlutterFlowTheme.of(context).accent1, fontSize: 31.0, fontWeight: FontWeight.w800, ), ), TextSpan( text: 'Shop', style: GoogleFonts.getFont( 'Montserrat', color: FlutterFlowTheme.of(context) .secondaryBackground, fontWeight: FontWeight.w800, fontSize: 31.0, ), ) ], style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', letterSpacing: 2.0, useGoogleFonts: false, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 24.0, 0.0, 32.0), child: Text( 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', textAlign: TextAlign.center, style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryBackground, useGoogleFonts: false, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 34.0, 0.0, 34.0, 0.0), child: FFButtonWidget( onPressed: () async { context.goNamed('EnterPhone'); }, text: 'Get Started', options: FFButtonOptions( width: double.infinity, height: 48.0, padding: EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), ], ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/login
mirrored_repositories/flutterflow_ecommerce_app/lib/login/get_started/get_started_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'get_started_widget.dart' show GetStartedWidget; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class GetStartedModel extends FlutterFlowModel<GetStartedWidget> { /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() { unfocusNode.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/login
mirrored_repositories/flutterflow_ecommerce_app/lib/login/enter_phone/enter_phone_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/flutter_flow/flutter_flow_drop_down.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import '/flutter_flow/form_field_controller.dart'; import '/flutter_flow/custom_functions.dart' as functions; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; import 'package:provider/provider.dart'; import 'enter_phone_model.dart'; export 'enter_phone_model.dart'; class EnterPhoneWidget extends StatefulWidget { const EnterPhoneWidget({Key? key}) : super(key: key); @override _EnterPhoneWidgetState createState() => _EnterPhoneWidgetState(); } class _EnterPhoneWidgetState extends State<EnterPhoneWidget> { late EnterPhoneModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => EnterPhoneModel()); _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); authManager.handlePhoneAuthStateChanges(context); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).secondaryBackground, body: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: double.infinity, height: 197.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).secondary, FlutterFlowTheme.of(context).primary ], stops: [0.0, 1.0], begin: AlignmentDirectional(1.0, 0.0), end: AlignmentDirectional(-1.0, 0), ), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(300.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), ), child: Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 32.0, 0.0), child: Text( 'What Is Your Phone Number?', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 25.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(24.0, 33.0, 24.0, 0.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Text( 'Please enter your phone number to verify your account', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context).secondaryText, fontSize: 17.0, useGoogleFonts: false, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 24.0, 0.0, 32.0), child: Container( width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.0), border: Border.all( color: FlutterFlowTheme.of(context).alternate, ), ), child: Row( mainAxisSize: MainAxisSize.max, children: [ Flexible( child: FlutterFlowDropDown<String>( controller: _model.dropDownValueController ??= FormFieldController<String>( _model.dropDownValue ??= '🇺🇦', ), options: ['🇺🇦', '🇺🇸'], onChanged: (val) => setState(() => _model.dropDownValue = val), width: 300.0, height: 50.0, textStyle: FlutterFlowTheme.of(context).bodyMedium, icon: Icon( Icons.keyboard_arrow_down_rounded, color: FlutterFlowTheme.of(context) .secondaryText, size: 24.0, ), elevation: 2.0, borderColor: Colors.transparent, borderWidth: 0.0, borderRadius: 8.0, margin: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 8.0, 0.0), hidesUnderline: true, isSearchable: false, isMultiSelect: false, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 8.0, 0.0, 0.0, 0.0), child: Text( valueOrDefault<String>( functions.getDialCode(_model.dropDownValue!), '+380', ), style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryText, fontSize: 19.0, useGoogleFonts: false, ), ), ), Expanded( flex: 3, child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 8.0, 0.0, 8.0, 0.0), child: Container( width: 100.0, child: TextFormField( controller: _model.textController, focusNode: _model.textFieldFocusNode, obscureText: false, decoration: InputDecoration( hintText: '(99) 999 99 99', hintStyle: FlutterFlowTheme.of(context) .labelMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .primaryBackground, fontSize: 19.0, useGoogleFonts: false, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, errorBorder: InputBorder.none, focusedErrorBorder: InputBorder.none, ), style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryText, fontSize: 19.0, useGoogleFonts: false, ), keyboardType: TextInputType.phone, validator: _model.textControllerValidator .asValidator(context), inputFormatters: [_model.textFieldMask], ), ), ), ), ], ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 8.0), child: FFButtonWidget( onPressed: () async { setState(() { FFAppState().phoneNumber = functions.clearFromPhoneMask( '${functions.getDialCode(_model.dropDownValue!)}${_model.textController.text}'); }); final phoneNumberVal = FFAppState().phoneNumber; if (phoneNumberVal == null || phoneNumberVal.isEmpty || !phoneNumberVal.startsWith('+')) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( 'Phone Number is required and has to start with +.'), ), ); return; } await authManager.beginPhoneAuth( context: context, phoneNumber: phoneNumberVal, onCodeSent: (context) async { context.goNamedAuth( 'OTPCode', context.mounted, ignoreRedirect: true, ); }, ); }, text: 'Send Verification Code', options: FFButtonOptions( width: double.infinity, height: 64.0, padding: EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), Padding( padding: EdgeInsets.all(16.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { context.pushNamed('Navigation'); }, child: Text( 'Skip', textAlign: TextAlign.center, style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Text', color: FlutterFlowTheme.of(context) .primaryBackground, fontSize: 17.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ], ), ), ], ), ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/login
mirrored_repositories/flutterflow_ecommerce_app/lib/login/enter_phone/enter_phone_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/flutter_flow/flutter_flow_drop_down.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import '/flutter_flow/form_field_controller.dart'; import '/flutter_flow/custom_functions.dart' as functions; import 'enter_phone_widget.dart' show EnterPhoneWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; import 'package:provider/provider.dart'; class EnterPhoneModel extends FlutterFlowModel<EnterPhoneWidget> { /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); // State field(s) for DropDown widget. String? dropDownValue; FormFieldController<String>? dropDownValueController; // State field(s) for TextField widget. FocusNode? textFieldFocusNode; TextEditingController? textController; final textFieldMask = MaskTextInputFormatter(mask: '(##) ### ## ##'); String? Function(BuildContext, String?)? textControllerValidator; /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() { unfocusNode.dispose(); textFieldFocusNode?.dispose(); textController?.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_app_bar/checkout_app_bar_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'checkout_app_bar_widget.dart' show CheckoutAppBarWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckoutAppBarModel extends FlutterFlowModel<CheckoutAppBarWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_app_bar/checkout_app_bar_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'checkout_app_bar_model.dart'; export 'checkout_app_bar_model.dart'; class CheckoutAppBarWidget extends StatefulWidget { const CheckoutAppBarWidget({Key? key}) : super(key: key); @override _CheckoutAppBarWidgetState createState() => _CheckoutAppBarWidgetState(); } class _CheckoutAppBarWidgetState extends State<CheckoutAppBarWidget> { late CheckoutAppBarModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CheckoutAppBarModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Align( alignment: AlignmentDirectional(0.0, -1.0), child: Container( width: double.infinity, height: 44.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).primary, FlutterFlowTheme.of(context).secondary ], stops: [0.0, 1.0], begin: AlignmentDirectional(-1.0, 0.0), end: AlignmentDirectional(1.0, 0), ), ), child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { context.safePop(); }, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: SvgPicture.asset( 'assets/images/back.svg', width: 24.0, height: 24.0, fit: BoxFit.scaleDown, ), ), ), Expanded( child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 16.0, 0.0), child: Text( 'Check Out', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', color: FlutterFlowTheme.of(context) .secondaryBackground, fontSize: 19.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ), ), ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_bottom_bar/checkout_bottom_bar_model.dart
import '/check_out/checkout_sucess_dialog/checkout_sucess_dialog_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'checkout_bottom_bar_widget.dart' show CheckoutBottomBarWidget; import 'package:aligned_dialog/aligned_dialog.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckoutBottomBarModel extends FlutterFlowModel<CheckoutBottomBarWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_bottom_bar/checkout_bottom_bar_widget.dart
import '/check_out/checkout_sucess_dialog/checkout_sucess_dialog_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:aligned_dialog/aligned_dialog.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'checkout_bottom_bar_model.dart'; export 'checkout_bottom_bar_model.dart'; class CheckoutBottomBarWidget extends StatefulWidget { const CheckoutBottomBarWidget({ Key? key, required this.totalPrice, required this.itemsPrice, required this.delivery, }) : super(key: key); final double? totalPrice; final double? itemsPrice; final double? delivery; @override _CheckoutBottomBarWidgetState createState() => _CheckoutBottomBarWidgetState(); } class _CheckoutBottomBarWidgetState extends State<CheckoutBottomBarWidget> { late CheckoutBottomBarModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CheckoutBottomBarModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Material( color: Colors.transparent, elevation: 3.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Container( width: double.infinity, height: 220.0, constraints: BoxConstraints( maxHeight: 220.0, ), decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: 40.0, constraints: BoxConstraints( maxHeight: 110.0, ), decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Text( 'Items', style: TextStyle( color: FlutterFlowTheme.of(context).primaryBackground, fontWeight: FontWeight.w600, fontSize: 14.0, ), ), ), Flexible( child: Text( '\$${formatNumber( widget.itemsPrice, formatType: FormatType.custom, format: '##0.00', locale: '', )}', style: TextStyle( color: FlutterFlowTheme.of(context).primaryBackground, fontWeight: FontWeight.w600, fontSize: 14.0, ), ), ), ], ), ), ), ), Container( height: 40.0, constraints: BoxConstraints( maxHeight: 110.0, ), decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Text( 'Delivery', style: TextStyle( color: FlutterFlowTheme.of(context).primaryBackground, fontWeight: FontWeight.w600, fontSize: 14.0, ), ), ), Flexible( child: Text( '\$${widget.delivery?.toString()}', style: TextStyle( color: FlutterFlowTheme.of(context).primaryBackground, fontWeight: FontWeight.w600, fontSize: 14.0, ), ), ), ], ), ), ), ), Container( height: 40.0, constraints: BoxConstraints( maxHeight: 110.0, ), decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Text( 'Total price', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17.0, ), ), ), Flexible( child: Text( '\$${(widget.itemsPrice! + widget.delivery!).toStringAsFixed(2)}', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17.0, ), ), ), ], ), ), ), ), Align( alignment: AlignmentDirectional(0.0, 0.0), child: Builder( builder: (context) => Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 0.0), child: FFButtonWidget( onPressed: () async { await showAlignedDialog( context: context, isGlobal: true, avoidOverflow: false, targetAnchor: AlignmentDirectional(0.0, 0.0) .resolve(Directionality.of(context)), followerAnchor: AlignmentDirectional(0.0, 0.0) .resolve(Directionality.of(context)), builder: (dialogContext) { return Material( color: Colors.transparent, child: CheckoutSucessDialogWidget(), ); }, ).then((value) => setState(() {})); }, text: 'Check Out ', options: FFButtonOptions( width: double.infinity, height: 40.0, padding: EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'SF Pro Display', color: Colors.white, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_payment_method/checkout_payment_method_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'checkout_payment_method_widget.dart' show CheckoutPaymentMethodWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckoutPaymentMethodModel extends FlutterFlowModel<CheckoutPaymentMethodWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_payment_method/checkout_payment_method_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'checkout_payment_method_model.dart'; export 'checkout_payment_method_model.dart'; class CheckoutPaymentMethodWidget extends StatefulWidget { const CheckoutPaymentMethodWidget({Key? key}) : super(key: key); @override _CheckoutPaymentMethodWidgetState createState() => _CheckoutPaymentMethodWidgetState(); } class _CheckoutPaymentMethodWidgetState extends State<CheckoutPaymentMethodWidget> { late CheckoutPaymentMethodModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CheckoutPaymentMethodModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Material( color: Colors.transparent, elevation: 5.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), ), child: Container( width: double.infinity, height: 60.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 16.0), child: Row( mainAxisSize: MainAxisSize.max, children: [ ClipRRect( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), child: Image.asset( 'assets/images/mastercard.png', width: 36.0, height: 27.0, fit: BoxFit.cover, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 0.0, 0.0), child: Text( '**** **** **** 5678', style: FlutterFlowTheme.of(context).bodyMedium, ), ), Spacer(), Text( 'Change', style: FlutterFlowTheme.of(context).bodyMedium, ), Icon( Icons.arrow_forward_ios_rounded, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ), ], ), ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/check_out_page/check_out_page_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/check_out/checkout_app_bar/checkout_app_bar_widget.dart'; import '/check_out/checkout_bottom_bar/checkout_bottom_bar_widget.dart'; import '/check_out/checkout_delivery_method/checkout_delivery_method_widget.dart'; import '/check_out/checkout_payment_method/checkout_payment_method_widget.dart'; import '/check_out/checkout_shipping_address/checkout_shipping_address_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'check_out_page_model.dart'; export 'check_out_page_model.dart'; class CheckOutPageWidget extends StatefulWidget { const CheckOutPageWidget({Key? key}) : super(key: key); @override _CheckOutPageWidgetState createState() => _CheckOutPageWidgetState(); } class _CheckOutPageWidgetState extends State<CheckOutPageWidget> { late CheckOutPageModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => CheckOutPageModel()); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: Color(0xFFF4F3F4), appBar: FFAppState().pageNumber != 4 ? AppBar( automaticallyImplyLeading: false, actions: [], flexibleSpace: FlexibleSpaceBar( background: Container( width: 100.0, height: 100.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).primary, FlutterFlowTheme.of(context).secondary ], stops: [0.0, 1.0], begin: AlignmentDirectional(-1.0, 0.0), end: AlignmentDirectional(1.0, 0), ), ), ), ), centerTitle: false, elevation: 0.0, ) : null, body: Stack( children: [ Column( mainAxisSize: MainAxisSize.max, children: [ wrapWithModel( model: _model.checkoutAppBarModel, updateCallback: () => setState(() {}), child: CheckoutAppBarWidget(), ), Container( height: 600.0, decoration: BoxDecoration(), child: ListView( padding: EdgeInsets.fromLTRB( 0, 24.0, 0, 24.0, ), shrinkWrap: true, scrollDirection: Axis.vertical, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 12.0, 0.0), child: FaIcon( FontAwesomeIcons.mapMarkerAlt, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ), ), Text( 'Shipping Address', style: FlutterFlowTheme.of(context).bodyLarge, ), ], ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 16.0, 16.0, 0.0), child: wrapWithModel( model: _model.checkoutShippingAddressModel, updateCallback: () => setState(() {}), child: CheckoutShippingAddressWidget(), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 33.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 12.0, 0.0), child: FaIcon( FontAwesomeIcons.truck, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ), ), Text( 'Delivery Method', style: FlutterFlowTheme.of(context).bodyLarge, ), ], ), ), Container( height: 120.0, decoration: BoxDecoration(), child: wrapWithModel( model: _model.checkoutDeliveryMethodModel, updateCallback: () => setState(() {}), child: CheckoutDeliveryMethodWidget( selectedIndex: 1, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 33.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 12.0, 0.0), child: FaIcon( FontAwesomeIcons.creditCard, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ), ), Text( 'Payment Method', style: FlutterFlowTheme.of(context).bodyLarge, ), ], ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 16.0, 16.0, 0.0), child: wrapWithModel( model: _model.checkoutPaymentMethodModel, updateCallback: () => setState(() {}), child: CheckoutPaymentMethodWidget(), ), ), ], ), ), ], ), Align( alignment: AlignmentDirectional(0.0, 1.0), child: StreamBuilder<List<CartRecord>>( stream: queryCartRecord( queryBuilder: (cartRecord) => cartRecord.where( 'user_id', isEqualTo: currentUserUid, ), singleRecord: true, ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<CartRecord> checkoutBottomBarCartRecordList = snapshot.data!; // Return an empty Container when the item does not exist. if (snapshot.data!.isEmpty) { return Container(); } final checkoutBottomBarCartRecord = checkoutBottomBarCartRecordList.isNotEmpty ? checkoutBottomBarCartRecordList.first : null; return wrapWithModel( model: _model.checkoutBottomBarModel, updateCallback: () => setState(() {}), child: CheckoutBottomBarWidget( totalPrice: 257.98, itemsPrice: checkoutBottomBarCartRecord!.price, delivery: 18.0, ), ); }, ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/check_out_page/check_out_page_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/check_out/checkout_app_bar/checkout_app_bar_widget.dart'; import '/check_out/checkout_bottom_bar/checkout_bottom_bar_widget.dart'; import '/check_out/checkout_delivery_method/checkout_delivery_method_widget.dart'; import '/check_out/checkout_payment_method/checkout_payment_method_widget.dart'; import '/check_out/checkout_shipping_address/checkout_shipping_address_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'check_out_page_widget.dart' show CheckOutPageWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckOutPageModel extends FlutterFlowModel<CheckOutPageWidget> { /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); // Model for CheckoutAppBar component. late CheckoutAppBarModel checkoutAppBarModel; // Model for CheckoutShippingAddress component. late CheckoutShippingAddressModel checkoutShippingAddressModel; // Model for CheckoutDeliveryMethod component. late CheckoutDeliveryMethodModel checkoutDeliveryMethodModel; // Model for CheckoutPaymentMethod component. late CheckoutPaymentMethodModel checkoutPaymentMethodModel; // Model for CheckoutBottomBar component. late CheckoutBottomBarModel checkoutBottomBarModel; /// Initialization and disposal methods. void initState(BuildContext context) { checkoutAppBarModel = createModel(context, () => CheckoutAppBarModel()); checkoutShippingAddressModel = createModel(context, () => CheckoutShippingAddressModel()); checkoutDeliveryMethodModel = createModel(context, () => CheckoutDeliveryMethodModel()); checkoutPaymentMethodModel = createModel(context, () => CheckoutPaymentMethodModel()); checkoutBottomBarModel = createModel(context, () => CheckoutBottomBarModel()); } void dispose() { unfocusNode.dispose(); checkoutAppBarModel.dispose(); checkoutShippingAddressModel.dispose(); checkoutDeliveryMethodModel.dispose(); checkoutPaymentMethodModel.dispose(); checkoutBottomBarModel.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_sucess_dialog/checkout_sucess_dialog_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'checkout_sucess_dialog_model.dart'; export 'checkout_sucess_dialog_model.dart'; class CheckoutSucessDialogWidget extends StatefulWidget { const CheckoutSucessDialogWidget({Key? key}) : super(key: key); @override _CheckoutSucessDialogWidgetState createState() => _CheckoutSucessDialogWidgetState(); } class _CheckoutSucessDialogWidgetState extends State<CheckoutSucessDialogWidget> { late CheckoutSucessDialogModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CheckoutSucessDialogModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Container( width: 330.0, height: 360.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(24.0), bottomRight: Radius.circular(24.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Stack( children: [ ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.asset( 'assets/images/dialog_image.png', width: double.infinity, height: 325.0, fit: BoxFit.cover, ), ), Container( width: 400.0, decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 128.0, 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ Text( 'Success', style: FlutterFlowTheme.of(context).titleLarge, ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 0.0), child: Text( 'Your order will be delivered soon.\nIt can be tracked in the \"Orders\" section.', style: FlutterFlowTheme.of(context).bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(32.0, 24.0, 23.0, 0.0), child: FFButtonWidget( onPressed: () async { context.safePop(); }, text: 'Continue Shopping', options: FFButtonOptions( width: 400.0, height: 40.0, padding: EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'SF Pro Display', color: Colors.white, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 24.0, 0.0, 0.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { context.safePop(); }, child: Container( width: double.infinity, height: 48.0, decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Text( 'Go to Orders', style: FlutterFlowTheme.of(context).labelLarge, ), ), ), ), ), ], ), ), ), Align( alignment: AlignmentDirectional(0.0, -1.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 0.0), child: Icon( Icons.check_circle_outline_rounded, color: FlutterFlowTheme.of(context).secondaryBackground, size: 64.0, ), ), ), ], ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_sucess_dialog/checkout_sucess_dialog_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'checkout_sucess_dialog_widget.dart' show CheckoutSucessDialogWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckoutSucessDialogModel extends FlutterFlowModel<CheckoutSucessDialogWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_shipping_address/checkout_shipping_address_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'checkout_shipping_address_widget.dart' show CheckoutShippingAddressWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckoutShippingAddressModel extends FlutterFlowModel<CheckoutShippingAddressWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_shipping_address/checkout_shipping_address_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'checkout_shipping_address_model.dart'; export 'checkout_shipping_address_model.dart'; class CheckoutShippingAddressWidget extends StatefulWidget { const CheckoutShippingAddressWidget({Key? key}) : super(key: key); @override _CheckoutShippingAddressWidgetState createState() => _CheckoutShippingAddressWidgetState(); } class _CheckoutShippingAddressWidgetState extends State<CheckoutShippingAddressWidget> { late CheckoutShippingAddressModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CheckoutShippingAddressModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Material( color: Colors.transparent, elevation: 5.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), child: Container( width: double.infinity, height: 100.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.circular(8.0), ), child: Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 12.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ Container( height: 20.0, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, children: [ Text( 'Oleh Chabanov', style: FlutterFlowTheme.of(context).bodyLarge, ), Spacer(), Text( 'Change', style: FlutterFlowTheme.of(context).bodyMedium, ), Icon( Icons.arrow_forward_ios_rounded, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ), ], ), ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 6.0, 0.0, 0.0), child: Text( '225 Highland Ave\nSpringfield, IL 62704, USA', style: FlutterFlowTheme.of(context).bodyMedium, ), ), ), ], ), ), ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_delivery_method/checkout_delivery_method_model.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'checkout_delivery_method_widget.dart' show CheckoutDeliveryMethodWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CheckoutDeliveryMethodModel extends FlutterFlowModel<CheckoutDeliveryMethodWidget> { /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out
mirrored_repositories/flutterflow_ecommerce_app/lib/check_out/checkout_delivery_method/checkout_delivery_method_widget.dart
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'checkout_delivery_method_model.dart'; export 'checkout_delivery_method_model.dart'; class CheckoutDeliveryMethodWidget extends StatefulWidget { const CheckoutDeliveryMethodWidget({ Key? key, int? selectedIndex, }) : this.selectedIndex = selectedIndex ?? 1, super(key: key); final int selectedIndex; @override _CheckoutDeliveryMethodWidgetState createState() => _CheckoutDeliveryMethodWidgetState(); } class _CheckoutDeliveryMethodWidgetState extends State<CheckoutDeliveryMethodWidget> { late CheckoutDeliveryMethodModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CheckoutDeliveryMethodModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return ListView( padding: EdgeInsets.fromLTRB( 16.0, 0, 16.0, 0, ), scrollDirection: Axis.horizontal, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 16.0, 10.0), child: Material( color: Colors.transparent, elevation: 2.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), ), child: Container( width: 110.0, height: 100.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), border: Border.all( color: widget.selectedIndex == 0 ? FlutterFlowTheme.of(context).accent1 : Color(0x00000000), width: 2.0, ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(17.0, 17.0, 17.0, 12.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ ClipRRect( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), child: Image.asset( 'assets/images/dhl.png', width: 70.0, height: 18.0, fit: BoxFit.contain, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 0.0), child: Text( '\$15', style: FlutterFlowTheme.of(context).bodyLarge, ), ), Text( '1-2 days', style: FlutterFlowTheme.of(context).labelSmall, ), ], ), ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 10.0), child: Material( color: Colors.transparent, elevation: 2.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), ), child: Container( width: 110.0, height: 100.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), border: Border.all( color: widget.selectedIndex == 1 ? FlutterFlowTheme.of(context).accent1 : Color(0x00000000), width: 2.0, ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(17.0, 17.0, 17.0, 12.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ ClipRRect( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), child: Image.asset( 'assets/images/fedex.png', width: 70.0, height: 18.0, fit: BoxFit.contain, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 0.0), child: Text( '\$18', style: FlutterFlowTheme.of(context).bodyLarge, ), ), Text( '1-2 days', style: FlutterFlowTheme.of(context).labelSmall, ), ], ), ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 10.0, 0.0, 10.0), child: Material( color: Colors.transparent, elevation: 2.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), ), child: Container( width: 110.0, height: 100.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), ), border: Border.all( color: widget.selectedIndex == 2 ? FlutterFlowTheme.of(context).accent1 : Color(0x00000000), width: 2.0, ), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(17.0, 17.0, 17.0, 12.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ ClipRRect( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), child: Image.asset( 'assets/images/usps.png', width: 70.0, height: 18.0, fit: BoxFit.contain, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 0.0), child: Text( '\$20', style: FlutterFlowTheme.of(context).bodyLarge, ), ), Text( '1-2 days', style: FlutterFlowTheme.of(context).labelSmall, ), ], ), ), ), ), ), ], ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/product
mirrored_repositories/flutterflow_ecommerce_app/lib/product/review/review_model.dart
import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'review_widget.dart' show ReviewWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class ReviewModel extends FlutterFlowModel<ReviewWidget> { /// State fields for stateful widgets in this component. // State field(s) for RatingBar widget. double? ratingBarValue; /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/product
mirrored_repositories/flutterflow_ecommerce_app/lib/product/review/review_widget.dart
import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'review_model.dart'; export 'review_model.dart'; class ReviewWidget extends StatefulWidget { const ReviewWidget({ Key? key, required this.review, }) : super(key: key); final ReviewsRecord? review; @override _ReviewWidgetState createState() => _ReviewWidgetState(); } class _ReviewWidgetState extends State<ReviewWidget> { late ReviewModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => ReviewModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Container( width: double.infinity, height: double.infinity, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.circular(8.0), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 24.0, 16.0, 17.0), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 24.0, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( 'Reviews', style: FlutterFlowTheme.of(context).bodyLarge, ), Spacer(), Text( 'See All', style: FlutterFlowTheme.of(context).labelMedium, ), Icon( Icons.arrow_forward_ios_rounded, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ), ], ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 16.0, 0.0, 0.0), child: Text( widget.review!.userName, style: FlutterFlowTheme.of(context).bodyMedium, ), ), Container( width: double.infinity, height: 16.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, ), child: Row( mainAxisSize: MainAxisSize.max, children: [ RatingBar.builder( onRatingUpdate: (newValue) => setState(() => _model.ratingBarValue = newValue), itemBuilder: (context, index) => Icon( Icons.star_rounded, color: FlutterFlowTheme.of(context).accent2, ), direction: Axis.horizontal, initialRating: _model.ratingBarValue ??= widget.review!.rating, unratedColor: FlutterFlowTheme.of(context).alternate, itemCount: 5, itemSize: 12.0, glowColor: FlutterFlowTheme.of(context).accent2, ), Spacer(), Text( dateTimeFormat('yMMMd', widget.review!.date!), style: FlutterFlowTheme.of(context).bodyMedium, ), ], ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 16.0, 0.0, 0.0), child: Text( widget.review!.text, style: FlutterFlowTheme.of(context).bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 14.0, 0.0, 0.0), child: Text( '${widget.review?.foundHelpfulCount?.toString()} people found this helpful', maxLines: 5, style: FlutterFlowTheme.of(context).bodyMedium, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 16.0, 0.0, 0.0), child: Container( height: 25.0, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( 'Comment', style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'SF Pro Display', decoration: TextDecoration.underline, useGoogleFonts: false, ), ), Spacer(), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 6.0, 0.0), child: Text( 'Helpful', style: FlutterFlowTheme.of(context).bodyMedium, ), ), Builder( builder: (context) { if (widget.review?.isHelpfull ?? false) { return Icon( Icons.thumb_up, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ); } else { return Icon( Icons.thumb_up_off_alt, color: FlutterFlowTheme.of(context).secondaryText, size: 24.0, ); } }, ), ], ), ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/product
mirrored_repositories/flutterflow_ecommerce_app/lib/product/product_bottom_bar/product_bottom_bar_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'product_bottom_bar_widget.dart' show ProductBottomBarWidget; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class ProductBottomBarModel extends FlutterFlowModel<ProductBottomBarWidget> { /// State fields for stateful widgets in this component. // Stores action output result for [Backend Call - Create Document] action in Button widget. CartContentRecord? newCartContent; /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() {} /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/product
mirrored_repositories/flutterflow_ecommerce_app/lib/product/product_bottom_bar/product_bottom_bar_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'product_bottom_bar_model.dart'; export 'product_bottom_bar_model.dart'; class ProductBottomBarWidget extends StatefulWidget { const ProductBottomBarWidget({ Key? key, required this.product, required this.cart, }) : super(key: key); final ProductsRecord? product; final DocumentReference? cart; @override _ProductBottomBarWidgetState createState() => _ProductBottomBarWidgetState(); } class _ProductBottomBarWidgetState extends State<ProductBottomBarWidget> { late ProductBottomBarModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => ProductBottomBarModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Material( color: Colors.transparent, elevation: 3.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Container( width: double.infinity, height: 100.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(0.0), bottomRight: Radius.circular(0.0), topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0), ), ), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, buttonSize: 40.0, icon: Icon( Icons.arrow_back_rounded, color: FlutterFlowTheme.of(context).primaryText, size: 24.0, ), onPressed: () async { context.safePop(); }, ), Flexible( flex: 3, child: FFButtonWidget( onPressed: () async { var cartContentRecordReference = CartContentRecord.collection.doc(); await cartContentRecordReference .set(createCartContentRecordData( cartId: widget.cart?.id, price: widget.product?.price, image: widget.product?.imagesUrl?.first, ammount: 1, text: widget.product?.title, )); _model.newCartContent = CartContentRecord.getDocumentFromData( createCartContentRecordData( cartId: widget.cart?.id, price: widget.product?.price, image: widget.product?.imagesUrl?.first, ammount: 1, text: widget.product?.title, ), cartContentRecordReference); await widget.cart!.update({ ...mapToFirestore( { 'content': FieldValue.arrayUnion( [_model.newCartContent?.reference]), 'price': FieldValue.increment(widget.product!.price), }, ), }); context.safePop(); setState(() {}); }, text: 'Add to Cart', options: FFButtonOptions( height: 40.0, padding: EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'SF Pro Display', color: Colors.white, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), Builder( builder: (context) { if (widget.product?.inFavorites?.contains(currentUserUid) == true) { return FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, buttonSize: 40.0, icon: Icon( Icons.favorite_sharp, color: FlutterFlowTheme.of(context).primaryText, size: 24.0, ), onPressed: () async { await widget.product!.reference.update({ ...mapToFirestore( { 'in_favorites': FieldValue.arrayRemove([currentUserUid]), }, ), }); }, ); } else { return FlutterFlowIconButton( borderColor: Colors.transparent, borderRadius: 20.0, borderWidth: 1.0, buttonSize: 40.0, icon: Icon( Icons.favorite_border, color: FlutterFlowTheme.of(context).primaryText, size: 24.0, ), onPressed: () async { await widget.product!.reference.update({ ...mapToFirestore( { 'in_favorites': FieldValue.arrayUnion([currentUserUid]), }, ), }); }, ); } }, ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/product
mirrored_repositories/flutterflow_ecommerce_app/lib/product/porduct_page/porduct_page_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/components/product_widget.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import '/product/product_bottom_bar/product_bottom_bar_widget.dart'; import '/product/review/review_widget.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart' as smooth_page_indicator; import 'porduct_page_widget.dart' show PorductPageWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class PorductPageModel extends FlutterFlowModel<PorductPageWidget> { /// Local state fields for this page. List<ColorsRecord> selectedColor = []; void addToSelectedColor(ColorsRecord item) => selectedColor.add(item); void removeFromSelectedColor(ColorsRecord item) => selectedColor.remove(item); void removeAtIndexFromSelectedColor(int index) => selectedColor.removeAt(index); void insertAtIndexInSelectedColor(int index, ColorsRecord item) => selectedColor.insert(index, item); void updateSelectedColorAtIndex(int index, Function(ColorsRecord) updateFn) => selectedColor[index] = updateFn(selectedColor[index]); List<SizesRecord> selectedSizes = []; void addToSelectedSizes(SizesRecord item) => selectedSizes.add(item); void removeFromSelectedSizes(SizesRecord item) => selectedSizes.remove(item); void removeAtIndexFromSelectedSizes(int index) => selectedSizes.removeAt(index); void insertAtIndexInSelectedSizes(int index, SizesRecord item) => selectedSizes.insert(index, item); void updateSelectedSizesAtIndex(int index, Function(SizesRecord) updateFn) => selectedSizes[index] = updateFn(selectedSizes[index]); /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); // State field(s) for PageView widget. PageController? pageViewController; int get pageViewCurrentIndex => pageViewController != null && pageViewController!.hasClients && pageViewController!.page != null ? pageViewController!.page!.round() : 0; // State field(s) for RatingBar widget. double? ratingBarValue; // Model for review component. late ReviewModel reviewModel; // Model for ProductBottomBar component. late ProductBottomBarModel productBottomBarModel; /// Initialization and disposal methods. void initState(BuildContext context) { reviewModel = createModel(context, () => ReviewModel()); productBottomBarModel = createModel(context, () => ProductBottomBarModel()); } void dispose() { unfocusNode.dispose(); reviewModel.dispose(); productBottomBarModel.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/product
mirrored_repositories/flutterflow_ecommerce_app/lib/product/porduct_page/porduct_page_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/components/product_widget.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import '/product/product_bottom_bar/product_bottom_bar_widget.dart'; import '/product/review/review_widget.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart' as smooth_page_indicator; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'porduct_page_model.dart'; export 'porduct_page_model.dart'; class PorductPageWidget extends StatefulWidget { const PorductPageWidget({ Key? key, required this.product, }) : super(key: key); final ProductsRecord? product; @override _PorductPageWidgetState createState() => _PorductPageWidgetState(); } class _PorductPageWidgetState extends State<PorductPageWidget> { late PorductPageModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => PorductPageModel()); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: Color(0xFFF4F3F4), body: Stack( children: [ SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.max, children: [ Container( width: double.infinity, height: 356.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, ), child: Stack( children: [ Builder( builder: (context) { final images = widget.product?.imagesUrl?.toList() ?? []; return Container( width: double.infinity, height: 500.0, child: Stack( children: [ PageView.builder( controller: _model.pageViewController ??= PageController( initialPage: min(0, images.length - 1)), scrollDirection: Axis.horizontal, itemCount: images.length, itemBuilder: (context, imagesIndex) { final imagesItem = images[imagesIndex]; return ClipRRect( borderRadius: BorderRadius.circular(0.0), child: Image.network( imagesItem, width: double.infinity, height: 200.0, fit: BoxFit.cover, ), ); }, ), Align( alignment: AlignmentDirectional(0.0, 1.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 16.0), child: smooth_page_indicator .SmoothPageIndicator( controller: _model .pageViewController ??= PageController( initialPage: min(0, images.length - 1)), count: images.length, axisDirection: Axis.horizontal, onDotClicked: (i) async { await _model.pageViewController! .animateToPage( i, duration: Duration(milliseconds: 500), curve: Curves.ease, ); }, effect: smooth_page_indicator.SlideEffect( spacing: 8.0, radius: 16.0, dotWidth: 8.0, dotHeight: 8.0, dotColor: Color(0x91FFFFFF), activeDotColor: Color(0xE0FFFFFF), paintStyle: PaintingStyle.fill, ), ), ), ), ], ), ); }, ), Container( width: double.infinity, height: 45.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [Color(0xCE000000), Colors.transparent], stops: [0.0, 1.0], begin: AlignmentDirectional(0.0, -1.0), end: AlignmentDirectional(0, 1.0), ), ), ), ], ), ), Container( width: double.infinity, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0), topLeft: Radius.circular(0.0), topRight: Radius.circular(0.0), ), ), child: Align( alignment: AlignmentDirectional(0.0, -1.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 16.0, 0.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 30.0, decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 16.0, 0.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, children: [ RatingBar.builder( onRatingUpdate: (newValue) => setState( () => _model.ratingBarValue = newValue), itemBuilder: (context, index) => Icon( Icons.star_rounded, color: FlutterFlowTheme.of(context) .accent2, ), direction: Axis.horizontal, initialRating: _model.ratingBarValue ??= widget.product!.raiting.toDouble(), unratedColor: FlutterFlowTheme.of(context) .primaryBackground, itemCount: 5, itemSize: 12.0, glowColor: FlutterFlowTheme.of(context).accent2, ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 8.0, 0.0, 0.0, 0.0), child: Text( '${widget.product?.raiting?.toString()} reviews', style: FlutterFlowTheme.of(context) .bodyMedium, ), ), Spacer(), Align( alignment: AlignmentDirectional(1.0, 0.0), child: Builder( builder: (context) { if (valueOrDefault<bool>( widget.product?.inStock, false, )) { return Text( 'In Stock', style: TextStyle( color: FlutterFlowTheme.of(context) .success, fontWeight: FontWeight.bold, fontSize: 12.0, height: 16.0, ), ); } else { return Text( 'Out of Stock', style: TextStyle( color: FlutterFlowTheme.of(context) .accent3, fontWeight: FontWeight.bold, fontSize: 12.0, height: 16.0, ), ); } }, ), ), ], ), ), ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 14.0, 0.0, 0.0), child: Text( widget.product!.title, textAlign: TextAlign.start, maxLines: 1, style: FlutterFlowTheme.of(context).bodyMedium, ), ), ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 12.0, 0.0, 0.0), child: Text( '\$${widget.product?.price?.toString()}', style: FlutterFlowTheme.of(context).bodyMedium, ), ), ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 16.0, 0.0, 0.0), child: Text( 'Colors', style: FlutterFlowTheme.of(context).labelMedium, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 8.0, 0.0, 0.0), child: Container( width: double.infinity, height: 50.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context) .secondaryBackground, ), child: Builder( builder: (context) { final colorImages = widget.product?.colorImages?.toList() ?? []; return ListView.separated( padding: EdgeInsets.zero, scrollDirection: Axis.horizontal, itemCount: colorImages.length, separatorBuilder: (_, __) => SizedBox(width: 12.0), itemBuilder: (context, colorImagesIndex) { final colorImagesItem = colorImages[colorImagesIndex]; return Builder( builder: (context) { if (!false) { return Container( width: 47.0, height: 47.0, constraints: BoxConstraints( minWidth: 47.0, minHeight: 47.0, maxWidth: 47.0, maxHeight: 47.0, ), decoration: BoxDecoration( color: FlutterFlowTheme.of( context) .secondaryBackground, image: DecorationImage( fit: BoxFit.contain, image: Image.network( colorImagesItem, ).image, ), borderRadius: BorderRadius.circular( 8.0), border: Border.all( color: FlutterFlowTheme.of( context) .accent1, width: 2.0, ), ), ); } else { return Container( width: 100.0, height: 100.0, constraints: BoxConstraints( minWidth: 47.0, minHeight: 47.0, maxWidth: 47.0, maxHeight: 47.0, ), decoration: BoxDecoration( color: FlutterFlowTheme.of( context) .secondaryBackground, image: DecorationImage( fit: BoxFit.contain, image: Image.network( colorImagesItem, ).image, ), borderRadius: BorderRadius.circular( 8.0), ), ); } }, ); }, ); }, ), ), ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 16.0, 0.0, 0.0), child: Text( 'Sizes', style: FlutterFlowTheme.of(context).labelMedium, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 8.0, 0.0, 24.0), child: Container( width: double.infinity, height: 200.0, constraints: BoxConstraints( maxHeight: 47.0, ), decoration: BoxDecoration( color: FlutterFlowTheme.of(context) .secondaryBackground, ), child: Visibility( visible: false, child: StreamBuilder<List<SizesRecord>>( stream: querySizesRecord(), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context) .primary, ), ), ), ); } List<SizesRecord> listViewSizesRecordList = snapshot.data!; return ListView.separated( padding: EdgeInsets.zero, scrollDirection: Axis.horizontal, itemCount: listViewSizesRecordList.length, separatorBuilder: (_, __) => SizedBox(width: 12.0), itemBuilder: (context, listViewIndex) { final listViewSizesRecord = listViewSizesRecordList[ listViewIndex]; return Builder( builder: (context) { if (FFAppState() .filterSizes .contains(listViewSizesRecord .size)) { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { setState(() { FFAppState() .removeFromFilterSizes( listViewSizesRecord .size); FFAppState() .removeFromFilterSizesIds( listViewSizesRecord .reference); }); }, child: Container( width: 47.0, height: 47.0, decoration: BoxDecoration( color: FlutterFlowTheme.of( context) .accent1, borderRadius: BorderRadius.circular( 8.0), ), child: Align( alignment: AlignmentDirectional( 0.0, 0.0), child: Text( listViewSizesRecord .size, style: FlutterFlowTheme.of( context) .titleSmall, ), ), ), ); } else { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { setState(() { FFAppState() .addToFilterSizes( listViewSizesRecord .size); FFAppState() .addToFilterSizesIds( listViewSizesRecord .reference); }); }, child: Container( width: 47.0, height: 47.0, decoration: BoxDecoration( color: FlutterFlowTheme .of(context) .secondaryBackground, borderRadius: BorderRadius.circular( 8.0), border: Border.all( color: FlutterFlowTheme.of( context) .alternate, ), ), child: Align( alignment: AlignmentDirectional( 0.0, 0.0), child: Text( listViewSizesRecord .size, style: FlutterFlowTheme.of( context) .bodyMedium, ), ), ), ); } }, ); }, ); }, ), ), ), ), ], ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 8.0, 0.0, 0.0), child: Container( width: double.infinity, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, borderRadius: BorderRadius.circular(8.0), ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 16.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 24.0, 0.0, 0.0), child: Text( 'Product details', style: FlutterFlowTheme.of(context).bodyLarge, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 8.0, 0.0, 0.0), child: Text( widget.product!.title, maxLines: 4, style: FlutterFlowTheme.of(context).bodyMedium, ), ), Align( alignment: AlignmentDirectional(0.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0.0, 12.0, 0.0, 0.0), child: FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, buttonSize: 40.0, fillColor: Color(0x00E7B944), icon: Icon( Icons.keyboard_arrow_down_rounded, color: FlutterFlowTheme.of(context) .primaryText, size: 24.0, ), onPressed: () { print('IconButton pressed ...'); }, ), ), ), ], ), ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 8.0, 0.0, 0.0), child: Container( width: double.infinity, height: 280.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).secondaryBackground, ), child: StreamBuilder<List<ReviewsRecord>>( stream: queryReviewsRecord( singleRecord: true, ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<ReviewsRecord> reviewReviewsRecordList = snapshot.data!; // Return an empty Container when the item does not exist. if (snapshot.data!.isEmpty) { return Container(); } final reviewReviewsRecord = reviewReviewsRecordList.isNotEmpty ? reviewReviewsRecordList.first : null; return wrapWithModel( model: _model.reviewModel, updateCallback: () => setState(() {}), child: ReviewWidget( review: reviewReviewsRecord!, ), ); }, ), ), ), Align( alignment: AlignmentDirectional(-1.0, 0.0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 32.0, 16.0, 0.0), child: Text( 'Products related to this item', style: FlutterFlowTheme.of(context).bodyLarge, ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 16.0, 0.0, 0.0), child: Container( height: 400.0, decoration: BoxDecoration(), child: StreamBuilder<List<ProductsRecord>>( stream: queryProductsRecord(), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<ProductsRecord> listViewProductsRecordList = snapshot.data!; return ListView.separated( padding: EdgeInsets.fromLTRB( 16.0, 0, 16.0, 0, ), shrinkWrap: true, scrollDirection: Axis.horizontal, itemCount: listViewProductsRecordList.length, separatorBuilder: (_, __) => SizedBox(width: 16.0), itemBuilder: (context, listViewIndex) { final listViewProductsRecord = listViewProductsRecordList[listViewIndex]; return Container( width: 140.0, decoration: BoxDecoration(), child: ProductWidget( key: Key( 'Keyruv_${listViewIndex}_of_${listViewProductsRecordList.length}'), discount: listViewProductsRecord.discount, image: listViewProductsRecord.imagesUrl.first, raiting: listViewProductsRecord.raiting, title: listViewProductsRecord.title, price: listViewProductsRecord.price, discountPrice: listViewProductsRecord.discountPrice, isFavorite: false, docRef: listViewProductsRecord.reference, doc: listViewProductsRecord, ), ); }, ); }, ), ), ), ], ), ), Align( alignment: AlignmentDirectional(0.0, 1.0), child: StreamBuilder<List<CartRecord>>( stream: queryCartRecord( queryBuilder: (cartRecord) => cartRecord.where( 'user_id', isEqualTo: currentUserUid, ), singleRecord: true, ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<CartRecord> productBottomBarCartRecordList = snapshot.data!; // Return an empty Container when the item does not exist. if (snapshot.data!.isEmpty) { return Container(); } final productBottomBarCartRecord = productBottomBarCartRecordList.isNotEmpty ? productBottomBarCartRecordList.first : null; return wrapWithModel( model: _model.productBottomBarModel, updateCallback: () => setState(() {}), child: ProductBottomBarWidget( product: widget.product!, cart: productBottomBarCartRecord!.reference, ), ); }, ), ), ], ), ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/category
mirrored_repositories/flutterflow_ecommerce_app/lib/category/category_view/category_view_model.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/components/product_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'category_view_widget.dart' show CategoryViewWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:provider/provider.dart'; class CategoryViewModel extends FlutterFlowModel<CategoryViewWidget> { /// Local state fields for this component. String allType = '3IsjNApvCaUKWQyC0fl0'; String sortBy = 'Price: lowest to high'; /// State fields for stateful widgets in this component. // State field(s) for GridView widget. PagingController<DocumentSnapshot?, ProductsRecord>? gridViewPagingController1; Query? gridViewPagingQuery1; List<StreamSubscription?> gridViewStreamSubscriptions1 = []; // State field(s) for GridView widget. PagingController<DocumentSnapshot?, ProductsRecord>? gridViewPagingController2; Query? gridViewPagingQuery2; List<StreamSubscription?> gridViewStreamSubscriptions2 = []; /// Initialization and disposal methods. void initState(BuildContext context) {} void dispose() { gridViewStreamSubscriptions1.forEach((s) => s?.cancel()); gridViewPagingController1?.dispose(); gridViewStreamSubscriptions2.forEach((s) => s?.cancel()); gridViewPagingController2?.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. PagingController<DocumentSnapshot?, ProductsRecord> setGridViewController1( Query query, { DocumentReference<Object?>? parent, }) { gridViewPagingController1 ??= _createGridViewController1(query, parent); if (gridViewPagingQuery1 != query) { gridViewPagingQuery1 = query; gridViewPagingController1?.refresh(); } return gridViewPagingController1!; } PagingController<DocumentSnapshot?, ProductsRecord> _createGridViewController1( Query query, DocumentReference<Object?>? parent, ) { final controller = PagingController<DocumentSnapshot?, ProductsRecord>(firstPageKey: null); return controller ..addPageRequestListener( (nextPageMarker) => queryProductsRecordPage( queryBuilder: (_) => gridViewPagingQuery1 ??= query, nextPageMarker: nextPageMarker, streamSubscriptions: gridViewStreamSubscriptions1, controller: controller, pageSize: 25, isStream: true, ), ); } PagingController<DocumentSnapshot?, ProductsRecord> setGridViewController2( Query query, { DocumentReference<Object?>? parent, }) { gridViewPagingController2 ??= _createGridViewController2(query, parent); if (gridViewPagingQuery2 != query) { gridViewPagingQuery2 = query; gridViewPagingController2?.refresh(); } return gridViewPagingController2!; } PagingController<DocumentSnapshot?, ProductsRecord> _createGridViewController2( Query query, DocumentReference<Object?>? parent, ) { final controller = PagingController<DocumentSnapshot?, ProductsRecord>(firstPageKey: null); return controller ..addPageRequestListener( (nextPageMarker) => queryProductsRecordPage( queryBuilder: (_) => gridViewPagingQuery2 ??= query, nextPageMarker: nextPageMarker, streamSubscriptions: gridViewStreamSubscriptions2, controller: controller, pageSize: 25, isStream: true, ), ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/category
mirrored_repositories/flutterflow_ecommerce_app/lib/category/category_view/category_view_widget.dart
import '/auth/firebase_auth/auth_util.dart'; import '/backend/backend.dart'; import '/components/product_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:provider/provider.dart'; import 'category_view_model.dart'; export 'category_view_model.dart'; class CategoryViewWidget extends StatefulWidget { const CategoryViewWidget({ Key? key, required this.category, }) : super(key: key); final CategoriesRecord? category; @override _CategoryViewWidgetState createState() => _CategoryViewWidgetState(); } class _CategoryViewWidgetState extends State<CategoryViewWidget> { late CategoryViewModel _model; @override void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @override void initState() { super.initState(); _model = createModel(context, () => CategoryViewModel()); } @override void dispose() { _model.maybeDispose(); super.dispose(); } @override Widget build(BuildContext context) { context.watch<FFAppState>(); return Column( mainAxisSize: MainAxisSize.max, children: [ Container( width: double.infinity, height: 40.0, decoration: BoxDecoration( color: Color(0x00FFFFFF), ), child: StreamBuilder<List<ProductTypeRecord>>( stream: queryProductTypeRecord(), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } List<ProductTypeRecord> listViewProductTypeRecordList = snapshot.data!; return ListView.separated( padding: EdgeInsets.fromLTRB( 16.0, 0, 16.0, 0, ), shrinkWrap: true, scrollDirection: Axis.horizontal, itemCount: listViewProductTypeRecordList.length, separatorBuilder: (_, __) => SizedBox(width: 8.0), itemBuilder: (context, listViewIndex) { final listViewProductTypeRecord = listViewProductTypeRecordList[listViewIndex]; return Builder( builder: (context) { if (listViewProductTypeRecord.reference.id == FFAppState().firterProductTypeId) { return FFButtonWidget( onPressed: () { print('Button pressed ...'); }, text: listViewProductTypeRecord.name, options: FFButtonOptions( height: 40.0, padding: EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).accent1, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( fontFamily: 'SF Pro Display', color: Colors.white, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(40.0), ), ); } else { return FFButtonWidget( onPressed: () async { setState(() { FFAppState().firterProductTypeId = listViewProductTypeRecord.reference.id; }); }, text: listViewProductTypeRecord.name, options: FFButtonOptions( height: 40.0, padding: EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( fontFamily: 'SF Pro Display', color: Colors.white, useGoogleFonts: false, ), elevation: 3.0, borderSide: BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(40.0), ), ); } }, ); }, ); }, ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 24.0, 16.0, 0.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Builder( builder: (context) { if (valueOrDefault<bool>( FFAppState().firterProductTypeId == '3IsjNApvCaUKWQyC0fl0', false, )) { return FutureBuilder<int>( future: queryProductsRecordCount( queryBuilder: (productsRecord) => productsRecord .where( 'price', isLessThanOrEqualTo: FFAppState().filterPriceHigher.toDouble(), ) .where( 'price', isGreaterThanOrEqualTo: FFAppState().filterPriceLower.toDouble(), ) .whereArrayContainsAny( 'colors', FFAppState() .filterColorIds .map((e) => e.id) .toList()), ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } int textCount = snapshot.data!; return Text( '${textCount.toString()} items', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Display', fontSize: 19.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ); }, ); } else { return FutureBuilder<int>( future: queryProductsRecordCount( queryBuilder: (productsRecord) => productsRecord .where( 'type', isEqualTo: FFAppState().firterProductTypeId, ) .where( 'price', isLessThanOrEqualTo: FFAppState().filterPriceHigher.toDouble(), ) .where( 'price', isGreaterThanOrEqualTo: FFAppState().filterPriceLower.toDouble(), ) .whereArrayContainsAny( 'colors', FFAppState() .filterColorIds .map((e) => e.id) .toList()), ), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { return Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ); } int textCount = snapshot.data!; return Text( '${textCount.toString()} items', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'SF Pro Display', fontSize: 19.0, fontWeight: FontWeight.bold, useGoogleFonts: false, ), ); }, ); } }, ), ), ], ), ), Builder( builder: (context) { if (valueOrDefault<bool>( _model.sortBy == 'Price: lowest to high', false, )) { return Container( decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 53.0), child: PagedGridView<DocumentSnapshot<Object?>?, ProductsRecord>( pagingController: _model.setGridViewController1( ProductsRecord.collection .where( 'price', isLessThanOrEqualTo: FFAppState().filterPriceHigher.toDouble(), ) .where( 'price', isGreaterThanOrEqualTo: FFAppState().filterPriceLower.toDouble(), ) .where( 'type', isEqualTo: FFAppState().firterProductTypeId == '3IsjNApvCaUKWQyC0fl0' ? null : FFAppState().firterProductTypeId, ) .whereArrayContainsAny( 'colors', FFAppState() .filterColorIds .map((e) => e.id) .toList()) .orderBy('price'), ), padding: EdgeInsets.zero, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 17.0, mainAxisSpacing: 24.0, childAspectRatio: 0.6, ), primary: false, shrinkWrap: true, scrollDirection: Axis.vertical, builderDelegate: PagedChildBuilderDelegate<ProductsRecord>( // Customize what your widget looks like when it's loading the first page. firstPageProgressIndicatorBuilder: (_) => Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ), // Customize what your widget looks like when it's loading another page. newPageProgressIndicatorBuilder: (_) => Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ), itemBuilder: (context, _, gridViewIndex) { final gridViewProductsRecord = _model .gridViewPagingController1! .itemList![gridViewIndex]; return ProductWidget( key: Key( 'Keyd3x_${gridViewIndex}_of_${_model.gridViewPagingController1!.itemList!.length}'), discount: gridViewProductsRecord.discount, image: gridViewProductsRecord.imagesUrl.first, raiting: gridViewProductsRecord.raiting, title: gridViewProductsRecord.title, price: gridViewProductsRecord.price, discountPrice: gridViewProductsRecord.discountPrice, isFavorite: gridViewProductsRecord.inFavorites .contains(currentUserUid) == true, docRef: gridViewProductsRecord.reference, doc: gridViewProductsRecord, ); }, ), ), ), ); } else { return Container( decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 53.0), child: PagedGridView<DocumentSnapshot<Object?>?, ProductsRecord>( pagingController: _model.setGridViewController2( ProductsRecord.collection .where( 'price', isLessThanOrEqualTo: FFAppState().filterPriceHigher.toDouble(), ) .where( 'price', isGreaterThanOrEqualTo: FFAppState().filterPriceLower.toDouble(), ) .where( 'type', isEqualTo: FFAppState().firterProductTypeId == '3IsjNApvCaUKWQyC0fl0' ? null : FFAppState().firterProductTypeId, ) .whereArrayContainsAny( 'colors', FFAppState() .filterColorIds .map((e) => e.id) .toList()) .orderBy('price', descending: true), ), padding: EdgeInsets.zero, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 17.0, mainAxisSpacing: 24.0, childAspectRatio: 0.6, ), primary: false, shrinkWrap: true, scrollDirection: Axis.vertical, builderDelegate: PagedChildBuilderDelegate<ProductsRecord>( // Customize what your widget looks like when it's loading the first page. firstPageProgressIndicatorBuilder: (_) => Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ), // Customize what your widget looks like when it's loading another page. newPageProgressIndicatorBuilder: (_) => Center( child: SizedBox( width: 50.0, height: 50.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>( FlutterFlowTheme.of(context).primary, ), ), ), ), itemBuilder: (context, _, gridViewIndex) { final gridViewProductsRecord = _model .gridViewPagingController2! .itemList![gridViewIndex]; return ProductWidget( key: Key( 'Key7az_${gridViewIndex}_of_${_model.gridViewPagingController2!.itemList!.length}'), discount: gridViewProductsRecord.discount, image: gridViewProductsRecord.imagesUrl.first, raiting: gridViewProductsRecord.raiting, title: gridViewProductsRecord.title, price: gridViewProductsRecord.price, discountPrice: gridViewProductsRecord.discountPrice, isFavorite: gridViewProductsRecord.inFavorites .contains(currentUserUid) == true, docRef: gridViewProductsRecord.reference, doc: gridViewProductsRecord, ); }, ), ), ), ); } }, ), ], ); } }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/category
mirrored_repositories/flutterflow_ecommerce_app/lib/category/category_page/category_page_model.dart
import '/backend/backend.dart'; import '/category/app_bar/app_bar_widget.dart'; import '/category/category_view/category_view_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'category_page_widget.dart' show CategoryPageWidget; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; class CategoryPageModel extends FlutterFlowModel<CategoryPageWidget> { /// Local state fields for this page. String title = 'N/A'; CategoriesRecord? category; /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); // Model for appBar component. late AppBarModel appBarModel; // Model for CategoryView component. late CategoryViewModel categoryViewModel; /// Initialization and disposal methods. void initState(BuildContext context) { appBarModel = createModel(context, () => AppBarModel()); categoryViewModel = createModel(context, () => CategoryViewModel()); } void dispose() { unfocusNode.dispose(); appBarModel.dispose(); categoryViewModel.dispose(); } /// Action blocks are added here. /// Additional helper methods are added here. }
0
mirrored_repositories/flutterflow_ecommerce_app/lib/category
mirrored_repositories/flutterflow_ecommerce_app/lib/category/category_page/category_page_widget.dart
import '/backend/backend.dart'; import '/category/app_bar/app_bar_widget.dart'; import '/category/category_view/category_view_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import 'category_page_model.dart'; export 'category_page_model.dart'; class CategoryPageWidget extends StatefulWidget { const CategoryPageWidget({ Key? key, String? title, required this.category, }) : this.title = title ?? 'N/A', super(key: key); final String title; final CategoriesRecord? category; @override _CategoryPageWidgetState createState() => _CategoryPageWidgetState(); } class _CategoryPageWidgetState extends State<CategoryPageWidget> { late CategoryPageModel _model; final scaffoldKey = GlobalKey<ScaffoldState>(); @override void initState() { super.initState(); _model = createModel(context, () => CategoryPageModel()); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (isiOS) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarBrightness: Theme.of(context).brightness, systemStatusBarContrastEnforced: true, ), ); } context.watch<FFAppState>(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: Color(0xFFF4F3F4), appBar: FFAppState().pageNumber != 4 ? AppBar( automaticallyImplyLeading: false, actions: [], flexibleSpace: FlexibleSpaceBar( background: Container( width: 100.0, height: 100.0, decoration: BoxDecoration( gradient: LinearGradient( colors: [ FlutterFlowTheme.of(context).primary, FlutterFlowTheme.of(context).secondary ], stops: [0.0, 1.0], begin: AlignmentDirectional(-1.0, 0.0), end: AlignmentDirectional(1.0, 0), ), ), ), ), centerTitle: false, elevation: 0.0, ) : null, body: SafeArea( top: true, child: Column( mainAxisSize: MainAxisSize.max, children: [ wrapWithModel( model: _model.appBarModel, updateCallback: () => setState(() {}), child: AppBarWidget( title: widget.title, ), ), Flexible( child: ListView( padding: EdgeInsets.zero, shrinkWrap: true, scrollDirection: Axis.vertical, children: [ Container( decoration: BoxDecoration(), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(0.0, 16.0, 0.0, 0.0), child: wrapWithModel( model: _model.categoryViewModel, updateCallback: () => setState(() {}), child: CategoryViewWidget( category: widget.category!, ), ), ), ), ], ), ), ], ), ), ), ); } }
0