repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutter_Pokedex/lib
mirrored_repositories/flutter_Pokedex/lib/utils/size.dart
import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; Size getTextSize(BuildContext context, String text, TextStyle style) { final textPainter = TextPainter( text: TextSpan( text: text, style: style, ), maxLines: 1, textScaleFactor: MediaQuery.of(context).textScaleFactor, textDirection: TextDirection.ltr, )..layout(); return textPainter.size; }
0
mirrored_repositories/flutter_Pokedex/lib
mirrored_repositories/flutter_Pokedex/lib/utils/string.dart
import 'package:intl/intl.dart'; String removeTrailingZero(double n) { final formatter = NumberFormat() ..minimumFractionDigits = 0 ..maximumFractionDigits = 2; return formatter.format(n); }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/progress.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; class ProgressBar extends StatelessWidget { const ProgressBar({ this.color = AppColors.red, this.backgroundColor = AppColors.lighterGrey, this.enableAnimation = true, required this.progress, }); final Color backgroundColor; final Color color; final double progress; final bool enableAnimation; @override Widget build(BuildContext context) { final child = Container( decoration: ShapeDecoration( shape: StadiumBorder(), color: color, ), ); return Container( clipBehavior: Clip.hardEdge, height: 3, alignment: Alignment.centerLeft, decoration: ShapeDecoration( shape: StadiumBorder(), color: AppColors.lighterGrey, ), child: enableAnimation ? AnimatedAlign( duration: Duration(milliseconds: 260), alignment: Alignment(1, 0), widthFactor: progress, child: child, ) : FractionallySizedBox( widthFactor: progress, child: child, ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/spacer.dart
import 'package:flutter/material.dart'; class HSpacer extends SizedBox { const HSpacer(double size) : super(width: size); } class VSpacer extends SizedBox { const VSpacer(double size) : super(height: size); }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/main_tab_view.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/colors.dart'; import '../../states/theme/theme_cubit.dart'; class MainTabData { final Widget child; final String label; const MainTabData({ required this.label, required this.child, }); } class MainTabView extends StatelessWidget { final List<MainTabData> tabs; final Animation<double>? paddingAnimation; const MainTabView({ Key? key, required this.tabs, this.paddingAnimation, }) : super(key: key); @override Widget build(BuildContext context) { var themeCubit = BlocProvider.of<ThemeCubit>(context, listen: true); var isDark = themeCubit.isDark; return DefaultTabController( length: tabs.length, initialIndex: 0, child: Container( width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Theme.of(context).backgroundColor, borderRadius: BorderRadius.vertical(top: Radius.circular(30)), ), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ _buildTopAnimatedPadding(), _buildTabBar(isDark), _buildTabContent(), ], ), ), ); } Widget _buildTopAnimatedPadding() { if (paddingAnimation == null) { return SizedBox(height: 6); } return AnimatedBuilder( animation: paddingAnimation!, builder: (context, _) => SizedBox( height: (1 - paddingAnimation!.value) * 16 + 6, ), ); } Widget _buildTabBar(bool isDark) { return TabBar( labelColor: isDark ? AppColors.whiteGrey : AppColors.black, unselectedLabelColor: isDark ? AppColors.whiteGrey : AppColors.grey, labelPadding: EdgeInsets.symmetric(vertical: 16), indicatorSize: TabBarIndicatorSize.label, indicatorWeight: 2, indicatorColor: AppColors.indigo, tabs: tabs.map((tab) => Text(tab.label)).toList(), ); } Widget _buildTabContent() { return Expanded( child: TabBarView( children: tabs.map((tab) => tab.child).toList(), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/animated_slide.dart
import 'package:flutter/material.dart'; class AnimatedSlide extends AnimatedWidget { const AnimatedSlide({ required this.child, required this.animation, }) : super(listenable: animation); final Animation<double> animation; final Widget child; @override Widget build(BuildContext context) { final slideWidth = MediaQuery.of(context).size.width * 0.3; return Transform.translate( offset: Offset(slideWidth * (1 - animation.value), 0), child: child, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/pokeball_background.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/ui/widgets/main_app_bar.dart'; import '../../states/theme/theme_cubit.dart'; class PokeballBackground extends StatelessWidget { static const double _pokeballWidthFraction = 0.664; final Widget child; final Widget? floatingActionButton; const PokeballBackground({ Key? key, required this.child, this.floatingActionButton, }) : super(key: key); @override Widget build(BuildContext context) { final safeAreaTop = MediaQuery.of(context).padding.top; final pokeballSize = MediaQuery.of(context).size.width * _pokeballWidthFraction; final appBarHeight = AppBar().preferredSize.height; final iconButtonPadding = mainAppbarPadding; final iconSize = IconTheme.of(context).size ?? 0; final pokeballTopMargin = -(pokeballSize / 2 - safeAreaTop - appBarHeight / 2); final pokeballRightMargin = -(pokeballSize / 2 - iconButtonPadding - iconSize / 2); var themeCubit = BlocProvider.of<ThemeCubit>(context, listen: true); var isDark = themeCubit.isDark; return Scaffold( // backgroundColor: Colors.white, body: Stack( fit: StackFit.expand, children: [ Positioned( top: pokeballTopMargin, right: pokeballRightMargin, child: Image( image: AppImages.pokeball, width: pokeballSize, height: pokeballSize, color: !isDark ? AppColors.whiteGrey : Colors.black.withOpacity(0.05), ), ), child, ], ), floatingActionButton: floatingActionButton, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/pokemon_type.dart
import 'package:flutter/material.dart'; import 'package:pokedex/domain/entities/pokemon_types.dart'; import 'package:pokedex/ui/widgets/spacer.dart'; class PokemonType extends StatelessWidget { const PokemonType( this.type, { Key? key, this.large = false, this.colored = false, this.extra = '', }) : super(key: key); final PokemonTypes type; final String extra; final bool large; final bool colored; @override Widget build(BuildContext context) { var bgColor = Theme.of(context).backgroundColor; return Material( color: Colors.transparent, child: Container( padding: EdgeInsets.symmetric( horizontal: large ? 19 : 12, vertical: large ? 6 : 4, ), decoration: ShapeDecoration( shape: StadiumBorder(), color: (colored ? type.color : bgColor).withOpacity(0.2), ), child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Text( type.value, textScaleFactor: 1, style: TextStyle( fontSize: large ? 12 : 8, height: 0.8, fontWeight: large ? FontWeight.bold : FontWeight.normal, color: colored ? type.color : bgColor), textAlign: TextAlign.center, ), HSpacer(5), Text( extra, textScaleFactor: 1, style: TextStyle( fontSize: large ? 12 : 8, height: 0.8, fontWeight: large ? FontWeight.bold : FontWeight.normal, color: colored ? type.color : bgColor, ), ), ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/modal.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; class Modal extends StatelessWidget { static const Radius _borderRadius = Radius.circular(30.0); const Modal({ this.title, required this.child, }); final String? title; final Widget child; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(top: 14), decoration: BoxDecoration( color: Theme.of(context).backgroundColor, borderRadius: BorderRadius.only( topLeft: _borderRadius, topRight: _borderRadius, ), ), child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ _DragLine(), _Title(title), child, ], ), ); } } class _DragLine extends StatelessWidget { @override Widget build(BuildContext context) { final width = MediaQuery.of(context).size.width * 0.2; return Container( width: width, height: 3, decoration: ShapeDecoration( shape: StadiumBorder(), color: AppColors.lighterGrey, ), ); } } class _Title extends StatelessWidget { const _Title(this.text); final String? text; @override Widget build(BuildContext context) { if (text == null) { return SizedBox(); } return Padding( padding: EdgeInsets.only( top: 18, bottom: 8, ), child: Text( text ?? '', style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/animated_fade.dart
import 'package:flutter/material.dart'; class AnimatedFade extends AnimatedWidget { const AnimatedFade({ required this.child, required this.animation, }) : super(listenable: animation); final Animation<double> animation; final Widget child; @override Widget build(BuildContext context) { final opacity = animation.value; return IgnorePointer( ignoring: opacity < 1, child: Opacity( opacity: opacity, child: child, ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/auto_slideup_panel.dart
import 'package:flutter/material.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; class AutoSlideUpPanel extends StatefulWidget { final double minHeight; final double maxHeight; final Widget child; final void Function(double)? onPanelSlide; const AutoSlideUpPanel({ Key? key, required this.minHeight, required this.maxHeight, required this.child, this.onPanelSlide, }) : super(key: key); @override State<AutoSlideUpPanel> createState() => _PokemonInfoCardState(); } class _PokemonInfoCardState extends State<AutoSlideUpPanel> with SingleTickerProviderStateMixin { late AnimationController _autoSlideUpController; @override void initState() { _autoSlideUpController = AnimationController( vsync: this, duration: Duration(milliseconds: 300), )..forward(); super.initState(); } @override void dispose() { _autoSlideUpController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: _autoSlideUpController, child: widget.child, builder: (_, child) { return SlidingUpPanel( minHeight: widget.minHeight * _autoSlideUpController.value, maxHeight: widget.maxHeight, boxShadow: null, color: Colors.transparent, panel: child, onPanelSlide: widget.onPanelSlide, ); }, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/main_app_bar.dart
import 'package:flutter/material.dart'; import 'package:pokedex/routes.dart'; import 'package:pokedex/utils/size.dart'; const double mainAppbarPadding = 28; class MainSliverAppBar extends SliverAppBar { static const TextStyle _textStyle = TextStyle( // color: Colors.black, fontWeight: FontWeight.bold, fontSize: kToolbarHeight / 3, height: 1, ); MainSliverAppBar( {GlobalKey? appBarKey, String title = 'Pokedex', double height = kToolbarHeight + mainAppbarPadding * 2, double expandedFontSize = 30, void Function()? onLeadingPress = AppNavigator.pop, void Function()? onTrailingPress, required BuildContext context}) : super( centerTitle: true, expandedHeight: height, floating: false, pinned: true, backgroundColor: Colors.transparent, elevation: 0, leading: IconButton( padding: EdgeInsets.symmetric(horizontal: mainAppbarPadding), onPressed: onLeadingPress, icon: Icon( Icons.arrow_back, color: Theme.of(context).textTheme.bodyLarge!.color, ), ), actions: [ IconButton( padding: EdgeInsets.symmetric(horizontal: mainAppbarPadding), icon: Icon(Icons.favorite_border_outlined, color: Theme.of(context).textTheme.bodyLarge!.color), onPressed: onTrailingPress, ), ], flexibleSpace: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final safeAreaTop = MediaQuery.of(context).padding.top; final minHeight = safeAreaTop + kToolbarHeight; final maxHeight = height + safeAreaTop; final percent = (constraints.maxHeight - minHeight) / (maxHeight - minHeight); final fontSize = _textStyle.fontSize ?? 16; final currentTextStyle = _textStyle.copyWith( fontSize: fontSize + (expandedFontSize - fontSize) * percent, ); final textWidth = getTextSize(context, title, currentTextStyle).width; final startX = mainAppbarPadding; final endX = MediaQuery.of(context).size.width / 2 - textWidth / 2 - startX; final dx = startX + endX - endX * percent; return Container( color: Theme.of(context).backgroundColor.withOpacity(0.8 - percent * 0.8), child: Stack( fit: StackFit.expand, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: kToolbarHeight / 3), child: Transform.translate( child: Text( title, style: currentTextStyle, ), offset: Offset(dx, constraints.maxHeight - kToolbarHeight), ), ), ], ), ); }, ), ); } class MainAppBar extends AppBar { MainAppBar({Widget? title, IconData? rightIcon}) : super( title: title, backgroundColor: Colors.transparent, elevation: 0, leading: IconButton( padding: EdgeInsets.symmetric(horizontal: mainAppbarPadding), icon: Icon(Icons.arrow_back), onPressed: AppNavigator.pop, ), actions: <Widget>[ Padding( padding: EdgeInsets.only(right: mainAppbarPadding), child: Icon( rightIcon, color: Colors.white, ), ), ], ); }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/animated_overlay.dart
import 'package:flutter/material.dart'; class AnimatedOverlay extends AnimatedWidget { final Color color; final Widget? child; final void Function()? onPress; const AnimatedOverlay({ required Animation animation, required this.color, this.child, this.onPress, }) : super(listenable: animation); Animation<double> get animation => listenable as Animation<double>; @override Widget build(BuildContext context) { return Stack( fit: StackFit.expand, children: [ IgnorePointer( ignoring: animation.value == 0, child: InkWell( onTap: onPress, child: Container( color: color.withOpacity(animation.value * 0.5), ), ), ), if (child != null) child!, ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/pokemon_refresh_control.dart
import 'package:flutter/cupertino.dart'; import 'package:pokedex/configs/images.dart'; class PokemonRefreshControl extends StatelessWidget { final Future<void> Function() onRefresh; const PokemonRefreshControl({ Key? key, required this.onRefresh, }) : super(key: key); @override Widget build(BuildContext context) { return CupertinoSliverRefreshControl( onRefresh: onRefresh, builder: (_, __, ___, ____, _____) => Image( image: AppImages.pikloader, ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/hero.dart
import 'package:flutter/material.dart'; class HeroText extends Hero { HeroText(String text, {TextStyle? style, String? tag, Key? textKey}) : super( tag: tag ?? text, child: Material( color: Colors.transparent, child: Text(text, key: textKey, style: style), ), ); }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/pokemon_image.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'; import 'package:flutter/material.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/domain/entities/pokemon.dart'; class PokemonImage extends StatelessWidget { static const Size _cacheMaxSize = Size(700, 700); final Pokemon pokemon; final EdgeInsets padding; final bool useHero; final Size size; final ImageProvider placeholder; final Color? tintColor; const PokemonImage({ Key? key, required this.pokemon, required this.size, this.padding = EdgeInsets.zero, this.useHero = true, this.placeholder = AppImages.bulbasaur, this.tintColor, }) : super(key: key); @override Widget build(BuildContext context) { return HeroMode( enabled: useHero, child: Hero( tag: pokemon.image, child: AnimatedPadding( duration: Duration(milliseconds: 600), curve: Curves.easeOutQuint, padding: padding, child: CachedNetworkImage( imageUrl: pokemon.image, imageRenderMethodForWeb: ImageRenderMethodForWeb.HtmlImage, useOldImageOnUrlChange: true, maxWidthDiskCache: _cacheMaxSize.width.toInt(), maxHeightDiskCache: _cacheMaxSize.height.toInt(), fadeInDuration: Duration(milliseconds: 120), fadeOutDuration: Duration(milliseconds: 120), imageBuilder: (_, image) => Image( image: image, width: size.width, height: size.height, alignment: Alignment.bottomCenter, color: tintColor, fit: BoxFit.contain, ), placeholder: (_, __) => Image( image: placeholder, width: size.width, height: size.height, alignment: Alignment.bottomCenter, color: Colors.black12, fit: BoxFit.contain, ), errorWidget: (_, __, ___) => Stack( alignment: Alignment.center, children: [ Image( image: placeholder, width: size.width, height: size.height, color: Colors.black12, ), Icon( Icons.warning_amber_rounded, size: size.width * 0.3, color: Colors.black26, ), ], ), ), ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/pokemon_card.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/domain/entities/pokemon.dart'; import 'package:pokedex/ui/widgets/pokemon_image.dart'; import 'package:pokedex/ui/widgets/pokemon_type.dart'; class PokemonCard extends StatelessWidget { static const double _pokeballFraction = 0.75; static const double _pokemonFraction = 0.76; final Pokemon pokemon; final void Function()? onPress; const PokemonCard( this.pokemon, { this.onPress, }); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constrains) { final itemHeight = constrains.maxHeight; return Container( decoration: BoxDecoration( color: pokemon.color, borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( color: pokemon.color.withOpacity(0.4), blurRadius: 15, offset: Offset(0, 8), ), ], ), child: ClipRRect( borderRadius: BorderRadius.circular(15), child: Material( color: pokemon.color, child: InkWell( onTap: onPress, splashColor: Colors.white10, highlightColor: Colors.white10, child: Stack( children: [ _buildPokeballDecoration(height: itemHeight), _buildPokemon(height: itemHeight), _buildPokemonNumber(), _CardContent(pokemon), ], ), ), ), ), ); }, ); } Widget _buildPokeballDecoration({required double height}) { final pokeballSize = height * _pokeballFraction; return Positioned( bottom: -height * 0.13, right: -height * 0.03, child: Image( image: AppImages.pokeball, width: pokeballSize, height: pokeballSize, color: Colors.white.withOpacity(0.14), ), ); } Widget _buildPokemon({required double height}) { final pokemonSize = height * _pokemonFraction; return Positioned( bottom: -2, right: 2, child: PokemonImage( size: Size.square(pokemonSize), pokemon: pokemon, ), ); } Widget _buildPokemonNumber() { return Positioned( top: 10, right: 14, child: Text( pokemon.number, style: TextStyle( fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black12, ), ), ); } } class _CardContent extends StatelessWidget { final Pokemon pokemon; const _CardContent(this.pokemon, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Align( alignment: Alignment.centerLeft, child: Padding( padding: EdgeInsets.fromLTRB(16, 24, 16, 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: <Widget>[ Hero( tag: pokemon.number + pokemon.name, child: Text( pokemon.name, style: TextStyle( fontSize: 14, height: 0.7, fontWeight: FontWeight.bold, color: Theme.of(context).backgroundColor, ), ), ), SizedBox(height: 10), ..._buildTypes(context), ], ), ), ); } List<Widget> _buildTypes(BuildContext context) { return pokemon.types .take(2) .map( (type) => Padding( padding: EdgeInsets.only(bottom: 6), child: PokemonType(type), ), ) .toList(); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/fab.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; class FabItemData { final IconData icon; final void Function()? onPress; final String title; const FabItemData(this.title, this.icon, {this.onPress}); } class FabItem extends StatelessWidget { final FabItemData item; const FabItem(this.item, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { var bgColor = Theme.of(context).backgroundColor; return MaterialButton( shape: StadiumBorder(), padding: EdgeInsets.fromLTRB(24, 8, 16, 8), color: bgColor, splashColor: Colors.grey[100], highlightColor: Colors.grey[100], elevation: 0, highlightElevation: 2, disabledColor: bgColor, onPressed: item.onPress, child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Text(item.title), SizedBox(width: 8), Icon(item.icon, color: AppColors.indigo), ], ), ); } } class ExpandedAnimationFab extends AnimatedWidget { final List<FabItemData> items; final void Function()? onPress; const ExpandedAnimationFab({ required this.items, required Animation animation, this.onPress, }) : super(listenable: animation); Animation<double> get animation => listenable as Animation<double>; @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ IgnorePointer( ignoring: animation.value == 0, child: ListView.separated( shrinkWrap: true, padding: EdgeInsets.symmetric(vertical: 12), physics: NeverScrollableScrollPhysics(), itemCount: items.length, separatorBuilder: (_, __) => SizedBox(height: 9), itemBuilder: _buildItem, ), ), FloatingActionButton( backgroundColor: AppColors.indigo, child: AnimatedIcon( icon: AnimatedIcons.menu_close, progress: animation, ), onPressed: onPress, ), ], ); } Widget _buildItem(BuildContext context, int index) { final screenWidth = MediaQuery.of(context).size.width; final transform = Matrix4.translationValues( -(screenWidth - animation.value * screenWidth) * ((items.length - index) / 4), 0.0, 0.0, ); return Align( alignment: Alignment.centerRight, child: Transform( transform: transform, child: Opacity( opacity: animation.value, child: FabItem(items[index]), ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/widgets/search_bar.dart
import 'package:flutter/material.dart'; import 'package:pokedex/ui/widgets/spacer.dart'; class SearchBar extends StatelessWidget { const SearchBar({ this.margin = const EdgeInsets.symmetric(horizontal: 28), }); final EdgeInsets margin; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 18, vertical: 8), margin: margin, decoration: ShapeDecoration( shape: StadiumBorder(), color: Theme.of(context).scaffoldBackgroundColor, ), child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(Icons.search, size: 26), HSpacer(13), Expanded( child: TextFormField( decoration: InputDecoration( isDense: true, hintText: 'Search Pokemon, Move, Ability etc', contentPadding: EdgeInsets.zero, hintStyle: TextStyle( fontSize: 14, // color: AppColors.grey, height: 1, ), border: InputBorder.none, ), ), ), ], ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/modals/search_modal.dart
import 'package:flutter/material.dart'; import 'package:pokedex/ui/widgets/modal.dart'; import 'package:pokedex/ui/widgets/search_bar.dart'; class SearchBottomModal extends StatelessWidget { @override Widget build(BuildContext context) { final viewInsets = MediaQuery.of(context).viewInsets.bottom; final safeAreaBottom = MediaQuery.of(context).padding.bottom; return Modal( child: Flexible( child: Padding( padding: EdgeInsets.fromLTRB(26, 14, 26, 14 + viewInsets + safeAreaBottom), child: SearchBar(margin: EdgeInsets.zero), ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui
mirrored_repositories/flutter_Pokedex/lib/ui/modals/generation_modal.dart
import 'package:flutter/material.dart'; import 'package:pokedex/data/generations.dart'; import 'package:pokedex/domain/entities/generation.dart'; import 'package:pokedex/ui/screens/pokedex/widgets/generation_card.dart'; import 'package:pokedex/ui/widgets/modal.dart'; class GenerationModal extends StatelessWidget { Widget _buildGenerationCard(Generation generation) { return GenerationCard(generation); } Widget _buildGenerations(BuildContext context, ScrollController scrollController) { final safeAreaBottom = MediaQuery.of(context).padding.bottom; return Expanded( child: GridView.builder( padding: EdgeInsets.fromLTRB(26, 26, 26, 26 + safeAreaBottom), controller: scrollController, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 1.55, crossAxisSpacing: 10, mainAxisSpacing: 10, ), itemCount: generations.length, itemBuilder: (_, index) => _buildGenerationCard(generations[index]), ), ); } @override Widget build(BuildContext context) { return DraggableScrollableSheet( expand: true, initialChildSize: 0.7, maxChildSize: 1, minChildSize: 0.5, builder: (_, scrollController) { return Modal( title: 'Generation', child: _buildGenerations(context, scrollController), ); }, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/pokemon_info.dart
import 'dart:math'; import 'package:flutter/material.dart' hide AnimatedSlide; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/domain/entities/pokemon.dart'; import 'package:pokedex/domain/entities/pokemon_props.dart'; import 'package:pokedex/domain/entities/pokemon_types.dart'; import 'package:pokedex/states/pokemon/pokemon_bloc.dart'; import 'package:pokedex/states/pokemon/pokemon_event.dart'; import 'package:pokedex/states/pokemon/pokemon_selector.dart'; import 'package:pokedex/ui/screens/pokemon_info/state_provider.dart'; import 'package:pokedex/ui/widgets/animated_fade.dart'; import 'package:pokedex/ui/widgets/animated_slide.dart'; import 'package:pokedex/ui/widgets/auto_slideup_panel.dart'; import 'package:pokedex/ui/widgets/hero.dart'; import 'package:pokedex/ui/widgets/main_app_bar.dart'; import 'package:pokedex/ui/widgets/main_tab_view.dart'; import 'package:pokedex/ui/widgets/pokemon_image.dart'; import 'package:pokedex/ui/widgets/pokemon_type.dart'; import 'package:pokedex/ui/widgets/progress.dart'; import 'package:pokedex/utils/string.dart'; import '../../../states/theme/theme_cubit.dart'; part 'sections/background_decoration.dart'; part 'sections/pokemon_overall_info.dart'; part 'sections/pokemon_info_card.dart'; part 'sections/pokemon_info_card_about.dart'; part 'sections/pokemon_info_card_basestats.dart'; part 'sections/pokemon_info_card_evolutions.dart'; class PokemonInfo extends StatefulWidget { @override _PokemonInfoState createState() => _PokemonInfoState(); } class _PokemonInfoState extends State<PokemonInfo> with TickerProviderStateMixin { late AnimationController _slideController; late AnimationController _rotateController; @override void initState() { _slideController = AnimationController( vsync: this, duration: Duration(milliseconds: 300), ); _rotateController = AnimationController( vsync: this, duration: Duration(milliseconds: 5000), )..repeat(); super.initState(); } @override void dispose() { _slideController.dispose(); _rotateController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return PokemonInfoStateProvider( slideController: _slideController, rotateController: _rotateController, child: Scaffold( body: Stack( children: <Widget>[ _BackgroundDecoration(), _PokemonInfoCard(), _PokemonOverallInfo(), ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/state_provider.dart
import 'package:flutter/material.dart'; class PokemonInfoStateProvider extends InheritedWidget { final AnimationController slideController; final AnimationController rotateController; const PokemonInfoStateProvider({ Key? key, required this.slideController, required this.rotateController, required Widget child, }) : super(child: child); static PokemonInfoStateProvider of(BuildContext context) { final result = context.dependOnInheritedWidgetOfExactType<PokemonInfoStateProvider>(); return result!; } @override bool updateShouldNotify(covariant PokemonInfoStateProvider oldWidget) => false; }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/sections/pokemon_info_card_evolutions.dart
part of '../pokemon_info.dart'; class _PokemonBall extends StatelessWidget { final Pokemon pokemon; const _PokemonBall(this.pokemon); @override Widget build(BuildContext context) { final screenHeight = MediaQuery.of(context).size.height; final pokeballSize = screenHeight * 0.1; final pokemonSize = pokeballSize * 0.85; return Column( children: [ Stack( alignment: Alignment.center, children: <Widget>[ Image( image: AppImages.pokeball, width: pokeballSize, height: pokeballSize, color: AppColors.lightGrey, ), PokemonImage( pokemon: pokemon, size: Size.square(pokemonSize), ), ], ), SizedBox(height: 3), Text(pokemon.name), ], ); } } class _PokemonEvolution extends StatefulWidget { final Pokemon pokemon; const _PokemonEvolution(this.pokemon); @override _PokemonEvolutionState createState() => _PokemonEvolutionState(); } class _PokemonEvolutionState extends State<_PokemonEvolution> { Pokemon get pokemon => widget.pokemon; Widget _buildRow({ required Pokemon current, required Pokemon next, required String reason, }) { return Row( children: <Widget>[ Expanded(child: _PokemonBall(current)), Expanded( child: Column( children: <Widget>[ Icon(Icons.arrow_forward, color: AppColors.lightGrey), SizedBox(height: 7), Text(reason, style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold)), ], ), ), Expanded(child: _PokemonBall(next)), ], ); } @override Widget build(BuildContext context) { final slideController = PokemonInfoStateProvider.of(context).slideController; return AnimatedBuilder( animation: slideController, builder: (context, child) { final scrollable = slideController.value.floor() == 1; return SingleChildScrollView( physics: scrollable ? BouncingScrollPhysics() : NeverScrollableScrollPhysics(), padding: EdgeInsets.symmetric(vertical: 31, horizontal: 28), child: child, ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( 'Evolution Chain', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, height: 0.8, ), ), SizedBox(height: 28), ListView.separated( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), separatorBuilder: (_, __) => Divider(height: 58), itemCount: pokemon.evolutions.length - 1, itemBuilder: (_, index) => _buildRow( current: pokemon.evolutions[index], next: pokemon.evolutions[index + 1], reason: pokemon.evolutions[index + 1].evolutionReason, ), ), ], ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/sections/pokemon_overall_info.dart
part of '../pokemon_info.dart'; class _PokemonOverallInfo extends StatefulWidget { const _PokemonOverallInfo(); @override _PokemonOverallInfoState createState() => _PokemonOverallInfoState(); } class _PokemonOverallInfoState extends State<_PokemonOverallInfo> with TickerProviderStateMixin { static const double _pokemonSliderViewportFraction = 0.56; static const int _endReachedThreshold = 4; final GlobalKey _currentTextKey = GlobalKey(); final GlobalKey _targetTextKey = GlobalKey(); double textDiffLeft = 0.0; double textDiffTop = 0.0; late PageController _pageController; late AnimationController _horizontalSlideController; PokemonBloc get pokemonBloc => context.read<PokemonBloc>(); AnimationController get slideController => PokemonInfoStateProvider.of(context).slideController; AnimationController get rotateController => PokemonInfoStateProvider.of(context).rotateController; Animation<double> get textFadeAnimation => Tween(begin: 1.0, end: 0.0).animate(slideController); Animation<double> get sliderFadeAnimation => Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation( parent: slideController, curve: Interval(0.0, 0.5, curve: Curves.ease), )); @override void initState() { _horizontalSlideController = AnimationController( vsync: this, duration: Duration(microseconds: 300), )..forward(); super.initState(); } @override void didChangeDependencies() { final pageIndex = pokemonBloc.state.selectedPokemonIndex; _pageController = PageController( viewportFraction: _pokemonSliderViewportFraction, initialPage: pageIndex, ); super.didChangeDependencies(); } @override void dispose() { _horizontalSlideController.dispose(); _pageController.dispose(); super.dispose(); } void _calculatePokemonNamePosition() { WidgetsBinding.instance.addPostFrameCallback((_) { final targetTextBox = _targetTextKey.currentContext?.findRenderObject() as RenderBox?; final currentTextBox = _currentTextKey.currentContext?.findRenderObject() as RenderBox?; if (targetTextBox == null || currentTextBox == null) return; final targetTextPosition = targetTextBox.localToGlobal(Offset.zero); final currentTextPosition = currentTextBox.localToGlobal(Offset.zero); final newDiffLeft = targetTextPosition.dx - currentTextPosition.dx; final newDiffTop = targetTextPosition.dy - currentTextPosition.dy; if (newDiffLeft != textDiffLeft || newDiffTop != textDiffTop) { setState(() { textDiffLeft = newDiffLeft; textDiffTop = newDiffTop; }); } }); } void _onSelectedPokemonChanged(int index) { final pokemons = pokemonBloc.state.pokemons; final selectedPokemon = pokemons[index]; pokemonBloc.add(PokemonSelectChanged(pokemonId: selectedPokemon.number)); final shouldLoadMore = index >= pokemons.length - _endReachedThreshold; if (shouldLoadMore) { pokemonBloc.add(PokemonLoadMoreStarted()); } } @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ _buildAppBar(), SizedBox(height: 9), _buildPokemonName(), SizedBox(height: 9), _buildPokemonTypes(), SizedBox(height: 25), _buildPokemonSlider(), ], ); } AppBar _buildAppBar() { return MainAppBar( // A placeholder for easily calculate the translate of the pokemon name title: CurrentPokemonSelector((pokemon) { _calculatePokemonNamePosition(); return Text( pokemon.name, key: _targetTextKey, style: TextStyle( color: Colors.transparent, fontWeight: FontWeight.w900, fontSize: 22, ), ); }), rightIcon: Icons.favorite_border, ); } Widget _buildPokemonName() { var bgColor = Theme.of(context).backgroundColor; return Padding( padding: EdgeInsets.symmetric(horizontal: 26), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ AnimatedBuilder( animation: slideController, builder: (_, __) { final value = slideController.value; return Transform.translate( offset: Offset(textDiffLeft * value, textDiffTop * value), child: CurrentPokemonSelector((pokemon) { return HeroText( pokemon.name, textKey: _currentTextKey, style: TextStyle( color: bgColor, fontWeight: FontWeight.w900, fontSize: 36 - (36 - 22) * value, ), ); }), ); }, ), AnimatedSlide( animation: _horizontalSlideController, child: AnimatedFade( animation: textFadeAnimation, child: CurrentPokemonSelector((pokemon) { return HeroText( pokemon.number, style: TextStyle( color: bgColor, fontWeight: FontWeight.w900, fontSize: 18, ), ); }), ), ), ], ), ); } Widget _buildPokemonTypes() { return AnimatedFade( animation: textFadeAnimation, child: Padding( padding: EdgeInsets.symmetric(horizontal: 26), child: CurrentPokemonSelector((pokemon) { return Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( child: Wrap( spacing: 8, runSpacing: 8, children: pokemon.types.take(3).map((type) => PokemonType(type, large: true)).toList(), ), ), AnimatedSlide( animation: _horizontalSlideController, child: Text( pokemon.genera, style: TextStyle(color: Theme.of(context).backgroundColor), ), ), ], ); }), ), ); } Widget _buildPokemonSlider() { final screenSize = MediaQuery.of(context).size; final sliderHeight = screenSize.height * 0.24; final pokeballSize = screenSize.height * 0.24; final pokemonSize = screenSize.height * 0.3; return AnimatedFade( animation: sliderFadeAnimation, child: SizedBox( width: screenSize.width, height: sliderHeight, child: Stack( children: <Widget>[ Align( alignment: Alignment.bottomCenter, child: RotationTransition( turns: rotateController, child: Image( image: AppImages.pokeball, width: pokeballSize, height: pokeballSize, color: Colors.white12, ), ), ), NumberOfPokemonsSelector((numberOfPokemons) { return PageView.builder( allowImplicitScrolling: true, physics: BouncingScrollPhysics(), controller: _pageController, itemCount: numberOfPokemons, onPageChanged: _onSelectedPokemonChanged, itemBuilder: (_, index) { return PokemonSelector(index, (pokemon, selected) { return PokemonImage( pokemon: pokemon, size: Size.square(pokemonSize), padding: EdgeInsets.symmetric( vertical: selected ? 0 : screenSize.height * 0.04, ), tintColor: selected ? null : Colors.black26, useHero: selected, ); }); }, ); }), ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/sections/background_decoration.dart
part of '../pokemon_info.dart'; class _BoxDecoration extends StatelessWidget { static const Size size = Size.square(144); const _BoxDecoration(); @override Widget build(BuildContext context) { return Transform.rotate( angle: pi * 5 / 12, alignment: Alignment.center, child: Container( width: size.width, height: size.height, decoration: BoxDecoration( borderRadius: BorderRadius.circular(24), gradient: LinearGradient( begin: Alignment(-0.2, -0.2), end: Alignment(1.5, -0.3), colors: [ Colors.white.withOpacity(0.3), Colors.white.withOpacity(0), ], ), ), ), ); } } class _DottedDecoration extends StatelessWidget { static const Size size = Size(57, 31); final Animation<double> animation; const _DottedDecoration({required this.animation}); @override Widget build(BuildContext context) { return AnimatedFade( animation: animation, child: Image( image: AppImages.dotted, width: size.width, height: size.height, color: Colors.white30, ), ); } // const _DottedDecoration({ // required Animation<double> animation, // }) : super( // animation: animation, // child: const Image( // image: AppImages.dotted, // width: size.width, // height: size.height, // color: Colors.white30, // ), // ); } class _BackgroundDecoration extends StatefulWidget { const _BackgroundDecoration(); @override State<_BackgroundDecoration> createState() => _BackgroundDecorationState(); } class _BackgroundDecorationState extends State<_BackgroundDecoration> { Animation<double> get slideController => PokemonInfoStateProvider.of(context).slideController; Animation<double> get rotateController => PokemonInfoStateProvider.of(context).rotateController; @override Widget build(BuildContext context) { return Stack( children: [ _buildBackground(), _buildBoxDecoration(), _buildDottedDecoration(), _buildAppBarPokeballDecoration(), ], ); } Widget _buildBackground() { return CurrentPokemonSelector((pokemon) { return AnimatedContainer( duration: Duration(milliseconds: 300), constraints: BoxConstraints.expand(), color: pokemon.color, ); }); } Widget _buildBoxDecoration() { return Positioned( top: -_BoxDecoration.size.height * 0.4, left: -_BoxDecoration.size.width * 0.4, child: _BoxDecoration(), ); } Widget _buildDottedDecoration() { return Positioned( top: 4, right: 72, child: _DottedDecoration(animation: slideController), ); } Widget _buildAppBarPokeballDecoration() { final screenSize = MediaQuery.of(context).size; final safeAreaTop = MediaQuery.of(context).padding.top; final pokeSize = screenSize.width * 0.5; final appBarHeight = AppBar().preferredSize.height; final iconButtonPadding = mainAppbarPadding; final iconSize = IconTheme.of(context).size ?? 0; final pokeballTopMargin = -(pokeSize / 2 - safeAreaTop - appBarHeight / 2); final pokeballRightMargin = -(pokeSize / 2 - iconButtonPadding - iconSize / 2); return Positioned( top: pokeballTopMargin, right: pokeballRightMargin, child: IgnorePointer( ignoring: true, child: AnimatedFade( animation: slideController, child: RotationTransition( turns: rotateController, child: Image( image: AppImages.pokeball, width: pokeSize, height: pokeSize, color: Colors.white24, ), ), ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/sections/pokemon_info_card_basestats.dart
part of '../pokemon_info.dart'; class Stat extends StatelessWidget { final Animation animation; final String label; final double? progress; final num value; const Stat({ required this.animation, required this.label, required this.value, this.progress, }); @override Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.max, children: <Widget>[ Expanded( flex: 2, child: Text( label, style: TextStyle(color: Theme.of(context).textTheme.caption!.color!.withOpacity(0.6)), ), ), Expanded( flex: 1, child: Text('$value'), ), Expanded( flex: 5, child: AnimatedBuilder( animation: animation, builder: (context, widget) { final currentProgress = progress ?? value / 100; return ProgressBar( progress: animation.value * currentProgress, color: currentProgress < 0.5 ? AppColors.red : AppColors.teal, enableAnimation: animation.value == 1, ); }, ), ), ], ); } } class _PokemonBaseStats extends StatefulWidget { final Pokemon pokemon; const _PokemonBaseStats(this.pokemon); @override State<_PokemonBaseStats> createState() => _PokemonBaseStatsState(); } class _PokemonBaseStatsState extends State<_PokemonBaseStats> with SingleTickerProviderStateMixin { late Animation<double> _progressAnimation; late AnimationController _progressController; Pokemon get pokemon => widget.pokemon; AnimationController get slideController => PokemonInfoStateProvider.of(context).slideController; @override void initState() { _progressController = AnimationController( vsync: this, duration: Duration(milliseconds: 400), ); _progressAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation( curve: Curves.easeInOut, parent: _progressController, )); _progressController.forward(); super.initState(); } @override void dispose() { _progressController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: slideController, builder: (context, child) { final scrollable = slideController.value.floor() == 1; return SingleChildScrollView( padding: EdgeInsets.all(24), physics: scrollable ? BouncingScrollPhysics() : NeverScrollableScrollPhysics(), child: child, ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.max, children: <Widget>[ buildStats(pokemon.stats), SizedBox(height: 27), Text( 'Type defenses', style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, height: 0.8, ), ), SizedBox(height: 15), Text( 'The effectiveness of each type on ${pokemon.name}.', style: TextStyle(color: AppColors.black.withOpacity(0.6)), ), SizedBox(height: 15), _buildEffectivenesses(pokemon.typeEffectiveness), ], ), ); } Widget buildStats(PokemonStats stats) { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Stat(animation: _progressAnimation, label: 'Hp', value: stats.hp), SizedBox(height: 14), Stat(animation: _progressAnimation, label: 'Atttack', value: stats.attack), SizedBox(height: 14), Stat(animation: _progressAnimation, label: 'Defense', value: stats.defense), SizedBox(height: 14), Stat(animation: _progressAnimation, label: 'Sp. Atk', value: stats.specialAttack), SizedBox(height: 14), Stat(animation: _progressAnimation, label: 'Sp. Def', value: stats.specialDefense), SizedBox(height: 14), Stat(animation: _progressAnimation, label: 'Speed', value: stats.speed), SizedBox(height: 14), Stat( animation: _progressAnimation, label: 'Total', value: stats.total, progress: stats.total / 600, ), ], ); } Widget _buildEffectivenesses(Map<PokemonTypes, double> typeEffectiveness) { return Wrap( spacing: 8, runSpacing: 8, children: typeEffectiveness.keys .map( (type) => PokemonType( type, large: true, colored: true, extra: 'x' + removeTrailingZero(typeEffectiveness[type] ?? 1), ), ) .toList(), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/sections/pokemon_info_card_about.dart
part of '../pokemon_info.dart'; class _Label extends Text { _Label(String text, bool isDark) : super( text, style: TextStyle( color: isDark ? AppColors.whiteGrey.withOpacity(0.6) : AppColors.black.withOpacity(0.6), height: 0.8, ), ); } class _ContentSection extends StatelessWidget { final String label; final List<Widget>? children; const _ContentSection({ Key? key, required this.label, this.children, }) : super(key: key); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( label, style: TextStyle(height: 0.8, fontWeight: FontWeight.bold), ), SizedBox(height: 22), if (children != null) ...children! ], ); } } class _TextIcon extends StatelessWidget { final ImageProvider icon; final String text; const _TextIcon(this.icon, this.text); @override Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image(image: icon, width: 12, height: 12), SizedBox(width: 4), Text(text, style: TextStyle(height: 0.8)), ], ); } } class _PokemonAbout extends StatelessWidget { final Pokemon pokemon; const _PokemonAbout(this.pokemon); @override Widget build(BuildContext context) { final slideController = PokemonInfoStateProvider.of(context).slideController; var themeCubit = BlocProvider.of<ThemeCubit>(context, listen: true); var isDark = themeCubit.isDark; return AnimatedBuilder( animation: slideController, builder: (context, child) { final scrollable = slideController.value.floor() == 1; return SingleChildScrollView( padding: EdgeInsets.symmetric(vertical: 19, horizontal: 27), physics: scrollable ? BouncingScrollPhysics() : NeverScrollableScrollPhysics(), child: child, ); }, child: Column( children: <Widget>[ _buildDescription(pokemon.description), SizedBox(height: 28), _buildHeightWeight(pokemon.height, pokemon.weight, context, isDark), SizedBox(height: 31), _buildBreeding(pokemon.gender, pokemon.eggGroups, isDark), SizedBox(height: 35), _buildLocation(), SizedBox(height: 26), _buildTraining(pokemon.baseExp, isDark), ], ), ); } Widget _buildDescription(String description) { return Text( description, style: TextStyle(height: 1.3), ); } Widget _buildHeightWeight(String height, String weight, BuildContext context, bool isDark) { return Container( padding: EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: Theme.of(context).backgroundColor, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.12), offset: Offset(0, 8), blurRadius: 23, ) ], ), child: Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ _Label('Height', isDark), SizedBox(height: 11), Text( '${height}', style: TextStyle( height: 0.8, ), ) ], ), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ _Label('Weight', isDark), SizedBox(height: 11), Text('${weight}', style: TextStyle( height: 0.8, )) ], ), ), ], ), ); } Widget _buildBreeding(PokemonGender gender, List<String> eggGroups, bool isDark) { return _ContentSection( label: 'Breeding', children: [ Row( children: <Widget>[ Expanded(child: _Label('Gender', isDark)), if (gender.genderless) Expanded( flex: 3, child: Text('Genderless', style: TextStyle(height: 0.8)), ) else ...[ Expanded( child: _TextIcon(AppImages.male, '${gender.male}%'), ), Expanded( flex: 2, child: _TextIcon(AppImages.female, '${gender.female}%'), ), ], ], ), SizedBox(height: 18), Row( children: <Widget>[ Expanded(child: _Label('Egg Groups', isDark)), Expanded( flex: 2, child: Text(eggGroups.join(', '), style: TextStyle(height: 0.8)), ), Expanded(flex: 1, child: SizedBox()), ], ), ], ); } Widget _buildLocation() { return _ContentSection( label: 'Location', children: [ AspectRatio( aspectRatio: 2.2, child: Container( decoration: BoxDecoration( color: AppColors.teal, borderRadius: BorderRadius.circular(12), ), ), ), ], ); } Widget _buildTraining(double baseExp, bool isDark) { return _ContentSection( label: 'Training', children: [ Row( children: <Widget>[ Expanded(flex: 1, child: _Label('Base EXP', isDark)), Expanded(flex: 3, child: Text('${baseExp}')), ], ), ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokemon_info/sections/pokemon_info_card.dart
part of '../pokemon_info.dart'; class _PokemonInfoCard extends StatefulWidget { static const double minCardHeightFraction = 0.54; const _PokemonInfoCard(); @override State<_PokemonInfoCard> createState() => _PokemonInfoCardState(); } class _PokemonInfoCardState extends State<_PokemonInfoCard> { AnimationController get slideController => PokemonInfoStateProvider.of(context).slideController; @override Widget build(BuildContext context) { final screenHeight = MediaQuery.of(context).size.height; final safeArea = MediaQuery.of(context).padding; final appBarHeight = AppBar().preferredSize.height; final cardMinHeight = screenHeight * _PokemonInfoCard.minCardHeightFraction; final cardMaxHeight = screenHeight - appBarHeight - safeArea.top; return AutoSlideUpPanel( minHeight: cardMinHeight, maxHeight: cardMaxHeight, onPanelSlide: (position) => slideController.value = position, child: CurrentPokemonSelector((pokemon) { return MainTabView( paddingAnimation: slideController, tabs: [ MainTabData( label: 'About', child: _PokemonAbout(pokemon), ), MainTabData( label: 'Base Stats', child: _PokemonBaseStats(pokemon), ), MainTabData( label: 'Evolution', child: _PokemonEvolution(pokemon), ), MainTabData( label: 'Moves', child: Align( alignment: Alignment.topCenter, child: Text('Under development'), ), ), ], ); }), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/type_screen.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pokedex/ui/screens/types/type_grid.dart'; import 'package:pokedex/ui/widgets/main_app_bar.dart'; import 'package:pokedex/ui/widgets/pokeball_background.dart'; // Class that is related to creating the whole type-effects page class TypeEffectScreen extends StatelessWidget { List<Widget> _buildHeader(BuildContext context, bool innerBoxIsScrolled) { return [ MainSliverAppBar( title: 'Type Effects', context: context, ), ]; } @override Widget build(BuildContext context) { return PokeballBackground( child: NestedScrollView( headerSliverBuilder: _buildHeader, body: TypeEffectGrid(), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/modal_sheet.dart
import 'package:flutter/material.dart'; import 'package:pokedex/ui/screens/types/modal_draggable.dart'; import 'package:pokedex/configs/types.dart'; import 'colored_pokeball.dart'; // Class that is responsible for making the modal sheet appear when a type is clicked on class ModalSheet extends StatelessWidget { const ModalSheet({ Key? key, required this.width, required this.index, }) : super(key: key); final double width; final int index; @override Widget build(BuildContext context) { return Card( color: types[index].color, shape: CircleBorder(), child: InkWell( customBorder: CircleBorder(), onTap: () { showModalBottomSheet( isScrollControlled: true, elevation: 10, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20))), context: context, builder: (b) { return ModalDraggable(width: width, index: index); }); }, child: CircularContainer(width: width, index: index), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/bold_texts.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; // A class that generates Bold Texts required for the individual types icon class BoldText extends StatelessWidget { const BoldText({ Key? key, required this.text, }) : super(key: key); final String text; @override Widget build(BuildContext context) { return Text( text, style: TextStyle(fontWeight: FontWeight.bold, color: AppColors.whiteGrey, shadows: [ Shadow( // bottomLeft offset: Offset(-1, -1), color: Colors.black), Shadow( // bottomRight offset: Offset(1, -1), color: Colors.black), Shadow( // topRight offset: Offset(1, 1), color: Colors.black), Shadow( // topLeft offset: Offset(-1, 1), color: Colors.black), ]), textAlign: TextAlign.center, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/type_container.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/types.dart'; import 'package:pokedex/core/utils.dart'; import 'package:pokedex/ui/screens/types/type_entities/type_constants.dart'; import 'bold_texts.dart'; // The Class that is responsible for the type images class TypeDisplayContainer extends StatelessWidget { const TypeDisplayContainer( {Key? key, required this.index, required this.path, required this.value, required this.width, required this.height, required this.typeList, required this.j}) : super(key: key); final int index; final int? j; final String path; final List<String> typeList; final dynamic value; final double? width; final double height; @override Widget build(BuildContext context) { var col = Colors.black; var text = ''; void assigner() { if (path == "name") { col = types[index].color; text = getEnumValue(types[index].type).toUpperCase(); } else if (j != null) { col = types[typeIndices[typeList[j!].toLowerCase()]!].color; text = getEnumValue(types[typeIndices[typeList[j!].toLowerCase()]!].type).toUpperCase(); } } assigner(); return Container( alignment: Alignment.center, margin: EdgeInsets.only(left: 5, right: 5), width: width, height: height, decoration: BoxDecoration( borderRadius: BorderRadius.circular(200), border: Border.all(color: AppColors.black.withAlpha(100)), boxShadow: [ (width != 75) ? BoxShadow( color: AppColors.grey, blurRadius: 25.0, // soften the shadow spreadRadius: 7.0, //extend the shadow offset: Offset( 15.0, // Move to right 10 horizontally 5.0, // Move to bottom 5 Vertically ), ) : BoxShadow() ], color: col, ), child: BoldText(text: text)); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/colored_pokeball.dart
import 'package:flutter/material.dart'; import 'package:pokedex/ui/screens/types/type_container.dart'; // A class that is responsible for the pokeball kind of grids that contain types class CircularContainer extends StatelessWidget { const CircularContainer({ Key? key, required this.width, required this.index, }) : super(key: key); final double width; final int index; @override Widget build(BuildContext context) { return Stack( children: [ Align( child: Container( decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all(color: Colors.black87, width: 2.5)), ), ), Align( child: Container( height: 5, color: Colors.white, )), Align( alignment: Alignment.center, child: Container( width: width / 7, decoration: BoxDecoration( color: Colors.white70, shape: BoxShape.circle, border: Border.all(color: Colors.black87, width: 2.5)), ), ), Align( alignment: Alignment.center, child: TypeDisplayContainer( index: index, path: "name", value: null, width: null, j: null, height: 30, typeList: [], ), ), ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/redirector.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/core/utils.dart'; import 'package:pokedex/configs/types.dart'; // Class responsible for creating the cards that redirects to other pages in the list view class Redirection extends StatelessWidget { const Redirection({ Key? key, required this.index, required this.term, required this.func, }) : super(key: key); final int index; final String term; final void Function() func; @override Widget build(BuildContext context) { return Card( child: InkWell( onTap: func, child: Container( height: 50, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Padding( padding: const EdgeInsets.only(left: 8.0), child: Image( image: AppImages.pokeball, width: 30, height: 30, color: types[index].color.withOpacity(0.5), ), ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( "${getEnumValue(types[index].type)[0].toUpperCase() + getEnumValue(types[index].type).substring(1)} Type " + term), ) ], ), Padding( padding: const EdgeInsets.only(right: 8.0), child: Icon( Icons.arrow_forward_ios, size: 20, color: AppColors.black.withOpacity(0.5), ), ) ], ), ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/modal_contents.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/configs/types.dart'; import 'package:pokedex/core/utils.dart'; import 'package:pokedex/domain/entities/pokemon.dart'; import 'package:pokedex/routes.dart'; import 'package:pokedex/states/pokemon/pokemon_bloc.dart'; import 'package:pokedex/states/pokemon/pokemon_event.dart'; import 'package:pokedex/states/pokemon/pokemon_state.dart'; import 'package:pokedex/ui/widgets/pokemon_card.dart'; import 'package:pokedex/ui/screens/types/type_container.dart'; import 'package:pokedex/ui/screens/types/type_entities/widget_list.dart'; // Class responsible for creating the list present in the modal page consisting of various effects related to the selected type class ModalContents extends StatefulWidget { const ModalContents({ Key? key, required this.index, required this.width, required this.scroller, }) : super(key: key); final int index; final double width; final ScrollController scroller; @override _ModalContentsState createState() => _ModalContentsState(); } class _ModalContentsState extends State<ModalContents> { final List<bool> _isOpen = [false, false, false]; @override void initState() { super.initState(); scheduleMicrotask(() { context.read<PokemonBloc>().add(PokemonLoadStarted(loadAll: true)); }); } void _onPokemonPress(int index, Pokemon pokemon) { context.read<PokemonBloc>().add(PokemonSelectChanged(pokemonId: pokemon.number)); AppNavigator.push(Routes.pokemonInfo, pokemon); } PokeTypes get pokeType => types[widget.index]; ExpansionPanel _buildTypePokemonPanel(List<Pokemon> pokemons) { final filteredPokemons = pokemons.where((pokemon) => pokemon.types.contains(pokeType.type)).toList(); return ExpansionPanel( headerBuilder: (context, isOpen) { return Row( children: [ Padding( padding: const EdgeInsets.only(left: 8.0), child: Image( image: AppImages.pokeball, width: 30, height: 30, color: pokeType.color.withOpacity(0.5), ), ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( "${getEnumValue(pokeType.type)[0].toUpperCase() + getEnumValue(pokeType.type).substring(1)} Type " "Pokemons"), ) ], ); }, canTapOnHeader: true, body: Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: filteredPokemons.isNotEmpty ? GridView.count( shrinkWrap: true, crossAxisCount: 2, childAspectRatio: 1.4, crossAxisSpacing: 10, mainAxisSpacing: 10, physics: const NeverScrollableScrollPhysics(), children: filteredPokemons.map((pokemon) { return PokemonCard( pokemon, onPress: () => _onPokemonPress(pokemons.indexOf(pokemon), pokemon), ); }).toList(), ) : Padding( padding: const EdgeInsets.only(bottom: 10.0), child: Text("No Pokemon found", style: TextStyle(fontSize: 16, color: Colors.black54)), ), ), isExpanded: _isOpen[0], ); } ExpansionPanel _buildTypeItemsPanel() { return ExpansionPanel( headerBuilder: (context, isOpen) { return Row( children: [ Padding( padding: const EdgeInsets.only(left: 8.0), child: Image( image: AppImages.pokeball, width: 30, height: 30, color: pokeType.color.withOpacity(0.5), ), ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( "${getEnumValue(pokeType.type)[0].toUpperCase() + getEnumValue(pokeType.type).substring(1)} Type " "Items"), ) ], ); }, canTapOnHeader: true, body: Text("Under development"), isExpanded: _isOpen[1], ); } Widget _buildTypePanelList(List<Pokemon> pokemons) => ExpansionPanelList( animationDuration: const Duration(milliseconds: 500), children: [ _buildTypePokemonPanel(pokemons), _buildTypeItemsPanel(), ], expansionCallback: (i, isOpen) => setState(() => _isOpen[i] = !isOpen), ); Widget _buildError() => Container( padding: EdgeInsets.only(bottom: 28), alignment: Alignment.center, child: Icon( Icons.warning_amber_rounded, size: 60, color: Colors.black26, ), ); @override Widget build(BuildContext context) { return ListView( physics: BouncingScrollPhysics(), controller: widget.scroller, children: [ Padding( padding: EdgeInsets.only(top: 10), child: Container( alignment: Alignment.center, child: TypeDisplayContainer( index: widget.index, path: "name", value: null, width: 200.0, j: null, height: 70, typeList: [], )), //type_card ), Center( child: Container( margin: EdgeInsets.only(top: 20), height: 1, width: widget.width / 1.7, color: Colors.black12, ), ), if (pokeType.superEffective.isNotEmpty) Column( crossAxisAlignment: CrossAxisAlignment.center, children: lister(widget.index, 2, widget.width, "Effective Against".toUpperCase()), ), Column( crossAxisAlignment: CrossAxisAlignment.center, children: lister(widget.index, 0.5, widget.width, "Weak Against".toUpperCase()), ), Column( crossAxisAlignment: CrossAxisAlignment.center, children: lister(widget.index, 1, widget.width, "Normal Against".toUpperCase()), ), if (pokeType.nilEffective.isNotEmpty) Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: lister(widget.index, 0, widget.width, "No Effect Against".toUpperCase()), ), BlocBuilder<PokemonBloc, PokemonState>(builder: (_, state) { if (state.error != null) { return _buildError(); } return _buildTypePanelList(state.pokemons); }), ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/modal_draggable.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/ui/screens/types/modal_contents.dart'; // Class responsible for generating the modal page when clicked on a type class ModalDraggable extends StatelessWidget { const ModalDraggable({ Key? key, required this.width, required this.index, }) : super(key: key); final double width; final int index; @override Widget build(BuildContext context) { return DraggableScrollableSheet( initialChildSize: 0.25, maxChildSize: 0.92, expand: false, builder: (b, s) { return Container( decoration: BoxDecoration( color: Theme.of(context).backgroundColor, borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))), child: Stack( children: [ Align( child: Image( image: AppImages.pokeball, width: width / 2, height: width / 2, color: AppColors.black.withOpacity(0.1), ), ), ModalContents(index: index, width: width, scroller: s), //type_listview ], ), ); }); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/type_grid.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/types.dart'; import 'modal_sheet.dart'; // Class responsible for creating the grid of pokeballs that consists of the respective types class TypeEffectGrid extends StatelessWidget { @override Widget build(BuildContext context) { final w = MediaQuery.of(context).size.width; return Builder(builder: (context) { return CustomScrollView( slivers: [ SliverPadding( padding: EdgeInsets.all(10), sliver: SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, crossAxisSpacing: 10, mainAxisSpacing: 10, ), delegate: SliverChildBuilderDelegate( (_, index) => ModalSheet( width: w, index: index, ), childCount: types.length, ), ), ), ], ); }); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/type_entities/type_funcs.dart
import 'package:pokedex/configs/types.dart'; import 'package:pokedex/ui/screens/types/type_entities/type_constants.dart'; // A function that returns a list of types of pokemon that when attacked to, hit normally List<String> normalTypeReturner(List<String> combined) { var normalSet = typeNames.toSet(); // Create a set from the constant list of types for (var i = 0; i < combined.length; i++) { if (normalSet.contains(combined[i].toLowerCase())) { normalSet.remove(combined[i].toLowerCase()); } } // Removes the types that are already present as super/weak/nil effective from the set return normalSet.toList(); } // A function that return the required list depending on the number given List<String> effectreturner(int i, dynamic n) { if (n == 0) { return types[i].nilEffective; } else if (n == 1) { return normalTypeReturner( types[i].nilEffective + types[i].superEffective + types[i].notEffective); } else if (n == 0.5) { return types[i].notEffective; } else { return types[i].superEffective; } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/type_entities/type_constants.dart
// A list of types in the world of Pokemon const List<String> typeNames = [ "normal", "fire", "water", "electric", "grass", "ice", "fighting", "poison", "ground", "flying", "psychic", "bug", "rock", "ghost", "dragon", "dark", "steel", "fairy" ]; // A map that consists of types and it's indices const Map<String, int> typeIndices = { "normal": 0, "fire": 1, "water": 2, "electric": 3, "grass": 4, "ice": 5, "fighting": 6, "poison": 7, "ground": 8, "flying": 9, "psychic": 10, "bug": 11, "rock": 12, "ghost": 13, "dragon": 14, "dark": 15, "steel": 16, "fairy": 17 };
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types
mirrored_repositories/flutter_Pokedex/lib/ui/screens/types/type_entities/widget_list.dart
import 'package:flutter/material.dart'; import 'package:pokedex/ui/screens/types/type_container.dart'; import 'package:pokedex/ui/screens/types/type_entities/type_funcs.dart'; // A function that return a list of widgets that are used in displaying the effectiveness List<Widget> lister(int index, dynamic value, double width, String term) { var arr = effectreturner(index, value); return [ Container( alignment: Alignment.centerLeft, child: Padding( padding: const EdgeInsets.all(8), child: Text( term, textAlign: TextAlign.left, style: TextStyle( fontSize: 16, // color: Colors.black54, ), ), ), ), Container( alignment: Alignment.topCenter, padding: const EdgeInsets.only(left: 8.0, top: 8), width: width * 0.75, child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, alignment: WrapAlignment.center, children: [ for (int j = 0; j < arr.length; j++) Padding( padding: const EdgeInsets.only(top: 8.0), child: TypeDisplayContainer( index: index, path: "effects", value: value, width: 75.0, j: j, height: 25, typeList: arr, ), ) ], )), Container( margin: EdgeInsets.only(top: 20), height: 1, width: width / 1.7, color: Colors.black12, ), ]; }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex/pokedex.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/durations.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/core/extensions/animation.dart'; import 'package:pokedex/domain/entities/pokemon.dart'; import 'package:pokedex/routes.dart'; import 'package:pokedex/states/pokemon/pokemon_bloc.dart'; import 'package:pokedex/states/pokemon/pokemon_event.dart'; import 'package:pokedex/states/pokemon/pokemon_selector.dart'; import 'package:pokedex/states/pokemon/pokemon_state.dart'; import 'package:pokedex/ui/modals/generation_modal.dart'; import 'package:pokedex/ui/modals/search_modal.dart'; import 'package:pokedex/ui/widgets/pokemon_card.dart'; import 'package:pokedex/ui/widgets/animated_overlay.dart'; import 'package:pokedex/ui/widgets/fab.dart'; import 'package:pokedex/ui/widgets/main_app_bar.dart'; import 'package:pokedex/ui/widgets/pokeball_background.dart'; import 'package:pokedex/ui/widgets/pokemon_refresh_control.dart'; part 'sections/fab_menu.dart'; part 'sections/pokemon_grid.dart'; class PokedexScreen extends StatefulWidget { const PokedexScreen(); @override State<StatefulWidget> createState() => _PokedexScreenState(); } class _PokedexScreenState extends State<PokedexScreen> { @override Widget build(BuildContext context) { return PokeballBackground( child: Stack( children: [ _PokemonGrid(), _FabMenu(), ], ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex/widgets/generation_card.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/domain/entities/generation.dart'; import '../../../../states/theme/theme_cubit.dart'; class GenerationCard extends StatelessWidget { const GenerationCard(this.generation); final Generation generation; @override Widget build(BuildContext context) { var themeCubit = BlocProvider.of<ThemeCubit>(context, listen: true); var isDark = themeCubit.isDark; return LayoutBuilder(builder: (context, constraints) { final height = constraints.maxHeight; return Container( decoration: BoxDecoration( color: isDark ? Colors.black87 : Colors.white, borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( offset: Offset(0, 8), blurRadius: 15, color: AppColors.black.withOpacity(0.12), ), ], ), child: Stack( children: <Widget>[ Container( constraints: BoxConstraints.expand(), padding: EdgeInsets.all(16), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( generation.title, style: TextStyle(fontWeight: FontWeight.bold), ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: generation.pokemons .map( (pokemon) => Expanded( child: Image.asset( pokemon, fit: BoxFit.contain, width: height * 0.41, height: height * 0.41, ), ), ) .toList(), ), ], ), ), Positioned( bottom: -height * 0.136, right: -height * 0.03, child: Image( image: AppImages.pokeball, width: height * 0.754, height: height * 0.754, color: AppColors.black.withOpacity(0.05), ), ), ], ), ); }); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex/sections/pokemon_grid.dart
part of '../pokedex.dart'; class _PokemonGrid extends StatefulWidget { const _PokemonGrid(); @override _PokemonGridState createState() => _PokemonGridState(); } class _PokemonGridState extends State<_PokemonGrid> { static const double _endReachedThreshold = 200; final GlobalKey<NestedScrollViewState> _scrollKey = GlobalKey(); PokemonBloc get pokemonBloc => context.read<PokemonBloc>(); @override void initState() { super.initState(); scheduleMicrotask(() { pokemonBloc.add(PokemonLoadStarted()); _scrollKey.currentState?.innerController.addListener(_onScroll); }); } @override void dispose() { _scrollKey.currentState?.innerController.dispose(); _scrollKey.currentState?.dispose(); super.dispose(); } void _onScroll() { final innerController = _scrollKey.currentState?.innerController; if (innerController == null || !innerController.hasClients) return; final thresholdReached = innerController.position.extentAfter < _endReachedThreshold; if (thresholdReached) { // Load more! pokemonBloc.add(PokemonLoadMoreStarted()); } } Future _onRefresh() async { pokemonBloc.add(PokemonLoadStarted()); return pokemonBloc.stream.firstWhere((e) => e.status != PokemonStateStatus.loading); } void _onPokemonPress(Pokemon pokemon) { pokemonBloc.add(PokemonSelectChanged(pokemonId: pokemon.number)); AppNavigator.push(Routes.pokemonInfo, pokemon); } @override Widget build(BuildContext context) { return NestedScrollView( key: _scrollKey, headerSliverBuilder: (_, __) => [ MainSliverAppBar( context: context, ), ], body: PokemonStateStatusSelector((status) { switch (status) { case PokemonStateStatus.loading: return _buildLoading(); case PokemonStateStatus.loadSuccess: case PokemonStateStatus.loadMoreSuccess: case PokemonStateStatus.loadingMore: return _buildGrid(); case PokemonStateStatus.loadFailure: case PokemonStateStatus.loadMoreFailure: return _buildError(); default: return Container(); } }), ); } Widget _buildLoading() { return Center( child: Image(image: AppImages.pikloader), ); } Widget _buildGrid() { return CustomScrollView( slivers: [ PokemonRefreshControl(onRefresh: _onRefresh), SliverPadding( padding: EdgeInsets.all(28), sliver: NumberOfPokemonsSelector((numberOfPokemons) { return SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 1.4, crossAxisSpacing: 10, mainAxisSpacing: 10, ), delegate: SliverChildBuilderDelegate( (_, index) { return PokemonSelector(index, (pokemon, _) { return PokemonCard( pokemon, onPress: () => _onPokemonPress(pokemon), ); }); }, childCount: numberOfPokemons, ), ); }), ), SliverToBoxAdapter( child: PokemonCanLoadMoreSelector((canLoadMore) { if (!canLoadMore) { return SizedBox.shrink(); } return Container( padding: EdgeInsets.only(bottom: 28), alignment: Alignment.center, child: Image(image: AppImages.pikloader), ); }), ), ], ); } Widget _buildError() { return CustomScrollView( slivers: [ PokemonRefreshControl(onRefresh: _onRefresh), SliverFillRemaining( child: Container( padding: EdgeInsets.only(bottom: 28), alignment: Alignment.center, child: Icon( Icons.warning_amber_rounded, size: 60, color: Colors.black26, ), ), ), ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex
mirrored_repositories/flutter_Pokedex/lib/ui/screens/pokedex/sections/fab_menu.dart
part of '../pokedex.dart'; class _FabMenu extends StatefulWidget { const _FabMenu(); @override State<_FabMenu> createState() => _FabMenuState(); } class _FabMenuState extends State<_FabMenu> with SingleTickerProviderStateMixin { late AnimationController _fabController; late Animation<double> _fabAnimation; bool _isFabMenuVisible = false; @override void initState() { _fabController = AnimationController( vsync: this, duration: animationDuration, ); _fabAnimation = _fabController.curvedTweenAnimation( begin: 0.0, end: 1.0, ); super.initState(); } @override void dispose() { _fabController.dispose(); super.dispose(); } void _toggleFabMenu() { _isFabMenuVisible = !_isFabMenuVisible; if (_isFabMenuVisible) { _fabController.forward(); } else { _fabController.reverse(); } } void _showSearchModal() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) => SearchBottomModal(), ); } void _showGenerationModal() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) => GenerationModal(), ); } void onPress([Function? callback]) { _toggleFabMenu(); callback?.call(); } @override Widget build(BuildContext context) { final safeAreaBottom = MediaQuery.of(context).padding.bottom; return AnimatedOverlay( animation: _fabAnimation, color: Colors.black, onPress: _toggleFabMenu, child: Container( alignment: Alignment.bottomRight, padding: EdgeInsets.only(right: 26, bottom: 26 + safeAreaBottom), child: ExpandedAnimationFab( animation: _fabAnimation, onPress: _toggleFabMenu, items: [ FabItemData( 'Favourite Pokemon', Icons.favorite, onPress: () => onPress(), ), FabItemData( 'All Type', Icons.filter_vintage, onPress: () => onPress(), ), FabItemData( 'All Gen', Icons.flash_on, onPress: () => onPress(_showGenerationModal), ), FabItemData( 'Search', Icons.search, onPress: () => onPress(_showSearchModal), ), ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items/items.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/durations.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/core/extensions/animation.dart'; import 'package:pokedex/states/item/item_bloc.dart'; import 'package:pokedex/states/item/item_event.dart'; import 'package:pokedex/states/item/item_selector.dart'; import 'package:pokedex/states/item/item_state.dart'; import 'package:pokedex/ui/modals/generation_modal.dart'; import 'package:pokedex/ui/modals/search_modal.dart'; import 'package:pokedex/ui/widgets/animated_overlay.dart'; import 'package:pokedex/ui/widgets/fab.dart'; import 'package:pokedex/ui/widgets/main_app_bar.dart'; import 'package:pokedex/ui/widgets/pokeball_background.dart'; import 'package:pokedex/ui/widgets/pokemon_refresh_control.dart'; import 'widgets/item_card.dart'; part 'sections/fab_menu.dart'; part 'sections/items_grid.dart'; class ItemsScreen extends StatefulWidget { const ItemsScreen(); @override _ItemsScreenState createState() => _ItemsScreenState(); } class _ItemsScreenState extends State<ItemsScreen> { @override Widget build(BuildContext context) { return PokeballBackground( child: Stack( children: [ _ItemGrid(), ], ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items/widgets/item_category.dart
import 'package:flutter/material.dart'; import 'package:pokedex/core/extensions/context.dart'; import 'package:pokedex/ui/widgets/spacer.dart'; class ItemCategory extends StatelessWidget { const ItemCategory( this.name, { Key? key, }) : super(key: key); final String name; @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(top: 3), child: Material( color: Colors.transparent, child: Container( padding: EdgeInsets.symmetric( horizontal: 12, vertical: context.responsive(4), ), decoration: ShapeDecoration( shape: StadiumBorder(), color: Colors.white.withOpacity(0.2), ), child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Text( name, textScaleFactor: 1, style: TextStyle( fontSize: 10, height: 0.8, fontWeight: FontWeight.normal, color: Colors.white, ), textAlign: TextAlign.center, ), HSpacer(5), ], ), ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items/widgets/item_card.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/domain/entities/item.dart'; import 'package:pokedex/core/extensions/context.dart'; import 'package:pokedex/ui/widgets/spacer.dart'; import '../../../../states/theme/theme_cubit.dart'; import 'item_category.dart'; class ItemCard extends StatelessWidget { static const double _pokeballFraction = 0.60; static const double _itemFraction = 0.61; const ItemCard( this.item, { this.onPress, required this.index, }); final int index; final Function()? onPress; final Item item; Widget _buildPokeballDecoration({required double height}) { final pokeballSize = height * _pokeballFraction; return Positioned( bottom: -height * 0.13, right: -height * 0.03, child: Image( image: AppImages.pokeball, width: pokeballSize, height: pokeballSize, color: Colors.white.withOpacity(0.14), ), ); } Widget _buildItem({required double height}) { final itemSize = height * _itemFraction; return Positioned( bottom: -2, right: 2, child: Hero( tag: item.image, child: CachedNetworkImage( imageUrl: item.image, width: itemSize, height: itemSize, // imageRenderMethodForWeb: ImageRenderMethodForWeb.HtmlImage, useOldImageOnUrlChange: true, fit: BoxFit.contain, alignment: Alignment.bottomRight, placeholder: (context, url) => Image( image: AppImages.bulbasaur, width: itemSize, height: itemSize, color: Colors.black12, ), errorWidget: (_, __, error) => Stack( alignment: Alignment.center, children: [ Image( image: AppImages.bulbasaur, width: itemSize, height: itemSize, color: Colors.black12, ), Icon( Icons.warning_amber_rounded, size: itemSize * 0.4, color: Colors.black45, ), ], ), ), ), ); } @override Widget build(BuildContext context) { var themeCubit = BlocProvider.of<ThemeCubit>(context, listen: true); var isDark = themeCubit.isDark; return LayoutBuilder( builder: (context, constrains) { final itemHeight = constrains.maxHeight; return Container( decoration: BoxDecoration( color: isDark ? Colors.black12 : AppColors.grey, borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( color: AppColors.grey.withOpacity(0.12), blurRadius: 30, offset: Offset(0, 8), ), ], ), child: ClipRRect( borderRadius: BorderRadius.circular(15), child: Material( color: AppColors.grey, child: InkWell( onTap: onPress, splashColor: Colors.white10, highlightColor: Colors.white10, child: Stack( children: [ _buildPokeballDecoration(height: itemHeight), _buildItem(height: itemHeight), _CardContent(item), ], ), ), ), ), ); }, ); } } class _CardContent extends StatelessWidget { const _CardContent(this.item, {Key? key}) : super(key: key); final Item item; Widget _buildCategory(BuildContext context) { return Padding( padding: EdgeInsets.only( left: context.responsive(3), right: context.responsive(3), ), child: ItemCategory(item.category), ); } @override Widget build(BuildContext context) { return Align( alignment: Alignment.centerLeft, child: Padding( padding: EdgeInsets.only( left: 16, right: 16, top: context.responsive(24), bottom: context.responsive(16), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: <Widget>[ Hero( tag: item.name, child: Text( item.name, style: TextStyle( fontSize: 14, height: 0.7, fontWeight: FontWeight.bold, color: Colors.white, ), ), ), VSpacer(context.responsive(10)), _buildCategory(context), ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items/sections/fab_menu.dart
part of '../items.dart'; class _FabMenu extends StatefulWidget { const _FabMenu(); @override State<_FabMenu> createState() => _FabMenuState(); } class _FabMenuState extends State<_FabMenu> with SingleTickerProviderStateMixin { late AnimationController _fabController; late Animation<double> _fabAnimation; bool _isFabMenuVisible = false; @override void initState() { _fabController = AnimationController( vsync: this, duration: animationDuration, ); _fabAnimation = _fabController.curvedTweenAnimation( begin: 0.0, end: 1.0, ); super.initState(); } @override void dispose() { _fabController.dispose(); super.dispose(); } void _toggleFabMenu() { _isFabMenuVisible = !_isFabMenuVisible; if (_isFabMenuVisible) { _fabController.forward(); } else { _fabController.reverse(); } } void _showSearchModal() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) => SearchBottomModal(), ); } void _showGenerationModal() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) => GenerationModal(), ); } void onPress([Function? callback]) { _toggleFabMenu(); callback?.call(); } @override Widget build(BuildContext context) { final safeAreaBottom = MediaQuery.of(context).padding.bottom; return AnimatedOverlay( animation: _fabAnimation, color: Theme.of(context).backgroundColor, onPress: _toggleFabMenu, child: Container( alignment: Alignment.bottomRight, padding: EdgeInsets.only(right: 26, bottom: 26 + safeAreaBottom), child: ExpandedAnimationFab( animation: _fabAnimation, onPress: _toggleFabMenu, items: [ FabItemData( 'Favourite Pokemon', Icons.favorite, onPress: () => onPress(), ), FabItemData( 'All Type', Icons.filter_vintage, onPress: () => onPress(), ), FabItemData( 'All Gen', Icons.flash_on, onPress: () => onPress(_showGenerationModal), ), FabItemData( 'Search', Icons.search, onPress: () => onPress(_showSearchModal), ), ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items
mirrored_repositories/flutter_Pokedex/lib/ui/screens/items/sections/items_grid.dart
part of '../items.dart'; class _ItemGrid extends StatefulWidget { const _ItemGrid(); @override _ItemGridState createState() => _ItemGridState(); } class _ItemGridState extends State<_ItemGrid> { static const double _endReachedThreshold = 200; final GlobalKey<NestedScrollViewState> _scrollKey = GlobalKey(); ItemBloc get itemBloc => context.read<ItemBloc>(); @override void initState() { super.initState(); scheduleMicrotask(() { itemBloc.add(ItemLoadStarted()); _scrollKey.currentState?.innerController.addListener(_onScroll); }); } @override void dispose() { _scrollKey.currentState?.innerController.dispose(); _scrollKey.currentState?.dispose(); super.dispose(); } void _onScroll() { final innerController = _scrollKey.currentState?.innerController; if (innerController == null || !innerController.hasClients) return; final thresholdReached = innerController.position.extentAfter < _endReachedThreshold; if (thresholdReached) { // Load more! itemBloc.add(ItemLoadMoreStarted()); } } Future _onRefresh() async { itemBloc.add(ItemLoadStarted()); return itemBloc.stream.firstWhere((e) => e.status != ItemStateStatus.loading); } @override Widget build(BuildContext context) { return NestedScrollView( key: _scrollKey, headerSliverBuilder: (_, __) => [ MainSliverAppBar(context: context), ], body: ItemStateStatusSelector((status) { switch (status) { case ItemStateStatus.loading: return _buildLoading(); case ItemStateStatus.loadSuccess: case ItemStateStatus.loadMoreSuccess: case ItemStateStatus.loadingMore: return _buildGrid(); case ItemStateStatus.loadFailure: case ItemStateStatus.loadMoreFailure: return _buildError(); default: return Container(); } }), ); } Widget _buildLoading() { return Center( child: Image(image: AppImages.pikloader), ); } Widget _buildGrid() { return CustomScrollView( slivers: [ PokemonRefreshControl(onRefresh: _onRefresh), SliverPadding( padding: EdgeInsets.all(28), sliver: NumberOfItemsSelector((numberOfItems) { return SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 1.4, crossAxisSpacing: 10, mainAxisSpacing: 10, ), delegate: SliverChildBuilderDelegate( (_, index) { return ItemSelector(index, (item, _) { return ItemCard( item, index: index, // onPress: () => _onItemPress(item), ); }); }, childCount: numberOfItems, ), ); }), ), SliverToBoxAdapter( child: ItemCanLoadMoreSelector((canLoadMore) { if (!canLoadMore) { return SizedBox.shrink(); } return Container( padding: EdgeInsets.only(bottom: 28), alignment: Alignment.center, child: Image(image: AppImages.pikloader), ); }), ), ], ); } Widget _buildError() { return CustomScrollView( slivers: [ PokemonRefreshControl(onRefresh: _onRefresh), SliverFillRemaining( child: Container( padding: EdgeInsets.only(bottom: 28), alignment: Alignment.center, child: Icon( Icons.warning_amber_rounded, size: 60, color: Colors.black26, ), ), ), ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home/home.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pokedex/configs/colors.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/data/categories.dart'; import 'package:pokedex/domain/entities/category.dart'; import 'package:pokedex/ui/widgets/search_bar.dart'; import 'package:pokedex/ui/widgets/pokeball_background.dart'; import 'package:pokedex/routes.dart'; import '../../../states/theme/theme_cubit.dart'; import 'widgets/news_card.dart'; import 'widgets/category_card.dart'; part 'sections/pokemon_news.dart'; part 'sections/header_card_content.dart'; class HomeScreen extends StatefulWidget { @override State<StatefulWidget> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { final ScrollController _scrollController = ScrollController(); bool showTitle = false; @override void initState() { _scrollController.addListener(_onScroll); super.initState(); } @override void dispose() { _scrollController.dispose(); super.dispose(); } void _onScroll() { if (!_scrollController.hasClients) return; final offset = _scrollController.offset; final showTitle = offset > _HeaderCardContent.height - kToolbarHeight; // Prevent unneccesary rebuild if (this.showTitle == showTitle) return; setState(() { this.showTitle = showTitle; }); } @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollView( controller: _scrollController, headerSliverBuilder: (_, __) => [ SliverAppBar( expandedHeight: _HeaderCardContent.height, floating: true, pinned: true, elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(30), ), ), backgroundColor: AppColors.red, flexibleSpace: FlexibleSpaceBar( collapseMode: CollapseMode.pin, centerTitle: true, title: Visibility( visible: showTitle, child: Text( 'Pokedex', style: Theme.of(context) .appBarTheme .toolbarTextStyle! .copyWith(fontWeight: FontWeight.bold), ), ), background: _HeaderCardContent(), ), ), ], body: _PokemonNews(), ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home/widgets/category_card.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/domain/entities/category.dart'; class CategoryCard extends StatelessWidget { final Category category; final void Function()? onPress; const CategoryCard( this.category, { this.onPress, }); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constrains) { final itemHeight = constrains.maxHeight; final itemWidth = constrains.maxWidth; return Stack( children: <Widget>[ Align( alignment: Alignment.bottomCenter, child: _Shadows(color: category.color, width: itemWidth * 0.82), ), Material( color: category.color, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), clipBehavior: Clip.antiAlias, child: InkWell( splashColor: Colors.white10, highlightColor: Colors.white10, onTap: onPress, child: Stack( children: [ _buildPokeballDecoration(height: itemHeight), _buildCircleDecoration(height: itemHeight), _CardContent(category.name), ], ), ), ) ], ); }, ); } Widget _buildCircleDecoration({required double height}) { return Positioned( top: -height * 0.616, left: -height * 0.53, child: CircleAvatar( radius: (height * 1.03) / 2, backgroundColor: Colors.white.withOpacity(0.14), ), ); } Widget _buildPokeballDecoration({required double height}) { return Positioned( top: -height * 0.16, right: -height * 0.25, child: Image( image: AppImages.pokeball, width: height * 1.388, height: height * 1.388, color: Colors.white.withOpacity(0.14), ), ); } } class _CardContent extends StatelessWidget { const _CardContent(this.name); final String name; @override Widget build(BuildContext context) { return Container( alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(horizontal: 16.0), child: Text( name, style: TextStyle( fontSize: 14, fontWeight: FontWeight.bold, color: Colors.white, ), ), ); } } class _Shadows extends StatelessWidget { const _Shadows({required this.color, required this.width}); final Color color; final double width; @override Widget build(BuildContext context) { return Container( width: width * 0.82, height: 11, decoration: BoxDecoration( boxShadow: [ BoxShadow( color: color, offset: Offset(0, 3), blurRadius: 23, ), ], ), ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home/widgets/news_card.dart
import 'package:flutter/material.dart'; import 'package:pokedex/configs/colors.dart'; class NewsCard extends StatelessWidget { final ImageProvider thumbnail; final String time; final String title; const NewsCard({ required this.title, required this.time, required this.thumbnail, }); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: 28, vertical: 16), child: Row( mainAxisSize: MainAxisSize.max, children: <Widget>[ Expanded(child: _buildContent(context)), SizedBox(width: 36), Image(image: thumbnail, width: 110, height: 66), ], ), ); } Widget _buildContent(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( title, style: TextStyle( fontWeight: FontWeight.bold, ), ), SizedBox(height: 6), Text( time, style: TextStyle( fontSize: 10, color: AppColors.darkGrey, ), ), ], ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home/sections/pokemon_news.dart
part of '../home.dart'; class _PokemonNews extends StatelessWidget { const _PokemonNews(); @override Widget build(BuildContext context) { return ListView( physics: ClampingScrollPhysics(), children: <Widget>[ _buildHeader(context), _buildNews(), ], ); } Widget _buildHeader(BuildContext context) { return Padding( padding: EdgeInsets.fromLTRB(28, 0, 28, 22), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( 'Pokémon News', style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, ), ), Text( 'View All', style: TextStyle( fontSize: 14, fontWeight: FontWeight.w500, color: AppColors.indigo, ), ), ], ), ); } Widget _buildNews() { return ListView.separated( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: 9, separatorBuilder: (context, index) => Divider(), itemBuilder: (context, index) { return NewsCard( title: 'Pokémon Rumble Rush Arrives Soon', time: '15 May 2019', thumbnail: AppImages.thumbnail, ); }, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home
mirrored_repositories/flutter_Pokedex/lib/ui/screens/home/sections/header_card_content.dart
part of '../home.dart'; class _HeaderCardContent extends StatelessWidget { static const double height = 582; void _onSelectCategory(Category category) { AppNavigator.push(category.route); } @override Widget build(BuildContext context) { var themeCubit = BlocProvider.of<ThemeCubit>(context, listen: true); var isDark = themeCubit.isDark; return Container( clipBehavior: Clip.hardEdge, decoration: BoxDecoration( // color: Colors.white, borderRadius: BorderRadius.vertical(bottom: Radius.circular(30)), // border: Border( // bottom: BorderSide( // color: Colors.white, // ), // ), ), child: PokeballBackground( child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ SafeArea( child: Align( alignment: Alignment.topLeft, child: IconButton( onPressed: () { // Function to toggle theme themeCubit.toggleTheme(); }, padding: EdgeInsets.only( left: 28, ), icon: Icon( isDark ? Icons.wb_sunny_outlined : Icons.dark_mode_outlined, color: isDark ? Colors.yellow : Colors.black, size: 25, )), ), ), _buildTitle(), SearchBar(), _buildCategories(context), ], ), ), ); } Widget _buildTitle() { return Expanded( child: Container( constraints: BoxConstraints.expand(), padding: EdgeInsets.all(28), alignment: Alignment.bottomLeft, child: Text( 'What Pokemon\nare you looking for?', style: TextStyle( fontSize: 30, height: 1.6, fontWeight: FontWeight.w900, ), ), ), ); } Widget _buildCategories(BuildContext context) { return GridView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.fromLTRB(28, 42, 28, 62), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 10, childAspectRatio: 2.6, mainAxisSpacing: 15, ), itemCount: categories.length, itemBuilder: (context, index) { return CategoryCard( categories[index], onPress: () => _onSelectCategory(categories[index]), ); }, ); } }
0
mirrored_repositories/flutter_Pokedex/lib/ui/screens
mirrored_repositories/flutter_Pokedex/lib/ui/screens/splash/splash.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:pokedex/configs/images.dart'; import 'package:pokedex/routes.dart'; class SplashScreen extends StatefulWidget { @override State<StatefulWidget> createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { static const double _splashIconSize = 50; @override void initState() { scheduleMicrotask(() async { await AppImages.precacheAssets(context); await Future.delayed(Duration(milliseconds: 400)); await AppNavigator.replaceWith(Routes.home); }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image( image: AppImages.pikloader, width: _splashIconSize, height: _splashIconSize, fit: BoxFit.contain, ), Text( 'Pokedex', textAlign: TextAlign.center, style: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, ), ) ], ), ), ); } }
0
mirrored_repositories/flutter_Pokedex
mirrored_repositories/flutter_Pokedex/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_test/flutter_test.dart'; void main() { testWidgets('Some testcase', (WidgetTester tester) async { expect(true, isTrue); }); }
0
mirrored_repositories/flutter_background_sandbox
mirrored_repositories/flutter_background_sandbox/lib/main.dart
import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Background', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { void startServiceInPlatform() async { if (Platform.isAndroid) { var methodChannel = MethodChannel("com.lambiengcode.messages"); String data = await methodChannel.invokeMethod("startService"); debugPrint(data); } } @override Widget build(BuildContext context) { return Container( color: Colors.white, child: Center( child: RaisedButton( child: Text("Start Background"), onPressed: () { startServiceInPlatform(); }), ), ); } }
0
mirrored_repositories/flutter_background_sandbox
mirrored_repositories/flutter_background_sandbox/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:background_service/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/Astralis
mirrored_repositories/Astralis/lib/main.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'screens/homepage.dart'; import 'screens/sign_up_page.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Healthrific', theme: ThemeData( primaryColor:Color(0xff44337b), accentColor:Color(0xffebeafd), visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'Healthrific'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { bool isSignedIn; @override void didChangeDependencies() async { // TODO: implement didChangeDependencies SharedPreferences prefs = await SharedPreferences.getInstance(); isSignedIn = prefs.getBool('SignedIn'); super.didChangeDependencies(); } @override Widget build(BuildContext context) { return FutureBuilder<FirebaseUser>( future: FirebaseAuth.instance.currentUser(), builder: (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot){ if (snapshot.hasData){ FirebaseUser user = snapshot.data; // this is your user instance return HomePage(); } /// other way there is no user logged. return SignUpPage(); } ); } }
0
mirrored_repositories/Astralis
mirrored_repositories/Astralis/lib/sizeconfig.dart
import 'package:flutter/widgets.dart'; class SizeConfig { static MediaQueryData _mediaQueryData; static double screenWidth; static double screenHeight; static double blockSizeHorizontal; static double blockSizeVertical; void init(BuildContext context) { _mediaQueryData = MediaQuery.of(context); screenWidth = _mediaQueryData.size.width; screenHeight = _mediaQueryData.size.height; blockSizeHorizontal = screenWidth / 100; blockSizeVertical = screenHeight / 100; } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/models/health_cardview.dart
import 'package:flutter/cupertino.dart'; class Health_card { final String title; final int id; final AssetImage tipImage; final String url; Health_card(this.title,this.id,this.tipImage,this.url); }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/elements/covid_info_model.dart
class GlobalInfo { var cases; var deaths; var recovered; var active; var critical; var affectedCountries; GlobalInfo({this.cases,this.deaths,this.recovered,this.active,this.critical,this.affectedCountries}); factory GlobalInfo.fromJson(final json) { return GlobalInfo( cases:json["cases"], deaths : json["deaths"], recovered : json["recovered"], active : json["active"], critical: json['critical'], affectedCountries: json['affectedCountries'] ); } } class CountryInfo { var cases; var deaths; var recovered; var active; var critical; CountryInfo({this.cases,this.deaths,this.recovered,this.active,this.critical,}); factory CountryInfo.fromJson(final json) { return CountryInfo( cases:json["cases"], deaths : json["deaths"], recovered : json["recovered"], active : json["active"], critical: json['critical'], ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/elements/auth_elements.dart
String validateEmail(String value) { Pattern pattern = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'; RegExp regex = new RegExp(pattern); if (!regex.hasMatch(value)) return 'Enter a valid Email Address'; else return null; } String validateName(String value){ if(value.length < 6) return 'Name too short, minimum length is 6'; else return null; } String validatePassword(String value){ if(value.length < 6) return 'Password is too short, minimum length is 6'; else return null; }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/elements/user.dart
class User { final String uid; User({ this.uid }); }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/services/auth.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:healthrific/elements/user.dart'; class AuthService{ final FirebaseAuth _auth = FirebaseAuth.instance; User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid) : null; } Future signInWithEmailAndPassword(String email, String password) async { try { AuthResult result = await _auth.signInWithEmailAndPassword(email: email, password: password); FirebaseUser user = result.user; return user; } catch (error) { print(error.toString()); return null; } } Future registerWithEmailAndPassword(String name, String email, String password) async { try { AuthResult result = await _auth.createUserWithEmailAndPassword(email: email, password: password); UserUpdateInfo updateInfo= UserUpdateInfo(); updateInfo.displayName=name; FirebaseUser user = result.user; user.updateProfile(updateInfo); return _userFromFirebaseUser(user); } catch (error) { print(error.toString()); return null; } } Future signOut() async { try { return await _auth.signOut(); } catch (error) { print(error.toString()); return null; } } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/services/covid_info_api.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:healthrific/elements/covid_info_model.dart'; class Info{ final String url = "https://disease.sh/v2/all"; Future<GlobalInfo> getGlobalJsonData() async { var response = await http.get( Uri.encodeFull(url), ); if (response.statusCode == 200) { final convertDataJson = jsonDecode(response.body); return GlobalInfo.fromJson(convertDataJson); } else { throw Exception('Something went wrong! Try again later'); } } Future<CountryInfo> getCountryJsonData(country) async { var response = await http.get( Uri.encodeFull("https://disease.sh/v2/countries/$country?yesterday=false"), ); if (response.statusCode == 200) { final convertDataJson = jsonDecode(response.body); return CountryInfo.fromJson(convertDataJson); } else { throw Exception('Something went wrong! Try again later'); } } } class CountryInfoWidget extends StatefulWidget { final String country; const CountryInfoWidget({this.country}); @override _CountryInfoWidgetState createState() => _CountryInfoWidgetState(); } class _CountryInfoWidgetState extends State<CountryInfoWidget> { @override Widget build(BuildContext context) { return FutureBuilder( future: Info().getCountryJsonData(widget.country), builder: (context, snapshot) { if(snapshot.hasData){ return Padding( padding: const EdgeInsets.all(8.0), child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Text(widget.country), Text('${snapshot.data.cases}',textAlign: TextAlign.start,) ], ), ); }else return CircularProgressIndicator(); }, ); } } class GlobalInfoWidget extends StatelessWidget{ final int snapshotData; final String title; const GlobalInfoWidget({@required this.snapshotData, @required this.title}); @override Widget build(BuildContext context) { return Column( children: <Widget>[ Text( title, style: TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.bold), ), Text('$snapshotData'), ], ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/reset_password.dart
import 'package:flutter/material.dart'; import 'package:healthrific/elements/auth_elements.dart'; import 'package:healthrific/sizeconfig.dart'; class ResetPasswordPage extends StatefulWidget { @override _ResetPasswordPageState createState() => _ResetPasswordPageState(); } class _ResetPasswordPageState extends State<ResetPasswordPage> { final TextEditingController _emailController = TextEditingController(); final _formKey2 = GlobalKey<FormState>(); bool submitted = false; @override Widget build(BuildContext context) { SizeConfig().init(context); return Scaffold( appBar: AppBar( elevation: 0.0, backgroundColor: Colors.white, ), body: Container( padding: EdgeInsets.all(10.0), child: Column(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'Reset Password', textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 28, color: Theme.of(context).primaryColor, ), ), SizedBox(height: 20.0), Padding( padding: EdgeInsets.all(10.0), child: Form( key: _formKey2, autovalidate: false, child: Column( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Row( children: <Widget>[ SizedBox( width: 14.0, ), Icon(Icons.email), SizedBox( width: 14.0, ), Expanded( child: TextFormField( validator:validateEmail, controller: _emailController, decoration: InputDecoration( hintText: 'Email Address', border: InputBorder.none), )), SizedBox( width: 14.0, ), ], ), ), SizedBox(height: 20.0), Container( padding: EdgeInsets.only(bottom: 10, top: 20), width: SizeConfig.blockSizeHorizontal * 48, child: FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0)), textColor: Colors.white, color: Theme.of(context).primaryColor, child: submitted ? Text('Email sent. Send Again!') : Text('Reset Password'), onPressed: () { if(_formKey2.currentState.validate()){ setState(() { submitted = true; print(submitted); }); } }, ), ), ], ), ), ), ], ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/healthtipselectpage.dart
import 'dart:async'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:healthrific/models/health_cardview.dart'; import 'package:webview_flutter/webview_flutter.dart'; class HealthTipsSelectPage extends StatelessWidget{ final Health_card health_card; HealthTipsSelectPage({Key key,@required this.health_card}) : super(key: key); Completer<WebViewController> _controller = Completer<WebViewController>(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(health_card.title), ), body: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, child: WebView( initialUrl: health_card.url, javascriptMode: JavascriptMode.unrestricted, onWebViewCreated: (WebViewController webViewController){ _controller.complete(webViewController); }, onPageStarted: (String url) { print('Page started loading: $url'); }, onPageFinished: (String url) { print('Page finished loading: $url'); }, gestureNavigationEnabled: true, ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/selftest.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:healthrific/screens/homepage.dart'; var finalScore = 0; var questionNumber = 0; var quiz = new Quiz(); class Quiz { var questions = [ "Are you experiencing any of the following symptoms?", "Have you ever had any of the following?", "Have you travelled anywhere internationally in the last 28-45 days?", "Which of the following apply to you?", ]; var choices = [ ["Cough", "Fever", "Difficulty in breathing", "None of the above"], [ "Diabetes", "Hypertension", "Lung disease", "None of the above" ], ["Yes", "No","",""], [ "I have recently interacted with a person tested COVID-19 positive.", "I'm a health care worker and examined a person without protection who was tested COVID-19 positive.", "None of the above","" ] ]; } class SelfTest extends StatefulWidget { @override State<StatefulWidget> createState() { return new Quiz1State(); } } class Quiz1State extends State<SelfTest> { @override Widget build(BuildContext context) { return new WillPopScope( onWillPop: () async => false, child: Scaffold( body: new Container( margin: const EdgeInsets.all(10.0), alignment: Alignment.topCenter, child: new Column( children: <Widget>[ new Padding(padding: EdgeInsets.all(20.0)), new Container( alignment: Alignment.centerRight, child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text( "Question ${questionNumber + 1} of ${quiz.questions.length}", style: new TextStyle(fontSize: 22.0), ), ], ), ), new Padding(padding: EdgeInsets.all(10.0)), new Text( quiz.questions[questionNumber], style: new TextStyle( fontSize: 20.0, ), ), new Padding(padding: EdgeInsets.all(10.0)), new Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ //button 1 new MaterialButton( minWidth: 120.0, color: Colors.blueGrey, onPressed: () { if (quiz.choices[questionNumber][0] != "None of the above") { debugPrint("Correct"); finalScore++; } else { debugPrint("Wrong"); } updateQuestion(); }, child: new Text( quiz.choices[questionNumber][0], style: new TextStyle(fontSize: 20.0, color: Colors.white), ), ), new Padding(padding: EdgeInsets.all(10.0)), //button 2 new MaterialButton( minWidth: 120.0, color: Colors.blueGrey, onPressed: () { if (quiz.choices[questionNumber][1] != "None of the above") { debugPrint("Correct"); finalScore++; } else { debugPrint("Wrong"); } updateQuestion(); }, child: new Text( quiz.choices[questionNumber][1], style: new TextStyle(fontSize: 20.0, color: Colors.white), ), ), ], ), new Padding(padding: EdgeInsets.all(10.0)), new Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ //button 3 new MaterialButton( minWidth: 120.0, color: Colors.blueGrey, onPressed: () { if (quiz.choices[questionNumber][2] == "Yes") { debugPrint("Correct"); finalScore++; } else { debugPrint("Wrong"); } updateQuestion(); }, child: new Text( quiz.choices[questionNumber][2], style: new TextStyle(fontSize: 20.0, color: Colors.white), ), ), //button 4 new MaterialButton( minWidth: 120.0, color: Colors.blueGrey, onPressed: () { if (quiz.choices[questionNumber][3] != "None of the above") { debugPrint("Correct"); finalScore++; } else { debugPrint("Wrong"); } updateQuestion(); }, child: new Text( quiz.choices[questionNumber][3], style: new TextStyle(fontSize: 20.0, color: Colors.white), ), ), ], ), ], ), ), )); } void updateQuestion() { setState(() { if (questionNumber == quiz.questions.length - 1) { Navigator.push( context, new MaterialPageRoute( builder: (context) => new Summary( score: finalScore, ))); } else { questionNumber++; } }); } } class Summary extends StatelessWidget { final int score; Summary({Key key, @required this.score}) : super(key: key); @override Widget build(BuildContext context) { return new WillPopScope( onWillPop: () async => false, child: Scaffold( body: new Container( child: new Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new Text( "Risk Level: $score / 4", style: new TextStyle(fontSize: 35.0), ), new Padding(padding: EdgeInsets.all(30.0)), new MaterialButton( color: Colors.red, onPressed: () { questionNumber = 0; finalScore = 0; Navigator.pop(context); Navigator.pop(context); Navigator.push(context, MaterialPageRoute(builder: (context)=> HomePage())); }, child: new Text( "Quit", style: new TextStyle(fontSize: 20.0, color: Colors.white), ), ) ], ), ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/health_tips.dart
import 'package:flutter/material.dart'; import 'package:healthrific/models/health_cardview.dart'; import 'healthtipselectpage.dart'; class HealthTipsPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0.0, title: Text('Health Tips',style: TextStyle(color: Theme.of(context).primaryColor),), backgroundColor: Colors.white,), body : Center(child : CardList()), backgroundColor: Colors.white, ); } } class CardList extends StatefulWidget{ @override State<StatefulWidget> createState() { return ListWidget(); } } class ListWidget extends State<CardList>{ final List<Health_card> cardlist = [ Health_card("Immunity Booster Kit",1, AssetImage('images/immunity.jpg') ,"https://www.healthline.com/nutrition/how-to-boost-immune-health#5.-Limit-added-sugars"), Health_card("Self Protection Guide",2,AssetImage('images/selfprotect.jpg'), "https://www.who.int/health-topics/coronavirus#tab=tab_2"), Health_card("Healthy Diet for Children and Senior Citizens",3, AssetImage('images/childrenandold.jpg'), "https://www.helpguide.org/articles/healthy-eating/healthy-food-for-kids.html"), Health_card("Emergency Tips",4, AssetImage('images/emergency.jpg'), "https://www.healthforteens.co.uk/health/in-an-emergency/7-most-common-medical-emergencies/") ]; @override Widget build(BuildContext context) { return Container( child: new ListView.builder( padding: EdgeInsets.symmetric(horizontal: 20), itemCount: cardlist.length, itemBuilder: (BuildContext context,int index) => buildCard(context, index) ), ); } Widget buildCard(BuildContext context,int index){ final card = cardlist[index]; return Container( child: Card( color: Colors.purple, elevation: 10, child: InkWell( child: Padding( padding: const EdgeInsets.all(1.0), child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ Image( image : card.tipImage, fit: BoxFit.contain, ), Text( card.title, textScaleFactor: 1.5, style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white) ), ] ), ), ], ), ), onTap: (){ Navigator.push(context, MaterialPageRoute( builder: (context) => HealthTipsSelectPage(health_card:card) )); }, ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/bluetooth_device_list.dart
import 'package:flutter/material.dart'; import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart'; class BluetoothDeviceListEntry extends ListTile { BluetoothDeviceListEntry({ @required BluetoothDevice device, int rssi, GestureTapCallback onTap, GestureLongPressCallback onLongPress, bool enabled = true, }) : super( onTap: onTap, onLongPress: onLongPress, enabled: enabled, leading: Icon(Icons.devices), title: Text(device.name ?? "Unknown device"), subtitle: Text(device.address.toString()), trailing: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ rssi != null ? Container( margin: new EdgeInsets.all(8.0), child: DefaultTextStyle( style: _computeTextStyle(rssi), child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Text(rssi.toString()), Text('dBm'), ], ), ), ) : Container(width: 0, height: 0), device.isConnected ? Icon(Icons.import_export) : Container(width: 0, height: 0), device.isBonded ? Icon(Icons.link) : Container(width: 0, height: 0), ], ), ); static TextStyle _computeTextStyle(int rssi) { if (rssi >= -35) return TextStyle(color: Colors.greenAccent[700]); else if (rssi >= -45) return TextStyle( color: Color.lerp( Colors.greenAccent[700], Colors.lightGreen, -(rssi + 35) / 10)); else if (rssi >= -55) return TextStyle( color: Color.lerp( Colors.lightGreen, Colors.lime[600], -(rssi + 45) / 10)); else if (rssi >= -65) return TextStyle( color: Color.lerp(Colors.lime[600], Colors.amber, -(rssi + 55) / 10)); else if (rssi >= -75) return TextStyle( color: Color.lerp( Colors.amber, Colors.deepOrangeAccent, -(rssi + 65) / 10)); else if (rssi >= -85) return TextStyle( color: Color.lerp( Colors.deepOrangeAccent, Colors.redAccent, -(rssi + 75) / 10)); else return TextStyle(color: Colors.redAccent); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/self_test.dart
import 'package:flutter/material.dart'; import 'package:healthrific/screens/selftest.dart'; class SelfTestPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0.0, title: Text('Self Assessment test',style: TextStyle(color: Theme.of(context).primaryColor),), backgroundColor: Colors.white,), body: Center( child: Container( child: FlatButton( onPressed: (){ Navigator.push(context, MaterialPageRoute(builder: (context)=> SelfTest())); }, color: Colors.white, child: Text("Take Self Assessment Test", style: TextStyle( fontSize: 20.0, color: Colors.purple, fontWeight: FontWeight.bold ),), ) ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/homepage.dart
import 'package:flutter/material.dart'; import 'package:healthrific/services/auth.dart'; import 'covid_info.dart'; import 'health_tips.dart'; import 'kiosk_test.dart'; import 'self_test.dart'; import 'sign_up_page.dart'; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { int _currentIndex = 0; AuthService _auth = AuthService(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(elevation: 1.0, actions: [ FlatButton.icon( icon: Icon(Icons.person,color: Colors.white,), label: Text('logout',style: TextStyle(color: Colors.white),), onPressed: () async { await _auth.signOut(); Navigator.pop(context); Navigator.pushReplacement(context, MaterialPageRoute( builder: (context) => SignUpPage())); }), ], ), body: IndexedStack( index: _currentIndex, children: <Widget>[ HealthTipsPage(), CovidInfoPage(), SelfTestPage(), KioskTestPage(), ], ), bottomNavigationBar: BottomNavigationBar(elevation: 2.0, onTap: (int index){ setState(() { _currentIndex = index; }); }, currentIndex: _currentIndex, items: [ BottomNavigationBarItem( icon: Icon(Icons.assistant,color: Theme.of(context).primaryColor,), backgroundColor: Theme.of(context).accentColor, title: Text('Tips',style: TextStyle(color: Theme.of(context).primaryColor),), ), BottomNavigationBarItem( icon: Icon(Icons.info,color: Theme.of(context).primaryColor), backgroundColor: Theme.of(context).accentColor, title: Text('Info',style: TextStyle(color: Theme.of(context).primaryColor),) ), BottomNavigationBarItem( icon: Icon(Icons.note,color: Theme.of(context).primaryColor), backgroundColor: Theme.of(context).accentColor, title: Text('Self Test',style: TextStyle(color: Theme.of(context).primaryColor),) ), BottomNavigationBarItem( icon: Icon(Icons.scanner,color: Theme.of(context).primaryColor), backgroundColor: Theme.of(context).accentColor, title: Text('Kiosk Test',style: TextStyle(color: Theme.of(context).primaryColor),) ), ]), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/sign_in_page.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:healthrific/elements/auth_elements.dart'; import 'package:healthrific/screens/reset_password.dart'; import 'package:healthrific/sizeconfig.dart'; import 'package:healthrific/screens/homepage.dart'; import 'package:healthrific/services/auth.dart'; class SignInPage extends StatefulWidget { @override _SignInPageState createState() => _SignInPageState(); } class _SignInPageState extends State<SignInPage> { final TextEditingController _emailController = TextEditingController(); final TextEditingController _passController = TextEditingController(); final _formKey = GlobalKey<FormState>(); final AuthService _auth = AuthService(); bool isAuthenticating = false; @override Widget build(BuildContext context) { SizeConfig().init(context); return Scaffold( appBar: AppBar( elevation: 0.0, backgroundColor: Colors.white, ), backgroundColor: Colors.white, body: Container( padding: EdgeInsets.all(10.0), child: Column(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'Sign In', textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 28, color: Theme.of(context).primaryColor, ), ), SizedBox(height: SizeConfig.blockSizeVertical * 3), Padding( padding: EdgeInsets.all(10.0), child: Form( key: _formKey, autovalidate: false, child: Column( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Row( children: <Widget>[ SizedBox( width: 14.0, ), Icon(Icons.email), SizedBox( width: 14.0, ), Expanded( child: TextFormField( validator: validateEmail, controller: _emailController, decoration: InputDecoration( hintText: 'Email Address', border: InputBorder.none), )), SizedBox( width: 14.0, ), ], ), ), SizedBox(height: SizeConfig.blockSizeVertical * 3), Container( decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Row( children: <Widget>[ SizedBox( width: 14.0, ), Icon(Icons.lock), SizedBox( width: 14.0, ), Expanded( child: TextFormField( validator: validatePassword, obscureText: true, controller: _passController, decoration: InputDecoration( hintText: 'Password', border: InputBorder.none), )), SizedBox( width: 14.0, ), ], ), ), SizedBox(height: SizeConfig.blockSizeVertical * 3), GestureDetector( onTap: (){ Navigator.push(context, CupertinoPageRoute(builder: (context) => ResetPasswordPage())); }, child: Center( child: Text( 'Forgot Password?', style: TextStyle(color: Theme.of(context).primaryColor), )), ), isAuthenticating ? CircularProgressIndicator() : Container( padding: EdgeInsets.only(bottom: 10, top: 20), width: SizeConfig.blockSizeHorizontal * 36, child: FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0)), textColor: Colors.white, color: Theme.of(context).primaryColor, child: Text('Sign In'), onPressed: () async { if(_formKey.currentState.validate()) { dynamic result = await _auth .signInWithEmailAndPassword( _emailController.text, _passController.text); if (result != null) { setState(() { isAuthenticating = true; Navigator.pop(context); Navigator.push(context, MaterialPageRoute( builder: (context) => HomePage())); }); } } }, ), ), ], ), ), ), ], ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/discovery_page.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart'; import 'bluetooth_device_list.dart'; class DiscoveryPage extends StatefulWidget { /// If true, discovery starts on page start, otherwise user must press action button. final bool start; const DiscoveryPage({this.start = true}); @override _DiscoveryPage createState() => new _DiscoveryPage(); } class _DiscoveryPage extends State<DiscoveryPage> { StreamSubscription<BluetoothDiscoveryResult> _streamSubscription; List<BluetoothDiscoveryResult> results = List<BluetoothDiscoveryResult>(); bool isDiscovering; _DiscoveryPage(); @override void initState() { super.initState(); isDiscovering = widget.start; if (isDiscovering) { _startDiscovery(); } } void _restartDiscovery() { setState(() { results.clear(); isDiscovering = true; }); _startDiscovery(); } void _startDiscovery() { _streamSubscription = FlutterBluetoothSerial.instance.startDiscovery().listen((r) { setState(() { results.add(r); }); }); _streamSubscription.onDone(() { setState(() { isDiscovering = false; }); }); } @override void dispose() { // Avoid memory leak (`setState` after dispose) and cancel discovery _streamSubscription?.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: isDiscovering ? Text('Searching devices') : Text('Available devices'), actions: <Widget>[ isDiscovering ? FittedBox( child: Container( margin: new EdgeInsets.all(16.0), child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.white), ), ), ) : IconButton( icon: Icon(Icons.replay), onPressed: _restartDiscovery, ) ], ), body: ListView.builder( itemCount: results.length, itemBuilder: (BuildContext context, index) { BluetoothDiscoveryResult result = results[index]; return BluetoothDeviceListEntry( device: result.device, rssi: result.rssi, onTap: () { Navigator.of(context).pop(result.device); }, onLongPress: () async { try { bool bonded = false; if (result.device.isBonded) { print('Unbonding from ${result.device.address}...'); await FlutterBluetoothSerial.instance .removeDeviceBondWithAddress(result.device.address); print('Unbonding from ${result.device.address} has succed'); } else { print('Bonding with ${result.device.address}...'); bonded = await FlutterBluetoothSerial.instance .bondDeviceAtAddress(result.device.address); print( 'Bonding with ${result.device.address} has ${bonded ? 'succed' : 'failed'}.'); } setState(() { results[results.indexOf(result)] = BluetoothDiscoveryResult( device: BluetoothDevice( name: result.device.name ?? '', address: result.device.address, type: result.device.type, bondState: bonded ? BluetoothBondState.bonded : BluetoothBondState.none, ), rssi: result.rssi); }); } catch (ex) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Error occured while bonding'), content: Text("${ex.toString()}"), actions: <Widget>[ new FlatButton( child: new Text("Close"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } }, ); }, ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/sign_up_page.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:healthrific/elements/auth_elements.dart'; import 'package:healthrific/services/auth.dart'; import 'package:healthrific/sizeconfig.dart'; import 'package:healthrific/screens/homepage.dart'; import '../elements/auth_elements.dart'; import 'homepage.dart'; import 'sign_in_page.dart'; class SignUpPage extends StatefulWidget { @override _SignUpPageState createState() => _SignUpPageState(); } class _SignUpPageState extends State<SignUpPage> { final TextEditingController _emailController = TextEditingController(); final TextEditingController _passController = TextEditingController(); final TextEditingController _nameController = TextEditingController(); final AuthService _auth = AuthService(); String error = ''; final _formKey = GlobalKey<FormState>(); bool isAuthenticating = false; @override Widget build(BuildContext context) { SizeConfig().init(context); return Scaffold( body: SingleChildScrollView( child: Container( padding: EdgeInsets.all(10.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SizedBox( height: SizeConfig.blockSizeVertical * 16, ), Text( 'Sign Up', textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 28, color: Theme.of(context).primaryColor, ), ), SizedBox(height: SizeConfig.blockSizeVertical * 4), Padding( padding: EdgeInsets.all(10.0), child: Form( key: _formKey, autovalidate: false, child: Column( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Row( children: <Widget>[ SizedBox( width: 14.0, ), Icon(Icons.person), SizedBox( width: 14.0, ), Expanded( child: TextFormField( validator: validateName, controller: _nameController, decoration: InputDecoration( hintText: 'Full Name', border: InputBorder.none), )), SizedBox( width: 14.0, ), ], ), ), SizedBox(height: SizeConfig.blockSizeVertical * 3), Container( decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Row( children: <Widget>[ SizedBox( width: 14.0, ), Icon(Icons.email), SizedBox( width: 14.0, ), Expanded( child: TextFormField( validator: validateEmail, controller: _emailController, decoration: InputDecoration( hintText: 'Email Address', border: InputBorder.none), )), SizedBox( width: 14.0, ), ], ), ), SizedBox(height: SizeConfig.blockSizeVertical * 3), Container( decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Row( children: <Widget>[ SizedBox( width: 14.0, ), Icon(Icons.lock), SizedBox( width: 14.0, ), Expanded( child: TextFormField( validator: validatePassword, obscureText: true, controller: _passController, decoration: InputDecoration( hintText: 'Password', border: InputBorder.none), )), SizedBox( width: 14.0, ), ], ), ), SizedBox(height: SizeConfig.blockSizeVertical * 6), GestureDetector( onTap: () { Navigator.push(context, CupertinoPageRoute(builder: (context) => SignInPage())); }, child: Center( child: Text( 'Already have an account? Sign In', style: TextStyle(color: Theme.of(context).primaryColor), )), ), SizedBox( height: SizeConfig.blockSizeVertical * 3, ), isAuthenticating ? CircularProgressIndicator() : Container( padding: EdgeInsets.only(bottom: 10, top: 20), width: SizeConfig.blockSizeHorizontal * 36, child: FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0)), textColor: Colors.white, color: Theme.of(context).primaryColor, child: Text('Sign Up'), onPressed: () async { if (_formKey.currentState.validate()) { dynamic result = await _auth.registerWithEmailAndPassword( _nameController.text,_emailController.text, _passController.text); if(result != null) { setState(() { isAuthenticating = true; Navigator.pop(context); Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage())); }); } else{ error = 'Please check your entries'; } } }, ), ), ], ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/covid_info.dart
import 'package:healthrific/services/covid_info_api.dart'; import 'package:flutter/material.dart'; import 'package:healthrific/sizeconfig.dart'; class CovidInfoPage extends StatefulWidget { @override _CovidInfoPageState createState() => _CovidInfoPageState(); } class _CovidInfoPageState extends State<CovidInfoPage> { bool _isLoading = false; final Info globalInfoRef = Info(); @override Widget build(BuildContext context) { SizeConfig().init(context); return Scaffold( appBar: AppBar( elevation: 0.0, title: Text( 'Covid-19 Info', style: TextStyle(color: Theme.of(context).primaryColor), ), backgroundColor: Colors.white, ), backgroundColor: Colors.white, body: SingleChildScrollView( child: Column( children: <Widget>[ FutureBuilder( future: globalInfoRef.getGlobalJsonData(), builder: (context, snapshot) { if (snapshot.hasData) { return Container( height: SizeConfig.blockSizeVertical * 25, width: SizeConfig.blockSizeHorizontal * 100, margin: EdgeInsets.all(10.0), padding: EdgeInsets.all(12.0), decoration: BoxDecoration( color: Theme.of(context).accentColor, borderRadius: BorderRadius.all(Radius.circular(15.0)), boxShadow: [ BoxShadow(color: Colors.grey, blurRadius: 1.0) ]), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ GlobalInfoWidget(snapshotData: snapshot.data.cases, title: 'Total Cases'), GlobalInfoWidget(snapshotData: snapshot.data.recovered, title: 'Recovered'), GlobalInfoWidget(snapshotData: snapshot.data.deaths, title: 'Deaths'), ], ), Divider( thickness: 1.0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ GlobalInfoWidget(snapshotData: snapshot.data.active, title: 'Active'), GlobalInfoWidget(snapshotData: snapshot.data.critical, title: 'Critical'), GlobalInfoWidget(snapshotData: snapshot.data.affectedCountries, title: 'Countries'), ], ), ], ), ); } else return CircularProgressIndicator(); }, ), Container( // height: SizeConfig.blockSizeVertical * 35, // width: SizeConfig.blockSizeHorizontal * 100, margin: EdgeInsets.all(10.0), padding: EdgeInsets.all(12.0), decoration: BoxDecoration( color: Theme.of(context).accentColor, borderRadius: BorderRadius.all(Radius.circular(15.0)), boxShadow: [ BoxShadow(color: Colors.grey, blurRadius: 1.0) ]), child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Text( 'Country', style: TextStyle(color: Theme.of(context).primaryColor,fontWeight: FontWeight.bold), ), Text( 'Total Cases', style: TextStyle(color: Theme.of(context).primaryColor,fontWeight: FontWeight.bold), ), ], ), Divider(), CountryInfoWidget( country: 'USA', ), CountryInfoWidget( country: 'Brazil', ), CountryInfoWidget( country: 'Russia', ), CountryInfoWidget( country: 'India', ), CountryInfoWidget( country: 'UK ', ), CountryInfoWidget( country: 'Spain', ), CountryInfoWidget( country: 'Peru', ), CountryInfoWidget( country: 'Italy', ), CountryInfoWidget( country: 'Chile', ), CountryInfoWidget( country: 'Iran', ), ], ), ), ], ), )); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/qr_code.dart
import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; import '../sizeconfig.dart'; class QRCodePage extends StatelessWidget { final String time; const QRCodePage({this.time}); @override Widget build(BuildContext context) { SizeConfig().init(context); return Scaffold( appBar: AppBar( title: Text('QR Code'), ), body: Column( children: <Widget>[ Container(height: SizeConfig.blockSizeVertical * 40, width: SizeConfig.blockSizeHorizontal * 100, margin: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Theme.of(context).accentColor, borderRadius: BorderRadius.all(Radius.circular(15.0)), boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 1.0)]), child: Center( child: QrImage(padding: EdgeInsets.all(20.0), data: 'This is a simple QR code', version: QrVersions.auto, size: 300, gapless: false, ), ), ), SizedBox( height: 4.0, ), Container( height: SizeConfig.blockSizeVertical * 16, width: SizeConfig.blockSizeHorizontal * 100, margin: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Theme.of(context).accentColor, borderRadius: BorderRadius.all(Radius.circular(15.0)), boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 1.0)]), child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text('Valid For : ',style: TextStyle(color: Theme.of(context).primaryColor,fontWeight: FontWeight.bold),), Text('24 Hours'), ], ), Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text('Generated On : ',style: TextStyle(color: Theme.of(context).primaryColor,fontWeight: FontWeight.bold),), Text('$time'), ], ), ], ) ) ], ), ); } }
0
mirrored_repositories/Astralis/lib
mirrored_repositories/Astralis/lib/screens/kiosk_test.dart
import 'dart:async'; import 'dart:convert'; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart'; import 'package:intl/intl.dart'; import '../sizeconfig.dart'; import 'discovery_page.dart'; import 'qr_code.dart'; class KioskTestPage extends StatefulWidget { @override _KioskTestPageState createState() => _KioskTestPageState(); } class _KioskTestPageState extends State<KioskTestPage> { BluetoothState _bluetoothState = BluetoothState.UNKNOWN; BluetoothDevice _bluetoothDevice; BluetoothConnection connection; String _address = "..."; String _name = "..."; String name; List<String> dataList = []; String arduinoData = 'connect a device to receive data'; bool isConnected = false; Timer _discoverableTimeoutTimer; @override void initState() { super.initState(); FlutterBluetoothSerial.instance.state.then((state) { setState(() { _bluetoothState = state; }); }); Future.doWhile(() async { if (await FlutterBluetoothSerial.instance.isEnabled) { return false; } await Future.delayed(Duration(milliseconds: 0xDD)); return true; }).then((_) { FlutterBluetoothSerial.instance.address.then((address) { setState(() { _address = address; }); }); }); FlutterBluetoothSerial.instance.name.then((name) { setState(() { _name = name; }); }); } @override void dispose() { FlutterBluetoothSerial.instance.setPairingRequestHandler(null); _discoverableTimeoutTimer?.cancel(); super.dispose(); } void getDataFromArduino() async { connection.input.listen((Uint8List data) { setState(() { arduinoData = '${ascii.decode(data)}'; }); }); } @override Widget build(BuildContext context) { SizeConfig().init(context); return Scaffold( appBar: AppBar( elevation: 0.0, title: Text( 'Kiosk Test', style: TextStyle(color: Theme.of(context).primaryColor), ), backgroundColor: Colors.white, ), backgroundColor: Colors.white, body: SingleChildScrollView( child: Column( children: <Widget>[ SwitchListTile( title: const Text('Enable Bluetooth'), value: _bluetoothState.isEnabled, onChanged: (bool value) { future() async { if (value) { await FlutterBluetoothSerial.instance .requestEnable() .then((value) { setState(() { value = true; _bluetoothState = BluetoothState.STATE_ON; }); }); } else { await FlutterBluetoothSerial.instance .requestDisable() .then((value) { setState(() { _bluetoothState = BluetoothState.STATE_OFF; value = false; }); }); } } future().then((value) { setState(() {}); }); }, ), RaisedButton( color: Theme.of(context).primaryColor, elevation: 1.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), child: Text( 'Select the device', style: TextStyle(color: Colors.white), ), onPressed: () async { final BluetoothDevice selectedDevice = await Navigator.push( context, MaterialPageRoute(builder: (context) => DiscoveryPage())); setState(() { _bluetoothDevice = selectedDevice; name = selectedDevice.name; }); print(selectedDevice.address); print(selectedDevice.name); }, ), SizedBox( height: 10.0, ), Column( children: <Widget>[ _bluetoothDevice == null ? Text('No device selected') : Text(_bluetoothDevice.name), _bluetoothDevice == null ? Text('select a device to continue') : Text(_bluetoothDevice.address), ], ), SizedBox( height: 10.0, ), RaisedButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), elevation: 1.0, color: Theme.of(context).primaryColor, child: isConnected ? Text( 'Connected', style: TextStyle(color: Colors.white), ) : Text( 'Connect', style: TextStyle(color: Colors.white), ), onPressed: _bluetoothDevice == null ? null : () async { await BluetoothConnection.toAddress( _bluetoothDevice.address) .then((value) { connection = value; setState(() { isConnected = true; }); connection.isConnected ? getDataFromArduino() : null; setState(() { dataList = arduinoData.split(','); }); }); }, ), Container( height: SizeConfig.blockSizeVertical * 25, width: SizeConfig.blockSizeHorizontal * 100, margin: EdgeInsets.all(10.0), padding: EdgeInsets.all(12.0), decoration: BoxDecoration( color: Theme.of(context).accentColor, borderRadius: BorderRadius.all(Radius.circular(15.0)), boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 1.0)]), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ dataList.isEmpty ? Text('Your test results will appear here') : ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: dataList.length, itemBuilder: (context, index) { return Text(dataList[index]); }, ), ], ), ), RaisedButton( child: Text( 'Show QR code', style: TextStyle(color: Colors.white), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), elevation: 1.0, color: Theme.of(context).primaryColor, onPressed: !isConnected ? null : () { String time = DateFormat('dd-MM-yyyy').format(DateTime.now()); Navigator.push( context, MaterialPageRoute( builder: (context) => QRCodePage(time: time))); }, ), ], ), ), ); } }
0
mirrored_repositories/Astralis
mirrored_repositories/Astralis/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:healthrific/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/eBook-app-Flutter
mirrored_repositories/eBook-app-Flutter/lib/consttants.dart
import 'package:flutter/material.dart'; const kBlackColor = Color(0xFF393939); const kLightBlackColor = Color(0xFF8F8F8F); const kIconColor = Color(0xFFF48A37); const kProgressIndicator = Color(0xFFBE7066); final kShadowColor = Color(0xFFD3D3D3).withOpacity(.84);
0
mirrored_repositories/eBook-app-Flutter
mirrored_repositories/eBook-app-Flutter/lib/main.dart
import 'package:book_app/consttants.dart'; import 'package:book_app/screens/home_screen.dart'; import 'package:book_app/widgets/rounded_button.dart'; import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Book App', theme: ThemeData( scaffoldBackgroundColor: Colors.white, textTheme: Theme.of(context).textTheme.apply( displayColor: kBlackColor, ), ), home: WelcomeScreen(), ); } } class WelcomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Container( width: double.infinity, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/Bitmap.png"), fit: BoxFit.fill, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ RichText( text: TextSpan( style: Theme.of(context).textTheme.display3, children: [ TextSpan( text: "flamin", ), TextSpan( text: "go.", style: TextStyle(fontWeight: FontWeight.bold), ), ], ), ), SizedBox( width: MediaQuery.of(context).size.width * .6, child: RoundedButton( text: "start reading", fontSize: 20, press: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return HomeScreen(); }, ), ); }, ), ), ], ), ), ); } }
0
mirrored_repositories/eBook-app-Flutter/lib
mirrored_repositories/eBook-app-Flutter/lib/widgets/two_side_rounded_button.dart
import 'package:book_app/consttants.dart'; import 'package:flutter/material.dart'; class TwoSideRoundedButton extends StatelessWidget { final String text; final double radious; final Function press; const TwoSideRoundedButton({ Key key, this.text, this.radious = 29, this.press, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: press, child: Container( alignment: Alignment.center, padding: EdgeInsets.symmetric(vertical: 10), decoration: BoxDecoration( color: kBlackColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(radious), bottomRight: Radius.circular(radious), ), ), child: Text( text, style: TextStyle(color: Colors.white), ), ), ); } }
0
mirrored_repositories/eBook-app-Flutter/lib
mirrored_repositories/eBook-app-Flutter/lib/widgets/rounded_button.dart
import 'package:flutter/material.dart'; class RoundedButton extends StatelessWidget { final String text; final Function press; final double verticalPadding; final double horizontalPadding; final double fontSize; RoundedButton({ Key key, this.text, this.press, this.verticalPadding = 16, this.horizontalPadding = 30, this.fontSize = 16, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: press, child: Container( width: double.infinity, alignment: Alignment.center, margin: EdgeInsets.symmetric(vertical: 16), padding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: horizontalPadding), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30), boxShadow: [ BoxShadow( offset: Offset(0, 15), blurRadius: 30, color: Color(0xFF666666).withOpacity(.11), ), ], ), child: Text( text, style: TextStyle( fontSize: fontSize, fontWeight: FontWeight.bold, ), ), ), ); } }
0
mirrored_repositories/eBook-app-Flutter/lib
mirrored_repositories/eBook-app-Flutter/lib/widgets/reading_card_list.dart
import 'package:book_app/consttants.dart'; import 'package:book_app/widgets/book_rating.dart'; import 'package:book_app/widgets/two_side_rounded_button.dart'; import 'package:flutter/material.dart'; class ReadingListCard extends StatelessWidget { final String image; final String title; final String auth; final double rating; final Function pressDetails; final Function pressRead; const ReadingListCard({ Key key, this.image, this.title, this.auth, this.rating, this.pressDetails, this.pressRead, }) : super(key: key); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(left: 24, bottom: 40), height: 245, width: 202, child: Stack( children: <Widget>[ Positioned( bottom: 0, left: 0, right: 0, child: Container( height: 221, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(29), boxShadow: [ BoxShadow( offset: Offset(0, 10), blurRadius: 33, color: kShadowColor, ), ], ), ), ), Image.asset( image, width: 150, ), Positioned( top: 35, right: 10, child: Column( children: <Widget>[ IconButton( icon: Icon( Icons.favorite_border, ), onPressed: () {}, ), BookRating(score: rating), ], ), ), Positioned( top: 160, child: Container( height: 85, width: 202, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: EdgeInsets.only(left: 24), child: RichText( maxLines: 2, text: TextSpan( style: TextStyle(color: kBlackColor), children: [ TextSpan( text: "$title\n", style: TextStyle( fontWeight: FontWeight.bold, ), ), TextSpan( text: auth, style: TextStyle( color: kLightBlackColor, ), ), ], ), ), ), Spacer(), Row( children: <Widget>[ GestureDetector( onTap: pressDetails, child: Container( width: 101, padding: EdgeInsets.symmetric(vertical: 10), alignment: Alignment.center, child: Text("Details"), ), ), Expanded( child: TwoSideRoundedButton( text: "Read", press: pressRead, ), ) ], ) ], ), ), ), ], ), ); } }
0
mirrored_repositories/eBook-app-Flutter/lib
mirrored_repositories/eBook-app-Flutter/lib/widgets/book_rating.dart
import 'package:book_app/consttants.dart'; import 'package:flutter/material.dart'; class BookRating extends StatelessWidget { final double score; const BookRating({ Key key, this.score, }) : super(key: key); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(vertical: 8, horizontal: 6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), boxShadow: [ BoxShadow( offset: Offset(3, 7), blurRadius: 20, color: Color(0xFD3D3D3).withOpacity(.5), ), ], ), child: Column( children: <Widget>[ Icon( Icons.star, color: kIconColor, size: 15, ), SizedBox(height: 5), Text( "$score", style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, ), ), ], ), ); } }
0
mirrored_repositories/eBook-app-Flutter/lib
mirrored_repositories/eBook-app-Flutter/lib/screens/home_screen.dart
import 'package:book_app/consttants.dart'; import 'package:book_app/screens/details_screen.dart'; import 'package:book_app/widgets/book_rating.dart'; import 'package:book_app/widgets/reading_card_list.dart'; import 'package:book_app/widgets/two_side_rounded_button.dart'; import 'package:flutter/material.dart'; class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; return Scaffold( body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( width: double.infinity, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/main_page_bg.png"), alignment: Alignment.topCenter, fit: BoxFit.fitWidth, ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox(height: size.height * .1), Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: RichText( text: TextSpan( style: Theme.of(context).textTheme.display1, children: [ TextSpan(text: "What are you \nreading "), TextSpan( text: "today?", style: TextStyle( fontWeight: FontWeight.bold, )) ], ), ), ), SizedBox(height: 30), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: <Widget>[ ReadingListCard( image: "assets/images/book-1.png", title: "Crushing & Influence", auth: "Gary Venchuk", rating: 4.9, pressDetails: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return DetailsScreen(); }, ), ); }, ), ReadingListCard( image: "assets/images/book-2.png", title: "Top Ten Business Hacks", auth: "Herman Joel", rating: 4.8, ), SizedBox(width: 30), ], ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 24), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ RichText( text: TextSpan( style: Theme.of(context).textTheme.display1, children: [ TextSpan(text: "Best of the "), TextSpan( text: "day", style: TextStyle(fontWeight: FontWeight.bold), ), ], ), ), bestOfTheDayCard(size, context), RichText( text: TextSpan( style: Theme.of(context).textTheme.display1, children: [ TextSpan(text: "Continue "), TextSpan( text: "reading...", style: TextStyle(fontWeight: FontWeight.bold), ), ], ), ), SizedBox(height: 20), Container( height: 80, width: double.infinity, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(38.5), boxShadow: [ BoxShadow( offset: Offset(0, 10), blurRadius: 33, color: Color(0xFFD3D3D3).withOpacity(.84), ), ], ), child: ClipRRect( borderRadius: BorderRadius.circular(38.5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Expanded( child: Padding( padding: EdgeInsets.only(left: 30, right: 20), child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( "Crushing & Influence", style: TextStyle( fontWeight: FontWeight.bold, ), ), Text( "Gary Venchuk", style: TextStyle( color: kLightBlackColor, ), ), Align( alignment: Alignment.bottomRight, child: Text( "Chapter 7 of 10", style: TextStyle( fontSize: 10, color: kLightBlackColor, ), ), ), SizedBox(height: 5), ], ), ), Image.asset( "assets/images/book-1.png", width: 55, ) ], ), ), ), Container( height: 7, width: size.width * .65, decoration: BoxDecoration( color: kProgressIndicator, borderRadius: BorderRadius.circular(7), ), ), ], ), ), ), SizedBox(height: 40), ], ), ), ], ), ), ], ), ), ); } Container bestOfTheDayCard(Size size, BuildContext context) { return Container( margin: EdgeInsets.symmetric(vertical: 20), width: double.infinity, height: 245, child: Stack( children: <Widget>[ Positioned( bottom: 0, left: 0, right: 0, child: Container( padding: EdgeInsets.only( left: 24, top: 24, right: size.width * .35, ), height: 230, width: double.infinity, decoration: BoxDecoration( color: Color(0xFFEAEAEA).withOpacity(.45), borderRadius: BorderRadius.circular(29), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( margin: EdgeInsets.only(top: 10.0, bottom: 10.0), child: Text( "New York Time Best For 11th March 2020", style: TextStyle( fontSize: 9, color: kLightBlackColor, ), ), ), Text( "How To Win \nFriends & Influence", style: Theme.of(context).textTheme.title, ), Text( "Gary Venchuk", style: TextStyle(color: kLightBlackColor), ), Padding( padding: EdgeInsets.only(top: 10, bottom: 10.0), child: Row( children: <Widget>[ Padding( padding: EdgeInsets.only(right: 10.0), child: BookRating(score: 4.9), ), Expanded( child: Text( "When the earth was flat and everyone wanted to win the game of the best and people….", maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 10, color: kLightBlackColor, ), ), ), ], ), ), ], ), ), ), Positioned( right: 0, top: 0, child: Image.asset( "assets/images/book-3.png", width: size.width * .37, ), ), Positioned( bottom: 0, right: 0, child: SizedBox( height: 40, width: size.width * .3, child: TwoSideRoundedButton( text: "Read", radious: 24, press: () {}, ), ), ), ], ), ); } }
0
mirrored_repositories/eBook-app-Flutter/lib
mirrored_repositories/eBook-app-Flutter/lib/screens/details_screen.dart
import 'package:book_app/consttants.dart'; import 'package:book_app/widgets/book_rating.dart'; import 'package:book_app/widgets/rounded_button.dart'; import 'package:flutter/material.dart'; class DetailsScreen extends StatelessWidget { @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; return Scaffold( body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Stack( alignment: Alignment.topCenter, children: <Widget>[ Container( alignment: Alignment.topCenter, padding: EdgeInsets.only(top: size.height * .12, left: size.width * .1, right: size.width * .02), height: size.height * .48, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/bg.png"), fit: BoxFit.fitWidth, ), borderRadius: BorderRadius.only( bottomLeft: Radius.circular(50), bottomRight: Radius.circular(50), ), ), child: BookInfo(size: size,) ), Padding( padding: EdgeInsets.only(top: size.height * .48 - 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ ChapterCard( name: "Money", chapterNumber: 1, tag: "Life is about change", press: () {}, ), ChapterCard( name: "Power", chapterNumber: 2, tag: "Everything loves power", press: () {}, ), ChapterCard( name: "Influence", chapterNumber: 3, tag: "Influence easily like never before", press: () {}, ), ChapterCard( name: "Win", chapterNumber: 4, tag: "Winning is what matters", press: () {}, ), SizedBox(height: 10), ], ), ), ], ), Padding( padding: EdgeInsets.symmetric(horizontal: 24), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ RichText( text: TextSpan( style: Theme.of(context).textTheme.headline5, children: [ TextSpan( text: "You might also ", ), TextSpan( text: "like….", style: TextStyle(fontWeight: FontWeight.bold), ), ], ), ), SizedBox(height: 20), Stack( children: <Widget>[ Container( height: 180, width: double.infinity, ), Positioned( bottom: 0, left: 0, right: 0, child: Container( padding: EdgeInsets.only(left: 24, top: 24, right: 150), height: 160, width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(29), color: Color(0xFFFFF8F9), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ RichText( text: TextSpan( style: TextStyle(color: kBlackColor), children: [ TextSpan( text: "How To Win \nFriends & Influence \n", style: TextStyle( fontSize: 15, ), ), TextSpan( text: "Gary Venchuk", style: TextStyle(color: kLightBlackColor), ), ], ), ), Row( children: <Widget>[ BookRating( score: 4.9, ), SizedBox(width: 10), Expanded( child: RoundedButton( text: "Read", verticalPadding: 10, ), ), ], ) ], ), ), ), Positioned( top: 0, right: 0, child: Image.asset( "assets/images/book-3.png", width: 150, fit: BoxFit.fitWidth, ), ), ], ) ], ), ), SizedBox( height: 40, ), ], ), ), ); } } class ChapterCard extends StatelessWidget { final String name; final String tag; final int chapterNumber; final Function press; const ChapterCard({ Key key, this.name, this.tag, this.chapterNumber, this.press, }) : super(key: key); @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; return Container( padding: EdgeInsets.symmetric(vertical: 20, horizontal: 30), margin: EdgeInsets.only(bottom: 16), width: size.width - 48, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(38.5), boxShadow: [ BoxShadow( offset: Offset(0, 10), blurRadius: 33, color: Color(0xFFD3D3D3).withOpacity(.84), ), ], ), child: Row( children: <Widget>[ RichText( text: TextSpan( children: [ TextSpan( text: "Chapter $chapterNumber : $name \n", style: TextStyle( fontSize: 16, color: kBlackColor, fontWeight: FontWeight.bold, ), ), TextSpan( text: tag, style: TextStyle(color: kLightBlackColor), ), ], ), ), Spacer(), IconButton( icon: Icon( Icons.arrow_forward_ios, size: 18, ), onPressed: press, ) ], ), ); } } class BookInfo extends StatelessWidget { const BookInfo({ Key key, this.size, }) : super(key: key); final Size size; @override Widget build(BuildContext context) { return Container( child: Flex( crossAxisAlignment: CrossAxisAlignment.start, direction: Axis.horizontal, children: <Widget>[ Expanded( flex: 1, child: Column( children: <Widget>[ Container( alignment: Alignment.centerLeft, child: Text( "Crushing &", style: Theme.of(context).textTheme.headline4.copyWith( fontSize: 28 ), ), ), Container( margin: EdgeInsets.only(top: this.size.height * .005), alignment: Alignment.centerLeft, padding: EdgeInsets.only(top: 0), child: Text( "Influence", style: Theme.of(context).textTheme.subtitle1.copyWith( fontSize: 25, fontWeight: FontWeight.bold, ), ), ), Row( children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Container( width: this.size.width * .3, padding: EdgeInsets.only(top: this.size.height * .02), child: Text( "When the earth was flat andeveryone wanted to win the gameof the best and people and winning with an A game with all the things you have.", maxLines: 5, style: TextStyle( fontSize: 10, color: kLightBlackColor, ), ), ), Container( margin: EdgeInsets.only(top: this.size.height * .015), padding: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30), ), child: FlatButton( onPressed: () {}, child: Text("Read", style: TextStyle(fontWeight: FontWeight.bold),), ), ) ], ), Column( children: <Widget>[ IconButton( icon: Icon(Icons.favorite_border, size: 20, color: Colors.grey,), onPressed: () {}, ), BookRating(score: 4.9), ], ) ], ) ], ) ), Expanded( flex: 1, child: Container( color: Colors.transparent, child: Image.asset( "assets/images/book-1.png", height: double.infinity, alignment: Alignment.topRight, fit: BoxFit.fitWidth, ), )), ], ), ); } }
0
mirrored_repositories/eBook-app-Flutter
mirrored_repositories/eBook-app-Flutter/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:book_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/Auth_System_Appwrite
mirrored_repositories/Auth_System_Appwrite/lib/main.dart
import 'package:auth_system/data/model/user.dart'; import 'package:auth_system/data/service/appwrite_auth_service.dart'; import 'package:auth_system/view_pages/auth_pages/login.dart'; import 'package:auth_system/view_pages/homepages.dart'; import 'package:auth_system/view_pages/splashpage.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: Colors.pinkAccent, ), home: const MainPage(), ); } } class MainPage extends StatelessWidget { const MainPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return FutureBuilder<UserData>( future: AuthAppwrite.instance!.knowUserLogin(), builder: (_, snapshot) { // if (snapshot.connectionState == ConnectionState.waiting) { return const SplashPage(); } // if (snapshot.hasData) { return HomePage( user: snapshot.data!, ); } // return const LoginPage(); }, ); } }
0
mirrored_repositories/Auth_System_Appwrite/lib
mirrored_repositories/Auth_System_Appwrite/lib/view_pages/ano.dart
import 'package:appwrite/appwrite.dart'; import 'package:auth_system/data/service/appwrite_auth_service.dart'; import 'package:auth_system/main.dart'; import 'package:auth_system/widget/make_text.dart'; import 'package:auth_system/widget/route.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class AnoPage extends StatefulWidget { const AnoPage({Key? key}) : super(key: key); @override State<AnoPage> createState() => _AnoPageState(); } class _AnoPageState extends State<AnoPage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Anonymous User"), ), drawer: Drawer( child: ListView( padding: const EdgeInsets.all(0), children: [ UserAccountsDrawerHeader( accountName: makeText( "Anonymous User", ), accountEmail: makeText("anonymous@appwrite.com"), currentAccountPicture: CircleAvatar( backgroundColor: Colors.white, child: makeText( "A", textColor: Colors.black, fontWeight: FontWeight.bold, size: Theme.of(context).textTheme.headline6!.fontSize!, ), ), ), ListTile( title: makeText("Logout"), leading: const Icon(Icons.logout), onTap: () async { try { await AuthAppwrite.instance!.logout(); if (!mounted) return; pushReplacement(context, const MainPage()); } on AppwriteException catch (e) { if (kDebugMode) print(e.message); } }, ), ], ), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ makeText( "Forget all the reasons it won’t work and believe the one reason that it will!", fontWeight: FontWeight.bold, size: Theme.of(context).textTheme.headline6!.fontSize!, ), makeText("Anonymous Quotes"), ], ), ), ); } }
0
mirrored_repositories/Auth_System_Appwrite/lib
mirrored_repositories/Auth_System_Appwrite/lib/view_pages/splashpage.dart
import 'package:auth_system/widget/make_text.dart'; import 'package:flutter/material.dart'; class SplashPage extends StatelessWidget { const SplashPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Material( child: Center( child: makeText("Loading...."), ), ); } }
0
mirrored_repositories/Auth_System_Appwrite/lib
mirrored_repositories/Auth_System_Appwrite/lib/view_pages/homepages.dart
import 'package:appwrite/appwrite.dart'; import 'package:auth_system/data/model/user.dart'; import 'package:auth_system/data/service/appwrite_auth_service.dart'; import 'package:auth_system/main.dart'; import 'package:auth_system/widget/make_elevated_button.dart'; import 'package:auth_system/widget/make_text.dart'; import 'package:auth_system/widget/make_text_field.dart'; import 'package:auth_system/widget/route.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class HomePage extends StatefulWidget { final UserData user; const HomePage({Key? key, required this.user}) : super(key: key); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { late TextEditingController _updateName; late TextEditingController _updateEmail; late TextEditingController _pass; late TextEditingController _changeps; late TextEditingController _oldps; bool _obsecure = true; bool _obsecure1 = true; @override void initState() { super.initState(); _updateName = TextEditingController(); _updateEmail = TextEditingController(); _pass = TextEditingController(); _changeps = TextEditingController(); _oldps = TextEditingController(); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; var username = widget.user.name; var userValidate = username.toUpperCase(); return Scaffold( appBar: AppBar( elevation: 0, title: makeText("Auth System"), ), drawer: Drawer( child: ListView( children: [ UserAccountsDrawerHeader( accountName: makeText( widget.user.name, ), accountEmail: makeText(widget.user.email), currentAccountPicture: CircleAvatar( backgroundColor: Colors.white, child: makeText( userValidate.substring(0, 1).toUpperCase(), fontWeight: FontWeight.bold, size: Theme.of(context).textTheme.headline6!.fontSize!, ), ), ), ListTile( title: makeText("Logout"), leading: const Icon(Icons.logout), onTap: () async { try { await AuthAppwrite.instance!.logout(); if (!mounted) return; pushReplacement(context, const MainPage()); } on AppwriteException catch (e) { if (kDebugMode) print(e.message); } }, ), ], ), ), body: Padding( padding: const EdgeInsets.all(8.0), child: ListView( children: [ SizedBox( height: size.height * 0.01, ), // Change Name makeTextField( hintText: "Change Your Name", controller: _updateName, ), SizedBox( height: size.height * 0.02, ), makeElevatedButton( "Change Name", onPressed: () async { var name = _updateName.text; try { await AuthAppwrite.instance!.updateName(name: name); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText("Name Change"), ), ); _updateName.clear(); await AuthAppwrite.instance!.logout(); if (!mounted) return; push(context, const MainPage()); } on AppwriteException catch (e) { if (kDebugMode) print(e.message); ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText(e.message!), ), ); } }, ), SizedBox( height: size.height * 0.03, ), const Divider( height: 3, thickness: 7.0, color: Colors.amberAccent, ), SizedBox( height: size.height * 0.03, ), // change email makeTextField(controller: _updateEmail, hintText: "Change Email"), SizedBox( height: size.height * 0.01, ), makeTextField(controller: _pass, hintText: "Your Password"), SizedBox( height: size.height * 0.02, ), makeElevatedButton( "Change Email", onPressed: () async { var email = _updateEmail.text; var pass = _pass.text; try { await AuthAppwrite.instance!.updateEmail( email: email, password: pass, ); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText("Update Email"), ), ); _updateName.clear(); await AuthAppwrite.instance!.logout(); if (!mounted) return; push(context, const MainPage()); } on AppwriteException catch (e) { if (kDebugMode) print(e.message); ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText(e.message!), ), ); } }, ), SizedBox( height: size.height * 0.03, ), const Divider( height: 3, thickness: 7.0, color: Colors.amberAccent, ), SizedBox( height: size.height * 0.03, ), // change password makeTextField( controller: _oldps, hintText: "Enter Old Password", obscureText: _obsecure, suffixIcon: GestureDetector( child: Icon(_obsecure ? Icons.visibility : Icons.visibility_off), onTap: () { setState(() { _obsecure = !_obsecure; }); }, ), ), SizedBox( height: size.height * 0.01, ), makeTextField( controller: _changeps, hintText: "Change New Password", obscureText: _obsecure1, suffixIcon: GestureDetector( child: Icon(_obsecure1 ? Icons.visibility : Icons.visibility_off), onTap: () { setState( () { _obsecure1 = !_obsecure1; }, ); }, ), ), SizedBox( height: size.height * 0.02, ), makeElevatedButton( "Change Password", onPressed: () async { var pass = _changeps.text; var old = _oldps.text; try { await AuthAppwrite.instance!.updatePassword( password: pass, oldpw: old, ); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText("Change password"), ), ); _changeps.clear(); await AuthAppwrite.instance!.logout(); if (!mounted) return; push(context, const MainPage()); } on AppwriteException catch (e) { if (kDebugMode) print(e.message); ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText(e.message!), ), ); } }, ), ], ), ), ); } }
0
mirrored_repositories/Auth_System_Appwrite/lib/view_pages
mirrored_repositories/Auth_System_Appwrite/lib/view_pages/auth_pages/login.dart
import 'package:appwrite/appwrite.dart'; import 'package:auth_system/data/service/appwrite_auth_service.dart'; import 'package:auth_system/main.dart'; import 'package:auth_system/view_pages/auth_pages/signup.dart'; import 'package:auth_system/widget/make_elevated_button.dart'; import 'package:auth_system/widget/make_text.dart'; import 'package:auth_system/widget/make_text_button.dart'; import 'package:auth_system/widget/make_text_field.dart'; import 'package:auth_system/widget/route.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class LoginPage extends StatefulWidget { const LoginPage({Key? key}) : super(key: key); @override State<LoginPage> createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { bool _showPassword = true; late TextEditingController _email; late TextEditingController _pass; late FocusNode femail; late FocusNode fpass; @override void initState() { super.initState(); _email = TextEditingController(); _pass = TextEditingController(); femail = FocusNode(); fpass = FocusNode(); } @override void dispose() { femail.dispose(); fpass.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return SafeArea( child: Scaffold( body: SingleChildScrollView( child: Padding( padding: EdgeInsets.only( top: size.height * 0.09, left: size.width * 0.02, right: size.width * 0.02, ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ makeText( "Auth System", fontWeight: FontWeight.bold, size: Theme.of(context).textTheme.headline5!.fontSize, ), SizedBox( height: size.height * 0.2, ), makeText( "Log In", fontWeight: FontWeight.bold, textColor: Colors.grey, size: Theme.of(context).textTheme.headline6!.fontSize, ), SizedBox( height: size.height * 0.02, ), makeTextField( autofocus: true, controller: _email, hintText: "Enter your Email", obscureText: false, focusNode: femail, onFieldSubmitted: (next) { femail.unfocus(); FocusScope.of(context).requestFocus(fpass); }, textInputAction: TextInputAction.next, ), SizedBox( height: size.height * 0.013, ), makeTextField( autofocus: true, controller: _pass, hintText: "Enter your Password", obscureText: _showPassword, suffixIcon: InkWell( onTap: () { setState(() { _showPassword = !_showPassword; }); }, child: Icon(_showPassword ? Icons.visibility : Icons.visibility_off), ), focusNode: fpass, textInputAction: TextInputAction.done), SizedBox( height: size.height * 0.02, ), makeElevatedButton( "Login", textSize: Theme.of(context).textTheme.button!.fontSize!, onPressed: () async { var email = _email.text; var pass = _pass.text; try { await AuthAppwrite.instance!.login( email: email, password: pass, ); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText( "Welcome to Auth System", ), ), ); pushReplacement(context, const MainPage()); } on AppwriteException catch (e) { if(kDebugMode) print(e.message); ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText( e.message!, ), ), ); } }, minimumSize: Size( size.width * 0.5, size.height * 0.05, ), ), SizedBox( height: size.height * 0.02, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ makeText("If you don't have an account?"), SizedBox( width: size.width * 0.01, ), makeTextButton("Signup", onPressed: () { push(context, const SignupPage()); }), ], ), ], ), ), ), ), ); } }
0
mirrored_repositories/Auth_System_Appwrite/lib/view_pages
mirrored_repositories/Auth_System_Appwrite/lib/view_pages/auth_pages/signup.dart
import 'package:appwrite/appwrite.dart'; import 'package:auth_system/data/service/appwrite_auth_service.dart'; import 'package:auth_system/widget/make_elevated_button.dart'; import 'package:auth_system/widget/make_text.dart'; import 'package:auth_system/widget/make_text_button.dart'; import 'package:auth_system/widget/make_text_field.dart'; import 'package:auth_system/widget/route.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class SignupPage extends StatefulWidget { const SignupPage({Key? key}) : super(key: key); @override State<SignupPage> createState() => _SignupPageState(); } class _SignupPageState extends State<SignupPage> { bool _showPassword = true; late TextEditingController _name; late TextEditingController _email; late TextEditingController _pass; late FocusNode femail; late FocusNode fpass; late FocusNode fname; @override void initState() { super.initState(); _name = TextEditingController(); _email = TextEditingController(); _pass = TextEditingController(); femail = FocusNode(); fname = FocusNode(); fpass = FocusNode(); } @override void dispose() { fname.dispose(); femail.dispose(); fpass.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return Scaffold( body: SingleChildScrollView( child: Padding( padding: EdgeInsets.only( top: size.height * 0.09, left: size.width * 0.02, right: size.width * 0.02, ), child: Column( children: [ makeText( "Auth System", fontWeight: FontWeight.bold, size: Theme.of(context).textTheme.headline5!.fontSize, ), SizedBox( height: size.height * 0.2, ), makeText( "Sign Up", fontWeight: FontWeight.bold, textColor: Colors.grey, size: Theme.of(context).textTheme.headline6!.fontSize, ), SizedBox( height: size.height * 0.02, ), makeTextField( autofocus: true, controller: _name, hintText: "Enter your Full Name", obscureText: false, focusNode: fname, onFieldSubmitted: (val) { fname.unfocus(); FocusScope.of(context).requestFocus(femail); }, textInputAction: TextInputAction.next, ), SizedBox( height: size.height * 0.013, ), makeTextField( controller: _email, hintText: "Enter your Email", obscureText: false, focusNode: femail, onFieldSubmitted: (val) { femail.unfocus(); FocusScope.of(context).requestFocus(fpass); }, textInputAction: TextInputAction.next, ), SizedBox( height: size.height * 0.013, ), makeTextField( focusNode: fpass, textInputAction: TextInputAction.done, controller: _pass, hintText: "Enter your Password", obscureText: _showPassword, suffixIcon: InkWell( onTap: () { setState(() { _showPassword = !_showPassword; }); }, child: Icon( _showPassword ? Icons.visibility : Icons.visibility_off, ), ), ), SizedBox( height: size.height * 0.02, ), makeElevatedButton( "Create an Account", textSize: Theme.of(context).textTheme.button!.fontSize!, onPressed: () async { var email = _email.text; var name = _name.text; var pass = _pass.text; try { await AuthAppwrite.instance!.signup( userID: '', name: name, email: email, password: pass, ); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: const Duration(seconds: 1), content: makeText( "Successfully Create Your Account", ), ), ); pop(context); } on AppwriteException catch (e) { if (kDebugMode) print(e.message); } }, minimumSize: Size( size.width * 0.5, size.height * 0.05, ), ), SizedBox( height: size.height * 0.02, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ makeText("If you have an account?"), SizedBox( width: size.width * 0.01, ), makeTextButton("Login", onPressed: () { pop(context); }), ], ), ], ), ), ), ); } }
0
mirrored_repositories/Auth_System_Appwrite/lib
mirrored_repositories/Auth_System_Appwrite/lib/res/textstyle.dart
import 'package:flutter/cupertino.dart'; TextStyle textStyle({ Color? textColor, double? size, FontWeight? fontWeight, }) { return TextStyle( color: textColor, fontSize: size, fontWeight: fontWeight, ); }
0
mirrored_repositories/Auth_System_Appwrite/lib
mirrored_repositories/Auth_System_Appwrite/lib/res/appwrite_constant.dart
class AppwriteConstant { static const String projectId = "use your project ID"; static const String endpontId = "use your end point"; }
0
mirrored_repositories/Auth_System_Appwrite/lib/data
mirrored_repositories/Auth_System_Appwrite/lib/data/model/user.dart
import 'dart:convert'; import 'package:appwrite/models.dart'; import 'package:equatable/equatable.dart'; class UserData extends Equatable { // final String id; final String name; final DateTime registration; final bool status; final DateTime passwordUpdate; final String email; final bool emailVerification; final Map<String, dynamic> prefs; // const UserData({ required this.id, required this.name, required this.registration, required this.status, required this.passwordUpdate, required this.email, required this.emailVerification, required this.prefs, }); Map<String, dynamic> toMap() { return { 'id': id, 'name': name, 'registration': registration.millisecondsSinceEpoch, 'status': status, 'passwordUpdate': passwordUpdate, 'email': email, 'emailVerification': emailVerification, 'prefs': prefs, }; } factory UserData.fromMap(User user) { return UserData( id: user.$id, name: user.name, registration: DateTime.fromMillisecondsSinceEpoch( user.registration * 1000, ), status: user.status, passwordUpdate: DateTime.fromMillisecondsSinceEpoch( user.passwordUpdate * 1000, ), email: user.email, emailVerification: user.emailVerification, prefs: user.prefs.data, ); } String toJson() => json.encode(toMap()); factory UserData.fromJson(String source) => UserData.fromMap(json.decode(source)); @override String toString() { return 'UserData(id: $id, name: $name, registration: $registration, status: $status, passwordUpdate: $passwordUpdate, email: $email, emailVerification: $emailVerification, prefs: $prefs)'; } @override List<Object> get props => [ id, name, registration, status, passwordUpdate, email, emailVerification, prefs ]; }
0
mirrored_repositories/Auth_System_Appwrite/lib/data
mirrored_repositories/Auth_System_Appwrite/lib/data/service/appwrite_auth_service.dart
import 'package:appwrite/appwrite.dart'; import 'package:appwrite/models.dart'; import 'package:auth_system/data/model/user.dart'; import 'package:auth_system/res/appwrite_constant.dart'; class AuthAppwrite { static AuthAppwrite? _instance; late Client _client; late Account _account; AuthAppwrite._internal() { _client = Client(endPoint: AppwriteConstant.endpontId) .setProject(AppwriteConstant.projectId) .setSelfSigned(); _account = Account(_client); } static AuthAppwrite? get instance { if (_instance == null) return _instance = AuthAppwrite._internal(); return _instance; } Future signup({ required String userID, required String name, required String email, required String password, }) async { return _account.create( userId: userID.isEmpty ? 'unique()' : userID, name: name, email: email, password: password, ); } Future login({ required String email, required String password, }) { return _account.createEmailSession(email: email, password: password); } Future<UserData> knowUserLogin() async { User res = await _account.get(); return UserData.fromMap(res); } Future logout() async { await _account.deleteSessions(); } Future<UserData> updateName({ required String name, }) async { User res = await _account.updateName(name: name); return UserData.fromMap(res); } Future<UserData> updateEmail({ required String email, required String password, }) async { User res = await _account.updateEmail(email: email, password: password); return UserData.fromMap(res); } Future<UserData> updatePassword({ required String password, required String oldpw, }) async { User res = await _account.updatePassword( password: password, oldPassword: oldpw, ); return UserData.fromMap(res); } }
0