repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/widgets/movie_info_table.dart
import 'package:flutter/material.dart'; import '../../../../core/data/models/movies.dart'; import './movie_info_table_item.dart'; class MovieInfoTable extends StatelessWidget { const MovieInfoTable({Key? key, required this.movie}) : super(key: key); final Movie movie; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ MovieInfoTableItem(title: 'Type', content: movie.type), MovieInfoTableItem(title: 'Hour', content: '${movie.hours} hour'), MovieInfoTableItem(title: 'Director', content: movie.director), ], ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/widgets/book_button.dart
import 'package:flutter/material.dart'; import '../../booking/booking_page.dart'; import '../../../../core/data/models/movies.dart'; import '../../../../core/constants/constants.dart'; class BookButton extends StatelessWidget { const BookButton({Key? key, required this.movie}) : super(key: key); final Movie movie; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { const transitionDuration = Duration(milliseconds: 200); Navigator.of(context).push( PageRouteBuilder( transitionDuration: transitionDuration, reverseTransitionDuration: transitionDuration, pageBuilder: (_, animation, ___) { return FadeTransition( opacity: animation, child: BookingPage(movie: movie), ); }, ), ); }, child: Container( decoration: const BoxDecoration( color: AppColors.primaryColor, borderRadius: BorderRadius.all(Radius.circular(20)), ), ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/animations/opacity_tween.dart
import 'package:flutter/material.dart'; class OpacityTween extends StatelessWidget { const OpacityTween({ Key? key, this.begin = 0.2, this.curve = Curves.easeInToLinear, this.duration = const Duration(milliseconds: 700), required this.child, }) : super(key: key); final Widget child; final Duration duration; final Curve curve; final double begin; @override Widget build(BuildContext context) { return TweenAnimationBuilder<double>( tween: Tween(begin: begin, end: 1.0), curve: curve, duration: duration, builder: (_, value, child) { return Opacity(opacity: value, child: child); }, child: child, ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/animations/slide_up_tween.dart
import 'package:flutter/material.dart'; class SlideUpTween extends StatelessWidget { const SlideUpTween({ Key? key, required this.begin, this.curve = Curves.easeOut, this.duration = const Duration(milliseconds: 750), required this.child, }) : super(key: key); final Offset begin; final Curve curve; final Duration duration; final Widget child; @override Widget build(BuildContext context) { return TweenAnimationBuilder<Offset>( tween: Tween(begin: begin, end: const Offset(0, 0)), curve: curve, duration: duration, builder: (_, value, child) { return Transform.translate(offset: value, child: child); }, child: child, ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/animations/animations.dart
export 'opacity_tween.dart'; export 'slide_up_tween.dart';
0
mirrored_repositories/movie-booking-ui/lib/features
mirrored_repositories/movie-booking-ui/lib/features/booking/booking_page.dart
import 'package:flutter/material.dart'; import './widgets/widgets.dart'; import './animations/animations.dart'; import '../../core/data/models/movies.dart'; import '../../core/constants/constants.dart'; import '../biometrics/custom_biometrics_page.dart'; class BookingPage extends StatefulWidget { const BookingPage({Key? key, required this.movie}) : super(key: key); final Movie movie; @override State<BookingPage> createState() => _BookingPageState(); } class _BookingPageState extends State<BookingPage> with TickerProviderStateMixin { late final BookingPageAnimationController _controller; @override void initState() { _controller = BookingPageAnimationController( buttonController: AnimationController( duration: const Duration(milliseconds: 750), vsync: this, ), contentController: AnimationController( duration: const Duration(milliseconds: 750), vsync: this, ), ); WidgetsBinding.instance?.addPostFrameCallback((_) async { await _controller.buttonController.forward(); await _controller.buttonController.reverse(); await _controller.contentController.forward(); }); super.initState(); } @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { final w = constraints.maxWidth; final h = constraints.maxHeight; return Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( preferredSize: const Size.fromHeight(kToolbarHeight), child: CustomAnimatedOpacity( animation: _controller.topOpacityAnimation, child: MovieAppBar(title: widget.movie.name), ), ), body: Stack( alignment: Alignment.bottomCenter, children: [ Positioned( width: w, height: h * .9, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Column( children: [ const Spacer(), CustomAnimatedOpacity( animation: _controller.topOpacityAnimation, child: SizedBox( height: h * .075, child: MovieDates(dates: widget.movie.dates), ), ), const Spacer(), CustomAnimatedOpacity( animation: _controller.topOpacityAnimation, child: SizedBox( height: h * .2, width: w, child: MovieTheaterScreen( image: widget.movie.image, maxHeight: h, maxWidth: w, ), ), ), SizedBox(height: h * 0.01), CustomAnimatedOpacity( animation: _controller.bottomOpacityAnimation, child: MovieSeats(seats: widget.movie.seats), ), const Spacer(), CustomAnimatedOpacity( animation: _controller.bottomOpacityAnimation, child: const MovieSeatTypeLegend(), ), const Spacer(flex: 3), ], ), ), ), Positioned( bottom: 0, child: GestureDetector( onTap: () { const transitionDuration = Duration(milliseconds: 400); Navigator.of(context).push( PageRouteBuilder( transitionDuration: transitionDuration, reverseTransitionDuration: transitionDuration, pageBuilder: (_, animation, ___) { return FadeTransition( opacity: animation, // child: const BiometricsPage(), Uses Lottie child: const CustomBiometricsPage(), ); }, ), ); }, child: AnimatedBuilder( animation: _controller.buttonController, builder: (_, child) { final size = _controller .buttonSizeAnimation( Size(w * .7, h * .06), Size(w * 1.2, h * 1.1), ) .value; final margin = _controller.buttonMarginAnimation(h * .03).value; return Container( width: size.width, height: size.height, margin: EdgeInsets.only(bottom: margin), decoration: const BoxDecoration( color: AppColors.primaryColor, borderRadius: BorderRadius.all(Radius.circular(20)), ), ); }, ), ), ), Positioned( bottom: h * .05, child: const IgnorePointer( child: Text( 'Buy Ticket', style: AppTextStyles.bookButtonTextStyle, ), ), ), ], ), ); }); } @override void dispose() { _controller.dispose(); super.dispose(); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_seat_section.dart
import 'package:flutter/material.dart'; import './movie_seat_box.dart'; import '../../../core/data/models/movies.dart'; class MovieSeatSection extends StatelessWidget { const MovieSeatSection({Key? key, required this.seats, this.isFront = false}) : super(key: key); final List<Seat> seats; final bool isFront; @override Widget build(BuildContext context) { return Expanded( child: GridView.builder( padding: const EdgeInsets.symmetric( horizontal: 10, ), physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: isFront ? 16 : 20, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, mainAxisSpacing: 8, crossAxisSpacing: 8, ), itemBuilder: (_, index) { final seat = seats[index]; return MovieSeatBox(seat: seat); }, ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_seat_box.dart
import 'package:flutter/material.dart'; import '../../../core/data/models/movies.dart'; import '../../../core/constants/constants.dart'; class MovieSeatBox extends StatefulWidget { const MovieSeatBox({Key? key, required this.seat}) : super(key: key); final Seat seat; @override State<MovieSeatBox> createState() => _SeatBoxState(); } class _SeatBoxState extends State<MovieSeatBox> { @override Widget build(BuildContext context) { final color = widget.seat.isHidden ? Colors.white : widget.seat.isOcuppied ? Colors.black : widget.seat.isSelected ? AppColors.primaryColor : Colors.grey.shade200; return GestureDetector( onTap: () { setState(() { widget.seat.isSelected = !widget.seat.isSelected; }); }, child: AnimatedContainer( duration: const Duration(milliseconds: 300), decoration: BoxDecoration( color: color, borderRadius: const BorderRadius.all( Radius.circular(3), ), ), ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_app_bar.dart
import 'package:flutter/material.dart'; class MovieAppBar extends StatelessWidget { const MovieAppBar({Key? key, required this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { return AppBar( leading: IconButton( onPressed: () => Navigator.of(context).pop(), icon: const Icon(Icons.arrow_back_ios), ), title: Text(title), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/widgets.dart
export 'movie_app_bar.dart'; export 'movie_date_card.dart'; export 'movie_dates.dart'; export 'movie_screen_teather.dart'; export 'movie_seat_box.dart'; export 'movie_seat_section.dart'; export 'movie_seat_type_legend.dart'; export 'movie_seats.dart';
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_dates.dart
import 'package:flutter/material.dart'; import './movie_date_card.dart'; import '../../../core/data/models/movies.dart'; class MovieDates extends StatefulWidget { const MovieDates({Key? key, required this.dates}) : super(key: key); final List<MovieDate> dates; @override State<MovieDates> createState() => _MovieDatesState(); } class _MovieDatesState extends State<MovieDates> { int _selectedIndex = 0; @override Widget build(BuildContext context) { return ListView.separated( separatorBuilder: (_, __) => const SizedBox(width: 10), clipBehavior: Clip.none, physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, itemCount: widget.dates.length, itemBuilder: (context, index) { return GestureDetector( onTap: () { setState(() { _selectedIndex = index; }); }, child: MovieDateCard( date: widget.dates[index], isSelected: index == _selectedIndex, ), ); }, ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_seat_type_legend.dart
import 'package:flutter/material.dart'; import '../../../core/data/data.dart'; class MovieSeatTypeLegend extends StatelessWidget { const MovieSeatTypeLegend({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: seatTypes .map( (seatType) => Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ SizedBox( height: 12, width: 12, child: DecoratedBox( decoration: BoxDecoration( shape: BoxShape.circle, color: seatType.color, ), ), ), Padding( padding: const EdgeInsets.only(left: 7), child: Text(seatType.name), ) ], ), ), ) .toList(growable: false), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_screen_teather.dart
import 'package:flutter/material.dart'; class MovieTheaterScreen extends StatelessWidget { const MovieTheaterScreen({ Key? key, required this.image, required this.maxWidth, required this.maxHeight, }) : super(key: key); final String image; final double maxWidth; final double maxHeight; @override Widget build(BuildContext context) { return Stack( alignment: Alignment.bottomCenter, children: [ Container( transform: Matrix4.identity() ..setEntry(3, 2, 0.001) ..rotateX(.8), transformAlignment: Alignment.topCenter, decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular(15), ), image: DecorationImage( image: AssetImage(image), fit: BoxFit.cover, ), ), ), Positioned( bottom: maxHeight * .025, height: maxHeight * .03, width: maxWidth * .5, child: const CustomPaint( painter: MovieScreenLinePainter(), ), ), ], ); } } class MovieScreenLinePainter extends CustomPainter { const MovieScreenLinePainter(); @override void paint(Canvas canvas, Size size) { final paint = Paint() ..color = Colors.black38 ..style = PaintingStyle.stroke ..strokeWidth = 2.5; final h = size.height; final w = size.width; final path = Path() ..moveTo(0, h) ..quadraticBezierTo(w * 0.44, h * 0.57, w * 0.5, h * 0.6) ..quadraticBezierTo(w * 0.5, h * 0.6, w, h); canvas.drawPath(path, paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) => false; }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_seats.dart
import 'package:flutter/material.dart'; import './movie_seat_section.dart'; import '../../../core/data/models/movies.dart'; class MovieSeats extends StatelessWidget { const MovieSeats({Key? key, required this.seats}) : super(key: key); final List<List<Seat>> seats; @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ for (int i = 0; i < 3; i++) MovieSeatSection( seats: seats[i], isFront: true, ), ], ), const SizedBox(height: 20), Row( children: [ for (int i = 3; i < 6; i++) MovieSeatSection( seats: seats[i], ), ], ), ], ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/widgets/movie_date_card.dart
import 'package:flutter/material.dart'; import '../../../core/data/models/movies.dart'; import '../../../core/constants/constants.dart'; class MovieDateCard extends StatelessWidget { const MovieDateCard({ Key? key, required this.date, required this.isSelected, }) : super(key: key); final MovieDate date; final bool isSelected; @override Widget build(BuildContext context) { return Container( width: 100, decoration: BoxDecoration( color: isSelected ? AppColors.primaryColor : Colors.white, borderRadius: const BorderRadius.all(Radius.circular(15)), border: Border.all(color: AppColors.primaryColor), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '${date.day} ${date.month}', style: TextStyle( color: isSelected ? Colors.white70 : AppColors.primaryColor), ), const SizedBox(height: 5), Text( date.hour, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: isSelected ? Colors.white : AppColors.primaryColor, ), ), ], ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/animations/booking_page_animation_controller.dart
import 'package:flutter/material.dart'; class BookingPageAnimationController { final AnimationController buttonController; final AnimationController contentController; final Animation<double> bottomOpacityAnimation; final Animation<double> topOpacityAnimation; BookingPageAnimationController({ required this.buttonController, required this.contentController, }) : topOpacityAnimation = Tween<double>( begin: 0, end: 1, ).animate(CurvedAnimation( parent: contentController, curve: const Interval(0.1, 1, curve: Curves.fastOutSlowIn), )), bottomOpacityAnimation = Tween<double>( begin: 0, end: 1, ).animate(CurvedAnimation( parent: contentController, curve: const Interval(0, 0.5, curve: Curves.fastOutSlowIn), )); Animation<Size> buttonSizeAnimation(Size min, Size max) { return Tween<Size>(begin: min, end: max).animate(CurvedAnimation( parent: buttonController, curve: Curves.fastOutSlowIn, )); } Animation<double> buttonMarginAnimation(double begin) { return Tween<double>(begin: begin, end: 0).animate(CurvedAnimation( parent: buttonController, curve: Curves.fastOutSlowIn, )); } dispose() { buttonController.dispose(); contentController.dispose(); } }
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/animations/animations.dart
export 'custom_animated_opacity.dart'; export 'booking_page_animation_controller.dart';
0
mirrored_repositories/movie-booking-ui/lib/features/booking
mirrored_repositories/movie-booking-ui/lib/features/booking/animations/custom_animated_opacity.dart
import 'package:flutter/material.dart'; class CustomAnimatedOpacity extends AnimatedWidget { const CustomAnimatedOpacity({ Key? key, required Animation animation, required this.child, }) : super(key: key, listenable: animation); final Widget child; Animation<double> get progress => listenable as Animation<double>; @override Widget build(BuildContext context) { return Opacity( opacity: progress.value, child: child, ); } }
0
mirrored_repositories/movie-booking-ui/lib/features
mirrored_repositories/movie-booking-ui/lib/features/movies/movies_page.dart
import 'package:flutter/material.dart'; import './widgets/widgets.dart'; class MoviesPage extends StatefulWidget { const MoviesPage({Key? key}) : super(key: key); @override State<MoviesPage> createState() => _MoviesPageState(); } class _MoviesPageState extends State<MoviesPage> with SingleTickerProviderStateMixin { // late final TabController _tabController; // @override // void initState() { // _tabController = TabController(length: 3, vsync: this); // super.initState(); // } // @override // void dispose() { // _tabController.dispose(); // super.dispose(); // } @override Widget build(BuildContext context) { return DefaultTabController( length: 3, initialIndex: 0, animationDuration: const Duration(milliseconds: 250), child: Scaffold( appBar: AppBar( bottom: const TabBar( // controller: _tabController, isScrollable: true, indicator: DotIndicator(), tabs: [ Tab(text: 'Movie'), Tab(text: 'Series'), Tab(text: 'TV Show'), ], ), ), body: const TabBarView( // controller: _tabController, physics: NeverScrollableScrollPhysics(), children: [ MoviesView(), SizedBox.expand(), SizedBox.expand(), ], ), ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movies
mirrored_repositories/movie-booking-ui/lib/features/movies/widgets/movies_view.dart
import 'dart:ui' as ui; import 'package:flutter/material.dart'; import '../../../core/data/data.dart'; import '../../../core/constants/constants.dart'; import '../../../features/movie/movie_page.dart'; class MoviesView extends StatefulWidget { const MoviesView({Key? key}) : super(key: key); @override State<MoviesView> createState() => _MoviesViewState(); } class _MoviesViewState extends State<MoviesView> with SingleTickerProviderStateMixin { late final PageController _movieCardPageController; late final PageController _movieDetailPageController; double _movieCardPage = 0.0; double _movieDetailsPage = 0.0; int _movieCardIndex = 0; final _showMovieDetails = ValueNotifier(true); @override void initState() { _movieCardPageController = PageController(viewportFraction: 0.77) ..addListener(_movieCardPagePercentListener); _movieDetailPageController = PageController() ..addListener(_movieDetailsPagePercentListener); super.initState(); } _movieCardPagePercentListener() { setState(() { _movieCardPage = _movieCardPageController.page!; _movieCardIndex = _movieCardPageController.page!.round(); }); } _movieDetailsPagePercentListener() { setState(() { _movieDetailsPage = _movieDetailPageController.page!; }); } @override void dispose() { _movieCardPageController ..removeListener(_movieCardPagePercentListener) ..dispose(); _movieDetailPageController ..removeListener(_movieDetailsPagePercentListener) ..dispose(); super.dispose(); } @override Widget build(BuildContext context) { return LayoutBuilder( builder: (_, constraints) { final h = constraints.maxHeight; final w = constraints.maxWidth; return Column( children: [ const Spacer(), //* Movie Cards SizedBox( height: h * 0.65, child: PageView.builder( controller: _movieCardPageController, clipBehavior: Clip.none, itemCount: movies.length, onPageChanged: (page) { _movieDetailPageController.animateToPage( page, duration: const Duration(milliseconds: 500), curve: const Interval(0.25, 1, curve: Curves.decelerate), ); }, itemBuilder: (_, index) { final movie = movies[index]; final progress = (_movieCardPage - index); final scale = ui.lerpDouble(1, .8, progress.abs())!; final isCurrentPage = index == _movieCardIndex; // final isScrolling = _movieCardPageController // .position.isScrollingNotifier.value; // final isFirstPage = index == 0; return Transform.scale( alignment: Alignment.lerp( Alignment.topLeft, Alignment.center, -progress, ), scale: scale, //isScrolling && isFirstPage ? 1 - progress : scale, child: GestureDetector( onTap: () { _showMovieDetails.value = !_showMovieDetails.value; const transitionDuration = Duration(milliseconds: 550); Navigator.of(context).push( PageRouteBuilder( transitionDuration: transitionDuration, reverseTransitionDuration: transitionDuration, pageBuilder: (_, animation, ___) { return FadeTransition( opacity: animation, child: MoviePage(movie: movie), ); }, ), ); Future.delayed(transitionDuration, () { _showMovieDetails.value = !_showMovieDetails.value; }); }, child: Hero( tag: movie.image, child: AnimatedContainer( duration: const Duration(milliseconds: 300), curve: Curves.easeInOut, transform: Matrix4.identity() ..translate( isCurrentPage ? 0.0 : -20.0, isCurrentPage ? 0.0 : 60.0, ), decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular(70), ), boxShadow: [ BoxShadow( blurRadius: 25, offset: const Offset(0, 25), color: Colors.black.withOpacity(.2), ), ], image: DecorationImage( image: AssetImage(movie.image), fit: BoxFit.cover, ), ), ), ), ), ); }, ), ), const Spacer(), //* Movie Details SizedBox( height: h * 0.22, child: PageView.builder( controller: _movieDetailPageController, physics: const NeverScrollableScrollPhysics(), itemCount: movies.length, itemBuilder: (_, index) { final movie = movies[index]; final opacity = (index - _movieDetailsPage).clamp(0.0, 1.0); return Padding( padding: EdgeInsets.symmetric(horizontal: w * 0.1), child: Opacity( opacity: 1 - opacity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Hero( tag: movie.name, child: Material( type: MaterialType.transparency, child: Text( movie.name.toUpperCase(), style: AppTextStyles.movieNameTextStyle, ), ), ), ValueListenableBuilder<bool>( valueListenable: _showMovieDetails, builder: (_, value, __) { return Visibility( visible: value, child: Text( movie.actors.join(', '), style: AppTextStyles.movieDetails, ), ); }, ), ], ), ), ); }, ), ), ], ); }, ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movies
mirrored_repositories/movie-booking-ui/lib/features/movies/widgets/widgets.dart
export 'dot_indicator.dart'; export 'movies_view.dart';
0
mirrored_repositories/movie-booking-ui/lib/features/movies
mirrored_repositories/movie-booking-ui/lib/features/movies/widgets/dot_indicator.dart
import 'package:flutter/material.dart'; import '../../../core/constants/constants.dart'; class DotIndicator extends Decoration { const DotIndicator(); @override BoxPainter createBoxPainter([VoidCallback? onChanged]) { return const DotIndicatorPainter(); } } class DotIndicatorPainter extends BoxPainter { const DotIndicatorPainter(); static const radius = 6.0; @override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { // The [ImageConfiguration] object passed as the third // argument must, at a minimum, have a non-null [Size]. final dx = configuration.size!.width / 2; final dy = configuration.size!.height + radius / 2; final c = offset + Offset(dx, dy); final paint = Paint()..color = AppColors.primaryColor; canvas.drawCircle(c, radius, paint); } }
0
mirrored_repositories/movie-booking-ui/lib/features
mirrored_repositories/movie-booking-ui/lib/features/biometrics/biometrics_page.dart
import 'package:lottie/lottie.dart'; import 'package:flutter/material.dart'; import '../../core/constants/constants.dart'; class BiometricsPage extends StatelessWidget { const BiometricsPage({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Lottie.asset( faceIDLottie, width: 250, height: 250, frameRate: FrameRate(60), repeat: false, ), ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features
mirrored_repositories/movie-booking-ui/lib/features/biometrics/custom_biometrics_page.dart
import 'package:flutter/material.dart'; import './widgets/widgets.dart'; import './animations/animations.dart'; class CustomBiometricsPage extends StatefulWidget { const CustomBiometricsPage({Key? key, this.customPaintSize = 200.0}) : super(key: key); final double customPaintSize; @override State<CustomBiometricsPage> createState() => _BiometricsPageState(); } class _BiometricsPageState extends State<CustomBiometricsPage> with SingleTickerProviderStateMixin { late final FaceIDAnimationController _controller; @override void initState() { _controller = FaceIDAnimationController( customPaintSize: widget.customPaintSize, controller: AnimationController( duration: const Duration(seconds: 4), vsync: this, ), ); Future.delayed( const Duration(seconds: 1), () => _controller.forward().then( (_) => Navigator.of(context).pop(), ), ); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: CustomPaint( size: Size( widget.customPaintSize, widget.customPaintSize, ), painter: FaceIDPainter( animation: _controller, ), ), ), ); } @override void dispose() { _controller.dispose(); super.dispose(); } }
0
mirrored_repositories/movie-booking-ui/lib/features/biometrics
mirrored_repositories/movie-booking-ui/lib/features/biometrics/widgets/face_id_painter.dart
import 'dart:math' as math; import 'package:vector_math/vector_math.dart' as vector; import 'package:flutter/material.dart'; import '../animations/animations.dart'; import '../../../core/constants/constants.dart'; class FaceIDPainter extends CustomPainter { final FaceIDAnimationController animation; FaceIDPainter({required this.animation}) : super(repaint: animation.controller); @override void paint(Canvas canvas, Size size) { //* Layout assert(size.width == size.height); final s = size.height; // side final oneHalf = s / 2; final oneThird = s / 3; final twoThird = 2 * oneThird; final center = Offset(oneHalf, oneHalf); final radius = math.min(oneHalf, oneHalf); //* Animations final moveR1 = animation.moveR1.value; final moveL1 = animation.moveL1.value; final moveR2 = animation.moveR2.value; final moveU1 = animation.moveU1.value; final moveD1 = animation.moveD1.value; final moveU2 = animation.moveU2.value; final moveX = moveR1 + moveL1 + moveR2; final moveY = moveU1 + moveD1 + moveU2; final canBlink = animation.controller.value >= .6 && animation.controller.value <= .65; final canShowCheck1 = animation.controller.value >= .9; final canShowCheck2 = animation.controller.value >= .95; final check1X = animation.check1X.value; final check1Y = animation.check1Y.value; final check2X = animation.check2X.value; final check2Y = animation.check2Y.value; final closeRRect = animation.closeRRect.value; final borderRadiusRRect = animation.borderRadiusRRect.value; final faceOpacity = animation.faceOpacity.value; //* General Paint final strokeWidth = s * 0.06; final facePaint = Paint() ..strokeWidth = strokeWidth ..color = AppColors.primaryColor.withOpacity(faceOpacity) ..style = PaintingStyle.stroke ..strokeCap = StrokeCap.round; //* Eyes final eyeLength = s * .1; final eyeBlinkPaint = Paint() ..strokeWidth = strokeWidth ..color = canBlink ? Colors.transparent : AppColors.primaryColor.withOpacity(faceOpacity) ..strokeCap = StrokeCap.round; final leftEyeP1 = Offset(oneThird + moveX, oneThird + moveY); final leftEyeP2 = Offset(oneThird + moveX, oneThird + eyeLength + moveY); canvas.drawLine(leftEyeP1, leftEyeP2, facePaint); final rightEyeP1 = Offset(twoThird + moveX, oneThird + moveY); final rightEyeP2 = Offset(twoThird + moveX, oneThird + eyeLength + moveY); canvas.drawLine(rightEyeP1, rightEyeP2, eyeBlinkPaint); //* Smile final rect = Rect.fromCircle( center: Offset(center.dx + moveX, center.dy + moveY), radius: s * .225, ); final startAngle = vector.radians(130); final endAngle = vector.radians(-90); canvas.drawArc(rect, startAngle, endAngle, false, facePaint); //* Nose final offsetFactor = s * 0.006; final noseOffsetX = s * 0.015; final noseOffsetY = s * 0.175; final noseHeight = s * 0.225; final noseWidth = s * 0.05; final nosePath = Path() ..moveTo( (oneHalf + noseOffsetX) + moveX * offsetFactor, oneThird + moveY, ) ..lineTo( (oneHalf + noseOffsetX) + moveX * offsetFactor, oneThird + moveY + noseOffsetY, ) ..quadraticBezierTo( (oneHalf + noseOffsetX) + moveX * offsetFactor, oneThird + noseHeight + moveY, (oneHalf - noseWidth) + moveX * offsetFactor, oneThird + noseHeight + moveY, ); canvas.drawPath(nosePath, facePaint); //* Borders final paintBorders = Paint() ..style = PaintingStyle.stroke ..color = AppColors.primaryColor ..strokeWidth = strokeWidth ..strokeCap = StrokeCap.round; final rRect = RRect.fromRectAndRadius( Rect.fromCircle(center: center, radius: radius), Radius.circular(borderRadiusRRect), ); canvas.drawRRect(rRect, paintBorders); //* Border Separator final lines = Paint() ..style = PaintingStyle.fill ..color = Colors.white ..strokeWidth = s * 0.07; final closeOffsetYP1 = oneThird * (1 + closeRRect); final closeOffsetYP2 = oneThird * (2 - closeRRect); canvas.drawLine( Offset(0, closeOffsetYP1), Offset(0, closeOffsetYP2), lines, ); canvas.drawLine( Offset(s, closeOffsetYP1), Offset(s, closeOffsetYP2), lines, ); canvas.drawLine( Offset(closeOffsetYP1, 0), Offset(closeOffsetYP2, 0), lines, ); canvas.drawLine( Offset(closeOffsetYP1, s), Offset(closeOffsetYP2, s), lines, ); //* Borders Caps final circle = Paint() ..style = PaintingStyle.fill ..color = AppColors.primaryColor ..strokeWidth = s * 0.025; final capRadius = s * .03; canvas.drawCircle(Offset(0, closeOffsetYP1), capRadius, circle); canvas.drawCircle(Offset(0, closeOffsetYP2), capRadius, circle); canvas.drawCircle(Offset(s, closeOffsetYP1), capRadius, circle); canvas.drawCircle(Offset(s, closeOffsetYP2), capRadius, circle); canvas.drawCircle(Offset(closeOffsetYP1, 0), capRadius, circle); canvas.drawCircle(Offset(closeOffsetYP2, 0), capRadius, circle); canvas.drawCircle(Offset(closeOffsetYP1, s), capRadius, circle); canvas.drawCircle(Offset(closeOffsetYP2, s), capRadius, circle); //* Check final check1 = Paint() ..strokeCap = StrokeCap.round ..color = canShowCheck1 ? AppColors.primaryColor : Colors.transparent ..strokeWidth = strokeWidth; canvas.drawLine( Offset(s * .275, oneHalf), Offset(check1X, check1Y), check1, ); final check2 = Paint() ..strokeCap = StrokeCap.round ..color = canShowCheck2 ? AppColors.primaryColor : Colors.transparent ..strokeWidth = strokeWidth; canvas.drawLine( Offset(oneHalf, s * .7), Offset(check2X, check2Y), check2, ); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return true; } }
0
mirrored_repositories/movie-booking-ui/lib/features/biometrics
mirrored_repositories/movie-booking-ui/lib/features/biometrics/widgets/widgets.dart
export 'face_id_painter.dart';
0
mirrored_repositories/movie-booking-ui/lib/features/biometrics
mirrored_repositories/movie-booking-ui/lib/features/biometrics/animations/face_id_animation_controller.dart
import 'package:flutter/material.dart'; class FaceIDAnimationController { final AnimationController controller; final double customPaintSize; final Animation<double> moveR1; final Animation<double> moveL1; final Animation<double> moveR2; final Animation<double> moveU1; final Animation<double> moveD1; final Animation<double> moveU2; final Animation<double> closeRRect; final Animation<double> borderRadiusRRect; final Animation<double> faceOpacity; final Animation<double> check1X; final Animation<double> check1Y; final Animation<double> check2X; final Animation<double> check2Y; FaceIDAnimationController({ required this.controller, required this.customPaintSize, }) : moveR1 = Tween<double>( begin: 0, end: 20, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0, 0.2, curve: Curves.fastOutSlowIn), )), moveL1 = Tween<double>( begin: 0, end: -35, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.2, 0.4, curve: Curves.fastOutSlowIn), )), moveU1 = Tween<double>( begin: 0, end: -10, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.2, 0.3, curve: Curves.fastOutSlowIn), )), moveD1 = Tween<double>( begin: 0, end: 15, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.3, 0.4, curve: Curves.fastOutSlowIn), )), moveR2 = Tween<double>( begin: 0, end: 15, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.4, 0.6, curve: Curves.fastOutSlowIn), )), moveU2 = Tween<double>( begin: 0, end: -5, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.4, 0.6, curve: Curves.fastOutSlowIn), )), closeRRect = Tween<double>( begin: 0, end: 0.5, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.4, 0.6, curve: Curves.fastOutSlowIn), )), borderRadiusRRect = Tween<double>( begin: 50, end: 100, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.45, 0.6, curve: Curves.fastOutSlowIn), )), faceOpacity = Tween<double>( begin: 1, end: 0, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.825, 0.875, curve: Curves.fastOutSlowIn), )), check1X = Tween<double>( begin: customPaintSize * .275, end: customPaintSize * 0.5, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.9, 0.95, curve: Curves.fastOutSlowIn), )), check1Y = Tween<double>( begin: customPaintSize * 0.5, end: customPaintSize * 0.7, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.9, 0.95, curve: Curves.fastOutSlowIn), )), check2X = Tween<double>( begin: customPaintSize * 0.5, end: customPaintSize * 0.75, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.95, 1, curve: Curves.bounceOut), )), check2Y = Tween<double>( begin: customPaintSize * 0.7, end: customPaintSize * 0.3, ).animate(CurvedAnimation( parent: controller, curve: const Interval(0.95, 1, curve: Curves.bounceOut), )); TickerFuture forward() => controller.forward(); void dispose() { controller.dispose(); } }
0
mirrored_repositories/movie-booking-ui/lib/features/biometrics
mirrored_repositories/movie-booking-ui/lib/features/biometrics/animations/animations.dart
export 'face_id_animation_controller.dart';
0
mirrored_repositories/movie-booking-ui/lib/core
mirrored_repositories/movie-booking-ui/lib/core/constants/app_theme.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import './app_text_styles.dart'; class AppTheme { AppTheme._(); static ThemeData light = ThemeData( appBarTheme: const AppBarTheme( elevation: 0, foregroundColor: Colors.black, centerTitle: true, color: Colors.transparent, systemOverlayStyle: SystemUiOverlayStyle( statusBarColor: Colors.transparent, ), titleTextStyle: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: Colors.black, ), ), scaffoldBackgroundColor: Colors.white, tabBarTheme: const TabBarTheme( labelColor: Colors.black, labelStyle: AppTextStyles.labelStyle, unselectedLabelStyle: AppTextStyles.unselectedLabelStyle, ), ); }
0
mirrored_repositories/movie-booking-ui/lib/core
mirrored_repositories/movie-booking-ui/lib/core/constants/app_text_styles.dart
import 'package:flutter/material.dart'; class AppTextStyles { AppTextStyles._(); static const labelStyle = TextStyle( color: Colors.black, fontWeight: FontWeight.w700, fontSize: 28, ); static const unselectedLabelStyle = TextStyle( color: Colors.black87, fontWeight: FontWeight.w600, fontSize: 24, ); static const movieNameTextStyle = TextStyle( fontSize: 45, fontWeight: FontWeight.bold, ); static const movieDetails = TextStyle( height: 1.5, fontSize: 20, ); static const bookButtonTextStyle = TextStyle( color: Colors.white, fontSize: 20, fontWeight: FontWeight.w500, letterSpacing: 1.1, ); static const movieDescriptionStyle = TextStyle( fontSize: 20, fontWeight: FontWeight.w300, ); static const infoTitleStyle = TextStyle( fontSize: 20, fontWeight: FontWeight.w400, ); static const infoContentStyle = TextStyle( fontSize: 20, fontWeight: FontWeight.w700, ); }
0
mirrored_repositories/movie-booking-ui/lib/core
mirrored_repositories/movie-booking-ui/lib/core/constants/app_colors.dart
import 'package:flutter/material.dart'; class AppColors { AppColors._(); static const primaryColor = Color(0xFF006BF3); }
0
mirrored_repositories/movie-booking-ui/lib/core
mirrored_repositories/movie-booking-ui/lib/core/constants/constants.dart
export 'app_colors.dart'; export 'app_text_styles.dart'; export 'app_theme.dart'; export 'lotties.dart'; const appName = 'Flutter Movie Ticket';
0
mirrored_repositories/movie-booking-ui/lib/core
mirrored_repositories/movie-booking-ui/lib/core/constants/lotties.dart
const faceIDLottie = 'assets/lotties/face_id.json';
0
mirrored_repositories/movie-booking-ui/lib/core
mirrored_repositories/movie-booking-ui/lib/core/data/data.dart
import 'package:flutter/material.dart'; import './models/movies.dart'; import '../constants/constants.dart'; final section1 = List.generate( 16, (index) => Seat( isHidden: [0, 1, 4].contains(index), isOcuppied: [].contains(index), ), ); final section2 = List.generate( 16, (index) => Seat( isHidden: [4, 5, 6, 7].contains(index), isOcuppied: [12, 13].contains(index), ), ); final section3 = List.generate( 16, (index) => Seat( isHidden: [2, 3, 7].contains(index), isOcuppied: [13, 14, 15].contains(index), ), ); final section4 = List.generate( 20, (index) => Seat( isHidden: [].contains(index), isOcuppied: [1, 2, 3].contains(index), ), ); final section5 = List.generate( 20, (index) => Seat( isHidden: [].contains(index), isOcuppied: [].contains(index), ), ); final section6 = List.generate( 20, (index) => Seat( isHidden: [].contains(index), isOcuppied: [14].contains(index), ), ); final seats = [ section1, section2, section3, section4, section5, section6, ]; const seatTypes = [ SeatType(name: 'Available', color: Colors.grey), SeatType(name: 'Booked', color: Colors.black), SeatType(name: 'Selection', color: AppColors.primaryColor), ]; const dates = [ MovieDate(day: 11, month: 'OCT', hour: '6:00PM'), MovieDate(day: 11, month: 'OCT', hour: '8:00PM'), MovieDate(day: 11, month: 'OCT', hour: '9:00PM'), MovieDate(day: 11, month: 'OCT', hour: '10:00PM'), ]; final movies = [ Movie( name: 'Black Widow', image: 'assets/images/black_widow.jpg', screenPreview: 'assets/images/black_widow.jpg', description: 'Natasha Romanoff confronts the darker parts of her ledger when ' 'when a dangerous conspiracy with ties to her past arises.', type: 'Action', hours: 2, director: 'Cate Shortland', stars: 5, actors: [ 'Scarlett Johansson', 'Florence Pugh', 'Rachel Weisz', 'David Harbour', 'Ray Winstone', ], dates: dates, seats: seats, ), Movie( name: 'Cosmopolis', image: 'assets/images/cosmopolis.jpg', screenPreview: 'assets/images/cosmopolis.jpg', description: 'Riding across Manhattan in a stretch limo in order to get a haircut, ' 'a 28-year-old billionaire asset manager\'s day devolves into an ' 'odyssey with a cast of characters that start to tear his world apart.', type: 'Crime', hours: 2, director: 'David Cronenberg', stars: 5, actors: [ 'Robert Pattinson', 'Sarah Gadon', 'Paul Giamatti', 'Kevin Durand', 'Abdul Ayoola', ], dates: dates, seats: seats, ), Movie( name: 'Venom', image: 'assets/images/venom.jpg', screenPreview: 'assets/images/venom.jpg', description: 'A failed reporter is bonded to an alien entity, one of many symbiotes who ' 'have invaded Earth. But the being takes a liking to Earth and decides to ' 'protect it.', type: 'Adventure', hours: 2, director: 'Ruben Fleischer', stars: 5, actors: [ 'Tom Hardy', 'Michelle Williams', 'Riz Ahmed', 'Scott Haze', 'Reid Scott', ], dates: dates, seats: seats, ), Movie( name: 'Venom 2', image: 'assets/images/venom2.jpeg', screenPreview: 'assets/images/venom2.jpeg', description: 'Eddie Brock attempts to reignite his career by interviewing serial killer Cletus ' 'Kasady, who becomes the host of the symbiote Carnage and escapes prison after ' 'a failed execution.', type: 'Adventure', hours: 2, director: 'Andy Serkis', stars: 5, actors: [ 'Tom Hardy', 'Woody Harrelson', 'Michelle Williams', 'Naomie Harris', 'Reid Scott', ], dates: dates, seats: seats, ), Movie( name: 'Sensation', image: 'assets/images/sensation.jpg', screenPreview: 'assets/images/sensation.jpg', description: 'When a lowly postman is inducted into a top-secret superhuman DNA program at ' 'a research facility, it\'s revealed that he\'ll be able to receive, control ' 'and send information based on the senses of others.', type: 'Mystery', hours: 2, director: 'Martin Grof', stars: 5, actors: [ 'Eugene Simon', 'Emily Wyatt', 'Jennifer Martin', 'Marybeth Havens', 'Anil Desai', ], dates: dates, seats: seats, ), // Movie( // name: 'Aladdin ', // image: 'assets/images/aladdin.jpg', // screenPreview: 'assets/images/aladdin.jpg', // description: // 'A kind-hearted street urchin and a power-hungry Grand Vizier vie for ' // 'a magic lamp that has the power to make their deepest wishses come true.', // type: 'Fantasy', // hours: 2, // director: 'Ritchie', // stars: 5, // actors: [ // 'Will Smith', // 'Joey Ansah', // 'Naomi Scott', // 'Marwan Kenzari', // 'Nasim Pedrad', // ], // dates: dates, // seats: seats, // ), // Movie( // name: 'Aladdin 2 ', // image: 'assets/images/aladdin_2.jpg', // screenPreview: 'assets/images/aladdin_2.jpg', // description: // 'A kind-hearted street urchin and a power-hungry Grand Vizier vie for ' // 'a magic lamp that has the power to make their deepest wishses come true.', // type: 'Fantasy', // hours: 2, // director: 'Ritchie', // stars: 5, // actors: [ // 'Will Smith', // 'Joey Ansah', // 'Naomi Scott', // 'Marwan Kenzari', // 'Nasim Pedrad', // ], // dates: dates, // seats: seats, // ), ];
0
mirrored_repositories/movie-booking-ui/lib/core/data
mirrored_repositories/movie-booking-ui/lib/core/data/models/movies.dart
import 'package:flutter/material.dart'; class Movie { final String name; final String image; final String screenPreview; final String description; final String type; final int hours; final String director; final int stars; final List<String> actors; final List<MovieDate> dates; final List<List<Seat>> seats; const Movie({ required this.name, required this.image, required this.screenPreview, required this.description, required this.type, required this.hours, required this.director, required this.stars, required this.actors, required this.dates, required this.seats, }); } class MovieDate { final int day; final String month; final String hour; const MovieDate({ required this.day, required this.month, required this.hour, }); } class Seat { final bool isHidden; final bool isOcuppied; bool isSelected; Seat({ required this.isHidden, required this.isOcuppied, this.isSelected = false, }); } class SeatType { final String name; final Color color; const SeatType({ required this.name, required this.color, }); }
0
mirrored_repositories/movie-booking-ui
mirrored_repositories/movie-booking-ui/test/widget_test.dart
// // This is a basic Flutter widget test. // // // // To perform an interaction with a widget in your test, use the WidgetTester // // utility that Flutter provides. For example, you can send tap and scroll // // gestures. You can also use WidgetTester to find child widgets in the widget // // tree, read text, and verify that the values of widget properties are correct. // import 'package:flutter/material.dart'; // import 'package:flutter_test/flutter_test.dart'; // import 'package:movie_app_ui/main.dart'; // void main() { // testWidgets('Counter increments smoke test', (WidgetTester tester) async { // // Build our app and trigger a frame. // await tester.pumpWidget(const MyApp()); // // Verify that our counter starts at 0. // expect(find.text('0'), findsOneWidget); // expect(find.text('1'), findsNothing); // // Tap the '+' icon and trigger a frame. // await tester.tap(find.byIcon(Icons.add)); // await tester.pump(); // // Verify that our counter has incremented. // expect(find.text('0'), findsNothing); // expect(find.text('1'), findsOneWidget); // }); // }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/work_page.dart
// ignore_for_file: unnecessary_statements import 'package:example/code_viwer.dart'; import 'package:example/colors.dart'; import 'package:clipboard/clipboard.dart'; import 'package:example/console.dart'; import 'package:example/node.dart'; import 'package:example/node_manger.dart'; import 'package:example/nodes.dart'; import 'package:example/widgets.dart'; import 'package:flutter/material.dart'; import 'package:uuid/uuid.dart'; import 'package:widget_arrows/widget_arrows.dart'; class WorkPage extends StatefulWidget { @override State<WorkPage> createState() => _WorkPageState(); } class _WorkPageState extends State<WorkPage> { List<Node> nodes = []; int index = 0; List<Screen> userScreens = []; int selectedVar = -1; int selectedScreenNode = 0; int screenIndex = 0; Node appe = Node(); bool isRunningWidgetCreated = false; bool isRunning = false; bool showApp = true; bool appBar = true; Size privewSize = Size(350, 300); String log = "Create Screen"; Node runningWidget = Node(); dynamic runningWidgetInput; List<String> logs = []; @override Widget build(BuildContext context) { privewSize = Size(350, MediaQuery.of(context).size.height - 40); return Scaffold( backgroundColor: Colors.red, body: Visibility( visible: !isRunning, replacement: Container( height: double.infinity, width: double.infinity, color: backGroundColor, child: Stack( children: [ IconButton( onPressed: () { isRunning = false; setState(() {}); }, icon: Icon( Icons.back_hand_rounded, color: selectedNodeColor, size: 40, )), Center( child: appPley(), ), ], ), ), child: Stack( children: [ Stack( children: [ SizedBox( width: MediaQuery.of(context).size.width, child: ArrowContainer( child: NodeManger( onDeleteClass: (e) { userScreens.remove(userScreens[e.classId]); setState(() {}); }, onClass: (node, body) { selectedScreenNode = node.classId - 1; userScreens[selectedScreenNode].child = node.inputs[1]["child"]; if (isRunning == false) { appe = node.inputs[1]["child"]; } setState(() {}); }, onStopRun: () { appe = Node(); isRunning = false; setState(() {}); }, onDeClass: (e) { appe = Node(); userScreens[e.classId - 1].child = Node(); setState(() {}); }, onRun: (e, en) { isRunning = true; if (e.inputs[1]["child"] != null) { runningWidget = e; runningWidgetInput = en; appe = e.inputs[1]["child"]; userScreens[screenIndex].child = appe; } else { appe = e; } setState(() {}); }, updateApp: () { if (userScreens.length > screenIndex) { userScreens[screenIndex].child = appe; setState(() {}); } }, nodes: nodes, onPaste: (e, p) { nodes.add(Node( id: Uuid().v1(), inputs: e.inputs .map((e) => { 'targetId': e['targetId'], 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': e["valueType"], 'value': null }) .toList(), outputs: e.outputs .map((e) => { 'targetId': e['targetId'], 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': e["valueType"], 'value': null }) .toList(), title: e.title, color: e.color, x: p.globalPosition.dx, y: p.globalPosition.dy)); setState(() {}); }, onDelete: (e) { nodes.remove(e); setState(() {}); }, onSelect: (e) { if (e.isItCalss && isRunning == false) { selectedScreenNode = e.classId - 1; screenIndex = e.classId - 1; appe = e.inputs[1]["child"] ?? Node(); userScreens[screenIndex].child = appe; setState(() {}); } showDialog( context: context, builder: (context) { if (e.isItVar && e.type != "List") { selectedVar = e.outputs[0]["varId"]; return Dialog( backgroundColor: Colors.transparent, child: Container( decoration: BoxDecoration( color: nodeBarColor, border: Border.all( color: selectedNodeColor, width: 2), borderRadius: BorderRadius.circular(10)), height: 300, width: 500, child: Column( children: [ TextFiledForWork( onIcon: () {}, haveIcon: false, name: "Var Name", maxLength: 20, type: "String", value: e.varName, onChanged: (eg) { e.varName = eg.replaceAll(" ", ""); userScreens[screenIndex] .vars[selectedVar - 1] .varName = e.varName; userScreens[screenIndex].child = appe; setState(() {}); }), e.title != "Color" && e.title != "IconData" ? TextFiledForWork( onIcon: () {}, haveIcon: false, name: "Var Value", maxLength: 20, type: e.title, value: e.outputs[0]["value"] .toString(), onChanged: (eg) { if (eg.isNotEmpty) { if (e.outputs[0] ["valueType"] == "Num") { e.outputs[0]["value"] = double.parse(eg); userScreens[screenIndex] .vars[selectedVar - 1] .value = double.parse(eg); userScreens[screenIndex] .child = appe; } else { e.outputs[0]["value"] = eg; userScreens[screenIndex] .vars[selectedVar - 1] .value = eg; userScreens[screenIndex] .child = appe; } setState(() {}); } }) : e.title == "Color" ? Button( text: "Pick Color", onClick: () { showDialog( context: context, builder: (context) { return ColorPick( pikcerColor: e .outputs[ 0]["value"], colore: (eg) { e.outputs[0][ "value"] = eg; userScreens[ screenIndex] .vars[ selectedVar - 1] .value = eg; userScreens[ screenIndex] .child = appe; setState( () {}); }); }); }, ) : IconPick(newIcon: (icone) { e.outputs[0]["value"] = e.outputs[0]["value"] = icone; userScreens[screenIndex] .vars[selectedVar - 1] .value = icone; userScreens[screenIndex] .child = appe; setState(() {}); }) ], ), ), ); } else if (e.type == "List") { selectedVar = e.outputs[0]["varId"]; return Dialog( backgroundColor: Colors.transparent, child: Container( decoration: BoxDecoration( color: nodeBarColor, border: Border.all( color: selectedNodeColor, width: 2), borderRadius: BorderRadius.circular(10)), height: 300, width: 500, child: Column( children: [ TextFiledForWork( onIcon: () {}, haveIcon: false, name: "Var Name", maxLength: 20, type: "String", value: e.varName, onChanged: (eg) { e.varName = eg.replaceAll(" ", ""); userScreens[screenIndex] .vars[selectedVar - 1] .varName = e.varName; userScreens[screenIndex].child = appe; setState(() {}); }), Column( children: userScreens[screenIndex] .vars[selectedVar - 1] .value .map<Widget>((eg) { dynamic varr = e.outputs[0]["value"]; int itme = varr.indexOf(eg); return AddItmeToList( varr: e, onDelete: () { varr.remove(eg); userScreens[screenIndex] .vars[selectedVar - 1] .value = varr; Navigator.pop(context); }, onEdit: (e) { varr[itme] = e; userScreens[screenIndex] .vars[selectedVar - 1] .value[itme] = varr[itme]; userScreens[screenIndex] .child = appe; setState(() {}); }, value: varr[varr.indexOf(eg)]); }).toList(), ), Button( text: "Add Itme", onClick: () { dynamic value = e.title == "List(Color)" ? Colors.red : e.title == "List(String)" ? "String" : e.title == "List(Num)" ? 0 : Icons.abc; e.outputs[0]["value"].add(value); userScreens[screenIndex] .vars[selectedVar - 1] .value = e.outputs[0]["value"]; Navigator.pop(context); }) ], ), ), ); } else if (e.isItCalss == true) { return Dialog( backgroundColor: Colors.transparent, child: Container( decoration: BoxDecoration( color: nodeBarColor, border: Border.all( color: selectedNodeColor, width: 2), borderRadius: BorderRadius.circular(10)), height: 400, width: 600, child: Column( children: [ TextFiledForWork( onIcon: () {}, haveIcon: false, name: "Class name", maxLength: 20, type: "String", value: e.varName, onChanged: (eg) { e.varName = eg; userScreens[selectedScreenNode] .name = eg; setState(() {}); }), userScreens[selectedScreenNode] .vars .length > 0 ? VarPicker( vars: userScreens[ selectedScreenNode] .vars, onPick: (e) {}, ) : SizedBox() ], ), ), ); } else { return SizedBox(); } }); }, ), ), ), widgets(), ], ), Align( alignment: Alignment.centerRight, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Container( margin: EdgeInsets.only( top: 5, left: 9, right: 9, bottom: 2), width: 70, height: 30, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: selectedNodeColor), child: TextButton( onPressed: () { if (userScreens.isNotEmpty) { showDialog( context: context, builder: (context) { return CodeViwer( userScreen: userScreens, ); }, ); } }, child: Icon( Icons.code, color: nodeBarColor, size: 30, ), ), ), Container( margin: EdgeInsets.only( top: 5, left: 9, right: 9, bottom: 2), width: 70, height: 30, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: selectedNodeColor), child: TextButton( onPressed: () { logs.add("value"); showApp = !showApp; setState(() {}); }, child: Icon( Icons.visibility, color: nodeBarColor, size: 30, ), ), ), Container( margin: EdgeInsets.only( top: 5, left: 9, right: 9, bottom: 2), width: 70, height: 30, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: selectedNodeColor), child: TextButton( onPressed: () { showDialog( context: context, builder: (context) { return Console( logs: logs, onDelete: () { Future.delayed(Duration.zero, () { logs = []; setState(() {}); }); }); }, ); }, child: Icon( Icons.logo_dev, color: nodeBarColor, size: 30, ), ), ), ], ), Visibility( visible: showApp, child: Visibility(visible: !isRunning, child: appPley())), ], ), ), ], ), ), ); } Widget appPley() { return GestureDetector( onTap: () { setState(() {}); }, child: Container( height: privewSize.height, padding: EdgeInsets.all(10), decoration: BoxDecoration( color: backGroundColor, border: Border.all(color: selectedNodeColor, width: 2)), width: privewSize.width, child: Stack( children: [ userScreens.length > 0 ? widgetSelector(userScreens[screenIndex].child) : Center( child: Text( log, style: TextStyle(color: selectedNodeColor), ), ), ], )), ); } Widget widgets() { return Container( width: 200, height: privewSize.height + 30, decoration: BoxDecoration( color: appBar ? nodeBarColor : Colors.transparent, border: Border( right: BorderSide( color: appBar ? selectedNodeColor : Colors.transparent, width: 2))), child: Column( children: [ Container( margin: EdgeInsets.only(top: 5, left: 9, right: 9), width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: selectedNodeColor), child: TextButton( onPressed: () { appBar = !appBar; setState(() {}); }, child: Icon( Icons.disabled_visible, color: nodeBarColor, size: 30, ), )), Visibility( visible: appBar, child: SizedBox( height: privewSize.height - 10, width: 200, child: SingleChildScrollView( controller: ScrollController(), child: IntrinsicHeight( child: Wrap( children: [ ///---------------[widgets]-------------- Column( children: [ Text( " Widgets", style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: selectedNodeColor, fontFamily: 'Inter'), ), Wrap( children: [ NodeSelectorBox( name: "Screen", onAdd: (eg) { userScreens.add( Screen(id: Uuid().v1(), child: Node())); nodes.add(node("Screen", userScreens.length, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Scaffold", onAdd: (eg) { nodes.add(node( "Scaffold", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "AppBar", onAdd: (eg) { nodes.add(node( "AppBar", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Text", onAdd: (eg) { nodes.add( node("Text", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Container", onAdd: (eg) { nodes.add(node( "Container", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Row", onAdd: (eg) { nodes.add( node("Row", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Column", onAdd: (eg) { nodes.add(node( "Column", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Stack", onAdd: (eg) { nodes.add(node( "Stack", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Center", onAdd: (eg) { nodes.add(node( "Center", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Icon", onAdd: (eg) { nodes.add( node("Icon", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Button", onAdd: (eg) { nodes.add(node( "Button", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "GestureDetector", onAdd: (eg) { nodes.add(node("GestureDetector", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Image", onAdd: (eg) { nodes.add(node( "Image", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "SizedBox", onAdd: (eg) { nodes.add(node( "SizedBox", -1, eg, userScreens.length)); setState(() {}); }, ), ], ), ], ), ///---------------------------[Functions]----------------------- Column( children: [ Text( " Functions", style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: selectedNodeColor, fontFamily: 'Inter'), ), Wrap( children: [ NodeSelectorBox( name: "Add", onAdd: (eg) { nodes.add( node("Add", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Subtract", onAdd: (eg) { nodes.add(node( "Subtract", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Dividing", onAdd: (eg) { nodes.add(node( "Dividing", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Multiply", onAdd: (eg) { nodes.add(node( "Multiply", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Nav", onAdd: (eg) { nodes.add( node("Nav", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "SetVar", onAdd: (eg) { nodes.add(node( "SetVar", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Print", onAdd: (eg) { nodes.add(node( "Print", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "If", onAdd: (eg) { nodes.add( node("If", -1, eg, userScreens.length)); setState(() {}); }, ), NodeSelectorBox( name: "Run", onAdd: (eg) { if (isRunningWidgetCreated == false) { nodes.add(node( "Run", -1, eg, userScreens.length)); isRunningWidgetCreated = true; setState(() {}); } }, ), ], ), ], ), /// ----------------------------[Vars]------------------- Column( children: [ Text( " Vars", style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: selectedNodeColor, fontFamily: 'Inter'), ), Wrap( children: [ NodeSelectorBox( name: "String", onAdd: (eg) { showDialog( context: context, builder: (context) { return ScreenPicker( screens: userScreens, onPick: (e) { userScreens[userScreens.indexOf(e)] .vars .add(ScreenVar( varName: "myVar", value: "String", type: "String", id: "one")); nodes.add(node( "string", userScreens[ userScreens.indexOf(e)] .vars .length, eg, userScreens.length)); setState(() {}); }); }, ); setState(() {}); }, ), NodeSelectorBox( name: "Num", onAdd: (eg) { showDialog( context: context, builder: (context) { return ScreenPicker( screens: userScreens, onPick: (e) { userScreens[userScreens.indexOf(e)] .vars .add(ScreenVar( varName: "myVar", value: 0, type: "double", id: "one")); nodes.add(node( "Num", userScreens[ userScreens.indexOf(e)] .vars .length, eg, userScreens.length)); setState(() {}); }); }, ); }, ), NodeSelectorBox( name: "IconData", onAdd: (eg) { showDialog( context: context, builder: (context) { return ScreenPicker( screens: userScreens, onPick: (e) { userScreens[userScreens.indexOf(e)] .vars .add(ScreenVar( varName: "myVar", value: Icons.abc, type: "IconData", id: "one")); nodes.add(node( "IconData", userScreens[ userScreens.indexOf(e)] .vars .length, eg, userScreens.length)); setState(() {}); }); }, ); }, ), NodeSelectorBox( name: "Color", onAdd: (eg) { showDialog( context: context, builder: (context) { return ScreenPicker( screens: userScreens, onPick: (e) { userScreens[ userScreens.indexOf(e)] .vars .add(ScreenVar( varName: "myVar", value: Colors.blue, type: "Color", id: "one")); nodes.add(node( "color", userScreens[userScreens .indexOf(e)] .vars .length, eg, userScreens.length)); setState(() {}); }); }, ); }), ], ), ], ), ], ), ), ), ), ), ], ), ); } Widget widgetSelector(Node node) { if (node.title == "Text") { return Text( node.inputs[0]["isConected"] ? node.inputs[0]["fromVar"] ? userScreens[screenIndex] .vars[node.inputs[0]["varId"]] .value .toString() : node.inputs[0]["value"].outputs[1]["value"].toString() : node.inputs[0]["value"], style: TextStyle( fontWeight: node.inputs[3]["isConected"] ? node.inputs[3]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"] : node.inputs[3]["value"], color: node.inputs[1]["isConected"] ? node.inputs[1]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["value"] : node.inputs[1]["value"], fontSize: node.inputs[2]["isConected"] ? node.inputs[2]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"] : node.inputs[2]["value"], ), ); } else if (node.title == "Scaffold") { return SizedBox( height: privewSize.height - 25, width: privewSize.width - 25, child: Scaffold( backgroundColor: node.inputs[1]["isConected"] ? node.inputs[1]["fromVar"] ? userScreens[screenIndex] .vars[node.inputs[1]["varId"]] .value : node.inputs[1]["value"] : node.inputs[1]["value"], drawer: node.inputs[4]["isConected"] ? widgetSelector(node.inputs[4]["value"]) : null, appBar: PreferredSize( preferredSize: Size.fromHeight(node.inputs[3]["isConected"] ? node.inputs[3]["fromVar"] ? userScreens[screenIndex] .vars[node.inputs[3]["varId"]] .value : node.inputs[3]["value"] : node.inputs[3]["value"]), child: node.inputs[2]["isConected"] ? widgetSelector(node.inputs[2]["value"]) : SizedBox()), body: node.inputs[0]["isConected"] ? widgetSelector(node.inputs[0]["value"]) : null), ); } else if (node.title == "AppBar") { return AppBar( flexibleSpace: node.inputs[2]["isConected"] ? node.inputs[2]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"] != null ? widgetSelector(node.inputs[2]["value"]) : null : node.inputs[2]["value"] != null ? widgetSelector(node.inputs[2]["value"]) : null, title: node.inputs[0]["isConected"] ? node.inputs[0]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[0]["varId"]].value : node.inputs[0]["value"] != null ? widgetSelector(node.inputs[0]["value"]) : null : node.inputs[0]["value"] != null ? widgetSelector(node.inputs[0]["value"]) : null, backgroundColor: node.inputs[1]["isConected"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["value"], shadowColor: node.inputs[3]["isConected"] ? userScreens[screenIndex].vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"], ); } else if (node.title == "Container") { return Container( height: node.inputs[0]["isConected"] ? userScreens[screenIndex].vars[node.inputs[0]["varId"]].value : node.inputs[0]["max"] ? privewSize.height : node.inputs[0]["value"], width: node.inputs[1]["isConected"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["max"] ? privewSize.width : node.inputs[1]["value"], color: node.inputs[2]["isConected"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"], child: node.inputs[3]["isConected"] ? node.inputs[3]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"] != null ? widgetSelector(node.inputs[3]["value"]) : null : node.inputs[3]["value"] != null ? widgetSelector(node.inputs[3]["value"]) : null, ); } else if (node.title == "Button") { return ElevatedButton( onPressed: node.inputs[5]["value"].length > 0 ? () { node.inputs[5]["value"].forEach((Node nde) { event(nde); }); } : () {}, style: ElevatedButton.styleFrom( backgroundColor: node.inputs[0]["isConected"] ? userScreens[screenIndex].vars[node.inputs[0]["varId"]].value : node.inputs[0]["value"], foregroundColor: node.inputs[1]["isConected"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["value"], shadowColor: node.inputs[2]["isConected"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"], elevation: node.inputs[3]["isConected"] ? userScreens[screenIndex].vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"]), child: node.inputs[4]["isConected"] ? node.inputs[4]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[4]["varId"]].value : node.inputs[4]["value"] != null ? widgetSelector(node.inputs[4]["value"]) : SizedBox() : node.inputs[4]["value"] != null ? widgetSelector(node.inputs[4]["value"]) : SizedBox()); } else if (node.title == "Row") { List<Widget> children = node.inputs[0]["value"].isNotEmpty ? node.inputs[0]["value"] .map<Widget>((e) => widgetSelector(e)) .toList() : []; return Row( mainAxisAlignment: node.inputs[1]["value"] != null ? node.inputs[1]["value"] : MainAxisAlignment.start, crossAxisAlignment: node.inputs[2]["value"] != null ? node.inputs[2]["value"] : CrossAxisAlignment.start, children: children, ); } else if (node.title == "Column") { List<Widget> children = node.inputs[0]["value"].isNotEmpty ? node.inputs[0]["value"] .map<Widget>((e) => widgetSelector(e)) .toList() : []; return Column( mainAxisAlignment: node.inputs[1]["value"] != null ? node.inputs[1]["value"] : MainAxisAlignment.start, crossAxisAlignment: node.inputs[2]["value"] != null ? node.inputs[2]["value"] : CrossAxisAlignment.start, children: children, ); } else if (node.title == "Stack") { List<Widget> children = node.inputs[0]["value"].isNotEmpty ? node.inputs[0]["value"] .map<Widget>((e) => widgetSelector(e)) .toList() : []; return Stack( alignment: node.inputs[1]["value"] != null ? node.inputs[1]["value"] : AlignmentDirectional.topStart, children: children, ); } else if (node.title == "GestureDetector") { return GestureDetector( child: node.inputs[0]["isConected"] ? node.inputs[0]["value"] != null ? widgetSelector(node.inputs[0]["value"]) : null : null, onTap: node.inputs[1]["value"].length > 0 ? () { node.inputs[1]["value"].forEach((Node nde) { event(nde); }); } : () {}, onDoubleTap: node.inputs[2]["value"].length > 0 ? () { node.inputs[2]["value"].forEach((Node nde) { event(nde); }); } : () {}, onLongPress: node.inputs[3]["value"].length > 0 ? () { node.inputs[3]["value"].forEach((Node nde) { event(nde); }); } : () {}, ); } else if (node.title == "Center") { return Center( child: node.inputs[0]["isConected"] ? widgetSelector(node.inputs[0]["value"]) : null); } else if (node.title == "Icon") { return Icon( node.inputs[0]["isConected"] ? userScreens[screenIndex].vars[node.inputs[0]["varId"]].value : node.inputs[0]["value"], size: node.inputs[1]["max"] ? privewSize.width : node.inputs[1]["isConected"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["value"], color: node.inputs[2]["isConected"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"], ); } else if (node.title == "Image") { return Image.network( node.inputs[0]["isConected"] ? userScreens[screenIndex].vars[node.inputs[0]["varId"]].value : node.inputs[0]["value"], fit: node.inputs[3]["isConected"] ? userScreens[screenIndex].vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"], height: node.inputs[1]["isConected"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["max"] ? privewSize.height : node.inputs[1]["value"], width: node.inputs[2]["isConected"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["max"] ? privewSize.width : node.inputs[2]["value"], ); } else if (node.title == "SizedBox") { return SizedBox( height: node.inputs[0]["isConected"] ? userScreens[screenIndex].vars[node.inputs[0]["varId"]].value : node.inputs[0]["max"] ? privewSize.height : node.inputs[0]["value"], width: node.inputs[1]["isConected"] ? userScreens[screenIndex].vars[node.inputs[1]["varId"]].value : node.inputs[1]["max"] ? privewSize.width : node.inputs[1]["value"], child: node.inputs[2]["isConected"] ? node.inputs[2]["fromVar"] ? userScreens[screenIndex].vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"] != null ? widgetSelector(node.inputs[2]["value"]) : null : node.inputs[2]["value"] != null ? widgetSelector(node.inputs[2]["value"]) : null, ); } else { return SizedBox(); } } void event(Node nde) { if (nde.title == "SetVar") { if (nde.inputs[1]["fromVar"]) { userScreens[screenIndex].vars[nde.inputs[0]["value"]].value = userScreens[screenIndex].vars[nde.inputs[1]["value"]].value; } else { userScreens[screenIndex].vars[nde.inputs[0]["value"]].value = nde.inputs[1]["value"]; } } else if (nde.type == "Math") { double num1 = nde.inputs[0]["isConected"] ? userScreens[screenIndex].vars[nde.inputs[0]["varId"]].value : nde.inputs[0]["value"]; double num2 = nde.inputs[1]["isConected"] ? userScreens[screenIndex].vars[nde.inputs[1]["varId"]].value : nde.inputs[1]["value"]; if (nde.title == "Add") { userScreens[screenIndex].vars[nde.inputs[2]["value"]].value = num1 + num2; } else if (nde.title == "Subtract") { userScreens[screenIndex].vars[nde.inputs[2]["value"]].value = num1 + num2; } else if (nde.title == "Multiply") { userScreens[screenIndex].vars[nde.inputs[2]["value"]].value = num1 + num2; } else if (nde.title == "Dividing") { userScreens[screenIndex].vars[nde.inputs[2]["value"]].value = num1 + num2; } } else if (nde.title == "Nav") { selectedScreenNode = nde.inputs[0]["value"].classId - 1; screenIndex = nde.inputs[0]["value"].classId - 1; appe = nde.inputs[0]["value"].inputs[1]["child"] ?? Node(); userScreens[screenIndex].child = appe; } else if (nde.title == "If") { dynamic num1 = nde.inputs[0]["isConected"] ? userScreens[screenIndex].vars[nde.inputs[0]["varId"]].value : nde.inputs[0]["value"]; dynamic num2 = nde.inputs[2]["isConected"] ? userScreens[screenIndex].vars[nde.inputs[2]["varId"]].value : nde.inputs[2]["value"]; if (nde.inputs[1]["value"] == "==") { if (num1 == num2) { nde.inputs[3]["value"] != null ? nde.inputs[3]["value"].forEach((element) { event(element); }) : null; } else { nde.inputs[4]["value"] != null ? nde.inputs[4]["value"].forEach((element) { event(element); }) : null; } } else if (nde.inputs[1]["value"] == ">") { if (num1 > num2) { nde.inputs[3]["value"] != null ? nde.inputs[3]["value"].forEach((element) { event(element); }) : null; } else { nde.inputs[4]["value"] != null ? nde.inputs[4]["value"].forEach((element) { event(element); }) : null; } } else if (nde.inputs[1]["value"] == "<") { if (num1 < num2) { nde.inputs[3]["value"] != null ? nde.inputs[3]["value"].forEach((element) { event(element); }) : null; } else { nde.inputs[4]["value"] != null ? nde.inputs[4]["value"].forEach((element) { event(element); }) : null; } } else if (nde.inputs[1]["value"] == "!=") { if (num1 != num2) { nde.inputs[3]["value"] != null ? nde.inputs[3]["value"].forEach((element) { event(element); }) : null; } else { nde.inputs[4]["value"] != null ? nde.inputs[4]["value"].forEach((element) { event(element); }) : null; } } else if (nde.inputs[1]["value"] == ">=") { if (num1 >= num2) { nde.inputs[3]["value"] != null ? nde.inputs[3]["value"].forEach((element) { event(element); }) : null; } else { nde.inputs[4]["value"] != null ? nde.inputs[4]["value"].forEach((element) { event(element); }) : null; } } else if (nde.inputs[1]["value"] == "<=") { if (num1 <= num2) { nde.inputs[3]["value"] != null ? nde.inputs[3]["value"].forEach((element) { event(element); }) : null; } else { nde.inputs[4]["value"] != null ? nde.inputs[4]["value"].forEach((element) { event(element); }) : null; } } } else if (nde.title == "Print") { logs.add(nde.inputs[0]["fromVar"] ? userScreens[screenIndex].vars[nde.inputs[0]["varId"]].value : nde.inputs[0]["value"]); } userScreens[screenIndex].child = appe; setState(() {}); } } class Screen { Screen( {this.id = "", this.name = "MyClass", this.type = "StatefulWidget", required this.child}); String id = ""; String name = "MyClass"; String type = "StatefulWidget"; List<ScreenVar> vars = []; Node child = Node(); } class ScreenVar { ScreenVar({this.value, this.varName = "", this.id = "", this.type = ""}); String id; String varName = ""; String type; dynamic value; }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/node.dart
import 'package:flutter/material.dart'; class Node { Node( {this.type = "", this.id = "0", this.title = "", this.inputs = const [], this.outputs = const [], this.x = 0, this.y = 0, this.classId = "", this.isItCalss = false, this.varName = "", this.isItVar = false, this.visble = true, this.size = const Size(150, 100), this.color = Colors.red}); bool isItVar; bool isItCalss; dynamic classId; dynamic varName; String id; String type; String title; Color color; double x; double y; bool visble; Size size; List<Map<String, dynamic>> inputs = []; List<Map<String, dynamic>> outputs = []; }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/console.dart
import 'package:clipboard/clipboard.dart'; import 'package:example/colors.dart'; import 'package:flutter/material.dart'; class Console extends StatefulWidget { Console({this.logs = const [], required this.onDelete}); List<String> logs; Function onDelete; @override State<Console> createState() => _ConsoleState(); } class _ConsoleState extends State<Console> { @override Widget build(BuildContext context) { return Dialog( backgroundColor: Colors.transparent, child: Container( height: 500, width: 550, decoration: BoxDecoration( color: backGroundColor, border: Border.all(width: 2, color: selectedNodeColor), borderRadius: BorderRadius.circular(6)), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(8.0), child: text("Console"), ), SizedBox( width: 200, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ iconButton(() { Future.delayed(Duration.zero, () { FlutterClipboard.copy(widget.logs.toString()); }); }, Icons.copy_all), IconButton( onPressed: () { widget.onDelete(); Navigator.pop(context); }, icon: Icon( Icons.delete, color: selectedNodeColor, ), ), ], ), ) ], ), Divider( color: selectedNodeColor, thickness: 1, ), SizedBox( width: double.infinity, child: SingleChildScrollView( controller: ScrollController(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: widget.logs .map( (e) => text(e), ) .toList(), ), ), ), ], ), ), ); } Text text(String txt) { return Text( txt, style: TextStyle( color: selectedNodeColor, fontSize: 20, fontWeight: FontWeight.w600), ); } IconButton iconButton(Function onPressed, IconData icon) { return IconButton( onPressed: onPressed(), icon: Icon( icon, color: selectedNodeColor, ), ); } }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/widgets.dart
// ignore_for_file: must_be_immutable, unrelated_type_equality_checks import 'package:example/colors.dart'; import 'package:example/node.dart'; import 'package:example/work_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:flutter_iconpicker/IconPicker/icons.dart'; import 'package:flutter_iconpicker/flutter_iconpicker.dart'; import 'package:smart_dropdown/smart_dropdown.dart'; class TextFiledForWork extends StatelessWidget { TextFiledForWork( {required this.onChanged, required this.onIcon, this.value = "", this.type = "String", this.maxLength = 10, this.haveIcon = false, this.name = ""}); Function(String) onChanged; Function() onIcon; String value; String type; String name; int maxLength; bool haveIcon; @override Widget build(BuildContext context) { return Container( child: TextFormField( style: TextStyle( fontSize: 12, color: nodeTextColorTwo, fontFamily: 'Inter'), decoration: InputDecoration( prefixIcon: haveIcon ? IconButton( onPressed: () { onIcon(); }, icon: FittedBox(child: Icon(Icons.fullscreen))) : null, helperStyle: TextStyle(color: nodeTextColorTwo), labelText: name, labelStyle: TextStyle( color: selectedNodeColor, ), enabledBorder: UnderlineInputBorder( borderSide: BorderSide(color: selectedNodeColor), ), focusedBorder: UnderlineInputBorder( borderSide: BorderSide(color: selectedNodeColor), ), ), inputFormatters: type == "Num" ? [FilteringTextInputFormatter.digitsOnly] : [], keyboardType: TextInputType.number, initialValue: value, onChanged: (eg) { onChanged(eg); }, ), ); } } class IconPick extends StatelessWidget { IconPick({this.value = Icons.abc, required this.newIcon}); IconData value; Function(IconData icon) newIcon; @override Widget build(BuildContext context) { _pickIcon() async { IconData? icon = await FlutterIconPicker.showIconPicker( context, iconPackModes: [ IconPack.cupertino, IconPack.fontAwesomeIcons, IconPack.lineAwesomeIcons, IconPack.material ], adaptiveDialog: true, backgroundColor: backGroundColor, iconColor: Colors.white, ); newIcon(icon!); } return SizedBox( height: 40, width: 200, child: Button( text: "Pick Icon", onClick: () { _pickIcon(); }), ); } } Widget nodeIconSeter(String type, Color color, double size) { if (type == "Screen") { return Icon( Icons.screenshot, color: color, size: size, ); } else if (type == "StatelessWidget") { return Icon( Icons.hearing_disabled_rounded, color: color, size: size, ); } else if (type == "Scaffold") { return Icon( Icons.web_asset, color: color, size: size, ); } else if (type == "Run") { return Icon( Icons.play_circle_fill_outlined, color: color, size: size, ); } else if (type == "Text") { return Icon( Icons.text_format, color: color, size: size, ); } else if (type == "AppBar") { return Icon( Icons.power_input, color: color, size: size, ); } else if (type == "var" || type == "Num" || type == "String" || type == "Color" || type == "IconData") { return Icon( Icons.folder, color: color, size: size, ); } else if (type == "Container") { return Icon( Icons.crop_square, color: color, size: size, ); } else if (type == "Row") { return Icon( Icons.view_week, color: color, size: size, ); } else if (type == "Column") { return Icon( Icons.table_rows, color: color, size: size, ); } else if (type == "Stack") { return Icon( Icons.view_quilt, color: color, size: size, ); } else if (type == "Button") { return Icon( Icons.smart_button, color: color, size: size, ); } else if (type == "Event") { return Icon( Icons.not_started, color: color, size: size, ); } else if (type == "Add") { return Icon( Icons.add, color: color, size: size, ); } else if (type == "Subtract") { return Icon( Icons.remove, color: color, size: size, ); } else if (type == "Multiply") { return Icon( Icons.close, color: color, size: size, ); } else if (type == "Dividing") { return Icon( Icons.calculate, color: color, size: size, ); } else if (type == "SetVar") { return Icon( Icons.sync, color: color, size: size, ); } else if (type == "Nav") { return Icon( Icons.move_up, color: color, size: size, ); } else if (type == "Screen") { return Icon( Icons.screenshot, color: color, size: size, ); } else if (type == "GestureDetector") { return Icon( Icons.touch_app, color: color, size: size, ); } else if (type == "Center") { return Icon( Icons.filter_center_focus, color: color, size: size, ); } else if (type == "Icon") { return Icon( Icons.insert_emoticon, color: color, size: size, ); } else if (type == "If") { return Icon( Icons.unpublished, color: color, size: size, ); } else if (type == "Image") { return Icon( Icons.image, color: color, size: size, ); } else if (type == "SizedBox") { return Icon( Icons.crop, color: color, size: size, ); } else if (type == "Print") { return Icon( Icons.print, color: color, size: size, ); } else { return Icon( Icons.calculate, color: color, size: size, ); } } class NodeSelectorBox extends StatelessWidget { NodeSelectorBox({this.name = "", required this.onAdd}); String name; Function(Offset pos) onAdd; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: Draggable( child: box(name), feedback: box(name), onDraggableCanceled: (e, eg) { if (eg.dx > 180) { onAdd(eg); } }, ), ); } } class DropDown extends StatelessWidget { DropDown({this.items = const [], this.name = "", required this.onSelect}); List<SmartDropdownMenuItem> items; String name; Function(dynamic itme) onSelect; @override Widget build(BuildContext context) { return Container( child: SmartDropDown( items: items, hintText: name, borderRadius: 5, borderColor: nodeTextColorTwo, expandedColor: selectedNodeColor, onChanged: (val) { onSelect(val); }, ), ); } } Widget box(String text) { return Material( color: Colors.transparent, child: Container( height: 80, width: 80, decoration: BoxDecoration( border: Border.all(color: selectedNodeColor), color: nodeTitleContaner, borderRadius: BorderRadius.circular(6)), child: Center( child: SizedBox.expand( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ FittedBox( child: Text( text, style: TextStyle( color: nodeTextColorTwo, fontFamily: 'Inter', fontSize: 23), ), ), nodeIconSeter(text, nodeTextColorTwo, 40) ], ), ), ), ), ); } class AddItmeToList extends StatelessWidget { AddItmeToList( {required this.varr, required this.onEdit, required this.value, required this.onDelete}); Node varr; Function(dynamic) onEdit; Function() onDelete; dynamic value; @override Widget build(BuildContext context) { return Container( height: 60, width: 300, decoration: BoxDecoration( color: backGroundColor, border: Border.all(width: 1, color: selectedNodeColor), borderRadius: BorderRadius.circular(5)), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ varr.title == "List(String)" ? Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ FittedBox( child: Text( value.toString(), style: TextStyle( color: selectedNodeColor, fontWeight: FontWeight.w500), ), ), TextFiledForWork( value: value, name: "itme", onChanged: (e) { onEdit(e); }, onIcon: () {}), ], ) : varr.title == "List(Color)" ? Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Container( height: 20, width: 20, decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: value), ), Button( onClick: () { showDialog( context: context, builder: (context) { return ColorPick( pikcerColor: value, colore: (e) { onEdit(e); }); }); }, text: "Pick Color"), ], ) : varr.title == "List(Num)" ? Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ FittedBox( child: Text( value.toString(), style: TextStyle( color: selectedNodeColor, fontWeight: FontWeight.w500), ), ), TextFiledForWork( value: value, name: "Num", onChanged: (e) { onEdit(e); }, onIcon: () {}), ], ) : Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ FittedBox( child: Icon( value, color: selectedNodeColor, )), IconPick( value: value, newIcon: (e) { onEdit(e); }), ], ), Row( children: [ IconButton( onPressed: () { onDelete(); }, icon: Icon( Icons.delete, color: Colors.red, )) ], ) ]), ); } } class ScreenPicker extends StatelessWidget { ScreenPicker({this.screens = const [], required this.onPick}); List<Screen> screens; Function(Screen screen) onPick; @override Widget build(BuildContext context) { return Dialog( backgroundColor: Colors.transparent, child: Container( height: 400, width: 300, decoration: BoxDecoration( color: backGroundColor, borderRadius: BorderRadius.circular(10), border: Border.all(color: selectedNodeColor, width: 2)), child: Column( children: [ Center( child: Text("Screens", style: TextStyle( fontFamily: 'Inter', color: nodeTextColorTwo, fontSize: 20)), ), SizedBox( height: 10, ), SizedBox( height: 300, width: 300, child: SingleChildScrollView( controller: ScrollController(), child: Column( children: screens .map( (e) => GestureDetector( onTap: () { onPick(e); Navigator.pop(context); }, child: Container( margin: EdgeInsets.all(10), height: 30, width: 200, decoration: BoxDecoration( color: backGroundColor, border: Border.all( color: selectedNodeColor, width: 2), borderRadius: BorderRadius.circular(6)), child: Center( child: Text(e.name, style: TextStyle( fontFamily: 'Inter', color: selectedNodeColor, fontSize: 20)), ), ), ), ) .toList()), ), ), SizedBox( height: 10, ), ], ), ), ); } } class VarPicker extends StatelessWidget { VarPicker({this.vars = const [], required this.onPick}); List<ScreenVar> vars; Function(ScreenVar screen) onPick; @override Widget build(BuildContext context) { return SizedBox( height: 250, width: 350, child: Column( children: [ Center( child: Text("Screen vars", style: TextStyle( fontFamily: 'Inter', color: nodeTextColorTwo, fontSize: 20)), ), SizedBox( height: 10, ), SizedBox( height: 200, width: 270, child: SingleChildScrollView( controller: ScrollController(), child: Column( children: vars .map( (e) => GestureDetector( onTap: () { onPick(e); Navigator.pop(context); }, child: Container( margin: EdgeInsets.all(10), height: 30, width: 300, decoration: BoxDecoration( color: backGroundColor, border: Border.all( color: selectedNodeColor, width: 2), borderRadius: BorderRadius.circular(6)), child: Center( child: FittedBox( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( e.value.runtimeType == "MaterialColor" ? "color" : e.value.runtimeType.toString(), style: TextStyle( fontFamily: 'Inter', color: nodeTextColorTwo, fontSize: 20)), SizedBox( width: 5, ), Text(e.varName, style: TextStyle( fontFamily: 'Inter', color: selectedNodeColor, fontSize: 20)), SizedBox( width: 5, ), Text("=", style: TextStyle( fontFamily: 'Inter', color: selectedNodeColor, fontSize: 20)), Text(e.value.toString(), style: TextStyle( fontFamily: 'Inter', color: nodeTextColorTwo, fontSize: 20)), ], ), ), ), ), ), ) .toList()), ), ), SizedBox( height: 10, ), ], ), ); } } class ColorPick extends StatelessWidget { ColorPick({this.pikcerColor = Colors.red, required this.colore}); Function(Color color) colore; Color pikcerColor; @override Widget build(BuildContext context) { return Dialog( backgroundColor: backGroundColor, child: SizedBox( width: 240, height: 360, child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ ColorPicker( pickerAreaHeightPercent: 0.7, enableAlpha: true, displayThumbColor: true, paletteType: PaletteType.hsvWithHue, pickerAreaBorderRadius: BorderRadius.circular(5), portraitOnly: true, colorPickerWidth: 200, hexInputBar: true, pickerColor: pikcerColor, onColorChanged: (color) { colore(color); }, ), ], ), ), ), ); } } class Button extends StatelessWidget { Button({ required this.onClick, this.textColor = const Color.fromARGB(255, 30, 30, 30), this.buttonColor = const Color.fromARGB(255, 175, 251, 88), this.text = "", }); Function onClick; Color textColor; Color buttonColor; String text; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(10), width: 150, child: ElevatedButton( style: ElevatedButton.styleFrom(backgroundColor: buttonColor), onPressed: () { onClick(); }, child: FittedBox( child: Text( text, style: TextStyle( fontSize: 15, color: textColor, fontFamily: 'Inter', fontWeight: FontWeight.w600), ), ), )); } }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/colors.dart
import 'package:flutter/animation.dart'; Color backGroundColor = Color.fromARGB(255, 30, 30, 30); Color nodesColor = Color.fromARGB(255, 66, 66, 66); Color nodeInputAndLineColor = Color.fromARGB(255, 194, 194, 194); Color nodeTextColorTwo = Color.fromARGB(255, 233, 233, 233); Color nodeTitleContaner = Color.fromARGB(255, 42, 42, 42); Color nodeBarColor = Color.fromARGB(255, 29, 29, 29); Color selectedNodeColor = Color.fromARGB(255, 175, 251, 88);
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/main.dart
import 'package:example/home.dart'; import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) => MaterialApp( debugShowCheckedModeBanner: false, home: MyHomePage(), ); } class MyHomePage extends StatefulWidget { MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) => Home(); }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/home.dart
import 'package:example/colors.dart'; import 'package:example/widgets.dart'; import 'package:example/work_page.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher_string.dart'; class Home extends StatefulWidget { @override State<Home> createState() => _HomeState(); } class _HomeState extends State<Home> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backGroundColor, body: Stack(children: [ Image.network( "https://i.postimg.cc/wjBJXKr0/Cover-1.png", height: double.infinity, width: double.infinity, fit: BoxFit.cover, ), Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Flutter Node App Builder", style: TextStyle( color: selectedNodeColor, fontSize: 70, fontWeight: FontWeight.w600), ), SizedBox( width: 700, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ text("Build app in", nodeTextColorTwo), text("seconds !", selectedNodeColor), text("Free ", selectedNodeColor), text(",", nodeTextColorTwo), text("Open Source", selectedNodeColor), text(",", nodeTextColorTwo), text("Easy ", selectedNodeColor), text(",", nodeTextColorTwo), text("Fun ", selectedNodeColor), text(",", nodeTextColorTwo), text("and You ", selectedNodeColor), text(",", nodeTextColorTwo), text("Don't need any ", selectedNodeColor), text("Experience ", selectedNodeColor), ], ), ), ], ), ), Align( alignment: Alignment.bottomCenter, child: Padding( padding: const EdgeInsets.all(200.0), child: SizedBox( width: 400, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Button( onClick: () { Navigator.push( context, MaterialPageRoute( builder: (context) => WorkPage())); }, text: "Start", ), Button( onClick: () { launchUrlString( "https://github.com/mojtaby/Flutter-Visual-Programing", mode: LaunchMode.platformDefault); // }, text: "Source", ) ], ), ), )) ]), ); } Text text(String text, Color color) { return Text( text, style: TextStyle(color: color, fontSize: 18, fontWeight: FontWeight.w500), ); } }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/code_viwer.dart
import 'package:download/download.dart'; import 'package:example/code_builder.dart'; import 'package:example/colors.dart'; import 'package:example/work_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_iconpicker/IconPicker/icons.dart'; import 'package:flutter_syntax_view/flutter_syntax_view.dart'; class CodeViwer extends StatefulWidget { CodeViwer({this.userScreen = const []}); List<Screen> userScreen; @override State<CodeViwer> createState() => _CodeViwerState(); } class _CodeViwerState extends State<CodeViwer> { @override Widget build(BuildContext context) { CodeBuilder codeBuiler = CodeBuilder(screens: widget.userScreen); String code = codeBuiler .classBuilder(widget.userScreen[0]) .replaceAll("(#de", "") .replaceAll(")#de", "") .replaceAll("#de, #de", "") .replaceAll("}#de)", "}") .replaceAll(";#de,", "") .replaceAll(";,", ";") .replaceAll("#dee)", "") .replaceAll("(#dee", "") .replaceAll("#dee,", "") .replaceAll("#de)", "}") .replaceAll("(#g", "") .replaceAll("; #g", ";") .replaceAll(";)", ";") .replaceAll("}#de)", "}"); return Dialog( backgroundColor: Colors.transparent, child: Container( height: 500, width: 500, decoration: BoxDecoration( color: backGroundColor, border: Border.all(color: selectedNodeColor, width: 2), borderRadius: BorderRadius.circular(10)), child: Stack( children: [ SyntaxView( code: code, syntax: Syntax.DART, syntaxTheme: SyntaxTheme.vscodeDark(), fontSize: 12.0, withZoom: true, withLinesCount: true, expanded: true), Align( alignment: Alignment.bottomLeft, child: IconButton( onPressed: () { final stream = Stream.fromIterable(code.codeUnits); download(stream, 'myApp.dart'); }, icon: Icon( Icons.download, color: selectedNodeColor, )), ), ], ), ), ); } }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/code_builder.dart
// ignore_for_file: unnecessary_statements import 'package:example/node.dart'; import 'package:example/work_page.dart'; import 'package:flutter/cupertino.dart'; class CodeBuilder { CodeBuilder({this.screens = const []}); List<Screen> screens; dynamic classBuilder( Screen screen, ) { if (screen.type == "StatefulWidget") { return ''' ${screens.map((e) => ''' #de class ${e.name} extends StatefulWidget { const ${e.name}({super.key}); @override State<${e.name}> createState() => _${e.name}State(); } class _${e.name}State extends State<${e.name}> { @override Widget build(BuildContext context) { return ${e.child != null ? widgetBuilder(e, e.child) : ' Container();'} } ${e.vars.isNotEmpty ? e.vars.map((varre) => ''' ${varBuilder(varre)}''').toString().replaceAll("(", "").replaceAll(")", "") : ''} }#de''')}'''; } else { return ""; } } String varBuilder(ScreenVar varr) { return '${varr.type} ${varr.varName}= ${varr.type == "String" ? '"${varr.value}"' : varr.value};'; } String widgetBuilder(Screen screen, Node node) { if (node.title == "Scaffold") { return ''' Scaffold( backgroundColor: ${node.inputs[1]["isConected"] ? node.inputs[1]["fromVar"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["value"] : node.inputs[1]["value"]}, drawer: ${node.inputs[3]["isConected"] ? widgetBuilder(screen, node.inputs[3]["value"]) : null}, appBar: ${node.inputs[2]["isConected"] ? widgetBuilder(screen, node.inputs[2]["value"]) : null}, body: ${node.inputs[0]["isConected"] ? widgetBuilder(screen, node.inputs[0]["value"]) : null}), '''; } else if (node.title == "Text") { return '''Text( ${node.inputs[0]["isConected"] ? screen.vars[node.inputs[0]["varId"]].varName : '"${node.inputs[0]["value"]}"'}, style: TextStyle( fontWeight: ${node.inputs[3]["isConected"] ? node.inputs[3]["fromVar"] ? screen.vars[node.inputs[3]["varId"]].varName : node.inputs[3]["value"] : node.inputs[3]["value"]}, color:${node.inputs[1]["isConected"] ? node.inputs[1]["fromVar"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["value"] : node.inputs[1]["value"]}, fontSize: ${node.inputs[2]["isConected"] ? node.inputs[2]["fromVar"] ? screen.vars[node.inputs[2]["varId"]].varName : node.inputs[2]["value"] : node.inputs[2]["value"]}, ), ),'''; } else if (node.title == "AppBar") { return ''' PreferredSize( preferredSize: Size.fromHeight( ${node.inputs[2]["isConected"] ? screen.vars[node.inputs[2]["varId"]].varName : node.inputs[2]["max"] ? 'MediaQuery.of(context).size.height' : node.inputs[2]["value"]}, ), child: AppBar( flexibleSpace: ${node.inputs[3]["isConected"] ? node.inputs[3]["fromVar"] ? screen.vars[node.inputs[3]["varId"]].varName : node.inputs[3]["value"] != null ? widgetBuilder(screen, node.inputs[3]["value"]) : null : node.inputs[3]["value"] != null ? widgetBuilder(screen, node.inputs[3]["value"]) : null}, title: ${node.inputs[0]["isConected"] ? node.inputs[0]["fromVar"] ? screen.vars[node.inputs[0]["varId"]].varName : node.inputs[0]["value"] != null ? widgetBuilder(screen, node.inputs[0]["value"]) : null : node.inputs[0]["value"] != null ? widgetBuilder(screen, node.inputs[0]["value"]) : null}, backgroundColor: ${node.inputs[1]["isConected"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["value"]}, )),'''; } else if (node.title == "Container") { return ''' Container( height: ${node.inputs[0]["isConected"] ? screen.vars[node.inputs[0]["varId"]].varName : node.inputs[0]["max"] ? 'MediaQuery.of(context).size.height' : node.inputs[0]["value"]}, width:${node.inputs[1]["isConected"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["max"] ? 'MediaQuery.of(context).size.width' : node.inputs[1]["value"]}, color: ${node.inputs[2]["isConected"] ? screen.vars[node.inputs[2]["varId"]].varName : node.inputs[2]["value"]}, child:${node.inputs[3]["isConected"] ? node.inputs[3]["fromVar"] ? screen.vars[node.inputs[3]["varId"]].varName : node.inputs[3]["value"] != null ? widgetBuilder(screen, node.inputs[3]["value"]) : null : node.inputs[3]["value"] != null ? widgetBuilder(screen, node.inputs[3]["value"]) : null}, ),'''; } else if (node.title == "Button") { return '''ElevatedButton( onPressed: ${node.inputs[5]["value"].length > 0 ? '''() { ${node.inputs[5]["value"].map((Node nde) { return '''#de ${event(screen, nde)}; #dee'''; })} setState(() {}); }''' : '() {}'}, style: ElevatedButton.styleFrom( backgroundColor: ${node.inputs[0]["isConected"] ? screen.vars[node.inputs[0]["varId"]].value : node.inputs[0]["value"]}, foregroundColor: ${node.inputs[1]["isConected"] ? screen.vars[node.inputs[1]["varId"]].value : node.inputs[1]["value"]}, shadowColor: ${node.inputs[2]["isConected"] ? screen.vars[node.inputs[2]["varId"]].value : node.inputs[2]["value"]}, elevation: ${node.inputs[3]["isConected"] ? screen.vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"]}, child: ${node.inputs[4]["isConected"] ? node.inputs[4]["fromVar"] ? screen.vars[node.inputs[4]["varId"]].value : node.inputs[4]["value"] != null ? widgetBuilder(screen, node.inputs[4]["value"]) : SizedBox() : node.inputs[4]["value"] != null ? widgetBuilder(screen, node.inputs[4]["value"]) : SizedBox()}, ),'''; } else if (node.title == "Row") { return '''Row( mainAxisAlignment: ${node.inputs[1]["value"] != null ? node.inputs[1]["value"] : ' MainAxisAlignment.start'}, crossAxisAlignment: ${node.inputs[2]["value"] != null ? node.inputs[2]["value"] : 'CrossAxisAlignment.start'}, children: ${node.inputs[0]["value"].isNotEmpty ? node.inputs[0]["value"].map((e) => widgetBuilder(screen, e)).toList() : '[]'}, )'''; } else if (node.title == "Column") { return '''Column( mainAxisAlignment: ${node.inputs[1]["value"] != null ? node.inputs[1]["value"] : ' MainAxisAlignment.start'}, crossAxisAlignment: ${node.inputs[2]["value"] != null ? node.inputs[2]["value"] : 'CrossAxisAlignment.start'}, children: ${node.inputs[0]["value"].isNotEmpty ? node.inputs[0]["value"].map((e) => widgetBuilder(screen, e)).toList() : '[]'}, )'''; } else if (node.title == "Stack") { return '''Stack( alignment: ${node.inputs[1]["value"] != null ? node.inputs[1]["value"] : 'AlignmentDirectional.topStart'}, children: ${node.inputs[0]["value"].isNotEmpty ? node.inputs[0]["value"].map((e) => widgetBuilder(screen, e)).toList().toString().replaceAll(',,', ',') : '[]'}, )'''; } else if (node.title == "GestureDetector") { return ''' GestureDetector( child: ${node.inputs[0]["isConected"] ? node.inputs[0]["value"] != null ? widgetBuilder(screen, node.inputs[0]["value"]) : null : null}, onTap: ${node.inputs[1]["value"].length > 0 ? '''() { ${node.inputs[1]["value"].map((Node nde) { return '''#de ${event(screen, nde)}; #dee'''; })} setState(() {}); }''' : '() {}'}, onDoubleTap: ${node.inputs[2]["value"].length > 0 ? '''() { ${node.inputs[1]["value"].map((Node nde) { return '''#de ${event(screen, node)} #de'''; })} setState(() {}); }''' : '() {}'}, onLongPress:${node.inputs[3]["value"].length > 0 ? '''() { ${node.inputs[1]["value"].map((Node nde) { return '''#de ${event(screen, node)} #de'''; })} setState(() {}); }''' : '() {}'}, )'''; } else if (node.title == "Icon") { return '''Icon( ${node.inputs[0]["isConected"] ? screen.vars[node.inputs[0]["varId"]].varName : node.inputs[0]["value"]}, size: ${node.inputs[1]["max"] ? 'MediaQuery.of(context).size.width' : node.inputs[1]["isConected"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["value"]}, color:${node.inputs[2]["isConected"] ? screen.vars[node.inputs[2]["varId"]].varName : node.inputs[2]["value"]}, ),'''; } else if (node.title == "Center") { return '''Center(child:${node.inputs[0]["isConected"] ? widgetBuilder(screen, node.inputs[0]["value"]) : null}),'''; } else if (node.title == "SizedBox") { return '''SizedBox( height: ${node.inputs[0]["isConected"] ? screen.vars[node.inputs[0]["varId"]].varName : node.inputs[0]["max"] ? 'MediaQuery.of(context).size.height' : node.inputs[0]["value"]}, width: ${node.inputs[1]["isConected"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["max"] ? 'MediaQuery.of(context).size.width' : node.inputs[1]["value"]}, child: ${node.inputs[2]["isConected"] ? widgetBuilder(screen, node.inputs[2]["value"]) : null}, ),'''; } else if (node.title == "Image") { return '''Image.network( "${node.inputs[0]["isConected"] ? screen.vars[node.inputs[0]["varId"]].value : node.inputs[0]["value"]}", fit: ${node.inputs[3]["isConected"] ? screen.vars[node.inputs[3]["varId"]].value : node.inputs[3]["value"]}, height: ${node.inputs[1]["isConected"] ? screen.vars[node.inputs[1]["varId"]].varName : node.inputs[1]["max"] ? 'MediaQuery.of(context).size.height' : node.inputs[1]["value"]}, width: ${node.inputs[2]["isConected"] ? screen.vars[node.inputs[2]["varId"]].varName : node.inputs[2]["max"] ? 'MediaQuery.of(context).size.width' : node.inputs[2]["value"]}, ),'''; } else { return ''; } } String event(Screen screen, Node nde) { if (nde.title == "SetVar") { if (nde.inputs[1]["isConected"]) { return "${screen.vars[nde.inputs[0]["value"]].varName} = ${screen.vars[nde.inputs[1]["value"]].varName}"; } else { return "${screen.vars[nde.inputs[0]["value"]].varName} = ${nde.inputs[1]["value"]} "; } } else if (nde.type == "Math") { double num1 = nde.inputs[0]["isConected"] ? screen.vars[nde.inputs[0]["varId"]].varName : nde.inputs[0]["value"]; double num2 = nde.inputs[1]["isConected"] ? screen.vars[nde.inputs[1]["varId"]].varName : nde.inputs[1]["value"]; if (nde.title == "Add") { return "${screen.vars[nde.inputs[2]["value"]].varName} = $num1 + $num2"; } else if (nde.title == "Subtract") { return "${screen.vars[nde.inputs[2]["value"]].varName} = $num1 - $num2"; } else if (nde.title == "Multiply") { return "${screen.vars[nde.inputs[2]["value"]].varName} = $num1 * $num2"; } else if (nde.title == "Dividing") { return "${screen.vars[nde.inputs[2]["value"]].varName} = $num1 / $num2"; } else { return ""; } } else if (nde.title == "Nav") { return 'Navigator.push(context,MaterialPageRoute(builder: (context) => ${screens[nde.inputs[0]["value"].classId - 1].name}()))'; } else if (nde.title == "If") { dynamic num1 = nde.inputs[0]["isConected"] ? screen.vars[nde.inputs[0]["varId"]].varName : nde.inputs[0]["value"]; dynamic num2 = nde.inputs[2]["isConected"] ? screen.vars[nde.inputs[2]["varId"]].varName : nde.inputs[2]["value"]; if (nde.inputs[1]["value"] == "==") { return '''if($num1 == $num2){ ${nde.inputs[3]["value"].map((element) { return '#g ${event(screen, element)};'; })} }else { ${nde.inputs[4]["value"].map((element) { return '#g ${event(screen, element)};'; })} }'''; } else if (nde.inputs[1]["value"] == ">") { return '''if($num1 > $num2){ ${nde.inputs[3]["value"].map((element) { return '#g ${event(screen, element)};'; })} }else { ${nde.inputs[4]["value"].map((element) { return '#g ${event(screen, element)};'; })} }'''; } else if (nde.inputs[1]["value"] == "<") { return '''if($num1 < $num2){ ${nde.inputs[3]["value"].map((element) { return '#g ${event(screen, element)};'; })} }else { ${nde.inputs[4]["value"].map((element) { return '#g ${event(screen, element)};'; })} }'''; } else if (nde.inputs[1]["value"] == "!=") { return '''if($num1 != $num2){ ${nde.inputs[3]["value"].map((element) { return '#g ${event(screen, element)};'; })} }else { ${nde.inputs[4]["value"].map((element) { return '#g ${event(screen, element)};'; })} }'''; } else if (nde.inputs[1]["value"] == ">=") { return '''if($num1 >= $num2){ ${nde.inputs[3]["value"].map((element) { return '#g ${event(screen, element)};'; })} }else { ${nde.inputs[4]["value"].map((element) { return '#g ${event(screen, element)};'; })} }'''; } else if (nde.inputs[1]["value"] == "<=") { return '''if($num1 <= $num2){ ${nde.inputs[3]["value"].map((element) { return '#g ${event(screen, element)};'; })} }else { ${nde.inputs[4]["value"].map((element) { return '#g ${event(screen, element)};'; })} }'''; } else { return ""; } } else if (nde.title == "Print") { return "print(${nde.inputs[0]["isConected"] ? screen.vars[nde.inputs[0]["varId"]].varName : "'${nde.inputs[0]["value"]}'"})"; } else { return ""; } } }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/nodes.dart
import 'package:flutter/material.dart'; import 'package:flutter_iconpicker/IconPicker/icons.dart'; import 'package:uuid/uuid.dart'; import 'package:smart_dropdown/smart_dropdown.dart'; import 'node.dart'; Node node(String name, int varid, Offset pos, int classId) { if (name == "Screen") { return Node( isItCalss: true, size: Size(200, 120), type: "Screen", id: Uuid().v1(), title: "Screen", varName: "myClass", x: pos.dx, y: pos.dy, classId: varid, inputs: [ { 'show': false, "HaveMax": false, "name": "StatefulWidget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'widget', 'value': "Text", "canSetFromNode": false, "isConected": false, "haveTextFiled": false, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "varId": null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "child": null, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Class", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Class', 'value': "class", 'targetNode': null, 'targetInputInedx': null, }, ], ); } else if (name == "Scaffold") { return Node( x: pos.dx, y: pos.dy, type: "Scaffold", size: Size(200, 330), id: Uuid().v1(), title: "Scaffold", inputs: [ { "HaveMax": false, "varId": null, "body": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, "fromVar": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "child": null, "name": "body", 'FromId': null, }, { "HaveMax": false, "name": "BackGround Color", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 255, 255, 255), "isConected": false, "haveTextFiled": true, "fromVar": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "fromVar": false, "child": null, "name": "AppBar", 'FromId': null, }, { "HaveMax": true, "name": "AppBarHeight", "max": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 60, "isConected": false, "haveTextFiled": true, "fromVar": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "HaveMax": false, "varId": null, "Drawer": "Drawer", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "fromVar": false, "child": null, "name": "Drawer", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "class", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Container") { return Node( x: pos.dx, y: pos.dy, type: "Container", size: Size(200, 280), id: Uuid().v1(), title: "Container", inputs: [ { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 100, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Height", "fromVar": false, 'FromId': null, }, { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 100, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "fromVar": false, "name": "Width", 'FromId': null, }, { "HaveMax": false, "name": "Color", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 0, 149, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "child": null, "name": "Child", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "class", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Nav") { return Node( x: pos.dx, y: pos.dy, type: "Nav", size: Size(150, 148), id: Uuid().v1(), title: "Nav", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Class', 'value': 100, "max": false, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "To", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "AppBar") { return Node( size: Size(200, 300), x: pos.dx, y: pos.dy, type: "AppBar", id: Uuid().v1(), title: "AppBar", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Title", "fromVar": false, 'FromId': null, }, { "HaveMax": false, "name": "Color", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 255, 255, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "FlexibleSpace", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "ShadowColor", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 255, 255, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': AppBar(), 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Image") { return Node( size: Size(200, 280), x: pos.dx, y: pos.dy, type: "Image", id: Uuid().v1(), title: "Image", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'String', 'value': "https://i.postimg.cc/FKJ3wv68/Cover-1-1.png", "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Link", "fromVar": false, 'FromId': null, }, { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 100, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Height", "fromVar": false, 'FromId': null, }, { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 100, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "fromVar": false, "name": "Width", 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(BoxFit.contain, "Contain"), dropdownMenuItem(BoxFit.cover, "Cover"), dropdownMenuItem(BoxFit.fill, "Fill"), dropdownMenuItem(BoxFit.fitHeight, "FitHeight"), dropdownMenuItem(BoxFit.fitWidth, "FitWidth"), dropdownMenuItem(BoxFit.scaleDown, "ScaleDown"), ], "HaveMax": false, "name": "Fit", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': BoxFit.contain, "isConected": false, "haveTextFiled": true, "canSetFromNode": false, "fromVar": false, "varId": null, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': AppBar(), 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "SizedBox") { return Node( size: Size(200, 220), x: pos.dx, y: pos.dy, type: "SizedBox", id: Uuid().v1(), title: "SizedBox", inputs: [ { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 100, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Height", "fromVar": false, 'FromId': null, }, { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 100, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "fromVar": false, "name": "Width", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Child", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': AppBar(), 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Center") { return Node( x: pos.dx, y: pos.dy, type: "Center", id: Uuid().v1(), title: "Center", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Child", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "cla", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Icon") { return Node( x: pos.dx, y: pos.dy, type: "Icon", size: Size(200, 250), id: Uuid().v1(), title: "Icon", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'IconData', 'value': Icons.abc, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Icon", "fromVar": false, 'FromId': null, }, { "HaveMax": true, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 40, "max": false, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Height", "fromVar": false, 'FromId': null, }, { "HaveMax": false, "name": "Color", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 0, 153, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "cla", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Row") { return Node( x: pos.dx, y: pos.dy, type: "Row", size: Size(230, 200), id: Uuid().v1(), title: "Row", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': <Node>[], "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Children", "fromVar": false, 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(MainAxisAlignment.start, "Start"), dropdownMenuItem(MainAxisAlignment.center, "Center"), dropdownMenuItem(MainAxisAlignment.end, "End"), dropdownMenuItem(MainAxisAlignment.spaceAround, "SpaceAround"), dropdownMenuItem(MainAxisAlignment.spaceBetween, "SpaceBetween"), dropdownMenuItem(MainAxisAlignment.spaceEvenly, "SpaceEvenly"), ], "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': MainAxisAlignment.start, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": false, "name": "MainAxisAlignment", "fromVar": false, 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(CrossAxisAlignment.start, "Start"), dropdownMenuItem(CrossAxisAlignment.center, "Center"), dropdownMenuItem(CrossAxisAlignment.end, "End"), dropdownMenuItem(CrossAxisAlignment.baseline, "Baseline"), dropdownMenuItem(CrossAxisAlignment.stretch, "Stretch"), ], "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': CrossAxisAlignment.start, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": false, "name": "CrossAxisAlignment", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': 'clas', 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Column") { return Node( x: pos.dx, y: pos.dy, type: "Column", size: Size(230, 200), id: Uuid().v1(), title: "Column", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': <Node>[], "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Children", "fromVar": false, 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(MainAxisAlignment.start, "Start"), dropdownMenuItem(MainAxisAlignment.center, "Center"), dropdownMenuItem(MainAxisAlignment.end, "End"), dropdownMenuItem(MainAxisAlignment.spaceAround, "SpaceAround"), dropdownMenuItem(MainAxisAlignment.spaceBetween, "SpaceBetween"), dropdownMenuItem(MainAxisAlignment.spaceEvenly, "SpaceEvenly"), ], "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': MainAxisAlignment.start, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": false, "name": "MainAxisAlignment", "fromVar": false, 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(CrossAxisAlignment.start, "Start"), dropdownMenuItem(CrossAxisAlignment.center, "Center"), dropdownMenuItem(CrossAxisAlignment.end, "End"), dropdownMenuItem(CrossAxisAlignment.baseline, "Baseline"), dropdownMenuItem(CrossAxisAlignment.stretch, "Stretch"), ], "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': CrossAxisAlignment.start, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": false, "name": "CrossAxisAlignment", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': 'clas', 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Stack") { return Node( x: pos.dx, y: pos.dy, type: "Stack", size: Size(230, 200), id: Uuid().v1(), title: "Stack", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': <Node>[], "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Children", "fromVar": false, 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(AlignmentDirectional.topStart, "TopStart"), dropdownMenuItem(AlignmentDirectional.topCenter, "TopCenter"), dropdownMenuItem(AlignmentDirectional.topEnd, "TopEnd"), dropdownMenuItem(AlignmentDirectional.center, "Center"), dropdownMenuItem(AlignmentDirectional.centerEnd, "CenterEnd"), dropdownMenuItem(AlignmentDirectional.centerStart, "CenterStart"), dropdownMenuItem( AlignmentDirectional.bottomCenter, "BottomCenter"), dropdownMenuItem(AlignmentDirectional.bottomEnd, "BottomEnd"), dropdownMenuItem(AlignmentDirectional.bottomStart, "BottomStart"), ], "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': AlignmentDirectional.topStart, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": false, "name": "Alignment", "fromVar": false, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': 'clas', 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Button") { return Node( size: Size(200, 400), x: pos.dx, y: pos.dy, type: "Button", id: Uuid().v1(), title: "Button", inputs: [ { "HaveMax": false, "name": "backgroundColor", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 255, 255, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "foregroundColor", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 255, 255, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "shadowColor", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 91, 91, 91), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "elevation", "max": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'value': 2, "isConected": false, "haveTextFiled": true, "fromVar": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Child", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': <Node>[], "fromVar": false, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "OnClick", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "GestureDetector") { return Node( size: Size(200, 280), x: pos.dx, y: pos.dy, type: "GestureDetector", id: Uuid().v1(), title: "GestureDetector", inputs: [ { "HaveMax": false, "name": "Child", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': null, "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "fromVar": false, "varId": null, 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': <Node>[], "fromVar": false, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "onTap", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': <Node>[], "fromVar": false, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "onDoubleTap", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': <Node>[], "fromVar": false, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "onLongPress", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Subtract") { return Node( size: Size(200, 220), x: pos.dx, y: pos.dy, type: "Math", id: Uuid().v1(), title: "Subtract", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num1", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num2", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Set Var Name", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Dividing") { return Node( size: Size(200, 220), x: pos.dx, y: pos.dy, type: "Math", id: Uuid().v1(), title: "Dividing", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num1", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num2", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Set Var Name", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Multiply") { return Node( size: Size(200, 220), x: pos.dx, y: pos.dy, type: "Math", id: Uuid().v1(), title: "Multiply", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num1", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num2", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Set Var Name", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Add") { return Node( size: Size(200, 220), x: pos.dx, y: pos.dy, type: "Math", id: Uuid().v1(), title: "Add", inputs: [ { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num1", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 0, "isConected": false, "haveTextFiled": true, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Num2", 'FromId': null, }, { "HaveMax": false, "varId": null, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', "fromVar": false, 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, "name": "Set Var Name", 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Run") { return Node( x: pos.dx, y: pos.dy, type: "Run", id: Uuid().v1(), title: "Run", inputs: [ { "name": "Class", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Class', 'value': null, "isConected": false, "haveTextFiled": false, 'targetId': null, 'targetNode': null, "canSetFromNode": true, 'FromId': null, }, ], outputs: []); } else if (name == "Text") { return Node( x: pos.dx, y: pos.dy, size: Size(200, 270), type: "Text", id: Uuid().v1(), title: "Text", inputs: [ { "HaveMax": false, "name": "Text", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Any', "fromVar": false, 'value': "Text", "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "Color", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', 'value': Color.fromARGB(255, 9, 124, 255), "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "HaveMax": false, "name": "Font size", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', "fromVar": false, 'value': 20, "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem(FontWeight.normal, "Normal"), dropdownMenuItem(FontWeight.bold, "Bold"), dropdownMenuItem(FontWeight.w100, "w100"), dropdownMenuItem(FontWeight.w200, "w200"), dropdownMenuItem(FontWeight.w300, "w300"), dropdownMenuItem(FontWeight.w400, "w400"), dropdownMenuItem(FontWeight.w500, "w500"), dropdownMenuItem(FontWeight.w600, "w600"), dropdownMenuItem(FontWeight.w700, "w700"), dropdownMenuItem(FontWeight.w800, "w800"), dropdownMenuItem(FontWeight.w900, "w900"), ], "HaveMax": false, "name": "FontWeight", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': "FontWeight", "fromVar": false, 'value': FontWeight.normal, "isConected": false, "haveTextFiled": true, "canSetFromNode": false, "varId": null, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Widget", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Widget', 'value': "Text", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Print") { return Node( x: pos.dx, y: pos.dy, size: Size(200, 100), type: "Print", id: Uuid().v1(), title: "Print", inputs: [ { "HaveMax": false, "name": "Print", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'String', "fromVar": false, 'value': "Hello World!", "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "varId": null, 'FromId': null, }, ], outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ]); } else if (name == "Num") { return Node( x: pos.dx, y: pos.dy, isItVar: true, type: "var", id: Uuid().v1(), title: "Num", varName: "myVar", classId: classId, outputs: [ { "HaveMax": false, "name": "Num", 'id': Uuid().v1(), 'targetId': null, 'LineDx': 0, 'LineDy': 0, 'valueType': 'Num', 'targetsId': <String>[], 'targetNodesId': <Node>[], "varId": varid, 'value': 0, 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, { "name": "Var", 'id': Uuid().v1(), 'targetId': null, 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'targetsId': <String>[], 'targetNodesId': <Node>[], "varId": varid, 'value': 0, 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, ], inputs: []); } else if (name == "IconData") { return Node( x: pos.dx, y: pos.dy, isItVar: true, type: "var", id: Uuid().v1(), title: "IconData", varName: "myVar", classId: classId, outputs: [ { "HaveMax": false, "name": "IconData", 'id': Uuid().v1(), 'targetId': null, 'LineDx': 0, 'LineDy': 0, 'valueType': 'IconData', 'targetsId': <String>[], 'targetNodesId': <Node>[], "varId": varid, 'value': Icons.access_alarm_sharp, 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, { "name": "Var", 'id': Uuid().v1(), 'targetId': null, 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'targetsId': <String>[], 'targetNodesId': <Node>[], "varId": varid, 'value': 0, 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, ], inputs: []); } else if (name == "color") { return Node( x: pos.dx, y: pos.dy, isItVar: true, type: "var", id: Uuid().v1(), title: "Color", varName: "myVar", outputs: [ { "name": "Color", 'id': Uuid().v1(), 'targetId': null, 'targetsId': <String>[], 'targetNodesId': <Node>[], 'LineDx': 0, 'LineDy': 0, 'valueType': 'Color', "varId": varid, 'value': Color.fromARGB(255, 9, 124, 255), 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, { "name": "Var", 'id': Uuid().v1(), 'targetId': null, 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'targetsId': <String>[], 'targetNodesId': <Node>[], "varId": varid, 'value': 0, 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, ], inputs: []); } else if (name == "SetVar") { return Node( x: pos.dx, y: pos.dy, isItVar: false, size: Size(200, 160), type: "SetVar", id: Uuid().v1(), title: "SetVar", outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ], inputs: [ { "name": "Var", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'value': null, "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "name": "New Value", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': "null", 'value': null, "isConected": false, "haveTextFiled": true, "canSetFromNode": true, "varId": null, 'FromId': null, }, ]); } else if (name == "If") { return Node( x: pos.dx, y: pos.dy, isItVar: false, size: Size(200, 275), type: "If", id: Uuid().v1(), title: "If", outputs: [ { 'targetId': null, "name": "Function", 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': "clas", 'targetNode': null, 'targetInputInedx': null, }, ], inputs: [ { "name": "State One", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'value': null, "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "showOnTitle": true, 'show': false, "name": "State", "fromVar": false, "haveDropDown": true, "DropDownList": <SmartDropdownMenuItem<dynamic>>[ dropdownMenuItem("==", "=="), dropdownMenuItem(">", ">"), dropdownMenuItem("<", "<"), dropdownMenuItem("!=", "!="), dropdownMenuItem(">=", ">="), dropdownMenuItem("<=", "<="), ], 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'value': null, "isConected": false, "haveTextFiled": false, "canSetFromNode": false, "varId": null, 'FromId': null, }, { "name": "State Two", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'value': null, "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "name": "if True do", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': <Node>[], "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, { "name": "if False do", "fromVar": false, 'id': Uuid().v1(), 'LineDx': 0, 'LineDy': 0, 'valueType': 'Function', 'value': <Node>[], "isConected": false, "haveTextFiled": false, "canSetFromNode": true, "varId": null, 'FromId': null, }, ]); } else { return Node( x: pos.dx, y: pos.dy, isItVar: true, type: "var", id: Uuid().v1(), title: "String", varName: "myVar", outputs: [ { "name": "String", 'id': Uuid().v1(), 'targetId': null, 'targetsId': <String>[], 'targetNodesId': <Node>[], 'LineDx': 0, 'LineDy': 0, 'valueType': 'String', "varId": varid, 'value': "String", 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, { "name": "Var", 'id': Uuid().v1(), 'targetId': null, 'LineDx': 0, 'LineDy': 0, 'valueType': 'Var', 'targetsId': <String>[], 'targetNodesId': <Node>[], "varId": varid, 'value': 0, 'targetNode': null, 'targetInputInedx': null, "haveTextFiled": false, }, ], inputs: []); } } SmartDropdownMenuItem dropdownMenuItem(dynamic value, String text) { return SmartDropdownMenuItem(value: value, child: Text(text)); }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/lib/node_manger.dart
// ignore_for_file: unrelated_type_equality_checks, unused_local_variable import 'dart:convert'; import 'package:example/colors.dart'; import 'package:flutter_iconpicker/IconPicker/icons.dart'; import 'package:smart_dropdown/smart_dropdown.dart'; import 'package:example/widgets.dart'; import 'package:flutter/material.dart'; import 'package:context_menu_macos/context_menu_macos.dart'; import 'package:metooltip/metooltip.dart'; import 'package:uuid/uuid.dart'; import 'node.dart'; import 'package:widget_arrows/widget_arrows.dart'; class NodeManger extends StatefulWidget { NodeManger( {Key? key, this.nodes = const [], required this.onSelect, required this.onDelete, required this.onPaste, required this.updateApp, required this.onDeleteClass, required this.onDeClass, required this.onClass, required this.onStopRun, required this.onRun}) : super(key: key); List<Node> nodes; Function(Node) onSelect; Function(Node) onDelete; Function() onStopRun; Function(Node, Map<dynamic, dynamic>) onRun; Function(Node node, Node body) onClass; Function(Node node) onDeClass; Function(Node node) onDeleteClass; Function updateApp; Function(Node, TapDownDetails) onPaste; @override State<NodeManger> createState() => _NodeMangerState(); } class _NodeMangerState extends State<NodeManger> { TransformationController controller = TransformationController(); Node selectedNode = Node(); dynamic hoveredInput; dynamic copyedNode = "null"; // node:node,input:input var from = {}; // node:node,input:input var target = {}; @override Widget build(BuildContext context) { return GestureDetector( child: Scaffold( backgroundColor: Color.fromARGB(255, 30, 30, 30), body: InteractiveViewer( child: Stack( children: widget.nodes .map( (e) => Positioned( top: e.y, left: e.x, child: GestureDetector( onTap: () { selectedNode = e; widget.onSelect(selectedNode); setState(() {}); }, onSecondaryTapDown: (details) { contextMune(details, e); }, onPanUpdate: (d) { selectedNode = e; e.x = d.delta.dx + e.x; e.y = d.delta.dy + e.y; setState(() {}); }, child: node(e))), ) .toList(), ), ), ), ); } Widget node(Node e) { return Column( children: [ SizedBox( height: 30, child: IconButton( onPressed: () { e.visble = !e.visble; setState(() {}); }, icon: Icon( Icons.arrow_drop_down, color: selectedNode.id == e.id ? selectedNodeColor : Colors.white, )), ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ /// --------------------------------------- [inputs]----------------------------------------- Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: e.inputs.map((en) { if (en["canSetFromNode"] == true) { return MeTooltip( message: en["valueType"], child: GestureDetector( onDoubleTap: () { if (en["FromId"] != null) { Node nd = widget.nodes[ widget.nodes.indexOf(en["FromId"]["node"])]; dynamic output = nd.outputs[ nd.outputs.indexOf(en["FromId"]["output"])]; output["targetId"] = null; output["targetNode"] = null; output["targetInputInedx"] = null; if (en["valueType"] == "Num") { en["value"] = 0; } else if (en["valueType"] == "Color") { en["value"] = Color.fromARGB(255, 9, 124, 255); } else if (en["valueType"] == "IconData") { en["value"] = Icons.abc; } en["isConected"] = false; if (nd.isItVar) { dynamic ndout = nd.outputs[nd.outputs.indexOf(output)]; ndout["targetNodesId"].remove(e); ndout["targetsId"].remove(en["FromId"]["index"]); } en["fromVar"] = false; en["FromId"] = null; widget.updateApp(); setState(() {}); } }, child: Row( children: [ MouseRegion( onEnter: (event) { if (e != from) { target["node"] = e; target["input"] = en; } hoveredInput = en; setState(() {}); }, onExit: (e) { target = {}; hoveredInput = null; setState(() {}); }, child: Container( margin: EdgeInsets.only( top: e.visble ? 25 : 0, bottom: e.visble ? 25 : 0, right: e.visble ? 5 : 0), width: 12, height: 12, decoration: BoxDecoration( color: hoveredInput == en ? selectedNodeColor.withOpacity(0.5) : Colors.transparent, borderRadius: BorderRadius.circular(10), border: Border.all( color: nodeInputAndLineColor, width: 2)), child: ArrowElement( color: nodeInputAndLineColor, stretchMax: 250, bow: 0, tipLength: 5, padEnd: 5, padStart: 2, id: en['id'].toString(), child: SizedBox()), ), ), ], ), ), ); } else { return SizedBox(); } }).toList()), /// --------------------------------------- [title]----------------------------------------- Visibility( visible: e.visble, replacement: Container( width: e.size.width, height: 30, decoration: BoxDecoration( color: nodeTitleContaner, border: Border.all( width: 2, color: e == selectedNode ? selectedNodeColor : nodeTextColorTwo), borderRadius: const BorderRadius.only( topLeft: Radius.circular(5), topRight: Radius.circular(5)), ), child: Center( child: Text(e.title, style: TextStyle( fontFamily: 'Inter', fontSize: 20, color: e == selectedNode ? selectedNodeColor : nodeTextColorTwo)), ), ), child: Container( height: e.size.height, width: e.size.width, decoration: BoxDecoration( border: Border.all( color: selectedNode.id == e.id ? selectedNodeColor : Colors.transparent, width: 2), color: nodesColor, borderRadius: BorderRadius.circular(6)), child: Column(children: [ Container( width: double.infinity, height: 30, decoration: BoxDecoration( color: nodeTitleContaner, borderRadius: const BorderRadius.only( topLeft: Radius.circular(5), topRight: Radius.circular(5)), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ nodeIconSeter( e.type, e == selectedNode ? selectedNodeColor : nodeInputAndLineColor, 20), Text( e.title, style: TextStyle( fontFamily: 'Inter', fontSize: 15, color: nodeTextColorTwo), ), Text(e.varName, style: TextStyle( fontFamily: 'Inter', fontSize: 15, color: nodeTextColorTwo)), Row( children: e.inputs.map((en) { if (en["haveDropDown"] != null && en["haveDropDown"] == true && en["showOnTitle"] != null && en["showOnTitle"] == true) { return SizedBox( width: 90, child: DropDown( name: en["name"], items: en["DropDownList"] ?? [], onSelect: (itme) { en["value"] = itme; widget.updateApp(); setState(() {}); }, ), ); } else { return SizedBox(); } }).toList()) ], ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: e.inputs .map( (en) => en["show"] == null ? Visibility( visible: en["haveDropDown"] != null && en["haveDropDown"] == true, child: Container( height: 40, width: 125, child: DropDown( name: en["name"], items: en["DropDownList"] ?? [], onSelect: (itme) { en["value"] = itme; widget.updateApp(); setState(() {}); }, )), replacement: Visibility( visible: en["haveTextFiled"] && !en["isConected"] && en["valueType"] != "null", replacement: Padding( padding: const EdgeInsets.only( top: 10, bottom: 30), child: Visibility( visible: en["haveDropDown"] == null || en["haveDropDown"] == false, child: Text( e.type != "StatefulWidget" ? en["name"] : en["name"] != "StatefulWidget" ? en["name"] : e.varName, style: TextStyle( fontFamily: 'Inter', color: nodeTextColorTwo), ), ), ), child: SizedBox( width: 100, height: 60, child: en["valueType"] != "Color" && en["valueType"] != "IconData" ? TextFiledForWork( onIcon: () { en["max"] = !en["max"]; widget.updateApp(); setState(() {}); }, haveIcon: en["HaveMax"] != null ? en["HaveMax"] : false, name: en["name"], maxLength: 20, type: en["valueType"], value: en["value"] .toString(), onChanged: (eg) { if (eg.isNotEmpty) { if (en["valueType"] == "Num") { en["value"] = double.parse( eg); } else { en["value"] = eg; } widget.updateApp(); setState(() {}); } }) : en["valueType"] == "Color" ? Button( text: en["name"], onClick: () { showDialog( context: context, builder: (context) { return ColorPick( pikcerColor: en["value"] != null ? en[ "value"] : Colors .blue, colore: (ec) { en["value"] = ec; widget .updateApp(); setState( () {}); }); }); }) : IconPick( newIcon: (icon) { en["value"] = icon; widget.updateApp(); setState(() {}); })), ), ) : SizedBox(), ) .toList(), ), SizedBox( width: 10, ), Column( children: e.outputs .map( (en) => Text( en["name"], style: TextStyle( fontFamily: 'Inter', color: nodeTextColorTwo), ), ) .toList(), ), ], ) ])), ), /// --------------------------------------- [outputs]----------------------------------------- Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: e.outputs .map( (en) => GestureDetector( onDoubleTap: () { if (en["targetId"] != null && e.isItVar == false) { dynamic nodee = widget .nodes[widget.nodes.indexOf(en["targetNode"])] .inputs[en[ "targetNode"] .inputs .indexOf(en["targetInputInedx"])]; nodee["isConected"] = false; nodee["FromId"] = null; nodee["fromVar"] = false; nodee["child"] != null ? nodee["child"] = null : nodee["value"] = null; if (en["targetNode"].type == "Run") { widget.onStopRun(); } else if (nodee["valueType"] == "Function") { nodee["value"].remove(e); } else if (en["targetNode"].type == "Screen") { nodee["child"] = null; widget.onDeClass(en["targetNode"]); widget.updateApp(); } else if (en["targetNode"].title == "Row" || en["targetNode"].title == "Column" || en["targetNode"].title == "Stack") { nodee["value"].remove(e); } en["targetId"] = null; widget.updateApp(); setState(() {}); } }, child: Container( width: 12, height: 12, margin: EdgeInsets.all(e.visble ? 5 : 0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( color: e == selectedNode ? selectedNodeColor : nodeInputAndLineColor, width: 2)), child: MeTooltip( message: en["valueType"], preferOri: PreferOrientation.up, child: Padding( padding: EdgeInsets.only(top: 4, left: 4), child: GestureDetector( child: ArrowElement( color: e == selectedNode ? selectedNodeColor : nodeInputAndLineColor, straights: false, stretchMax: 250, bow: 0.001, tipLength: 5, padEnd: 0, padStart: 2, id: Uuid().v1(), targetIds: e.isItVar ? en["targetsId"].length > 0 ? en["targetsId"] : null : null, targetId: e.isItVar ? null : en["targetId"], child: CustomPaint( foregroundPainter: LinePinter( line: Offset(en["LineDx"], en["LineDy"])), child: GestureDetector( onTap: () {}, onPanUpdate: (d) { from["node"] = e; from["input"] = e.outputs[e.outputs.indexOf(en)]; en['isDraging'] = true; en['LineDx'] = en['LineDx'] + d.delta.dx; en['LineDy'] = en['LineDy'] + d.delta.dy; setState(() {}); }, onPanEnd: (d) { conect(en); }, ), ), ), ), ), ), ), ), ) .toList()), ], ), ], ); } // on conect 2node void conect(en) { if (from.isNotEmpty && target.isNotEmpty && from["node"] != target["node"] && target["input"]["isConected"] == false) { if (target["input"]["valueType"] == "Any" || en["valueType"] == target["input"]["valueType"]) { Node trgt = widget.nodes[widget.nodes.indexOf(target["node"])]; Node frm = widget.nodes[widget.nodes.indexOf(from["node"])]; if (trgt.title != "Row" && trgt.title != "Column" && trgt.title != "Stack" && target["input"]["valueType"] != "Function") { trgt.inputs[trgt.inputs.indexOf(target["input"])]["value"] = frm; trgt.inputs[trgt.inputs.indexOf(target["input"])]["isConected"] = true; } else if (target["input"]["valueType"] == "Function") { trgt.inputs[trgt.inputs.indexOf(target["input"])]["value"].add(frm); } else if (trgt.title == "Row" || trgt.title == "Column" || trgt.title == "Stack") { trgt.inputs[trgt.inputs.indexOf(target["input"])]["value"].add(frm); } frm.outputs[frm.outputs.indexOf(from["input"])]["targetId"] = trgt.inputs[trgt.inputs.indexOf(target["input"])]["id"]; en["targetInputInedx"] = trgt.inputs[trgt.inputs.indexOf(target["input"])]; trgt.inputs[trgt.inputs.indexOf(target["input"])]["FromId"] = { "node": frm, "output": from["input"], "index": trgt.inputs[trgt.inputs.indexOf(target["input"])]["id"] }; en["targetNode"] = trgt; if (frm.isItVar) { trgt.inputs[trgt.inputs.indexOf(target["input"])]["varId"] = frm.outputs[0]["varId"] - 1; trgt.inputs[trgt.inputs.indexOf(target["input"])]["fromVar"] = true; frm.outputs[frm.outputs.indexOf(from["input"])]["targetsId"] .add(trgt.inputs[trgt.inputs.indexOf(target["input"])]["id"]); frm.outputs[frm.outputs.indexOf(from["input"])]["targetNodesId"] .add(trgt); widget.updateApp(); } if (trgt.type == "Math" && trgt.inputs.indexOf(target["input"]) == 2) { trgt.inputs[2]["value"] = frm.outputs[0]["varId"] - 1; } if (trgt.type == "GetItme" && trgt.inputs.indexOf(target["input"]) == 0) { trgt.inputs[2]["ItmeType"] = frm.title == "List(Color)" ? "Color" : frm.title == "List(String)" ? "String" : frm.title == "List(Num)" ? "Num" : "IconData"; } if (frm.title == "Itme" && frm.inputs.indexOf(from["input"]) == 0) { frm.outputs[2]["valueType"] = trgt.inputs[2]["ItmeType"]; } else if (frm.title == "Itme" && frm.inputs.indexOf(from["input"]) == 2) { frm.outputs[2]["value"] = trgt.inputs[trgt.inputs.indexOf(target["input"])]["value"]; } if (trgt.title == "SetVar") { trgt.inputs[trgt.inputs.indexOf(target["input"])]["value"] = frm.outputs[0]["varId"] - 1; trgt.inputs[1]["valueType"] = frm.outputs[0]["valueType"]; trgt.inputs[trgt.inputs.indexOf(target["input"])]["isConected"] = true; } if (target["node"].type != "var" && target["node"].type != "Run") { if (target["node"].isItCalss) { trgt.inputs[1]["child"] = frm; widget.onClass(trgt, frm); } else { trgt.inputs[trgt.inputs.indexOf(target["input"])]["child"] = frm; } } else if (target["node"].type == "Run") { widget.onRun(frm, target); } widget.updateApp(); from = {}; target = {}; en['LineDx'] = 0; en['LineDy'] = 0; } else { from = {}; en['LineDx'] = 0; en['LineDy'] = 0; } } else { from = {}; en['LineDx'] = 0; en['LineDy'] = 0; } setState(() {}); } dynamic contextMune(details, Node node) { return showMacosContextMenu( context: context, globalPosition: details.globalPosition, children: [ MacosContextMenuItem( content: Text('Delete'), onTap: () { Future.delayed(Duration(milliseconds: 1), () { widget.onDelete(node); Navigator.pop(context); }); if (node.isItCalss) { widget.onDeleteClass(node); } node.inputs.forEach((en) { print(widget.nodes[widget.nodes.indexOf(en["targetNode"])] .outputs[en["targetInputInedx"]]["targetId"]); widget.nodes[widget.nodes.indexOf(en["targetNode"])] .outputs[en["targetInputInedx"]]["targetId"] = null; }); node.outputs.forEach((en) { dynamic tartget = widget.nodes[widget.nodes.indexOf(en["targetNode"])]; dynamic targetinputs = tartget .inputs[tartget.inputs.indexOf(en["targetInputInedx"])]; if (en["targetNode"].type == "Screen") { widget.onDeClass(en["targetNode"]); } targetinputs["value"] = null; targetinputs["targetId"] = null; targetinputs["targetNode"] = null; targetinputs["fromVar"] = false; targetinputs["child"] = null; targetinputs["isConected"] = false; en["targetId"] = null; en["targetNode"] = null; en["targetInputInedx"] = null; if (tartget.type == "Run") { widget.onStopRun(); } }); widget.updateApp(); setState(() {}); }, ), ], ); } } class LinePinter extends CustomPainter { LinePinter({this.line = const Offset(0, 0)}); Offset line; @override void paint(Canvas canvas, Size size) { Paint paint = Paint(); paint.strokeCap = StrokeCap.round; paint.color = nodeInputAndLineColor; paint.strokeWidth = 4; paint.strokeJoin = StrokeJoin.round; paint.style = PaintingStyle.stroke; canvas.drawLine(Offset(0, 0), line, paint); } @override bool shouldRepaint(LinePinter oldDelegate) => true; @override bool shouldRebuildSemantics(LinePinter oldDelegate) => true; }
0
mirrored_repositories/Flutter-Visual-Programing
mirrored_repositories/Flutter-Visual-Programing/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:example/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/favours-app/app
mirrored_repositories/favours-app/app/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key? key, required this.title}) : super(key: key); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect // how it looks. // This class is the configuration for the state. It holds the values (in this // case the title) provided by the parent (in this case the App widget) and // used by the build method of the State. Fields in a Widget subclass are // always marked "final". final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; void _incrementCounter() { setState(() { // This call to setState tells the Flutter framework that something has // changed in this State, which causes it to rerun the build method below // so that the display can reflect the updated values. If we changed // _counter without calling setState(), then the build method would not be // called again, and so nothing would appear to happen. _counter++; }); } @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. child: Column( // Column is also a layout widget. It takes a list of children and // arranges them vertically. By default, it sizes itself to fit its // children horizontally, and tries to be as tall as its parent. // // Invoke "debug painting" (press "p" in the console, choose the // "Toggle Debug Paint" action from the Flutter Inspector in Android // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) // to see the wireframe for each widget. // // Column has various properties to control how it sizes itself and // how it positions its children. Here we use mainAxisAlignment to // center the children vertically; the main axis here is the vertical // axis because Columns are vertical (the cross axis would be // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } }
0
mirrored_repositories/favours-app/app
mirrored_repositories/favours-app/app/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/FoodieMania-Food-Delivery-App
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_stripe/flutter_stripe.dart'; import 'package:food_delivery_app_ui/screens/introduction_screen.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); Stripe.publishableKey = '{publishable-key}'; await Stripe.instance.applySettings(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'FoodieMania: Food Delivery App', theme: ThemeData( primaryColor: Colors.black, primarySwatch: Colors.red, ), home: const IntroductionScreen(), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/widgets/rating_stars.dart
import 'package:flutter/material.dart'; class RatingStars extends StatelessWidget { final int? rating; const RatingStars(this.rating, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { String stars = ''; for (int i = 0; i < rating!; i++) { stars += '⭐ '; } stars.trim(); return Text( stars, style: const TextStyle( fontSize: 13.0 ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/widgets/popular_items.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import '../Provider/popular_items_provider.dart'; import '/model/order.dart'; import '/data/data.dart'; class PopularItems extends StatelessWidget { const PopularItems({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Consumer<PopularItemsProvider>( builder: (context, provider, _) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(horizontal: 22.0), child: Text( 'Popular Items', style: GoogleFonts.cabin( fontSize: 20, fontWeight: FontWeight.bold, ), ), ), const SizedBox( height: 18.0, ), SizedBox( height: 225.0, child: ListView.builder( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.symmetric(horizontal: 14.0), scrollDirection: Axis.horizontal, itemCount: currentUser.orders!.length, itemBuilder: (context, index) { Order order = currentUser.orders![index]; return Padding( padding: const EdgeInsets.only(right: 10.0), child: Container( width: 165.0, decoration: BoxDecoration( color: Colors.grey[100], borderRadius: BorderRadius.circular(20.0), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0), ), child: Image.asset( order.food!.imageUrl!, height: 95.0, width: double.infinity, fit: BoxFit.cover, ), ), const SizedBox(height: 10.0), Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( order.food!.name!, style: const TextStyle( fontSize: 13.0, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 4.0), Text( order.restaurant!.name!, style: TextStyle( fontSize: 11.0, color: Colors.grey[600], ), ), const SizedBox(height: 4.0), Text( order.date!, style: TextStyle( fontSize: 12.0, color: Colors.grey[600], ), ), ], ), ), Padding( padding: const EdgeInsets.all(15.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '\$${order.food!.price!.toStringAsFixed(2)}', style: const TextStyle( fontSize: 14.0, fontWeight: FontWeight.bold, ), ), Container( width: 32.0, height: 32.0, decoration: BoxDecoration( color: Theme.of(context).primaryColor, shape: BoxShape.circle, ), child: IconButton( onPressed: () { Provider.of<PopularItemsProvider>(context, listen: false) .addToCart(order); provider.loadHomePage(); }, icon: const Icon( Icons.add, size: 16.0, color: Colors.white, ), ), ), ], ), ), ], ), ), ); }, ), ), ], ); }, ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/widgets/nearby_restaurants.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import '/data/data.dart'; import '/screens/restaurant_screen.dart'; import '/widgets/rating_stars.dart'; class NearbyRestaurants extends StatelessWidget { const NearbyRestaurants({Key? key}) : super(key: key); Widget _buildNearbyRestaurants(BuildContext context) { return Column( children: restaurants.map((thisRestaurant) { return GestureDetector( onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => RestaurantScreen(restaurant: thisRestaurant)), ); }, child: Container( height: 90, margin: const EdgeInsets.symmetric( horizontal: 20, vertical: 6, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.3), spreadRadius: 3.0, blurRadius: 6.0, offset: const Offset(0, 3), ), ], ), child: Row( children: <Widget>[ ClipRRect( borderRadius: BorderRadius.circular(16), child: Hero( tag: thisRestaurant.imageUrl!, child: Image.asset( thisRestaurant.imageUrl!, height: 100.0, width: 100.0, fit: BoxFit.cover, ), ), ), Expanded( child: Padding( padding: const EdgeInsets.all(12), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( thisRestaurant.name!, style: const TextStyle( fontSize: 13.0, fontWeight: FontWeight.bold, ), ), RatingStars(thisRestaurant.rating!), const SizedBox(height: 12.0), Text( thisRestaurant.address!, style: const TextStyle( fontSize: 11.0, color: Colors.grey, ), ), ], ), ), ), ], ), ), ); }).toList(), ); } @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.only(left: 20, right: 20, top: 25, bottom: 10), child: Text( 'Nearby Restaurants', style: GoogleFonts.cabin( fontSize: 20, fontWeight: FontWeight.bold, ), ), ), _buildNearbyRestaurants(context), ], ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/database/db_model.dart
class Carts { int? id; double price; String food; String date; String imageURL; String restaurant; int quantity; Carts( {this.id, required this.date, required this.price, required this.food, required this.restaurant, required this.quantity, required this.imageURL}); Map<String, dynamic> toMap() { return { 'id': id, 'price': price, 'food': food, 'quantity': quantity, 'restaurant': restaurant, 'date': date, 'imageURL': imageURL }; } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/database/db_helper.dart
import 'dart:async'; import 'package:food_delivery_app_ui/database/db_model.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; class DatabaseHelper { static const _databaseName = 'cart_database.db'; static const _databaseVersion = 1; static const table = 'Cart'; static const columnId = 'id'; static const columnPrice = 'price'; static const columnFood = 'food'; static const columnQuantity = 'quantity'; static const columnRestaurant = 'restaurant'; static const columnDate = 'date'; static const columnimageURL = 'imageURL'; DatabaseHelper(); static final DatabaseHelper db_instance = DatabaseHelper(); static Database? _database; Future<Database> get database async { if (_database != null) return _database!; _database = await _initDatabase(); return _database!; } _initDatabase() async { String path = join(await getDatabasesPath(), _databaseName); return await openDatabase(path, version: _databaseVersion, onCreate: _onCreate); } Future _onCreate(Database db, int version) async { db.execute( "CREATE TABLE $table($columnId INTEGER PRIMARY KEY AUTOINCREMENT," "$columnPrice REAL NOT NULL, " "$columnFood TEXT NOT NULL, " "$columnQuantity INTEGER NOT NULL, " "$columnRestaurant TEXT NOT NULL, " "$columnimageURL TEXT NOT NULL, " "$columnDate TEXT NOT NULL)"); } Future<Carts> insert(Carts carts) async { final db = await database; await db.insert( table, carts.toMap(), ); return carts; } Future<List<Carts>> getCarts() async { final db = await database; final List<Map<String, dynamic>> maps = await db.query(table); return List.generate(maps.length, (i) { return Carts( id: maps[i]['id'], date: maps[i]['date'], price: maps[i]['price'], food: maps[i]['food'], quantity: maps[i]['quantity'], restaurant: maps[i]['restaurant'], imageURL: maps[i]['imageURL']); }); } Future<int> update(Carts carts) async { final db = await database; return await db.update( table, carts.toMap(), where: '$columnId = ?', whereArgs: [carts.id], ); } Future<int?> delete(int id) async { final db = await database; return await db.delete( table, where: '$columnId = ?', whereArgs: [id], ); } Future close() async { var db = await database; db.close(); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Utils/alert_dialog.dart
import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/database/db_helper.dart'; import 'package:food_delivery_app_ui/database/db_model.dart'; import 'package:food_delivery_app_ui/screens/home_screen.dart'; import 'package:food_delivery_app_ui/screens/payment_screen.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:rflutter_alert/rflutter_alert.dart'; class CustomAlertDialog { static void onAlertWithStyle( BuildContext context, String title, String desc, AlertType alertType, bool payConfirm, DatabaseHelper databaseHelper, List<Carts> carts) { var alertStyle = AlertStyle( animationType: AnimationType.fromBottom, isCloseButton: false, isOverlayTapDismiss: false, descStyle: GoogleFonts.cabin( fontSize: 16, ), animationDuration: const Duration(milliseconds: 600), alertBorder: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), side: const BorderSide( color: Colors.grey, ), ), titleStyle: GoogleFonts.cabin( fontSize: 23, color: Colors.green, fontWeight: FontWeight.w600), constraints: const BoxConstraints.expand( width: 320, ), overlayColor: const Color(0x55000000), alertElevation: 4, alertPadding: const EdgeInsets.only(top: 200), alertAlignment: Alignment.bottomCenter); Alert( context: context, style: alertStyle, type: alertType, title: title, desc: desc, buttons: [ DialogButton( height: 35, margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 45), onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const HomeScreen())); turn = true; payConfirm = false; for (Carts cart in carts) { databaseHelper.delete(cart.id!); } }, child: Center( child: Text( 'Return to Home Page', style: GoogleFonts.cabin(fontSize: 15.5, color: Colors.black), ), ), border: Border.all( color: Colors.black, width: 2.0, ), radius: BorderRadius.circular(40), color: Colors.transparent, ), ], ).show(); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Utils/snackbar.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class snackBar { static void showSnackBar(BuildContext context, String title) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0), ), padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10), duration: const Duration(milliseconds: 1000), backgroundColor: Colors.red, behavior: SnackBarBehavior.floating, dismissDirection: DismissDirection.horizontal, margin: const EdgeInsets.only(bottom: 620, left: 5, right: 5), content: Text( title, style: GoogleFonts.cabin(fontSize: 20, fontWeight: FontWeight.w600), ), ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Utils
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Utils/Reusable Components/animated_toggle_button.dart
import 'package:flutter/material.dart'; class AnimatedToggleButton extends StatefulWidget { final bool isOn; final Function(bool) onToggle; const AnimatedToggleButton({ Key? key, required this.isOn, required this.onToggle, }) : super(key: key); @override _AnimatedToggleButtonState createState() => _AnimatedToggleButtonState(); } class _AnimatedToggleButtonState extends State<AnimatedToggleButton> { bool _isOn = true; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(25), child: Stack( alignment: Alignment.center, children: [ GestureDetector( onTap: () { setState(() { _isOn = !_isOn; widget.onToggle(_isOn); }); }, child: AnimatedContainer( duration: const Duration(milliseconds: 300), width: 200, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.blue.shade100, ), child: Stack( alignment: _isOn ? Alignment.topLeft : Alignment.topRight, children: [ AnimatedPositioned( duration: const Duration(milliseconds: 300), curve: Curves.fastLinearToSlowEaseIn, child: Container( height: 40, width: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(6), color: Colors.blue.shade600), ), ), ], ), ), ), ], ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Utils
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Utils/Reusable Components/contact_page.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class ContactPage extends StatelessWidget { final String title, hint; TextEditingController controller; TextInputType type; final ValueChanged<String> onChanged; ContactPage( {required this.title, required this.hint, required this.type, required this.controller, required this.onChanged, Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 25), child: Text( title, style: GoogleFonts.cabin(fontSize: 18, fontWeight: FontWeight.bold), ), ), Padding( padding: const EdgeInsets.symmetric( vertical: 6, horizontal: 25, ), child: SizedBox( height: 40, child: TextFormField( onChanged: onChanged, controller: controller, keyboardType: type, style: GoogleFonts.cabin(color: Colors.black, fontSize: 15), decoration: InputDecoration( contentPadding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 15), fillColor: Colors.white70, filled: true, border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: const BorderSide(width: 0.8), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(6.0), borderSide: BorderSide( width: 1.5, color: Theme.of(context).primaryColor, ), ), hintText: hint, hintStyle: const TextStyle( fontSize: 14, )), ), ), ), ], ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/data/data.dart
import '/model/food.dart'; import '/model/order.dart'; import '/model/restaurant.dart'; import '/model/user.dart'; // Food final _burrito = Food(imageUrl: 'assets/images/burrito.jpg', name: 'Burrito', price: 8.99); final _steak = Food(imageUrl: 'assets/images/steak.jpg', name: 'Steak', price: 17.99); final _pasta = Food(imageUrl: 'assets/images/pasta.jpg', name: 'Pasta', price: 14.99); final _ramen = Food(imageUrl: 'assets/images/ramen.jpg', name: 'Ramen', price: 13.99); final _pancakes = Food(imageUrl: 'assets/images/pancakes.jpg', name: 'Pancakes', price: 9.99); final _burger = Food(imageUrl: 'assets/images/burger.jpg', name: 'Burger', price: 14.99); final _pizza = Food(imageUrl: 'assets/images/pizza.jpg', name: 'Pizza', price: 11.99); final _salmon = Food( imageUrl: 'assets/images/salmon.jpg', name: 'Salmon Salad', price: 12.99); // Restaurants final _restaurant0 = Restaurant( imageUrl: 'assets/images/restaurant0.jpg', name: 'Pizzalicious Restaurant', address: '123 Main St, New York, NY', rating: 5, menu: [_burrito, _steak, _pasta, _ramen, _pancakes, _burger, _pizza, _salmon], ); final _restaurant1 = Restaurant( imageUrl: 'assets/images/restaurant1.jpg', name: 'Delicious Bites', address: '456 Elm St, New York, NY', rating: 4, menu: [_steak, _pasta, _ramen, _pancakes, _burger, _pizza], ); final _restaurant2 = Restaurant( imageUrl: 'assets/images/restaurant2.jpg', name: 'Gourmet Fusion', address: '789 Oak St, New York, NY', rating: 4, menu: [_steak, _pasta, _pancakes, _burger, _pizza, _salmon], ); final _restaurant3 = Restaurant( imageUrl: 'assets/images/restaurant3.jpg', name: 'Spice Paradise', address: '321 Pine St, New York, NY', rating: 2, menu: [_burrito, _steak, _burger, _pizza, _salmon], ); final _restaurant4 = Restaurant( imageUrl: 'assets/images/restaurant4.jpg', name: 'The Savory Spot', address: '654 Maple St, New York, NY', rating: 3, menu: [_burrito, _ramen, _pancakes, _salmon], ); final _restaurant5 = Restaurant( imageUrl: 'assets/images/restaurant5.jpg', name: 'Cuisine Delights', address: '987 Walnut St, New York, NY', rating: 4, menu: [_ramen, _pancakes, _burger, _pizza, _salmon], ); final _restaurant6 = Restaurant( imageUrl: 'assets/images/restaurant6.jpg', name: 'Sizzlers Junction', address: '567 Cherry St, New York, NY', rating: 3, menu: [_burrito, _pasta, _pancakes, _salmon], ); final List<Restaurant> restaurants = [ _restaurant1, _restaurant5, _restaurant6, _restaurant0, _restaurant2, _restaurant3, _restaurant4, ]; // Popular Items final currentUser = User( name: 'Basit', orders: [ Order( date: 'Jun 2, 2023', food: _burger, restaurant: _restaurant5, quantity: 1, ), Order( date: 'Jun 2 , 2023', food: _pizza, restaurant: _restaurant3, quantity: 1, ), Order( date: 'Jun 3, 2023', food: _pasta, restaurant: _restaurant4, quantity: 1, ), Order( date: 'Jun 3, 2023', food: _steak, restaurant: _restaurant2, quantity: 1, ), Order( date: 'Jun 3, 2023', food: _ramen, restaurant: _restaurant0, quantity: 3, ), Order( date: 'Nov 5, 2019', food: _burrito, restaurant: _restaurant1, quantity: 2, ), ], );
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Provider/cart_screen_provider.dart
import 'package:flutter/foundation.dart'; import '../database/db_helper.dart'; import '../database/db_model.dart'; class CartProvider extends ChangeNotifier { DatabaseHelper? databaseHelper; Future<List<Carts>>? cartsList; double totalPrice = 0; int deliveryTime = 0; int len = 0; bool isEmpty = true; CartProvider() { databaseHelper = DatabaseHelper(); loadData(); } loadHomePage() async{ cartsList = databaseHelper!.getCarts(); List<Carts> carts = await cartsList!; len = carts.length; notifyListeners(); } loadData() async { cartsList = databaseHelper!.getCarts(); List<Carts> carts = await cartsList!; isEmpty = carts.isEmpty; double newTotalPrice = 0; deliveryTime = carts.length * 15; for (var order in carts) { newTotalPrice += order.price * order.quantity; } totalPrice = newTotalPrice; len = carts.length; notifyListeners(); } void decrementQuantity(Carts order) { if (order.quantity > 1) { order.quantity -= 1; databaseHelper!.update(order); loadData(); // notifyListeners(); } } void incrementQuantity(Carts order) { order.quantity += 1; if (kDebugMode) { print(totalPrice.toString()); } databaseHelper!.update(order); loadData(); } void deleteOrder(int id) { databaseHelper!.delete(id); loadData(); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Provider/payment_screen_provider.dart
import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/database/db_model.dart'; import 'package:food_delivery_app_ui/database/db_helper.dart'; import 'package:rflutter_alert/rflutter_alert.dart'; import '../Utils/alert_dialog.dart'; import '../ViewModel/stripe_payment.dart'; class PaymentProvider extends ChangeNotifier { late DatabaseHelper databaseHelper; late Future<List<Carts>> cartsList; bool turn = true; bool payConfirm = false; List<Carts> carts = []; int len = 0; PaymentProvider() { databaseHelper = DatabaseHelper(); loadData(); } Future<void> loadData() async { cartsList = databaseHelper.getCarts(); carts = await cartsList; len = carts.length; notifyListeners(); } void togglePaymentMethod(bool isOn) { turn = isOn; notifyListeners(); } Future<void> makeCardPayment(BuildContext context, String amount) async { // payConfirm = false; await makePayment( context, amount, "Payment Successful!", "Your payment has been successfully processed.", AlertType.success, false, databaseHelper, carts, ); } void setPayConfirm(bool value) { payConfirm = value; notifyListeners(); } void confirmOrder( BuildContext context, DatabaseHelper databaseHelper, List<Carts> carts) { CustomAlertDialog.onAlertWithStyle( context, "Order Confirmed!", "Your order has been confirmed successfully", AlertType.success, false, databaseHelper, carts, ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Provider/restaurant_screen_provider.dart
import 'package:flutter/foundation.dart'; import 'package:food_delivery_app_ui/model/restaurant.dart'; import 'package:intl/intl.dart'; import '../database/db_helper.dart'; import '../database/db_model.dart'; import '../model/food.dart'; class RestaurantProvider extends ChangeNotifier { DatabaseHelper? databaseHelper; late Future<List<Carts>> cartsList; bool isFav = false; RestaurantProvider() { databaseHelper = DatabaseHelper(); } loadData() async { cartsList = databaseHelper!.getCarts(); } void toggleFavorite() { isFav = !isFav; notifyListeners(); } void addToCart(Food menuItem, Restaurant? restaurant) { var now = DateTime.now(); var formatter = DateFormat('dd-MM-yyyy'); String formattedDate = formatter.format(now); databaseHelper! .insert(Carts( date: formattedDate, price: menuItem.price!.toDouble(), food: menuItem.name.toString(), restaurant: restaurant!.name.toString(), quantity: 1, imageURL: menuItem.imageUrl.toString())) .then((value) { if (kDebugMode) { print('cart inserted. $value'); } }).onError((error, stackTrace) { if (kDebugMode) { print('error: ' + error.toString()); } }); notifyListeners(); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Provider/popular_items_provider.dart
import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import '../database/db_helper.dart'; import '../database/db_model.dart'; import '../model/order.dart'; class PopularItemsProvider extends ChangeNotifier { DatabaseHelper? databaseHelper; Future<List<Carts>>? cartsList; int len = 0; double totalPrice = 0; PopularItemsProvider() { databaseHelper = DatabaseHelper(); loadHomePage(); } loadHomePage() async{ cartsList = databaseHelper!.getCarts(); List<Carts> carts = await cartsList!; len = carts.length; notifyListeners(); } void addToCart(Order order) { var now = DateTime.now(); var formatter = DateFormat('dd-MM-yyyy'); String formattedDate = formatter.format(now); databaseHelper! .insert(Carts( date: formattedDate, price: order.food!.price!.toDouble(), food: order.food!.name.toString(), restaurant: order.restaurant!.name.toString(), quantity: 1, imageURL: order.food!.imageUrl.toString())) .then((value) { if (kDebugMode) { print('cart inserted. $value'); } }).onError((error, stackTrace) { print('error: ' + error.toString()); }); notifyListeners(); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/Provider/contact_screen_provider.dart
import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class ContactProvider extends ChangeNotifier { late SharedPreferences _prefs; TextEditingController nameController = TextEditingController(); TextEditingController emailController = TextEditingController(); TextEditingController phoneController = TextEditingController(); TextEditingController addressController = TextEditingController(); bool isFormValid = false; ContactProvider() { loadUserInfo(); } Future<void> loadUserInfo() async { _prefs = await SharedPreferences.getInstance(); nameController.text = _prefs.getString('name') ?? ''; emailController.text = _prefs.getString('email') ?? ''; phoneController.text = _prefs.getString('phone') ?? ''; addressController.text = _prefs.getString('address') ?? ''; validateForm(); } Future<void> saveUserInfo() async { await _prefs.setString('name', nameController.text); await _prefs.setString('email', emailController.text); await _prefs.setString('phone', phoneController.text); await _prefs.setString('address', addressController.text); } void validateForm() { isFormValid = nameController.text.isNotEmpty && emailController.text.isNotEmpty && phoneController.text.isNotEmpty && addressController.text.isNotEmpty; notifyListeners(); } void saveUserInformation() { saveUserInfo(); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/model/order.dart
import '/model/food.dart'; import '/model/restaurant.dart'; class Order { final Restaurant? restaurant; final Food? food; final String? date; late final int? quantity; Order({ this.date, this.restaurant, this.food, this.quantity, }); }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/model/user.dart
import '/model/order.dart'; class User { final String? name; final List<Order>? orders; final List<Order>? cart; User({ this.name, this.orders, this.cart, }); }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/model/food.dart
class Food { final String? imageUrl; final String? name; final double? price; Food({ this.imageUrl, this.name, this.price, }); }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/model/restaurant.dart
import '/model/food.dart'; class Restaurant { final String? imageUrl; final String? name; final String? address; final int? rating; final List<Food>? menu; Restaurant({ this.imageUrl, this.name, this.address, this.rating, this.menu, }); }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/ViewModel/stripe_payment.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/Utils/alert_dialog.dart'; import 'package:food_delivery_app_ui/database/db_helper.dart'; import 'package:food_delivery_app_ui/database/db_model.dart'; import 'package:http/http.dart' as http; import 'package:flutter_stripe/flutter_stripe.dart'; import 'dart:convert'; import 'package:rflutter_alert/rflutter_alert.dart'; Map<String, dynamic>? paymentIntentData; Future<void> makePayment( BuildContext context, String amount, String title, String desc, AlertType alertType, bool payConfirm, DatabaseHelper databaseHelper, List<Carts> carts) async { try { paymentIntentData = await createPaymentIntent(amount, 'USD'); await Stripe.instance .initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( setupIntentClientSecret: '{secret-key}', paymentIntentClientSecret: paymentIntentData!['client_secret'], customFlow: true, style: ThemeMode.dark, merchantDisplayName: 'Basit')) .then((value) {}); displayPaymentSheet( context, title, desc, alertType, payConfirm, databaseHelper, carts); } catch (e, s) { if (kDebugMode) { print('Payment Exception: $e$s'); } } } displayPaymentSheet( BuildContext context, String title, String desc, AlertType alertType, bool payConfirm, DatabaseHelper databaseHelper, List<Carts> carts) async { try { await Stripe.instance.presentPaymentSheet().then((newValue) { CustomAlertDialog.onAlertWithStyle( context, title, desc, alertType, payConfirm, databaseHelper, carts); paymentIntentData = null; }).onError((error, stackTrace) { if (kDebugMode) { print('Exception/DISPLAYPAYMENTSHEET: $error $stackTrace'); } }); } on StripeException catch (e) { if (kDebugMode) { print('Exception/DISPLAYPAYMENTSHEET: $e'); } showDialog( context: context, builder: (_) => const AlertDialog( content: Text("Cancelled"), )); } catch (e) { if (kDebugMode) { print('$e'); } } } createPaymentIntent(String amount, String currency) async { try { Map<String, dynamic> body = { 'amount': calculateAmount(amount), 'currency': currency, 'payment_method_types[]': 'card', }; var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, headers: { 'Authorization': 'Bearer {secret-key}', 'Content-Type': 'application/x-www-form-urlencoded' }); return jsonDecode(response.body); } catch (err) { if (kDebugMode) { print('err charging user: ${err.toString()}'); } } } calculateAmount(String amount) { final a = (int.parse(amount)) * 100; return a.toString(); }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/ViewModel/splash_controller.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/screens/home_screen.dart'; class SplashScreenController { void SplashTime(BuildContext context) { Timer( const Duration(milliseconds: 4000), () => Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const HomeScreen()))); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/screens/cart_screen.dart
import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/Utils/snackbar.dart'; import 'package:food_delivery_app_ui/screens/contact_screen.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import '../Provider/cart_screen_provider.dart'; import '../database/db_model.dart'; class CartScreen extends StatefulWidget { const CartScreen({Key? key}) : super(key: key); @override State<CartScreen> createState() => _CartScreenState(); } class _CartScreenState extends State<CartScreen> { double totalPrice = 0; @override void initState() { super.initState(); loadData(); } loadData() async { final cartProvider = Provider.of<CartProvider>(context, listen: false); await cartProvider.loadData(); await cartProvider.loadHomePage(); } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Column( children: [ AppBar( backgroundColor: Colors.transparent, elevation: 0, leading: InkWell( onTap: () { // loadData(); Navigator.pop(context); }, child: const Icon( Icons.arrow_back_ios, color: Colors.black, )), title: const Text( 'Back', style: TextStyle(color: Colors.black), ), ), Padding( padding: const EdgeInsets.only(top: 5, left: 25, bottom: 8), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Cart', style: GoogleFonts.cabin(fontSize: 26), ) ], ), ), Expanded(child: Consumer<CartProvider>(builder: (context, cartProvider, _) { if (cartProvider.cartsList == null) { return const CircleAvatar( radius: 35, child: Icon(Icons.fastfood), ); } else { return FutureBuilder<List<Carts>>( future: cartProvider.cartsList, builder: (context, snapshot) { if (snapshot.hasData) { List<Carts> carts = snapshot.data!; return ListView.builder( physics: const BouncingScrollPhysics(), itemCount: snapshot.data!.length, itemBuilder: (context, index) { Carts order = carts[snapshot.data!.length - 1 - index]; return Container( height: 100, margin: const EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.0), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.3), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3), ), ], ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( width: 108.0, height: 100.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16.0), image: DecorationImage( image: AssetImage(order.imageURL), fit: BoxFit.cover, ), ), ), const SizedBox(width: 10.0), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( order.food, style: const TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 4), Text( order.restaurant, style: const TextStyle( fontSize: 12.0, color: Colors.grey, ), ), const SizedBox(height: 10.0), Row( children: [ GestureDetector( onTap: () { cartProvider .decrementQuantity(order); }, child: Container( width: 25.0, height: 25.0, decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.circular( 8.0), ), child: const Icon( Icons.remove, size: 18.0, color: Colors.black, ), ), ), Container( margin: const EdgeInsets.symmetric( horizontal: 12.0), child: Text( order.quantity.toString(), style: const TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, ), ), ), GestureDetector( onTap: () { cartProvider .incrementQuantity(order); }, child: Container( width: 25.0, height: 25.0, decoration: BoxDecoration( color: Theme.of(context) .primaryColor, borderRadius: BorderRadius.circular( 8.0), ), child: const Icon( Icons.add, size: 18.0, color: Colors.white, ), ), ), ], ), ], ), ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ IconButton( onPressed: () { cartProvider .deleteOrder(order.id!.toInt()); }, icon: const Icon( Icons.cancel, color: Colors.red, size: 24, )), const SizedBox( height: 22, ), Padding( padding: const EdgeInsets.symmetric( horizontal: 15, ), child: Text( '\$${order.price}', style: const TextStyle( fontSize: 15.5, fontWeight: FontWeight.bold, ), ), ), ], ), ], ), ); }, ); } else { return const SizedBox(); } }); } })), Container( padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.only( topRight: Radius.circular(50), topLeft: Radius.circular(50), ), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.95), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3), ), ], ), child: Padding( padding: const EdgeInsets.only( top: 25, left: 16, right: 16, ), child: Consumer<CartProvider>( builder: (context, cartProvider, _) { return Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( 'Delivery Time:', style: GoogleFonts.cabin( fontSize: 17, fontWeight: FontWeight.w600), ), Text( cartProvider.deliveryTime.toString() + ' min', style: GoogleFonts.cabin( fontSize: 17, fontWeight: FontWeight.w600), ), ], ), const SizedBox(height: 12.0), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( 'Total Cost:', style: GoogleFonts.cabin( fontSize: 17, fontWeight: FontWeight.w600), ), Text( '\$${cartProvider.totalPrice.toStringAsFixed(2)}', style: GoogleFonts.cabin( fontSize: 17, color: Colors.green.shade700, fontWeight: FontWeight.w600), ), ], ), const SizedBox(height: 20.0), Container( height: 50, padding: const EdgeInsets.only(top: 10, bottom: 10), child: ElevatedButton( onPressed: () { if (!cartProvider.isEmpty) { Navigator.push( context, MaterialPageRoute( builder: (context) => ContactScreen( amount: (cartProvider.totalPrice + 1) .toInt() .toString()))); } else { snackBar.showSnackBar(context, 'Cart is empty'); } }, child: Text( 'Payment', style: GoogleFonts.cabin( fontSize: 17, fontWeight: FontWeight.w600), ), style: ElevatedButton.styleFrom( elevation: 12, padding: const EdgeInsets.symmetric(horizontal: 70), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), ), ) ], ); })), ), ], ), ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/screens/contact_screen.dart
import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/screens/payment_screen.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import '../Provider/contact_screen_provider.dart'; import '../Utils/Reusable Components/contact_page.dart'; class ContactScreen extends StatelessWidget { final String amount; const ContactScreen({required this.amount, Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, body: SafeArea( child: WillPopScope( onWillPop: () async { return false; }, child: Column( children: [ AppBar( backgroundColor: Colors.transparent, elevation: 0, leading: InkWell( onTap: () { Navigator.pop(context); }, child: const Icon( Icons.arrow_back_ios, color: Colors.black, ), ), title: const Text( 'Back', style: TextStyle(color: Colors.black), ), ), Padding( padding: const EdgeInsets.only(top: 15, left: 25, bottom: 8), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Contact', style: GoogleFonts.cabin(fontSize: 26), ) ], ), ), const SizedBox( height: 20, ), Expanded(child: Consumer<ContactProvider>(builder: (context, provider, _) { return Column( children: [ Column( children: [ ContactPage( title: 'Name', hint: 'Enter Your Name', type: TextInputType.text, controller: provider.nameController, onChanged: (String value) => provider.validateForm(), ), ContactPage( title: 'Email', hint: 'Enter Your Email Address', type: TextInputType.emailAddress, controller: provider.emailController, onChanged: (String value) => provider.validateForm(), ), ContactPage( title: 'Contact', hint: 'Enter Your Phone no', type: TextInputType.phone, controller: provider.phoneController, onChanged: (String value) => provider.validateForm(), ), ContactPage( title: 'Address', hint: 'Enter Your Current Address', type: TextInputType.text, controller: provider.addressController, onChanged: (String value) => provider.validateForm(), ), Padding( padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 25, ), child: Text( 'Make sure to write the current address and active phone number ' 'as it will be used to deliver your item.', style: GoogleFonts.cabin( fontSize: 12, color: Colors.grey, ), ), ), ], ), Container( alignment: Alignment.bottomRight, height: 60, padding: const EdgeInsets.only(top: 22, right: 20), child: ElevatedButton( onPressed: provider.isFormValid ? () { provider.saveUserInformation(); Navigator.push( context, MaterialPageRoute( builder: (context) => PaymentScreen( amount: amount, ), ), ); } : null, child: const Text( 'Done', style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white, ), ), style: ElevatedButton.styleFrom( backgroundColor: Colors.black, elevation: 10, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), ), ), ), ), ], ); })), ], ), ), ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import '../Provider/cart_screen_provider.dart'; import '/widgets/popular_items.dart'; import '/widgets/nearby_restaurants.dart'; import '/screens/cart_screen.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { TextEditingController searchController = TextEditingController(); @override void initState() { loadData(); super.initState(); } loadData() async { final cartProvider = Provider.of<CartProvider>(context, listen: false); await cartProvider.loadHomePage(); } @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, body: Column( children: [ Column( children: [ Container( height: 175, width: double.infinity, decoration: const BoxDecoration( color: Colors.black, borderRadius: BorderRadius.only( bottomRight: Radius.circular(30), bottomLeft: Radius.circular(30), )), child: Consumer<CartProvider>( builder: (context, cartProvider, _) { return Column( children: [ Padding( padding: const EdgeInsets.only( top: 55, bottom: 20, left: 25, right: 28), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('FoodieMania', style: GoogleFonts.lobster( fontSize: 25, color: Colors.white)), GestureDetector( onTap: () { loadData(); Navigator.push( context, MaterialPageRoute( builder: (context) => const CartScreen())); }, child: Container( height: 30, width: 56, decoration: BoxDecoration( color: const Color(0xFF86DE29), borderRadius: BorderRadius.circular(8)), child: cartProvider.len != 0 ? Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const Icon( Icons.shopping_cart_outlined, size: 22, ), CircleAvatar( radius: 9, backgroundColor: Colors.black, child: Text( cartProvider.len.toString(), style: const TextStyle( fontSize: 11), ), ) ], ) : const Icon( Icons.shopping_cart_outlined, size: 25, ), ), ) ], ), ), Padding( padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 25, ), child: SizedBox( height: 38, child: TextFormField( controller: searchController, style: const TextStyle( color: Colors.white, fontSize: 14), decoration: InputDecoration( contentPadding: const EdgeInsets.symmetric( vertical: 5.0, horizontal: 15), fillColor: const Color(0xFF3B3A3A), filled: true, border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: const BorderSide(width: 0.8), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( width: 0.8, color: Theme.of(context).primaryColor, ), ), suffixIcon: const Icon( Icons.search, color: Colors.grey, size: 22, ), hintText: 'Search Food or Restaurants', hintStyle: GoogleFonts.cabin( fontSize: 14.5, color: Colors.white.withOpacity(.5), ), ), ), ), ), ], ); })), Container( height: 8, ), ], ), Expanded( child: ListView( shrinkWrap: true, physics: const BouncingScrollPhysics(), children: const [ PopularItems(), NearbyRestaurants(), ], ), ), ], ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/screens/introduction_screen.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import '../ViewModel/splash_controller.dart'; class IntroductionScreen extends StatefulWidget { const IntroductionScreen({Key? key}) : super(key: key); @override _IntroductionScreenState createState() => _IntroductionScreenState(); } class _IntroductionScreenState extends State<IntroductionScreen> { SplashScreenController splashScreenController = SplashScreenController(); @override void initState() { super.initState(); splashScreenController.SplashTime(context); } @override Widget build(BuildContext context) { return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Center( child: Container( height: 220, width: 220, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.black, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: const [ SizedBox( height: 80, width: 80, child: Image( image: AssetImage('assets/images/burger_icon.png'))), SizedBox( width: 5, ), SizedBox( height: 80, width: 80, child: Image( image: AssetImage('assets/images/pizza_icon.png'))), ], ), const SizedBox( height: 20, ), Text( 'FoodieMania', style: GoogleFonts.lobster(fontSize: 24, color: Colors.white), ), ], ), ), ) ], )); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/screens/restaurant_screen.dart
import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/database/db_helper.dart'; import 'package:food_delivery_app_ui/model/food.dart'; import 'package:food_delivery_app_ui/model/order.dart'; import 'package:food_delivery_app_ui/model/restaurant.dart'; import 'package:food_delivery_app_ui/widgets/rating_stars.dart'; import 'package:provider/provider.dart'; import '../Provider/restaurant_screen_provider.dart'; class RestaurantScreen extends StatefulWidget { final Restaurant? restaurant; const RestaurantScreen({this.restaurant, Key? key}) : super(key: key); @override State<RestaurantScreen> createState() => _RestaurantScreenState(); } class _RestaurantScreenState extends State<RestaurantScreen> { DatabaseHelper? databaseHelper; @override void initState() { super.initState(); databaseHelper = DatabaseHelper(); loadData(); } loadData() async { final restaurantProvider = Provider.of<RestaurantProvider>(context, listen: false); await restaurantProvider.loadData(); } Widget _buildMenuItem(BuildContext context, Food menuItem, Order order) { return Consumer<RestaurantProvider>( builder: (context, restaurantProvider, _) { return Stack( alignment: Alignment.center, children: <Widget>[ Container( height: 170.0, width: 170.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25.0), image: DecorationImage( image: AssetImage(menuItem.imageUrl!), opacity: 0.88, fit: BoxFit.cover, ), ), ), Container( height: 170.0, width: 170.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25.0), gradient: LinearGradient( begin: Alignment.topRight, end: Alignment.bottomLeft, tileMode: TileMode.mirror, stops: const <double>[0.1, 0.5, 0.7, 0.9], colors: <Color>[ Colors.black.withOpacity(0.3), Colors.black87.withOpacity(0.3), Colors.black54.withOpacity(0.3), Colors.black38.withOpacity(0.3), ], ), ), ), Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( menuItem.name!, style: const TextStyle( fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.white, letterSpacing: 1.2, ), ), Text( '\$${menuItem.price}', style: const TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, color: Colors.white, letterSpacing: 1.2, ), ), ], ), Positioned( bottom: 15.0, right: 15.0, child: Container( height: 36.0, width: 36.0, decoration: BoxDecoration( color: Colors.grey.withOpacity(.35), border: Border.all( color: Colors.white, width: 2.0, ), borderRadius: BorderRadius.circular(40)), child: IconButton( onPressed: () { restaurantProvider.addToCart(menuItem, widget.restaurant!); }, icon: const Icon( Icons.add, color: Colors.white, size: 16.4, ), ), ), ), ], ); }); } @override Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; return Scaffold( body: Column( children: [ Stack( children: <Widget>[ Hero( tag: widget.restaurant!.imageUrl!, child: Opacity( opacity: 0.95, child: Image.asset( widget.restaurant!.imageUrl!, height: 200.0, width: size.width, fit: BoxFit.cover, ), ), ), Padding( padding: const EdgeInsets.symmetric( horizontal: 20.0, vertical: 40.0, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( onPressed: () { Navigator.of(context).pop(); }, icon: const Icon( Icons.arrow_back_ios, size: 30.0, color: Colors.white, ), ), Consumer<RestaurantProvider>( builder: (context, restaurantProvider, _) { return IconButton( onPressed: () { restaurantProvider.toggleFavorite(); }, icon: restaurantProvider.isFav ? const Icon( Icons.favorite, size: 30.0, color: Color(0xFF86DE29), ) : const Icon( Icons.favorite_border_sharp, size: 30.0, color: Color(0xFF86DE29), ), ); }) ], ), ), ], ), Padding( padding: const EdgeInsets.all(20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( widget.restaurant!.name!, style: const TextStyle( fontSize: 22.0, fontWeight: FontWeight.w600, ), ), ], ), const SizedBox(height: 4.0), RatingStars(widget.restaurant!.rating!), const SizedBox(height: 6.0), Text( widget.restaurant!.address!, style: const TextStyle( fontSize: 18.0, ), ), ], ), ), const SizedBox( height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ ElevatedButton( onPressed: () {}, child: const Text('Reviews'), style: ButtonStyle( backgroundColor: MaterialStateColor.resolveWith( (states) => Theme.of(context).primaryColor, ), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), ), padding: MaterialStateProperty.all( const EdgeInsets.symmetric(horizontal: 30.0), ), ), ), ElevatedButton( onPressed: () {}, child: const Text('Contact'), style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (states) => const Color(0xFF86DE29)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), ), padding: MaterialStateProperty.all( const EdgeInsets.symmetric(horizontal: 30.0), ), ), ), ], ), const SizedBox(height: 25), const Center( child: Text( 'Menu', style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.w600, letterSpacing: 1.2, ), ), ), const SizedBox(height: 10.0), Expanded( child: GridView.builder( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, mainAxisSpacing: 12, crossAxisSpacing: 11), itemCount: widget.restaurant!.menu!.length, itemBuilder: (context, index) { Food food = widget.restaurant!.menu![index]; Order order = Order(); return _buildMenuItem(context, food, order); }, ), ), ], ), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App/lib
mirrored_repositories/FoodieMania-Food-Delivery-App/lib/screens/payment_screen.dart
import 'package:flutter/material.dart'; import 'package:food_delivery_app_ui/Utils/alert_dialog.dart'; import 'package:food_delivery_app_ui/ViewModel/stripe_payment.dart'; import 'package:food_delivery_app_ui/database/db_model.dart'; import 'package:food_delivery_app_ui/screens/cart_screen.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; import '../Provider/payment_screen_provider.dart'; import '../Utils/Reusable Components/animated_toggle_button.dart'; import '../database/db_helper.dart'; import 'package:rflutter_alert/rflutter_alert.dart'; bool turn = true; class PaymentScreen extends StatefulWidget { final String amount; const PaymentScreen({required this.amount, Key? key}) : super(key: key); @override _PaymentScreenState createState() => _PaymentScreenState(); } class _PaymentScreenState extends State<PaymentScreen> { Map<String, dynamic>? paymentIntentData; DatabaseHelper? databaseHelper; late List<Carts> carts; void togglePaymentMethod(bool isOn) { setState(() { turn = isOn; }); } @override void initState() { super.initState(); databaseHelper = DatabaseHelper(); loadData(); } loadData() async { carts = await databaseHelper!.getCarts(); } @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, body: SafeArea( child: Consumer<PaymentProvider>(builder: (context, provider, _) { return Column( children: [ AppBar( backgroundColor: Colors.transparent, elevation: 0, leading: InkWell( onTap: () { Navigator.pop(context); provider.setPayConfirm(false); setState(() { turn = true; }); }, child: const Icon( Icons.arrow_back_ios, color: Colors.black, )), title: const Text( 'Back', style: TextStyle(color: Colors.black), ), ), Padding( padding: const EdgeInsets.only(top: 10, bottom: 20, left: 30), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Payment', style: GoogleFonts.cabin(fontSize: 26), ) ], ), ), Expanded( child: Column( children: [ Container( decoration: BoxDecoration( color: Colors.white70, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.blue.withOpacity(0.3), spreadRadius: 2, blurRadius: 3, offset: const Offset(0, 3), ), ], ), child: Column( children: [ Container( margin: const EdgeInsets.all(30), padding: const EdgeInsets.all(18), height: 160, width: 260, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.3), spreadRadius: 1.5, blurRadius: 3.2, offset: const Offset(0, 3), ), ], gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Colors.blue.shade400, Colors.blueAccent.shade200 ], ), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.only(top: 3), child: Text( 'Total Balance', style: GoogleFonts.cabin( fontSize: 17, color: Colors.white, fontWeight: FontWeight.w600), ), ), Text( '\$${widget.amount}', style: GoogleFonts.cabin( fontSize: 36, letterSpacing: 1.5, color: Colors.white, fontWeight: FontWeight.w600), ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const CartScreen()), ); setState(() { turn = true; }); }, child: Container( height: 28, width: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(40), color: Colors.white70.withOpacity(0.7), ), child: Center( child: Text( 'View Cart', style: GoogleFonts.cabin( fontSize: 14, color: Colors.blue, fontWeight: FontWeight.w600), ), ), ), ), ], ), ), const SizedBox( height: 20, ), AnimatedToggleButton( isOn: turn, onToggle: togglePaymentMethod, ), ], ), ), const SizedBox( height: 20, ), Column( children: [ turn ? Column( children: [ Padding( padding: const EdgeInsets.only( top: 25, left: 20, bottom: 25), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Card Payment', style: GoogleFonts.cabin(fontSize: 18), ) ], ), ), InkWell( onTap: () async { provider.setPayConfirm(false); await makePayment( context, widget.amount, "Payment Successful!", "Your payment has been successfully processed.", AlertType.success, provider.payConfirm, databaseHelper!, carts); }, child: Padding( padding: const EdgeInsets.all(10), child: Container( height: 38, width: 230, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.blue, ), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Icons.payment_rounded, color: Colors.white, ), const SizedBox( width: 10, ), Text( 'Make Payment', style: GoogleFonts.cabin( fontSize: 17, color: Colors.white, fontWeight: FontWeight.w600), ), ], ), ), ), )), ], ) : Column( children: [ Padding( padding: const EdgeInsets.only( top: 25, left: 20, bottom: 25), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Cash On Delivery', style: GoogleFonts.cabin(fontSize: 18), ) ], ), ), InkWell( onTap: () { provider.setPayConfirm(true); // setState(() { // payConfirm = true; // }); }, child: Container( height: 38, width: 250, decoration: BoxDecoration( color: const Color(0xFF86DE29), borderRadius: BorderRadius.circular(10)), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox( width: 20, ), provider.payConfirm ? const Icon( Icons.circle, color: Colors.white, size: 16, ) : const Icon( Icons.circle_outlined, color: Colors.white, size: 16, ), const SizedBox( width: 32, ), Text( 'Cash On Delivery', style: GoogleFonts.cabin( fontSize: 17, color: Colors.white, fontWeight: FontWeight.w600), ), ], ), ), ), provider.payConfirm ? Column( children: [ const SizedBox( height: 20, ), Container( height: 55, padding: const EdgeInsets.only( top: 10, bottom: 10), child: ElevatedButton( onPressed: () { CustomAlertDialog.onAlertWithStyle( context, "Order Confirmed!", "Your order has been confirmed successfully", AlertType.success, provider.payConfirm, databaseHelper!, carts); }, child: Text( 'Confirm Order', style: GoogleFonts.cabin( fontSize: 15, color: Colors.white, fontWeight: FontWeight.w600), ), style: ElevatedButton.styleFrom( elevation: 12, padding: const EdgeInsets.symmetric( horizontal: 40), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), ), ) ], ) : Container(), ], ) ], ), ], ), ), ], ); })), ); } }
0
mirrored_repositories/FoodieMania-Food-Delivery-App
mirrored_repositories/FoodieMania-Food-Delivery-App/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:food_delivery_app_ui/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/simulate
mirrored_repositories/simulate/lib/simulate_core.dart
// ignore_for_file: use_build_context_synchronously, empty_catches import 'dart:async'; // import "package:un"; import "package:universal_io/io.dart"; import "package:simulate/ui/ui.dart"; import 'package:device_frame/device_frame.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; // import 'package:flutter_acrylic/flutter_acrylic.dart'; import 'package:flutter/foundation.dart'; import 'package:file_picker/file_picker.dart'; import 'package:window_manager/window_manager.dart'; export 'package:device_frame/device_frame.dart'; export 'package:file_picker/file_picker.dart'; import 'package:flutter_hicons/flutter_hicons.dart'; /// simulate part class MyScrollBehavior extends MaterialScrollBehavior { @override Set<PointerDeviceKind> get dragDevices => { PointerDeviceKind.touch, PointerDeviceKind.mouse, PointerDeviceKind.trackpad, PointerDeviceKind.stylus, PointerDeviceKind.invertedStylus, }; } /// simulate part class Simulate extends StatefulWidget { static Future<void> ensureInitialized({ Size? size, bool? center, Size? minimumSize, Size? maximumSize, bool? alwaysOnTop, bool? fullScreen, Color? backgroundColor, bool? skipTaskbar, String? title, TitleBarStyle? titleBarStyle, bool? windowButtonVisibility, bool isShowFrame = kDebugMode, FutureOr<void> Function(WindowManager windowManager)? onWindowInit, }) async { WidgetsFlutterBinding.ensureInitialized(); bool isSetWindowManager = false; bool isSetWindowTransparent = false; if (isShowFrame) { if (Platform.isAndroid) { } else if (Platform.isIOS) { } else { isSetWindowManager = true; isSetWindowTransparent = true; } } else { if (Platform.isAndroid) { } else if (Platform.isIOS) { } else { isSetWindowManager = true; isSetWindowTransparent = true; } } if (kIsWeb) { isSetWindowManager = false; isSetWindowTransparent = false; } if (isSetWindowTransparent) { // await Window.initialize(); // await Window.setEffect( // effect: WindowEffect.transparent, // ); } if (isSetWindowManager) { await windowManager.ensureInitialized(); WindowOptions windowOptions = WindowOptions( size: size, alwaysOnTop: alwaysOnTop, fullScreen: fullScreen, center: center, backgroundColor: Colors.transparent, skipTaskbar: false, titleBarStyle: TitleBarStyle.hidden, windowButtonVisibility: false, ); await windowManager.waitUntilReadyToShow(windowOptions, () async { await windowManager.show(); await windowManager.focus(); if (onWindowInit != null) { await onWindowInit(windowManager); } }); } } final Widget home; final DeviceInfo? deviceDefault; final bool isShowFrame; final bool isShowTopFrame; final Widget Function( BuildContext context, Widget home, DeviceInfo deviceInfo)? customView; final GlobalKey? allBodyKey; final GlobalKey? frameBodyKey; final EdgeInsets? paddingFrame; const Simulate({ super.key, this.paddingFrame, this.allBodyKey, this.frameBodyKey, required this.home, this.customView, this.deviceDefault, this.isShowFrame = kDebugMode, this.isShowTopFrame = true, }); @override State<Simulate> createState() => _SimulateState(); } class _SimulateState extends State<Simulate> { late DeviceInfo device = widget.deviceDefault ?? Devices.ios.iPhone13ProMax; bool isEnable = true; @override void initState() { super.initState(); } GlobalKey allBodyKey = GlobalKey(debugLabel: "all_body_a"); GlobalKey frameBodyKey = GlobalKey(debugLabel: "frame_body_a"); @override Widget build(BuildContext context) { if (!widget.isShowFrame) { return widget.home; } return RepaintBoundary( key: widget.key, child: Scaffold( backgroundColor: Colors.transparent, body: Column( children: [ Visibility( visible: () { if (!widget.isShowTopFrame) { return false; } if (kIsWeb) { return false; } if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { return true; } return false; }(), child: StatusBarSimulate( globalKey: widget.allBodyKey ?? allBodyKey, newGlobalKey: widget.frameBodyKey ?? frameBodyKey, child: Row( children: [ PopupMenuButton( child: Padding( padding: const EdgeInsets.all(8.0), child: Text( device.name, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), overflow: TextOverflow.clip, ), ), itemBuilder: (BuildContext context) { return [ ...Devices.all .map((DeviceInfo deviceInfo) { return PopupMenuItem( child: Text( "${deviceInfo.name} ${device.identifier.platform.name}", ), onTap: () { setState(() { device = deviceInfo.copyWith.call(); }); }, ); }) .toList() .cast<PopupMenuItem>(), ]; }, ), const Spacer(), MaterialButton( minWidth: 0, onPressed: () { setState(() { isEnable = !isEnable; }); }, child: Icon( (isEnable) ? Icons.toggle_on : Icons.toggle_off, color: (isEnable) ? Colors.blue : Colors.white, ), ), ], ), ), ), Expanded( child: RepaintBoundary( key: widget.frameBodyKey ?? frameBodyKey, child: bodyDevice(), ), ), ], ), ), ); } Widget bodyDevice() { return Padding( padding: widget.paddingFrame ?? const EdgeInsets.all(10), child: Center( child: (isEnable) ? DeviceFrame( device: device, orientation: MediaQuery.of(context).orientation, screen: (widget.customView != null) ? widget.customView!.call(context, widget.home, device) : widget.home, ) : widget.home, ), ); } } class StatusBarSimulate extends StatelessWidget { final GlobalKey globalKey; final GlobalKey newGlobalKey; final Widget child; const StatusBarSimulate({ super.key, required this.globalKey, required this.newGlobalKey, required this.child, }); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(5), child: Container( width: MediaQuery.of(context).size.width, height: 45, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.black, boxShadow: const [ BoxShadow( color: Colors.black12, spreadRadius: 0, blurRadius: 5, ), ], ), clipBehavior: Clip.antiAlias, child: DragToMoveArea( child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: child, ), Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [ PopupMenuButton( onSelected: (data) { if (kDebugMode) { print(data); } }, child: const Center( child: Padding( padding: EdgeInsets.all(8.0), child: Icon( Hicons.camera_1_light_outline, color: Colors.white, ), ), ), itemBuilder: (BuildContext context) { return [ PopupMenuItem( onTap: () async { try { String? selectedDirectory = await FilePicker.platform.getDirectoryPath(); if (selectedDirectory != null) { var getPathFile = "$selectedDirectory/${DateTime.now()}.png"; RenderRepaintBoundary boundary = globalKey.currentContext!.findRenderObject() as RenderRepaintBoundary; Uint8List? pngBytes = await screenShotWidget(boundary: boundary); if (pngBytes != null) { var file = File(getPathFile); await file.writeAsBytes(pngBytes); } } } catch (e) {} }, child: const Text("Screenshot"), ), PopupMenuItem( onTap: () async { try { String? selectedDirectory = await FilePicker.platform.getDirectoryPath(); if (selectedDirectory != null) { var getPathFile = "$selectedDirectory/${DateTime.now()}.png"; RenderRepaintBoundary boundary = newGlobalKey .currentContext! .findRenderObject() as RenderRepaintBoundary; Uint8List? pngBytes = await screenShotWidget(boundary: boundary); if (pngBytes != null) { var file = File(getPathFile); await file.writeAsBytes(pngBytes); } } } catch (e) {} }, child: const Text("Screenshot without bar"), ), ]; }, ), WindowCaptionButton.minimize( brightness: Brightness.dark, onPressed: () async { try { bool isMinimized = await windowManager.isMinimized(); if (isMinimized) { await windowManager.restore(); } else { await windowManager.minimize(); } } catch (e) {} }, ), FutureBuilder<bool>( future: () async { try { return windowManager.isMaximized(); } catch (e) { return false; } }(), builder: (BuildContext context, AsyncSnapshot<bool> snapshot) { if (snapshot.data == true) { return WindowCaptionButton.unmaximize( brightness: Brightness.dark, onPressed: () async { try { await windowManager.unmaximize(); } catch (e) {} }, ); } return WindowCaptionButton.maximize( brightness: Brightness.dark, onPressed: () async { try { await windowManager.maximize(); } catch (e) {} }, ); }, ), WindowCaptionButton.close( brightness: Brightness.dark, onPressed: () async { try { await windowManager.close(); } catch (e) {} }, ), ], ), ], ), ), ), ); } }
0
mirrored_repositories/simulate
mirrored_repositories/simulate/lib/simulate.dart
export "simulate_core.dart";
0
mirrored_repositories/simulate/lib
mirrored_repositories/simulate/lib/ui/ui_app.dart
import 'dart:typed_data'; import 'dart:ui' as ui; import 'package:flutter/rendering.dart'; Future<Uint8List?> screenShotWidget({ required RenderRepaintBoundary boundary, }) async { ui.Image image = await boundary.toImage(); ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); Uint8List pngBytes = byteData!.buffer.asUint8List(); return pngBytes; }
0
mirrored_repositories/simulate/lib
mirrored_repositories/simulate/lib/ui/ui_web.dart
import 'dart:typed_data'; import 'package:flutter/rendering.dart'; Future<Uint8List?> screenShotWidget({ required RenderRepaintBoundary boundary, }) async { return null; }
0
mirrored_repositories/simulate/lib
mirrored_repositories/simulate/lib/ui/ui.dart
export "ui_app.dart" if (dart.library.html) "ui_web.dart";
0
mirrored_repositories/simulate/example
mirrored_repositories/simulate/example/lib/main copy.dart
// // ignore_for_file: dead_code, non_constant_identifier_names // import 'dart:io'; // import 'package:path_provider/path_provider.dart'; // import 'package:simulate/simulate.dart'; // import 'package:flutter/material.dart'; // import 'package:iconsax/iconsax.dart'; // import 'package:http/http.dart' as http; // import 'package:hexaminate/hexaminate.dart'; // import 'package:easy_isolate/easy_isolate.dart'; // void main() async { // WidgetsFlutterBinding.ensureInitialized(); // EventEmitter emitter = EventEmitter(); // Worker worker = Worker(); // int _received = 0; // int _total = 0; // File? _image; // final List<int> _bytes = []; // late bool is_done = false; // var getPath = await getApplicationDocumentsDirectory(); // var paths = getPath.path; // String path = paths; // worker.init((data, isolateSendPort) async { // if (data is List<int>) { // _bytes.addAll(data); // _received += data.length; // emitter.emit("update", null, {"@type": "update", "bytes": _bytes, "received": _received, "total": _total}); // } else if (data is File) { // _image = data; // } else if (data is String) { // isolateSendPort.send("oke"); // } else if (data is int) { // _total = data; // emitter.emit("update", null, {"@type": "update", "total": _total, "bytes": _bytes, "received": _received}); // } else if (data is bool) { // var file = File('$path/image.png'); // await file.writeAsBytes(_bytes); // emitter.emit("update", null, {"@type": "done", "path": "$path/image.png"}); // _total = 0; // _received = 0; // _bytes.clear(); // } // }, (data, mainSendPort, onSendError) async { // late http.StreamedResponse _response; // _response = await http.Client().send(http.Request('GET', Uri.parse('https://upload.wikimedia.org/wikipedia/commons/f/ff/Pizigani_1367_Chart_10MB.jpg'))); // int total = _response.contentLength ?? 0; // mainSendPort.send(total); // _response.stream.listen((value) async { // await Future.delayed(const Duration(microseconds: 1)); // mainSendPort.send(value); // }).onDone(() async { // mainSendPort.send(true); // }); // }); // emitter.on("update", null, (Event ev, context) { // if (ev.eventData is Map) { // var update = ev.eventData as Map; // if (update["@type"] is String) { // var type = update["@type"]; // if (type == "start") { // worker.sendMessage("message"); // } // } // } // }); // // autoSimulateApp( // // debugShowCheckedModeBanner: false, // // home: MyPage( // // emitter: emitter, // // ), // // ); // runSimulate(home: MyPage(emitter: emitter), debugShowCheckedModeBanner: false); // } // class MyPage extends StatefulWidget { // const MyPage({Key? key, required this.emitter}) : super(key: key); // final EventEmitter emitter; // @override // State<MyPage> createState() => _MyPageState(); // } // class _MyPageState extends State<MyPage> { // var count = 0; // @override // Widget build(BuildContext context) { // return ScaffoldSimulate( // extendBody: true, // extendBodyBehindAppBar: true, // body: SingleChildScrollView( // physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), // child: ConstrainedBox( // constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width, minHeight: MediaQuery.of(context).size.height), // child: Column( // crossAxisAlignment: CrossAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center, // children: [ // Center( // child: Text( // "hello $count", // style: const TextStyle(color: Colors.black, fontSize: 50), // )), // ], // ), // ), // ), // floatingActionButton: Row( // mainAxisAlignment: MainAxisAlignment.end, // children: [ // FloatingActionButton( // heroTag: "azka", // onPressed: () { // Navigator.push(context, MaterialPageRoute(builder: (context) { // return SignPage( // emitter: widget.emitter, // ); // })); // }, // child: const Icon(Iconsax.backward), // ), // const SizedBox( // width: 20, // ), // FloatingActionButton( // heroTag: "baru", // onPressed: () { // setState(() { // count++; // }); // }, // child: const Icon(Iconsax.add_circle), // ), // ], // ), // ); // } // } // class SignPage extends StatefulWidget { // const SignPage({Key? key, required this.emitter}) : super(key: key); // final EventEmitter emitter; // @override // State<SignPage> createState() => _SignPageState(); // } // class _SignPageState extends State<SignPage> { // int _received = 0; // late EventEmitter emitter; // int _total = 0; // File? _image; // late List<int> _bytes = []; // GlobalKey globalKey = GlobalKey(); // late bool is_done = false; // @override // void initState() { // super.initState(); // setState(() { // emitter = widget.emitter; // }); // emitter.on("update", null, (Event ev, context) { // if (ev.eventData is Map) { // var update = ev.eventData as Map; // if (update["@type"] is String) { // var type = update["@type"]; // if (type == "update") { // setState(() { // _received = update["received"]; // _total = update["total"]; // _bytes = update["bytes"]; // }); // } // if (type == "done") { // _image = File(update["path"]); // } // } // } // }); // } // @override // Widget build(BuildContext context) { // print("Sas"); // return ScaffoldSimulate( // extendBody: true, // extendBodyBehindAppBar: true, // body: Padding( // padding: const EdgeInsets.all(20.0), // child: Center( // child: SizedBox.fromSize( // size: const Size(400, 300), // child: _image == null ? const Placeholder() : Image.file(_image!, fit: BoxFit.fill), // ), // ), // ), // floatingActionButton: Row( // mainAxisAlignment: MainAxisAlignment.end, // children: [ // FloatingActionButton( // heroTag: "azka", // onPressed: () { // Navigator.push(context, MaterialPageRoute(builder: (context) { // return MyPage( // emitter: widget.emitter, // ); // })); // }, // child: const Icon(Iconsax.backward), // ), // const SizedBox( // width: 20, // ), // FloatingActionButton.extended( // label: Text('${_received ~/ 1024}/${_total ~/ 1024} KB'), // icon: const Icon(Iconsax.document_download), // onPressed: () { // emitter.emit("update", null, {"@type": "start"}); // }, // ) // ], // ), // ); // } // }
0
mirrored_repositories/simulate/example
mirrored_repositories/simulate/example/lib/main.dart
import 'package:flutter/material.dart'; import 'package:simulate/simulate.dart'; void main() async { await Simulate.ensureInitialized(); runApp( const App(), ); } class App extends StatelessWidget { const App({ super.key, }); @override Widget build(BuildContext context) { return const MaterialApp( debugShowCheckedModeBanner: false, home: Simulate( isShowFrame: true, // set false for disabled isShowTopFrame: true, home: MaterialApp( debugShowCheckedModeBanner: false, debugShowMaterialGrid: false, showPerformanceOverlay: false, home: Home(), ), ), ); } } class Home extends StatefulWidget { const Home({ super.key, }); @override State<Home> createState() => _HomeState(); } class _HomeState extends State<Home> { @override Widget build(BuildContext context) { return Scaffold( body: const Center( child: Text("Alow"), ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) { return const LoginScreen(); }), ); }, child: const Icon( Icons.login, ), ), ); } } class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @override State<LoginScreen> createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: FloatingActionButton( onPressed: () { Navigator.pop(context); }, child: const Icon( Icons.arrow_back, ), ), ), body: const Center( child: Text("Alow"), ), ); } }
0
mirrored_repositories/simulate/example/.dart_tool
mirrored_repositories/simulate/example/.dart_tool/dartpad/web_plugin_registrant.dart
// Flutter web plugin registrant file. // // Generated file. Do not edit. // // @dart = 2.13 // ignore_for_file: type=lint import 'package:file_picker/_internal/file_picker_web.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; void registerPlugins([final Registrar? pluginRegistrar]) { final Registrar registrar = pluginRegistrar ?? webPluginRegistrar; FilePickerWeb.registerWith(registrar); registrar.registerMessageHandler(); }
0
mirrored_repositories/simulate/example
mirrored_repositories/simulate/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/dt_money
mirrored_repositories/dt_money/lib/main.dart
import 'package:dt_money/src/app.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); }
0
mirrored_repositories/dt_money/lib
mirrored_repositories/dt_money/lib/src/app.dart
import 'package:dt_money/src/providers/dashboard_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'features/home/home_page.dart'; import 'providers/transactions_provider.dart'; import 'services/local_storage_service.dart'; import 'services/shared_preferences_service/shared_preferences_service.dart'; import 'shared/colors.dart'; class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MultiProvider( providers: [ Provider<LocalStorageService>( create: (_) => SharedPreferencesImpl(), ), Provider( create: (context) => TransactionsService(context.read()), ), ChangeNotifierProvider( create: (context) => TransactionsStore(context.read()), ), Provider( create: (context) => DashboardService(context.read()), ), ChangeNotifierProvider( create: (context) => DashboardStore(context.read()), ), ], child: MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), darkTheme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme), home: const HomePage(), ), ); // return TransactionsProvider( // notifier: TransactionsStore(TransactionsService(SharedPreferencesImpl())), // child: MaterialApp( // debugShowCheckedModeBanner: false, // theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), // darkTheme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme), // home: const HomePage(), // ), // ); } }
0
mirrored_repositories/dt_money/lib/src
mirrored_repositories/dt_money/lib/src/shared/colors.dart
import 'package:flutter/material.dart'; const lightColorScheme = ColorScheme( brightness: Brightness.light, primary: Color(0xFF006C4B), onPrimary: Color(0xFFFFFFFF), primaryContainer: Color(0xFF89F8C6), onPrimaryContainer: Color(0xFF002114), secondary: Color(0xFF4D6357), onSecondary: Color(0xFFFFFFFF), secondaryContainer: Color(0xFFCFE9D9), onSecondaryContainer: Color(0xFF0A1F16), tertiary: Color(0xFF3D6373), onTertiary: Color(0xFFFFFFFF), tertiaryContainer: Color(0xFFC1E9FB), onTertiaryContainer: Color(0xFF001F29), error: Color(0xFFBA1A1A), errorContainer: Color(0xFFFFDAD6), onError: Color(0xFFFFFFFF), onErrorContainer: Color(0xFF410002), background: Color(0xFFFBFDF9), onBackground: Color(0xFF191C1A), surface: Color(0xFFFBFDF9), onSurface: Color(0xFF191C1A), surfaceVariant: Color(0xFFDBE5DD), onSurfaceVariant: Color(0xFF404943), outline: Color(0xFF707973), onInverseSurface: Color(0xFFEFF1ED), inverseSurface: Color(0xFF2E312F), inversePrimary: Color(0xFF6DDBAB), shadow: Color(0xFF000000), surfaceTint: Color(0xFF006C4B), ); const darkColorScheme = ColorScheme( brightness: Brightness.dark, primary: Color(0xFF6DDBAB), onPrimary: Color(0xFF003825), primaryContainer: Color(0xFF005138), onPrimaryContainer: Color(0xFF89F8C6), secondary: Color(0xFFB3CCBD), onSecondary: Color(0xFF1F352A), secondaryContainer: Color(0xFF354B40), onSecondaryContainer: Color(0xFFCFE9D9), tertiary: Color(0xFFA5CCDE), onTertiary: Color(0xFF073543), tertiaryContainer: Color(0xFF244C5B), onTertiaryContainer: Color(0xFFC1E9FB), error: Color(0xFFFFB4AB), errorContainer: Color(0xFF93000A), onError: Color(0xFF690005), onErrorContainer: Color(0xFFFFDAD6), background: Color(0xFF191C1A), onBackground: Color(0xFFE1E3DF), surface: Color(0xFF191C1A), onSurface: Color(0xFFE1E3DF), surfaceVariant: Color(0xFF404943), onSurfaceVariant: Color(0xFFBFC9C1), outline: Color(0xFF8A938C), onInverseSurface: Color(0xFF191C1A), inverseSurface: Color(0xFFE1E3DF), inversePrimary: Color(0xFF006C4B), shadow: Color(0xFF000000), surfaceTint: Color(0xFF6DDBAB), ); class AppColors { static const greenDark = Color(0xFF015F43); static const green = Color(0xFF00875F); static const greenLight = Color(0xFF00B37E); static const redDark = Color(0xFFAA2834); static const red = Color(0xFFF75A68); static const gray1 = Color(0xFF121214); static const gray2 = Color(0xFF202024); static const gray3 = Color(0xFF29292E); static const gray4 = Color(0xFF323238); static const gray5 = Color(0xFF7C7C8A); static const gray6 = Color(0xFFC4C4CC); static const gray7 = Color(0xFFE1E1E6); static const white = Color(0xFFFFFFFF); }
0
mirrored_repositories/dt_money/lib/src
mirrored_repositories/dt_money/lib/src/shared/text_field_validators.dart
class TextFieldValidators { static const requiredFiledError = 'Esse campo é obrigatório.'; static String? validateNotEmpty(String? text) { if (text != null) { if (text.isEmpty) return requiredFiledError; } return null; } static String? validateNotZero(num value) { if (value == 0) { return 'O deve ser maior que 0.'; } return null; } static String? noValidation(String? text) { return null; } }
0
mirrored_repositories/dt_money/lib/src
mirrored_repositories/dt_money/lib/src/shared/extensions.dart
import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; extension BreakpointUtils on BoxConstraints { bool get isTablet => maxWidth > 720; bool get isDesktop => maxWidth > 1120; bool get isMobile => !isTablet && !isDesktop; } extension ToReal on double { String toCurrency() { if(this == 0) return '0,00'; return NumberFormat('#,###.00', 'pt_BR').format(this); } }
0
mirrored_repositories/dt_money/lib/src/shared
mirrored_repositories/dt_money/lib/src/shared/widgets/column_builder.dart
import 'package:flutter/material.dart'; class ColumnBuilder extends StatelessWidget { const ColumnBuilder({ Key? key, required this.itemBuilder, required this.itemCount, this.mainAxisAlignment = MainAxisAlignment.start, this.mainAxisSize = MainAxisSize.max, this.crossAxisAlignment = CrossAxisAlignment.center, this.textDirection, this.verticalDirection = VerticalDirection.down, }) : super(key: key); final IndexedWidgetBuilder itemBuilder; final MainAxisAlignment mainAxisAlignment; final MainAxisSize mainAxisSize; final CrossAxisAlignment crossAxisAlignment; final TextDirection? textDirection; final VerticalDirection verticalDirection; final int itemCount; @override Widget build(BuildContext context) { return Column( children: List.generate( itemCount, (index) { return itemBuilder(context, index); }, ).reversed.toList(), ); } } // final int itemIndex = index ~/ 2; // final Widget widget; // if (index.isEven) { // widget = itemBuilder(context, itemIndex); // } else { // widget = separatorBuilder(context, itemIndex); // assert(() { // if (widget == null) { // throw FlutterError('separatorBuilder cannot return null.'); // } // return true; // }()); // }
0
mirrored_repositories/dt_money/lib/src/shared
mirrored_repositories/dt_money/lib/src/shared/widgets/primary_button.dart
import 'package:flutter/material.dart'; import '../colors.dart'; class PrimaryButton extends StatelessWidget { const PrimaryButton({ super.key, required this.label, required this.onPressed, this.buttonSize = ButtonSize.small, this.enabled = true, }); final String label; final VoidCallback? onPressed; final ButtonSize buttonSize; final bool enabled; @override Widget build(BuildContext context) { return TextButton( onPressed: enabled ? onPressed : null, style: TextButton.styleFrom( backgroundColor: enabled ? AppColors.green : AppColors.gray5, padding: buttonSize.padding, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(6.0)), ), ), child: Text( label, style: TextStyle( fontSize: buttonSize.fontSize, color: AppColors.white, height: 1.6, fontWeight: FontWeight.bold, ), ), ); } } enum ButtonSize { small(EdgeInsets.symmetric(vertical: 8, horizontal: 16), 14), medium(EdgeInsets.symmetric(vertical: 12, horizontal: 20), 16), large(EdgeInsets.symmetric(vertical: 16, horizontal: 32), 16); const ButtonSize(this.padding, this.fontSize); final EdgeInsetsGeometry padding; final double fontSize; }
0
mirrored_repositories/dt_money/lib/src/shared
mirrored_repositories/dt_money/lib/src/shared/widgets/default_textfield.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../colors.dart'; class DefaultTextField extends StatelessWidget { const DefaultTextField({ super.key, required this.hint, this.validator, this.onChanged, this.keyboardType, this.inputFormatters, this.initialValue, this.autovalidateMode, }); final String hint; final String? Function(String?)? validator; final void Function(String)? onChanged; final TextInputType? keyboardType; final List<TextInputFormatter>? inputFormatters; final String? initialValue; final AutovalidateMode? autovalidateMode; @override Widget build(BuildContext context) { return TextFormField( style: const TextStyle(color: AppColors.white), onChanged: onChanged, keyboardType: keyboardType, inputFormatters: inputFormatters, initialValue: initialValue, autovalidateMode: autovalidateMode, decoration: InputDecoration( fillColor: AppColors.gray1, filled: true, hintText: hint, hintStyle: const TextStyle( fontSize: 16, color: AppColors.gray5, height: 1.4, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(6), borderSide: const BorderSide(color: AppColors.greenLight), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(6), borderSide: const BorderSide(color: AppColors.red), ), contentPadding: const EdgeInsets.all(16), isDense: true, border: OutlineInputBorder( borderRadius: BorderRadius.circular(6), borderSide: BorderSide.none, ), ), validator: validator, ); } }
0
mirrored_repositories/dt_money/lib/src/features
mirrored_repositories/dt_money/lib/src/features/new_transaction/new_transaction_sheet.dart
import 'package:currency_text_input_formatter/currency_text_input_formatter.dart'; import 'package:dt_money/src/providers/dashboard_provider.dart'; import 'package:flutter/material.dart'; import '../../providers/transactions_provider.dart'; import '../../shared/text_field_validators.dart'; import '../../shared/widgets/default_textfield.dart'; import '../../shared/widgets/primary_button.dart'; import '../home/models/transaction.dart'; import 'new_transaction_store.dart'; import 'widgets/new_transaction_header.dart'; import 'widgets/toggleable_buttons_row.dart'; import 'package:provider/provider.dart'; class NewTransactionSheet extends StatefulWidget { const NewTransactionSheet({super.key}); @override State<NewTransactionSheet> createState() => _NewTransactionSheetState(); } class _NewTransactionSheetState extends State<NewTransactionSheet> { final formKey = GlobalKey<FormState>(); final store = NewTransactionStore(); final currencyFormatter = CurrencyTextInputFormatter( decimalDigits: 2, locale: 'pt_BR', symbol: 'R\$', ); var autovalidateMode = AutovalidateMode.onUserInteraction; void setAutoValidateMode() { setState(() => autovalidateMode = AutovalidateMode.always); } @override Widget build(BuildContext context) { return SafeArea( child: Form( key: formKey, child: Padding( padding: const EdgeInsets.all(24), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ const NewTransactionHeader(), const SizedBox(height: 24), DefaultTextField( hint: 'Descrição', onChanged: store.setDescription, validator: TextFieldValidators.validateNotEmpty, autovalidateMode: autovalidateMode, ), const SizedBox(height: 12), DefaultTextField( hint: 'Preço', initialValue: 'R\$ 0,00', keyboardType: TextInputType.number, inputFormatters: [currencyFormatter], onChanged: (text) { num value = currencyFormatter.getUnformattedValue(); store.setValue(value); }, validator: (_) { return TextFieldValidators.validateNotZero(store.value); }, autovalidateMode: autovalidateMode, ), const SizedBox(height: 12), DefaultTextField( hint: 'Categoria', onChanged: store.setCategory, validator: TextFieldValidators.validateNotEmpty, autovalidateMode: autovalidateMode, ), const SizedBox(height: 16), ToggleableButtonsRow( transactionTypeNotifier: store.typeNotifier, setIncome: store.typeNotifier.setIncome, setExpense: store.typeNotifier.setExpense, ), const SizedBox(height: 24), ValueListenableBuilder( valueListenable: store.typeNotifier, builder: (context, type, _) { return SizedBox( width: double.maxFinite, child: PrimaryButton( label: 'Cadastrar', enabled: store.typeNotifier.hasValidType, onPressed: () => validateForm(context), buttonSize: ButtonSize.medium, ), ); }, ), Padding( padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), ), ], ), ), ), ); } Future<void> validateForm(BuildContext context) async { final transactionStore = context.read<TransactionsStore>(); final dashboardStore = context.read<DashboardStore>(); if (formKey.currentState!.validate()) { final transaction = TransactionModel( description: store.description, value: store.value, category: store.category, type: TransactionType.values.byName(store.typeNotifier.value.name), entryDate: DateTime.now(), ); await transactionStore.addTransaction(transaction); await dashboardStore.updateDashboard(transaction); Navigator.pop(context); } } }
0
mirrored_repositories/dt_money/lib/src/features
mirrored_repositories/dt_money/lib/src/features/new_transaction/new_transaction_store.dart
import 'notifiers/transaction_type_notifier.dart'; class NewTransactionStore { final typeNotifier = TransactionTypeNotifier(); String description = ''; double value = 0; String category = ''; void setDescription(String text) => description = text; void setValue(num text) => value = text as double; void setCategory(String text) => category = text; }
0
mirrored_repositories/dt_money/lib/src/features
mirrored_repositories/dt_money/lib/src/features/new_transaction/new_transaction_dialog.dart
import 'package:currency_text_input_formatter/currency_text_input_formatter.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../providers/dashboard_provider.dart'; import '../../providers/transactions_provider.dart'; import '../../shared/colors.dart'; import '../../shared/text_field_validators.dart'; import '../../shared/widgets/default_textfield.dart'; import '../../shared/widgets/primary_button.dart'; import '../home/models/transaction.dart'; import 'new_transaction_store.dart'; import 'widgets/new_transaction_header.dart'; import 'widgets/toggleable_buttons_row.dart'; class NewTransactionDialog extends StatefulWidget { const NewTransactionDialog({super.key}); @override State<NewTransactionDialog> createState() => _NewTransactionDialogState(); } class _NewTransactionDialogState extends State<NewTransactionDialog> { final formKey = GlobalKey<FormState>(); final store = NewTransactionStore(); final currencyFormatter = CurrencyTextInputFormatter( decimalDigits: 2, locale: 'pt_BR', symbol: 'R\$', ); var autovalidateMode = AutovalidateMode.onUserInteraction; void setAutoValidateMode() { setState(() => autovalidateMode = AutovalidateMode.always); } @override Widget build(BuildContext context) { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)), backgroundColor: AppColors.gray2, child: Container( padding: const EdgeInsets.all(48), width: 528, child: Form( key: formKey, child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ const NewTransactionHeader(), const SizedBox(height: 24), DefaultTextField( hint: 'Descrição', onChanged: store.setDescription, validator: TextFieldValidators.validateNotEmpty, autovalidateMode: autovalidateMode, ), const SizedBox(height: 12), DefaultTextField( hint: 'Preço', initialValue: 'R\$ 0,00', keyboardType: TextInputType.number, inputFormatters: [currencyFormatter], onChanged: (text) { num value = currencyFormatter.getUnformattedValue(); store.setValue(value); }, validator: (_) { return TextFieldValidators.validateNotZero(store.value); }, autovalidateMode: autovalidateMode, ), const SizedBox(height: 12), DefaultTextField( hint: 'Categoria', onChanged: store.setCategory, validator: TextFieldValidators.validateNotEmpty, autovalidateMode: autovalidateMode, ), const SizedBox(height: 16), ToggleableButtonsRow( transactionTypeNotifier: store.typeNotifier, setIncome: store.typeNotifier.setIncome, setExpense: store.typeNotifier.setExpense, ), const SizedBox(height: 24), ValueListenableBuilder( valueListenable: store.typeNotifier, builder: (context, type, _) { return SizedBox( width: double.maxFinite, child: PrimaryButton( label: 'Cadastrar', enabled: store.typeNotifier.hasValidType, onPressed: () => validateForm(context), buttonSize: ButtonSize.large, ), ); }, ), ], ), ), ), ); } Future<void> validateForm(BuildContext context) async { final transactionStore = context.read<TransactionsStore>(); final dashboardStore = context.read<DashboardStore>(); if (formKey.currentState!.validate()) { final transaction = TransactionModel( description: store.description, value: store.value, category: store.category, type: TransactionType.values.byName(store.typeNotifier.value.name), entryDate: DateTime.now(), ); await transactionStore.addTransaction(transaction); await dashboardStore.updateDashboard(transaction); Navigator.pop(context); } } }
0
mirrored_repositories/dt_money/lib/src/features/new_transaction
mirrored_repositories/dt_money/lib/src/features/new_transaction/notifiers/transaction_type_notifier.dart
import 'package:flutter/material.dart'; class TransactionTypeNotifier extends ValueNotifier<ToggleableButtonsState> { TransactionTypeNotifier() : super(ToggleableButtonsState.unselected); void setIncome() => value = ToggleableButtonsState.income; void setExpense() => value = ToggleableButtonsState.expense; get hasValidType => value != ToggleableButtonsState.unselected; } enum ToggleableButtonsState { unselected([false, false], ''), income([true, false], 'income'), expense([false, true], 'expense'); const ToggleableButtonsState(this.state, this.value); final List<bool> state; final String value; }
0