repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/component/secondary_button.dart
import 'package:flutter/material.dart'; class SecondaryButton extends StatelessWidget { const SecondaryButton({ Key? key, required this.child, this.onPressed, }) : super(key: key); final Widget child; final VoidCallback? onPressed; @override Widget build(BuildContext context) { return TextButton( onPressed: onPressed, style: ButtonStyle( foregroundColor: MaterialStateProperty.all(Colors.white), overlayColor: MaterialStateProperty.all(Colors.white10), minimumSize: MaterialStateProperty.all(const Size(50, 40)), ), child: child, ); } }
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/component/sliver_gap.dart
import 'package:flutter/material.dart'; class SliverGap extends StatelessWidget { const SliverGap(this.height, {Key? key}) : super(key: key); final double height; @override Widget build(BuildContext context) { return SliverToBoxAdapter( child: SizedBox(height: height), ); } }
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/screen/about_screen.dart
import 'dart:io'; import 'package:feather_icons_svg/feather_icons_svg.dart'; import 'package:flutter/material.dart'; import 'package:pressable/pressable.dart'; import 'package:url_launcher/url_launcher.dart'; import '/component/back_button.dart'; class AboutScreen extends StatelessWidget { const AboutScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: CustomScrollView( physics: const NeverScrollableScrollPhysics(), slivers: [ SliverAppBar( title: Text( 'About this app'.toUpperCase(), style: const TextStyle(fontSize: 16), ), pinned: true, elevation: 10, leading: const CustomBackButton(), bottom: PreferredSize( preferredSize: const Size.fromHeight(2), child: Container( color: Colors.white24, width: double.infinity, height: 1, ), ), ), SliverToBoxAdapter( child: ListTile( title: const Text('GitHub repository'), subtitle: const Text('See the source code'), trailing: const FeatherIcon( FeatherIcons.link, strokeWidth: 1.5, color: Colors.white, ), onTap: () async { final url = Uri.parse('https://github.com/vaetas/inquire'); if (await canLaunchUrl(url)) { await launchUrl(url, mode: LaunchMode.externalApplication); } }, ), ), const SliverFillRemaining( hasScrollBody: false, child: _Footer(), ) ], ), ), ); } } class _Footer extends StatelessWidget { const _Footer({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Align( alignment: Alignment.bottomCenter, child: Pressable.opacity( onPressed: () async { final url = Uri.parse('https://www.vojtech.net/'); if (await canLaunchUrl(url)) { await launchUrl(url, mode: LaunchMode.externalApplication); } }, child: Padding( padding: const EdgeInsets.all(16.0), child: Text( 'Made with ❤️${Platform.isIOS ? '' : ' '}by Vojtech Pavlovsky', ), ), ), ); } }
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/screen/game_screen.dart
import 'package:animations/animations.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:inquire/util/log.dart'; import '/component/back_button.dart'; import '/model/progress_state/progress_state.dart'; import '/provider/progress_provider.dart'; import '/util/palette.dart'; class GameScreen extends ConsumerStatefulWidget { const GameScreen({Key? key}) : super(key: key); @override ConsumerState<GameScreen> createState() => _GameScreenState(); } class _GameScreenState extends ConsumerState<GameScreen> with LogMixin { @override void initState() { super.initState(); SchedulerBinding.instance.addPostFrameCallback((_) { _initGame(); }); } void _initGame() { final state = ref.read(progressProvider); if (state is ProgressStateActive) { log('Resuming previous game...'); } else { ref.read(progressProvider.notifier).start(); } } @override Widget build(BuildContext context) { const backgroundColor = Palette.primaryColor; final padding = MediaQuery.of(context).padding; final progress = ref.watch(progressProvider); return Scaffold( body: Padding( padding: EdgeInsets.only( top: padding.top, left: padding.left, right: padding.right, ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Row(children: const [CustomBackButton()]), ...progress.when( active: (currentQuestion, finishedQuestions) { return [ Expanded( key: const ValueKey('question_view'), child: PageTransitionSwitcher( transitionBuilder: ( child, primaryAnimation, secondaryAnimation, ) { return SharedAxisTransition( animation: primaryAnimation, secondaryAnimation: secondaryAnimation, transitionType: SharedAxisTransitionType.horizontal, fillColor: Colors.black, child: child, ); }, child: _QuestionTextView( key: ValueKey(currentQuestion.text.hashCode), text: currentQuestion.text, ), ), ), NextQuestionButton( onPressed: () { ref.read(progressProvider.notifier).nextQuestion(); }, ), ]; }, finished: () { return [ const Expanded( child: Center( child: Text( 'All questions answered.', style: TextStyle( color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold, ), ), ), ), const SizedBox(height: 56), ]; }, inactive: () { return const [SizedBox()]; }, ), ], ), ), backgroundColor: backgroundColor, ); } } class NextQuestionButton extends StatelessWidget { const NextQuestionButton({ Key? key, required this.onPressed, }) : super(key: key); final VoidCallback onPressed; @override Widget build(BuildContext context) { final padding = MediaQuery.of(context).padding; return InkWell( onTap: onPressed, focusColor: Colors.white, child: Column( mainAxisSize: MainAxisSize.min, children: [ Container( color: Colors.white24, width: double.infinity, height: 1, ), Container( color: Colors.black, width: double.infinity, padding: EdgeInsets.only( bottom: padding.bottom + 24, top: 24, left: 16, right: 16, ), child: Center( child: Text( 'Next question'.toUpperCase(), style: TextStyle( color: Colors.white.withOpacity(0.9), fontSize: 16, fontWeight: FontWeight.w600, ), ), ), ), ], ), ); } } class _QuestionTextView extends StatelessWidget { const _QuestionTextView({ Key? key, required this.text, }) : super(key: key); final String text; @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { return Container( height: double.infinity, padding: EdgeInsets.only( top: constraints.maxHeight * 0.2, left: 24, right: 24, ), child: Text( text, style: const TextStyle( color: Colors.white, fontFamily: Palette.serifFont, fontSize: 30, fontWeight: FontWeight.w600, ), textAlign: TextAlign.center, ), ); }, ); } }
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/screen/question_list_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '/component/back_button.dart'; import '/component/sliver_gap.dart'; import '/model/question/question.dart'; import '/provider/question_list_provider.dart'; class QuestionListScreen extends ConsumerWidget { const QuestionListScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context, WidgetRef ref) { final questions = ref.watch(questionListProvider); return Scaffold( body: CustomScrollView( slivers: [ SliverAppBar( title: Text( 'Question list'.toUpperCase(), style: const TextStyle(fontSize: 16), ), pinned: true, elevation: 10, leading: const CustomBackButton(), bottom: PreferredSize( preferredSize: const Size.fromHeight(2), child: Container( color: Colors.white24, width: double.infinity, height: 1, ), ), ), const SliverGap(24), SliverList( delegate: SliverChildBuilderDelegate( (context, index) { final q = questions[index]; return QuestionTile(question: q); }, childCount: questions.length, ), ), const SliverGap(64), ], ), ); } } class QuestionTile extends StatelessWidget { const QuestionTile({ Key? key, required this.question, }) : super(key: key); final Question question; @override Widget build(BuildContext context) { return ListTile( title: Text(question.text), ); } }
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/screen/home_screen.dart
import 'package:feather_icons_svg/feather_icons_svg.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import '/component/secondary_button.dart'; import '/model/progress_state/progress_state.dart'; import '/provider/progress_provider.dart'; import '/util/log.dart'; import '/util/palette.dart'; class HomeScreen extends ConsumerWidget with LogMixin { const HomeScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context, WidgetRef ref) { final progressState = ref.watch(progressProvider); return Scaffold( appBar: AppBar( title: const Text( 'Inquire.', style: TextStyle( fontFamily: Palette.serifFont, fontWeight: FontWeight.w700, ), ), ), body: SafeArea( child: Column( children: [ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( onTap: () { // if (progressState is ProgressStateActive) { // log('Resuming previous game...'); // } else { // ref.read(progressProvider.notifier).start(); // } context.go('/game'); }, child: Column( mainAxisSize: MainAxisSize.min, children: [ const _Line(), Padding( padding: const EdgeInsets.all(24.0), child: Text( progressState is ProgressStateActive ? 'Continue'.toUpperCase() : 'Play'.toUpperCase(), style: const TextStyle( fontSize: 30, fontWeight: FontWeight.w600, ), ), ), const _Line(), ], ), ), if (progressState is ProgressStateActive) _ResetButton( onPressed: () { ref.read(progressProvider.notifier).reset(); }, ) else const SizedBox(height: 48), ], ), ), const _Footer(), ], ), ), ); } } class _ResetButton extends StatelessWidget { const _ResetButton({ Key? key, this.onPressed, }) : super(key: key); final VoidCallback? onPressed; @override Widget build(BuildContext context) { return SecondaryButton( onPressed: onPressed, child: Row( mainAxisSize: MainAxisSize.min, children: [ const FeatherIcon( FeatherIcons.repeat, size: 16, ), const SizedBox(width: 8), Text( 'New game'.toUpperCase(), style: const TextStyle( fontWeight: FontWeight.w600, ), ), ], ), ); } } class _Footer extends StatelessWidget { const _Footer({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SecondaryButton( onPressed: () { context.go('/questions'); }, child: Text('Question list'.toUpperCase()), ), const SizedBox(width: 8), const Text('—'), const SizedBox(width: 8), SecondaryButton( onPressed: () { context.go('/about'); }, child: Text('About'.toUpperCase()), ), ], ); } } class _Line extends StatelessWidget { const _Line({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( color: Colors.white24, width: double.infinity, height: 1, ); } }
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/provider/question_list_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; import '/model/question/question.dart'; import '/repository/question_repository.dart'; import '/util/locator.dart'; class QuestionListNotifier extends StateNotifier<List<Question>> { QuestionListNotifier({ required this.questionRepository, }) : super([]); final QuestionRepository questionRepository; void load() { state = questionRepository.getQuestions(); } } final questionListProvider = StateNotifierProvider<QuestionListNotifier, List<Question>>( (ref) => QuestionListNotifier( questionRepository: locator<QuestionRepository>(), )..load(), );
0
mirrored_repositories/inquire/lib
mirrored_repositories/inquire/lib/provider/progress_provider.dart
import 'dart:math' as math; import 'package:collection/collection.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:inquire/model/question/question.dart'; import '/model/progress_state/progress_state.dart'; import '/provider/question_list_provider.dart'; import '/util/log.dart'; class ProgressNotifier extends StateNotifier<ProgressState> with LogMixin { ProgressNotifier(this.ref) : super(const ProgressState.inactive()); final Ref ref; late final _questions = ref.read(questionListProvider); late final _random = math.Random(); Question _getRandomQuestion({ required List<Question> questions, }) { final nextIndex = _random.nextInt(questions.length); return questions[nextIndex]; } Future<void> start() async { log('start'); state = ProgressState.active( currentQuestion: _getRandomQuestion(questions: _questions), remainingQuestions: _questions, ); } Future<void> nextQuestion() async { log('nextQuestion'); state.when( finished: () { throw StateError('Game is already finished'); }, active: (currentQuestion, remainingQuestions) { if (remainingQuestions.isEmpty) { state = const ProgressState.finished(); } else { final question = _getRandomQuestion( questions: remainingQuestions, ); state = ProgressState.active( currentQuestion: question, remainingQuestions: remainingQuestions .whereNot((element) => element.id == question.id) .toList(), ); } }, inactive: () { throw StateError('Game must be started before calling nextQuestion()'); }, ); } Future<void> reset() async { log('reset'); state = const ProgressState.inactive(); } @override set state(ProgressState value) { log('state: $value'); super.state = value; } } final progressProvider = StateNotifierProvider<ProgressNotifier, ProgressState>( ProgressNotifier.new, );
0
mirrored_repositories/inquire
mirrored_repositories/inquire/test/game_screen_test.dart
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:inquire/model/progress_state/progress_state.dart'; import 'package:inquire/model/question/question.dart'; import 'package:inquire/provider/progress_provider.dart'; import 'package:inquire/provider/question_list_provider.dart'; import 'package:inquire/repository/question_repository.dart'; import 'package:inquire/screen/game_screen.dart'; import 'package:mocktail/mocktail.dart'; class MockQuestionRepository extends Mock implements QuestionRepository {} void main() { late MockQuestionRepository questionRepository; late ProviderContainer providerContainer; const mockQuestion1 = Question(id: 1, text: 'ABC'); const mockQuestion2 = Question(id: 2, text: 'XYZ'); const questionList = [mockQuestion1, mockQuestion2]; Widget buildScreen() { providerContainer = ProviderContainer( overrides: [ questionListProvider.overrideWithProvider( StateNotifierProvider( (ref) => QuestionListNotifier(questionRepository: questionRepository) ..load(), ), ) ], ); return UncontrolledProviderScope( container: providerContainer, child: const MaterialApp( home: GameScreen(), ), ); } void setupQuestionListProvider() { questionRepository = MockQuestionRepository(); when(questionRepository.getQuestions).thenReturn(questionList); when(() => questionRepository.getQuestion(0)).thenReturn(mockQuestion1); when(() => questionRepository.getQuestion(1)).thenReturn(mockQuestion2); } // ignore: unnecessary_lambdas setUp(() { setupQuestionListProvider(); }); testWidgets('GameScreen shows questions', (tester) async { final usedQuestions = <Question>[]; await tester.pumpWidget(buildScreen()); await tester.pumpAndSettle(); verify(questionRepository.getQuestions).called(1); verifyNoMoreInteractions(questionRepository); final nextQuestionButton = find.byType(NextQuestionButton); expect(nextQuestionButton, findsOneWidget); final questionView = find.byKey(const ValueKey('question_view')); expect(questionView, findsOneWidget); final initialState = providerContainer.read(progressProvider); expect(initialState, isA<ProgressStateActive>()); final s = initialState as ProgressStateActive; final firstQuestion = s.currentQuestion; usedQuestions.add(firstQuestion); await tester.tap(nextQuestionButton); await tester.pump(); final secondQuestion = providerContainer.read(progressProvider) as ProgressStateActive; expect(secondQuestion, isNot(equals(firstQuestion))); }); }
0
mirrored_repositories/inquire
mirrored_repositories/inquire/test/question_list_screen_test.dart
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:inquire/model/question/question.dart'; import 'package:inquire/provider/question_list_provider.dart'; import 'package:inquire/repository/question_repository.dart'; import 'package:inquire/screen/question_list_screen.dart'; import 'package:mocktail/mocktail.dart'; class MockQuestionRepository extends Mock implements QuestionRepository {} void main() { late MockQuestionRepository questionRepository; const mockQuestion1 = Question(id: 1, text: 'ABC'); const mockQuestion2 = Question(id: 2, text: 'XYZ'); Widget buildScreen() { return ProviderScope( overrides: [ questionListProvider.overrideWithProvider( StateNotifierProvider( (ref) => QuestionListNotifier(questionRepository: questionRepository) ..load(), ), ), ], child: const MaterialApp( home: QuestionListScreen(), ), ); } void setupQuestionListProvider() { questionRepository = MockQuestionRepository(); when(questionRepository.getQuestions) .thenReturn([mockQuestion1, mockQuestion2]); } // ignore: unnecessary_lambdas setUp(() { setupQuestionListProvider(); }); testWidgets('QuestionListScreen displays questions', (tester) async { await tester.pumpWidget(buildScreen()); await tester.pumpAndSettle(); verify(questionRepository.getQuestions).called(1); verifyNoMoreInteractions(questionRepository); expect(find.byType(QuestionTile), findsNWidgets(2)); expect(find.text(mockQuestion1.text), findsOneWidget); expect(find.text(mockQuestion2.text), findsOneWidget); }); }
0
mirrored_repositories/life_countdown
mirrored_repositories/life_countdown/lib/life.dart
import 'package:scoped_model/scoped_model.dart'; import 'package:shared_preferences/shared_preferences.dart'; class Life extends Model { int life = 900; String _key; DateTime _birthDay = DateTime(2000, 1, 1); DateTime get birthDay => _birthDay; set birthDay(DateTime value) { _birthDay = value; _setBirthday(); notifyListeners(); } static int dateDifference(DateTime date1, DateTime date2) { int result = date1.day - date2.day >= 0 ? 0 : -1; return (date1.year - date2.year) * 12 + date1.month - date2.month + result; } Life(String key) { this._key = key; _initBirthday(); } int pastLife() { return dateDifference(DateTime.now(), this._birthDay); } int remainingLife() { return life - pastLife(); } Future _initBirthday() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); String birth = prefs.getString(_key) ?? null; if (birth != null) { this._birthDay = DateTime.parse(birth); } notifyListeners(); } Future<bool> _setBirthday() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.setString(_key, _birthDay.toString()); } }
0
mirrored_repositories/life_countdown
mirrored_repositories/life_countdown/lib/main.dart
import 'package:flutter/material.dart'; import 'package:life_countdown/grid.dart'; import 'package:life_countdown/life.dart'; import 'package:scoped_model/scoped_model.dart'; void main() { runApp(ScopedModel( child: MyApp(), model: Life("me"), )); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Life Countdown', theme: ThemeData( primaryColor: Colors.white, ), home: HomePage(), ); } } class HomePage extends StatefulWidget { HomePage({Key key}) : super(key: key); @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { void showDefaultYearPicker(BuildContext context, Life life) async { final DateTime dateTime = await showDatePicker( context: context, initialDate: life.birthDay, firstDate: DateTime(1950, 1), lastDate: DateTime.now(), builder: (BuildContext context, Widget child) { return Theme( data: ThemeData.dark(), child: child, ); }, ); if (dateTime != null && dateTime != life.birthDay) { life.birthDay = dateTime; } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( DateTime.now().toString().substring(0, 10), style: TextStyle( fontSize: 32, fontWeight: FontWeight.bold, fontFamily: "Barriecito"), ), centerTitle: true, elevation: 0, actions: <Widget>[ IconButton( icon: Icon(Icons.settings), onPressed: () { showDefaultYearPicker(context, ScopedModel.of<Life>(context)); }) ], ), body: Padding( padding: const EdgeInsets.all(1.0), child: ScopedModelDescendant<Life>( builder: (BuildContext context, Widget child, Life model) { return Column( children: <Widget>[ Grid(life: model), Padding( padding: const EdgeInsets.only(top: 40, bottom: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: EdgeInsets.only(right: 40), child: Container( height: 48, child: Image.asset("asset/iron_man.png")), ), Text( model.remainingLife().toString() + " / " + model.life.toString(), style: TextStyle( fontSize: 48, fontFamily: "Barriecito")), ], ), ), Text( "Stay Hungry \t Stay Foolish", style: TextStyle( fontFamily: "Barriecito", fontWeight: FontWeight.bold, fontSize: 24), ), ], ); }, ), ), ); } }
0
mirrored_repositories/life_countdown
mirrored_repositories/life_countdown/lib/grid.dart
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:life_countdown/life.dart'; class Grid extends StatefulWidget { Grid({Key key, @required this.life}) : super(key: key); final Life life; static List<int> colors = [ 0xFFFFFFFF, 0xAAD4DFE6, 0xAA8EC0E4, 0xAACADBE9, 0xAA6AAFE6, 0xAAA5DFF9, 0xAAFEEE7D, 0xAAFAB1CE, 0xAAFFDA8E ]; static BorderSide _borderThin = new BorderSide(width: 0.5, color: Color(0xFFE0E3DA)); static BorderSide _borderBold = new BorderSide(width: 1.0, color: Color(0xFFE0E3DA)); Border generateBorder(int x, int y) { BorderSide leftBorder = _borderThin; BorderSide topBorder = _borderThin; BorderSide rightBorder = _borderThin; BorderSide bottomBorder = _borderThin; if (x == 0) { topBorder = _borderBold; } else if (x == this.life.life / 30 - 1) { bottomBorder = _borderBold; } if (y == 0) { leftBorder = _borderBold; } else if (y == 29) { rightBorder = _borderBold; } return new Border( left: leftBorder, top: topBorder, right: rightBorder, bottom: bottomBorder, ); } @override _GridState createState() => _GridState(); } class _GridState extends State<Grid> { @override Widget build(BuildContext context) { final width = (MediaQuery.of(context).size.width - 2) / 30; var rng = new Random(); List<Widget> rowDetail(rowIndex) { List<Widget> result = new List<Widget>(); int pastMonth = widget.life.pastLife(); int month = rowIndex * 30; for (int i = 0; i < 30; i++) { int currentMonth = month + i; result.add(Container( width: width, height: width, decoration: BoxDecoration( border: widget.generateBorder(rowIndex, i), color: currentMonth < pastMonth ? Color(0xFF5E5E5F) : currentMonth == pastMonth ? Colors.red : currentMonth < pastMonth + 10 ? Colors.white : Color(Grid.colors[ rng.nextInt(18) > 8 ? 0 : rng.nextInt(9)])), )); } return result; } List<Widget> rowList() { List<Widget> result = new List<Widget>(); for (int i = 0; i < widget.life.life / 30; i++) { result.add(Row( children: rowDetail(i), )); } return result; } return Column( children: rowList(), ); } }
0
mirrored_repositories/ost_music_app_ui
mirrored_repositories/ost_music_app_ui/lib/main.dart
import 'dart:async'; import 'dart:developer'; import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:fontresoft/fontresoft.dart'; import 'package:go_router/go_router.dart'; import 'package:ost_music_app_ui/providers/providers.dart'; import 'package:ost_music_app_ui/routes/discover.dart'; import 'package:ost_music_app_ui/routes/error.dart'; import 'package:ost_music_app_ui/routes/library.dart'; import 'package:ost_music_app_ui/routes/now_playing.dart'; import 'package:ost_music_app_ui/routes/playlist.dart'; import 'data/constants/constants.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft, ]).then(appCallback); } class MyApp extends StatelessWidget { MyApp({super.key}); @override Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, WidgetRef ref, Widget? child) { var state = ref.watch(themeProvider.select((value) => value)); log(state.toString()); return MaterialApp.router( debugShowCheckedModeBanner: false, title: Constants.appName, themeMode: condition(state, ThemeMode.light, ThemeMode.dark), theme: ThemeData( useMaterial3: true, brightness: Brightness.light, colorSchemeSeed: Colors.purpleAccent, fontFamily: FontResoft.poppins, package: FontResoft.package, highlightColor: Colors.transparent, splashColor: Colors.transparent, typography: Typography.material2021(englishLike: Typography.dense2021), textTheme: const TextTheme(bodyMedium: TextStyle(color: Colors.white)), ), darkTheme: ThemeData( useMaterial3: true, brightness: Brightness.dark, colorSchemeSeed: Colors.purple, fontFamily: FontResoft.poppins, package: FontResoft.package, highlightColor: Colors.transparent, splashColor: Colors.transparent, textTheme: const TextTheme(bodyMedium: TextStyle()), ), routeInformationProvider: _router.routeInformationProvider, routeInformationParser: _router.routeInformationParser, routerDelegate: _router.routerDelegate, shortcuts: { ...WidgetsApp.defaultShortcuts, const SingleActivator(LogicalKeyboardKey.select): const ActivateIntent(), }, localizationsDelegates: const [], ); }, ); } final GoRouter _router = GoRouter( routes: <GoRoute>[ route(Constants.root, const Discover()), route(Constants.library, const Library()), route(Constants.discover, const Discover()), route(Constants.playlist, const Playlist()), route(Constants.nowPlaying, const NowPlaying()), route(Constants.error, const ErrorPage()), ], errorBuilder: (context, state) => const ErrorPage(), ); } GoRoute route(String path, Widget route) { return routeTransition(path, route); /*return GoRoute( path: path, builder: (BuildContext context, GoRouterState state) => route, );*/ } GoRoute routeTransition(String path, Widget route) { return GoRoute( path: path, pageBuilder: (context, state) => CustomTransitionPage( child: route, transitionsBuilder: (context, animation, _, child) => FadeTransition( opacity: CurvedAnimation(parent: animation, curve: Curves.easeInOutBack), child: child, ), transitionDuration: const Duration(seconds: 1), ), ); } launch(BuildContext context, String route, [Object? extra]) { GoRouter.of(context).push(route, extra: extra); } replace(BuildContext context, String route, [Object? extra]) { GoRouter.of(context).replace(route, extra: extra); } launchReplace(BuildContext context, String route, [Object? extra]) { GoRouter.of(context).pushReplacement(route, extra: extra); } finish(BuildContext context) => GoRouter.of(context).pop(); FutureOr appCallback(void value) { runApp( ProviderScope( child: ScreenUtilInit( designSize: const Size(360, 820), splitScreenMode: true, minTextAdapt: true, child: MyApp(), ), ), ); }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/widgets/artist_card.dart
import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/material.dart'; import '../data/constants/constants.dart'; class ArtistCard extends StatelessWidget { const ArtistCard({Key? key, required this.index}) : super(key: key); final int index; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Card( elevation: 2, shadowColor: const Color(0xff866684), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), child: Container( height: 115, width: Constants.wrapWidth, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: Colors.black45, image: DecorationImage(image: ExactAssetImage(Constants.artisteList[index].image), fit: BoxFit.cover), ), ), ), Constants.wrapWidth.spaceX( Text( overflow: TextOverflow.ellipsis, Constants.artisteList[index].name, style: const TextStyle(fontSize: 14), ), ), ], ); } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/widgets/album_card.dart
import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ost_music_app_ui/routes/now_playing.dart'; import '../data/constants/constants.dart'; import '../main.dart'; import '../utils/utils.dart'; class AlbumCard extends StatelessWidget { const AlbumCard({ required this.index, super.key, /*required this.ref*/ }); final int index; //final WidgetRef ref; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { //launch(context, Constants.nowPlaying, Constants.albumList[index]); Navigator.push( context, MaterialPageRoute( builder: (context) => const NowPlaying(), settings: RouteSettings(name: 'album', arguments: Constants.albumList[index]), ), ); //ref.watch(currentlyPlaying.notifier).current(Constants.albumList[index]); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Card( elevation: 2, shadowColor: const Color(0xff866684), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12).r), child: Container( height: 110.h, width: Constants.wrapWidth, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12).r, color: Colors.black45, image: DecorationImage(image: Utils.buildExactAssetImage(index), fit: BoxFit.cover), ), ), ), Padding( padding: EdgeInsets.only(left: 4.w), child: Constants.wrapWidth.spaceX(Text( overflow: TextOverflow.ellipsis, Constants.albumList[index].title!, style: TextStyle(fontSize: 16.h, color: Colors.white.withAlpha(190)), )), ), Padding( padding: EdgeInsets.only(left: 4.w), child: Constants.wrapWidth.spaceX(Text( softWrap: true, Constants.albumList[index].artiste!.name, style: TextStyle(fontSize: 12.h, color: Colors.white.withAlpha(100)), )), ), ], ), ); } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/widgets/bottom_nav.dart
import 'package:bottom_nav/bottom_nav.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ost_music_app_ui/data/models/album.dart'; import 'package:ost_music_app_ui/routes/now_playing.dart'; import '../data/constants/constants.dart'; import '../main.dart'; import '../providers/providers.dart'; import '../utils/page.dart'; class CustomBottomNav extends StatefulWidget { const CustomBottomNav({Key? key, required this.context, required this.ref, this.page}) : super(key: key); final BuildContext context; final WidgetRef ref; final NavPage? page; @override State<CustomBottomNav> createState() => _CustomBottomNavState(); } class _CustomBottomNavState extends State<CustomBottomNav> { @override Widget build(BuildContext context) { Album album = widget.ref.watch(currentlyPlaying.select((value) => value)); var isLaunched = widget.ref.watch(launchProvider.select((value) => value)); //Future.delayed(const Duration(seconds: 1), () => widget.ref.watch(launchProvider.notifier).launch(true)); return Theme( data: ThemeData( highlightColor: Colors.transparent, splashColor: Colors.transparent, ), child: BottomNav( divider: Divider(height: 1.h, color: Colors.white.withOpacity(0.3)), height: 91.5.h, padding: EdgeInsets.only(bottom: 15.h, left: 20.w, right: 20.w), onTap: (index) => buildNavSwitch(index, context, widget.ref), iconSize: 26.r, backgroundColor: const Color(0xff41415f), color: const Color(0xff878b9c), colorSelected: const Color(0xffe2a5a9), //indexSelected: isLaunched ? widget.ref.watch(tabProvider.select((value) => value)) : widget.page!.page, indexSelected: widget.page!.page, items: [ const BottomNavItem(label: 'Discover', child: CupertinoIcons.rays), const BottomNavItem(label: 'Library', child: CupertinoIcons.tray), BottomNavItem( label: '', child: Card( color: Colors.white.withAlpha(200), elevation: 10, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(180).r), child: Container( margin: const EdgeInsets.all(3).r, height: 42.h, width: 42.h, decoration: BoxDecoration( image: DecorationImage(image: ExactAssetImage(album != Album.empty() ? album.image! : Constants.album), fit: BoxFit.cover), borderRadius: BorderRadius.circular(180).r, ), ), ), ), const BottomNavItem(label: 'Store', child: CupertinoIcons.shopping_cart), const BottomNavItem(label: 'Account', child: CupertinoIcons.person), ], ), ); } } void buildNavSwitch(int index, BuildContext context, WidgetRef ref) { var cacheTabIndex = ref.watch(tabProvider.select((value) => value)); switch (index) { case 0: //ref.watch(launchProvider.notifier).launch(true); if (cacheTabIndex != 0) { launchReplace(context, Constants.discover); ref.watch(tabProvider.notifier).setTab = index; } break; case 1: //ref.watch(launchProvider.notifier).launch(true); if (cacheTabIndex != 1) { launchReplace(context, Constants.library); ref.watch(tabProvider.notifier).setTab = index; } break; case 2: if (cacheTabIndex != 2) { currentSong(ref).title == null ? null : Navigator.push( context, MaterialPageRoute( builder: (context) { return const NowPlaying(); }, settings: RouteSettings(name: 'album', arguments: currentSong(ref)), ), ); /*launchReplace(context, Constants.nowPlaying, currentSong(ref))*/ ref.watch(tabProvider.notifier).setTab = index; //ref.watch(launchProvider.notifier).launch(true); } break; case 3: //ref.watch(launchProvider.notifier).launch(true); ref.watch(tabProvider.notifier).setTab = index; break; case 4: //ref.watch(launchProvider.notifier).launch(true); ref.watch(tabProvider.notifier).setTab = index; break; default: //ref.watch(launchProvider.notifier).launch(true); ref.watch(tabProvider.notifier).setTab = index; } } Album currentSong(WidgetRef ref) => ref.watch(currentlyPlaying.select((value) => value));
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/widgets/painter.dart
import 'package:flutter/material.dart'; class Line extends CustomPainter { const Line({this.height = 18}); final double height; @override void paint(Canvas canvas, Size size) { var paint = Paint() ..color = const Color(0xfffcc8c0) ..style = PaintingStyle.stroke ..strokeWidth = 2.5 ..strokeCap = StrokeCap.round; var path = Path()..lineTo(0, height); canvas.drawPath(path, paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return false; } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/routes/now_playing.dart
import 'dart:developer'; import 'dart:ui'; import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:ost_music_app_ui/data/constants/constants.dart'; import 'package:ost_music_app_ui/data/models/album.dart'; import 'package:ost_music_app_ui/routes/playlist.dart'; import '../main.dart'; import '../providers/providers.dart'; class NowPlaying extends StatefulWidget { const NowPlaying({super.key}); @override State<NowPlaying> createState() => _NowPlayingState(); } class _NowPlayingState extends State<NowPlaying> with TickerProviderStateMixin { late AnimationController controller; late AnimationController rotationController; late Album album; late ImageProvider imageProvider; final List<Album> albumList = Constants.albumList; @override void initState() { super.initState(); controller = AnimationController(vsync: this, duration: const Duration(seconds: 30)); rotationController = AnimationController(vsync: this, duration: const Duration(seconds: 30)); controller.addListener(() { setState(() {}); }); startControllers(); } @override void dispose() { controller.dispose(); rotationController.dispose(); super.dispose(); } @override void didChangeDependencies() { //album = GoRouterState.of(context).extra as Album; album = ModalRoute.of(context)!.settings.arguments as Album; imageProvider = ExactAssetImage(album.image!); precacheImage(imageProvider, context); super.didChangeDependencies(); } @override Widget build(BuildContext context) { final limit = albumList.length - 1; var currentSong = albumList.indexOf(album); var nextSong = currentSong != limit ? albumList[currentSong + 1] : albumList[0]; var previousSong = currentSong != 0 ? albumList[currentSong - 1] : albumList[limit]; return Consumer(builder: (context, ref, child) { Future(() => ref.watch(currentlyPlaying.notifier).current(album)); return Container( decoration: BoxDecoration(image: DecorationImage(image: imageProvider, fit: BoxFit.cover)), padding: EdgeInsets.only(top: 56.h, bottom: 46.h, right: 36.w, left: 36.w), child: BackdropFilter( filter: ImageFilter.blur(sigmaY: 15, sigmaX: 15), child: Scaffold( backgroundColor: Colors.transparent, body: Center( child: Column( children: [ ///ROW 1 Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector(onTap: () => /*finish(context)*/ Navigator.pop(context), child: const Icon(CupertinoIcons.chevron_down, color: Colors.white)), GestureDetector(onTap: () {}, child: const Icon(CupertinoIcons.ellipsis, color: Colors.white)), ]), 35.h.spaceY(), /// Song Title Text( overflow: TextOverflow.ellipsis, maxLines: 1, album.title!, style: TextStyle(fontSize: 28.h, color: Colors.white, fontStyle: FontStyle.normal), ), //const Text('We Need Our Army Back', style: TextStyle(fontSize: 28, color: Colors.white, fontStyle: FontStyle.normal)), 10.h.spaceY(), /// Artist Name Text(album.artiste!.name, style: TextStyle(fontSize: 16.h, color: Colors.white)), //const Text('Hans Zimmer', style: TextStyle(fontSize: 16, color: Colors.white)), 45.h.spaceY(), /// Big Card RotationTransition( turns: rotationController, child: Card( color: Colors.white.withAlpha(90), elevation: 20.h, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(300).r), child: Container( margin: const EdgeInsets.all(10).r, height: .77.sw, width: .77.sw, decoration: BoxDecoration( image: DecorationImage(image: imageProvider, fit: BoxFit.cover), borderRadius: BorderRadius.circular(300).r, ), ), ), ), 50.h.spaceY(), /// Song Progress Indicator LinearProgressIndicator(value: controller.value), 10.h.spaceY(), Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('2:49', style: TextStyle(fontSize: 16.h, color: Colors.white)), Text('6:28', style: TextStyle(fontSize: 16.h, color: Colors.white)), ]), /// Music Control Buttons Consumer(builder: (BuildContext context, WidgetRef ref, Widget? child) { bool isPlay = ref.watch(playProvider.select((value) => value)); isPlay ? controller.repeat() : controller.stop(canceled: false); isPlay ? rotationController.repeat() : rotationController.stop(canceled: false); //log('Playing: $isPlay : ${controller.value}'); return Padding( padding: const EdgeInsets.all(42).r.copyWith(left: 64.w, right: 64.w), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: () { stopControllers(); replace(context, Constants.nowPlaying, previousSong); startControllers(); ref.watch(playProvider.notifier).play(true); ref.watch(currentlyPlaying.notifier).current(previousSong); }, child: Icon(CupertinoIcons.backward_fill, color: Colors.white, size: 40.r), ), GestureDetector( onTap: () { ref.watch(playProvider.notifier).play(!isPlay); }, child: Icon( isPlay ? CupertinoIcons.pause_fill : CupertinoIcons.play_fill, color: Colors.white, size: 60.r, ), ), GestureDetector( onTap: () { stopControllers(); //replace(context, Constants.nowPlaying, nextSong); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) { return const NowPlaying(); }, settings: RouteSettings(name: 'album', arguments: nextSong), ), ); startControllers(); ref.watch(playProvider.notifier).play(true); //ref.watch(currentlyPlaying.notifier).current(nextSong); }, child: Icon(CupertinoIcons.forward_fill, color: Colors.white, size: 40.r), ), ]), ); }), 20.h.spaceY(), /// Last Row Consumer( builder: (BuildContext context, WidgetRef ref, Widget? child) { return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Icon(CupertinoIcons.repeat, color: Colors.white.withOpacity(0.6), size: 30.r), GestureDetector( onTap: () { ref.watch(isLiked.notifier).like(!ref.watch(isLiked.select((value) => value))); }, child: ref.watch(isLiked.select((value) => value)) ? Icon(CupertinoIcons.heart_fill, color: Colors.white.withOpacity(0.6), size: 30.r) : Icon(CupertinoIcons.heart, color: Colors.white.withOpacity(0.6), size: 30.r), ), Icon(CupertinoIcons.down_arrow, color: Colors.white.withOpacity(0.6), size: 30.r), Icon(CupertinoIcons.text_bubble, color: Colors.white.withOpacity(0.6), size: 30.r), GestureDetector( //onTap: () => launchReplace(context, Constants.playlist, album), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return const Playlist(); }, settings: RouteSettings(name: 'album', arguments: album), ), ); }, child: Icon(CupertinoIcons.music_note_list, color: Colors.white.withOpacity(0.6), size: 30.r), ), ], ); }, ) ], ), ), ), ), ); }); } void startControllers() { controller.repeat(); rotationController.repeat(); } void stopControllers() { controller.reset(); rotationController.reset(); } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/routes/library.dart
import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:ost_music_app_ui/data/constants/constants.dart'; import 'package:ost_music_app_ui/utils/page.dart'; import '../main.dart'; import '../utils/utils.dart'; import '../widgets/album_card.dart'; import '../widgets/artist_card.dart'; import '../widgets/bottom_nav.dart'; import '../widgets/painter.dart'; class Library extends ConsumerStatefulWidget { const Library({Key? key}) : super(key: key); @override ConsumerState<Library> createState() => _LibraryState(); } class _LibraryState extends ConsumerState<Library> { @override void initState() { super.initState(); for (var i = 0; i < Constants.albumList.length; ++i) { ExactAssetImage(Constants.albumList[i].image!); } } @override void didChangeDependencies() { for (var i = 0; i < Constants.albumList.length; ++i) { precacheImage(Utils.buildExactAssetImage(i), context); } super.didChangeDependencies(); } @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration(gradient: Utils.buildGradient()), child: Scaffold( backgroundColor: Colors.transparent, body: SizedBox( width: double.infinity, child: SingleChildScrollView( child: Center( child: Column(children: [ 80.spaceY(), /// Row 1 --- Header Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('Library', style: TextStyle(fontSize: 32, color: Colors.white.withOpacity(0.9))), Icon(CupertinoIcons.bell, color: Colors.white.withOpacity(0.7)), ]), ), 15.spaceY(), /// Row 2 --- Slacker Radio Container( margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), /*foregroundDecoration: BoxDecoration( color: Colors.white.withOpacity(0.5), borderRadius: BorderRadius.circular(8), ),*/ decoration: BoxDecoration( color: Colors.white, boxShadow: const [BoxShadow(blurRadius: 2, color: Colors.grey)], borderRadius: BorderRadius.circular(8), image: const DecorationImage(opacity: 0.2, fit: BoxFit.cover, image: ExactAssetImage(Constants.wave)), ), child: const Padding( padding: EdgeInsets.symmetric(vertical: 30.0), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Padding( padding: EdgeInsets.only(right: 12, left: 18), child: Icon(CupertinoIcons.play_circle, color: Colors.black, size: 38), ), Text('Slacker Radio', style: TextStyle(color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold)), ], ), Padding( padding: EdgeInsets.symmetric(horizontal: 18), child: Icon(CupertinoIcons.music_note_list, color: Colors.black, size: 22), ), ]), ), ), 30.spaceY(), /// Row 3 --- Local, Recent, Offline Container( margin: const EdgeInsets.symmetric(horizontal: 50), color: Colors.transparent, child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ const Icon(CupertinoIcons.folder, size: 30, color: Colors.white), 10.spaceY(), const Text('Local', style: TextStyle()), ], ), GestureDetector( onTap: () => launch(context, Constants.discover), child: Column( children: [ const Icon(CupertinoIcons.clock, size: 30, color: Colors.white), 10.spaceY(), const Text('Recent', style: TextStyle()), ], ), ), Column( children: [ const Icon(CupertinoIcons.wifi_slash, size: 30, color: Colors.white), 10.spaceY(), const Text('Offline', style: TextStyle()), ], ), ]), ), 40.spaceY(), /// Row 4 --- Favourite Albums Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( padding: EdgeInsets.only(top: 3), child: CustomPaint(painter: Line()), ), 10.spaceX(), const Text('Favourite Albums', style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal)), ], ), Icon(CupertinoIcons.forward, color: Colors.white.withOpacity(0.6)) ]), ), 25.spaceY(), /// Horizontal List 158.spaceY( ListView.builder( shrinkWrap: true, itemExtent: 115, itemCount: Constants.albumList.length, scrollDirection: Axis.horizontal, itemBuilder: (_, index) { return AlbumCard(index: index/*, ref: ref*/); }, ), ), 30.spaceY(), ///Row 5 --- Collection of Artist Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( padding: EdgeInsets.only(top: 3), child: CustomPaint(painter: Line()), ), 10.spaceX(), const Text('Collection of Artist', style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal)), ], ), Icon(CupertinoIcons.forward, color: Colors.white.withOpacity(0.6)) ]), ), 20.spaceY(), /// Horizontal List 155.spaceY( ListView.builder( shrinkWrap: true, itemExtent: 115, itemCount: Constants.artisteList.length, scrollDirection: Axis.horizontal, itemBuilder: (_, index) { return ArtistCard(index: index); }, ), ), ]), ), ), ), bottomNavigationBar: CustomBottomNav(context: context, ref: ref,page: NavPage.library), ), ); } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/routes/error.dart
import 'package:flutter/material.dart'; class ErrorPage extends StatelessWidget { const ErrorPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Scaffold(); } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/routes/discover.dart
import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:just_audio/just_audio.dart'; import 'package:on_audio_query/on_audio_query.dart'; import '../data/constants/constants.dart'; import '../utils/page.dart'; import '../utils/utils.dart'; import '../widgets/album_card.dart'; import '../widgets/bottom_nav.dart'; import '../widgets/painter.dart'; class Discover extends ConsumerStatefulWidget { const Discover({Key? key}) : super(key: key); @override ConsumerState<Discover> createState() => _DiscoverState(); } class _DiscoverState extends ConsumerState<Discover> { final tabs = ['Film Score', 'Music Theatre', 'Video Game Music', 'Stream']; final OnAudioQuery _audioQuery = OnAudioQuery(); late AudioPlayer audioPlayer; bool _hasPermission = false; @override void initState() { super.initState(); audioPlayer = AudioPlayer(); for (var i = 0; i < Constants.albumList.length; ++i) { ExactAssetImage(Constants.albumList[i].image!); } // Check and request for permission. checkAndRequestPermissions(); } checkAndRequestPermissions({bool retry = true}) async { // The param 'retryRequest' is false, by default. _hasPermission = await _audioQuery.checkAndRequest( retryRequest: retry, ); // Only call update the UI if application has all required permissions. _hasPermission ? setState(() {}) : null; } @override void didChangeDependencies() { for (var i = 0; i < Constants.albumList.length; ++i) { precacheImage(Utils.buildExactAssetImage(i), context); } super.didChangeDependencies(); } @override void dispose() { audioPlayer.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration(gradient: Utils.buildGradient()), child: DefaultTabController( length: 4, child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( scrolledUnderElevation: 0, automaticallyImplyLeading: false, title: Text('Discover', style: TextStyle(fontSize: 32, color: Colors.white.withOpacity(0.9))), actions: [ Padding( padding: const EdgeInsets.only(right: 20), child: Icon(CupertinoIcons.search, color: Colors.white.withOpacity(0.7)), ), ], backgroundColor: Colors.transparent, bottom: TabBar( isScrollable: true, indicator: UnderlineTabIndicator( insets: EdgeInsets.symmetric(horizontal: -8.w, vertical: 1.h), borderRadius: BorderRadius.circular(20).r, borderSide: const BorderSide(color: Color(0xfffcc8c0), width: 2), ), dividerColor: Colors.white.withOpacity(0.2), labelColor: Colors.white, splashFactory: NoSplash.splashFactory, labelStyle: TextStyle(fontSize: 17.h), unselectedLabelColor: Colors.white.withOpacity(0.5), tabs: tabs.map((e) => Tab(text: e, height: 25.h)).toList(), ), ), body: SizedBox( width: double.infinity, child: SingleChildScrollView( child: Container( margin: const EdgeInsets.symmetric(horizontal: 20).w, child: Center( child: Column(children: [ 10.h.spaceY(), /// Row 2 --- Big Carousel Slider Card( elevation: 5, shadowColor: const Color(0xff866684), color: Colors.white, margin: EdgeInsets.symmetric(vertical: 10.h), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8).r), child: Container( height: 210.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8).r, image: const DecorationImage(fit: BoxFit.cover, image: ExactAssetImage(Constants.album)), ), ), ), 20.h.spaceY(), /// Row 4 --- New Albums Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(top: 3.h), child: const CustomPaint(painter: Line()), ), 10.w.spaceX(), Text('New Albums', style: TextStyle(fontSize: 20.h, fontWeight: FontWeight.normal)), ], ), Icon(CupertinoIcons.forward, color: Colors.white.withOpacity(0.6)) ]), 15.h.spaceY(), /// Horizontal List 158.h.spaceY( ListView.builder( shrinkWrap: true, itemExtent: 115, itemCount: Constants.albumList.length, scrollDirection: Axis.horizontal, itemBuilder: (_, index) { return AlbumCard(index: index/*, ref: ref*/); }, ), ), 30.h.spaceY(), ///Row 5 --- Collection of Artist Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(top: 3.h), child: const CustomPaint(painter: Line()), ), 10.w.spaceX(), const Text('Recommended Playlist', style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal)), ], ), Icon(CupertinoIcons.forward, color: Colors.white.withOpacity(0.6)) ]), 20.h.spaceY(), 300.h.spaceY( !_hasPermission ? noAccessToLibraryWidget() : FutureBuilder<List<SongModel>>( // Default values: future: _audioQuery.querySongs( sortType: null, orderType: OrderType.ASC_OR_SMALLER, uriType: UriType.EXTERNAL, ignoreCase: true, ), builder: (context, item) { // Display error, if any. if (item.hasError) { return Text(item.error.toString()); } // Waiting content. if (item.data == null) { return const CircularProgressIndicator(); } // 'Library' is empty. if (item.data!.isEmpty) return const Text("Nothing found!"); // You can use [item.data!] direct or you can create a: // List<SongModel> songs = item.data!; return ListView.builder( itemCount: item.data!.length, itemBuilder: (context, index) { return ListTile( title: Text(item.data![index].title), subtitle: Column( children: [ Text(item.data![index].artist ?? "No Artist"), ], ), trailing: GestureDetector( onTap: () { audioPlayer.setFilePath(item.data![index].data); //audioPlayer.stop(); audioPlayer.playerState.playing ? audioPlayer.stop() : audioPlayer.play(); }, child: const Icon(Icons.arrow_forward_rounded), ), // This Widget will query/load image. // You can use/create your own widget/method using [queryArtwork]. leading: QueryArtworkWidget( controller: _audioQuery, id: item.data![index].id, type: ArtworkType.AUDIO, ), ); }, ); }, ), ), 20.h.spaceY(), /// Vertical List 155.h.spaceY( ListView.builder( //shrinkWrap: true, itemCount: Constants.artisteList.length, itemBuilder: (_, index) { return buildArtists(index); }, ), ), ]), ), ), ), ), bottomNavigationBar: CustomBottomNav(context: context, ref: ref, page: NavPage.discover), ), ), ); } Widget buildArtists(int index) { return Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Card( elevation: 2, shadowColor: const Color(0xff866684), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), child: Container( height: 60, width: 60, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: Colors.black45, image: DecorationImage(image: ExactAssetImage(Constants.albumList[index].image!), fit: BoxFit.cover), ), ), ), 10.spaceX(), Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ 235.spaceX(Text( overflow: TextOverflow.ellipsis, Constants.albumList[index].title!, style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Colors.white.withAlpha(190)))), 5.spaceY(), Text(Constants.albumList[index].artiste!.name, style: TextStyle(fontSize: 12, color: Colors.white.withAlpha(150))), ]), ], ); } Widget noAccessToLibraryWidget() { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.redAccent.withOpacity(0.5), ), padding: const EdgeInsets.all(20), child: Column( mainAxisSize: MainAxisSize.min, children: [ const Text("Application doesn't have access to the library"), const SizedBox(height: 10), ElevatedButton( onPressed: () => checkAndRequestPermissions(retry: true), child: const Text("Allow"), ), ], ), ); } }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/routes/playlist.dart
import 'dart:ui'; import 'package:extensionresoft/extensionresoft.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:ost_music_app_ui/data/constants/constants.dart'; import 'package:ost_music_app_ui/routes/now_playing.dart'; import '../data/models/album.dart'; import '../main.dart'; import '../providers/providers.dart'; import '../utils/page.dart'; import '../widgets/bottom_nav.dart'; class Playlist extends ConsumerStatefulWidget { const Playlist({Key? key}) : super(key: key); @override ConsumerState<Playlist> createState() => _PlaylistState(); } class _PlaylistState extends ConsumerState<Playlist> { late Album album; late ImageProvider imageProvider; @override void didChangeDependencies() { // album = GoRouterState.of(context).extra as Album; album = ModalRoute.of(context)!.settings.arguments as Album; imageProvider = ExactAssetImage(album.image!); precacheImage(imageProvider, context); super.didChangeDependencies(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.transparent, body: Container( decoration: BoxDecoration(image: DecorationImage(image: imageProvider, fit: BoxFit.cover)), padding: const EdgeInsets.only(top: 56, bottom: 3), child: BackdropFilter( filter: ImageFilter.blur(sigmaY: 15, sigmaX: 15), child: Column( children: [ ///ROW 1 Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: () => replace(context, Constants.nowPlaying), child: const Padding( padding: EdgeInsets.only(right: 10, bottom: 10, left: 25), child: Icon(CupertinoIcons.chevron_back, color: Colors.white), ), ), GestureDetector( onTap: () {}, child: const Padding( padding: EdgeInsets.only(left: 10, bottom: 10, right: 25), child: Icon(Icons.share_outlined, color: Colors.white), ), ) ]), 15.spaceY(), /// ROW 2 Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Card( elevation: 2, shadowColor: const Color(0xff866684), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), child: Container( height: 100, width: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: Colors.black45, image: DecorationImage(image: imageProvider, fit: BoxFit.cover), ), ), ), 10.spaceX(), Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ //Text(softWrap: true, album.title, style: TextStyle(fontSize: 20, color: Colors.white.withAlpha(190))), 190.spaceX(Text( overflow: TextOverflow.ellipsis, maxLines: 3, 'Dunkirk (Original Motion Picture Soundtrack)', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white.withAlpha(190)))), 5.spaceY(), Text(album.artiste!.name, style: TextStyle(fontSize: 14, color: Colors.white.withAlpha(150))), ]), ], ), ), 15.spaceY(), /// Last Row Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Icon(CupertinoIcons.repeat, color: Colors.white.withOpacity(0.6)), Icon(CupertinoIcons.heart, color: Colors.white.withOpacity(0.6)), Icon(CupertinoIcons.down_arrow, color: Colors.white.withOpacity(0.6)), Icon(CupertinoIcons.text_bubble, color: Colors.white.withOpacity(0.6)), //Icon(CupertinoIcons.music_note_list, color: Colors.white.withOpacity(0.6)), ], ), ), 15.spaceY(), Divider(color: Colors.grey.withOpacity(0.7), height: 1), /// ListView Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: ListView.builder( padding: EdgeInsets.zero, itemExtent: 60, itemCount: Constants.albumList.length, itemBuilder: (c, index) { return Consumer( builder: (BuildContext context, WidgetRef ref, Widget? child) { return ListTile( onTap: () { replace(context, Constants.nowPlaying, Constants.albumList[index]); Navigator.push( context, MaterialPageRoute( builder: (context) { return const NowPlaying(); }, settings: RouteSettings(name: 'album', arguments: Constants.albumList[index]), ), ); ref.watch(currentlyPlaying.notifier).current(Constants.albumList[index]); }, minVerticalPadding: 1, horizontalTitleGap: -15, leading: Center(widthFactor: 1, child: Text('${index + 1}', style: TextStyle(color: Colors.white.withAlpha(150)))), title: Text(Constants.albumList[index].title!, style: const TextStyle(color: Colors.white)), subtitle: Text(Constants.albumList[index].artiste!.name, style: TextStyle(color: Colors.white.withAlpha(150))), trailing: Icon(CupertinoIcons.ellipsis, color: Colors.white.withAlpha(200)), ); }, ); }, ), ), ), ], ), ), ), /// BottomNavigation bottomNavigationBar: CustomBottomNav(context: context, ref: ref, page: NavPage.nowPlaying), ); } }
0
mirrored_repositories/ost_music_app_ui/lib/data
mirrored_repositories/ost_music_app_ui/lib/data/constants/constants.dart
import 'package:ost_music_app_ui/data/models/artiste.dart'; import '../models/album.dart'; class Constants { Constants._(); static const String appName = 'OST Music App UI'; static const String root = '/'; //Navigation routes static const String library = '/library'; static const String discover = '/discover'; static const String playlist = '/playlist'; static const String nowPlaying = '/nowPlaying'; static const String error = '/error'; //Images route static const String imageDir = "assets/images"; static const String iconDir = "assets/icons"; //Images static const String profile = "$imageDir/profile.png"; static const String wave = "$imageDir/music_wave.png"; static const String album = "$imageDir/album.jpg"; static Map<String, String> get image { var map = <String, String>{}; for (var i = 1; i <= 4; ++i) { map['art$i'] = '$imageDir/art_$i.jpg'; } return map; } static List<String> images = image.values.toList(); //Icons static const String appIcon = "$iconDir/icon.png"; static List<Album> albumList = [ Album(title: "Furious 7", image: images[0], artiste: artisteList[0]), Album(title: "Final Fantasy", image: images[1], artiste: artisteList[1]), Album(title: "Fifty Shades", image: images[2], artiste: artisteList[2]), Album(title: "Blade Runner", image: images[3], artiste: artisteList[3]), Album(title: "Manchester by the Sea Chorale", image: images[0], artiste: artisteList[4]), Album(title: "Final Fantasy", image: images[1], artiste: artisteList[1]), Album(title: "Fifty Shades", image: images[2], artiste: artisteList[2]), Album(title: "Blade Runner", image: images[3], artiste: artisteList[3]), ]; static const List<Artiste> artisteList = [ Artiste(name: 'Kim Min Jun', image: profile), Artiste(name: 'Nobuo Lilian', image: profile), Artiste(name: 'Craig Martins', image: profile), Artiste(name: 'Rose Jones', image: profile), Artiste(name: 'Lesley Barber', image: profile), ]; static const double wrapWidth = 105; static const Artiste getArtiste = Artiste(name: 'Kim Min Jun', image: profile); static Album getAlbums = Album(title: "Furious 7", image: image['art3'], artiste: getArtiste); }
0
mirrored_repositories/ost_music_app_ui/lib/data
mirrored_repositories/ost_music_app_ui/lib/data/models/album.dart
import 'artiste.dart'; class Album { const Album({required this.title, required this.image, required this.artiste}); factory Album.empty() { return const Album(title: null, image: null, artiste: null); } final String? title; final String? image; final Artiste? artiste; }
0
mirrored_repositories/ost_music_app_ui/lib/data
mirrored_repositories/ost_music_app_ui/lib/data/models/artiste.dart
class Artiste { const Artiste({required this.name, required this.image}); final String name; final String image; }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/utils/page.dart
enum NavPage { discover, library, nowPlaying, store, account, } extension PageExtension on NavPage { int get page => switch (this) { NavPage.discover => 0, NavPage.library => 1, NavPage.nowPlaying => 2, NavPage.store => 3, NavPage.account => 4, _ => -1, }; }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/utils/utils.dart
import 'dart:developer'; import 'package:flutter/material.dart'; import '../data/constants/constants.dart'; class Utils { Utils._(); static ExactAssetImage buildExactAssetImage(int index) => ExactAssetImage(Constants.albumList[index].image!); static Type check<T>(bool b, Function(T) callback) { return T; } static bool isNull(Object? object) => object == null; static LinearGradient buildGradient() => const LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ //Color(0xff3281f5), //Colors.lightBlue, //Color(0xff03A9F4), Color(0xff0283bd), //Color(0xff658abc), Color(0xff658abc), //Color(0xff5a84c0), //Color(0xff896785), Color(0xff866684), Color(0xff585070), Color(0xff595273), ]); }
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/play_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; /// Playing State class PlayNotifier extends StateNotifier<bool> { PlayNotifier() : super(true); play(bool value) => state = value; } final playProvider = StateNotifierProvider<PlayNotifier, bool>((ref) => PlayNotifier());
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/tab_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; /// Tab State class TabNotifier extends StateNotifier<int> { TabNotifier() : super(0); set setTab(int index) => state = index; } final tabProvider = StateNotifierProvider<TabNotifier, int>((ref) { return TabNotifier(); });
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/providers.dart
export 'play_provider.dart'; export 'launch_provider.dart'; export 'tab_provider.dart'; export 'theme_provider.dart'; export 'currently_playing_provider.dart'; export 'like_provider.dart';
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/launch_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; /// Launched State class LaunchNotifier extends StateNotifier<bool> { LaunchNotifier() : super(false); launch(bool value) => state = value; } final launchProvider = StateNotifierProvider<LaunchNotifier, bool>((ref) => LaunchNotifier());
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/currently_playing_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../data/models/album.dart'; class CurrentlyPlayingNotifier extends StateNotifier<Album> { CurrentlyPlayingNotifier() : super(Album.empty()); void current(Album album) => state = album; } final currentlyPlaying = StateNotifierProvider<CurrentlyPlayingNotifier, Album>((ref) => CurrentlyPlayingNotifier());
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/theme_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; /// Theme State class ThemeNotifier extends StateNotifier<bool> { ThemeNotifier() : super(true); void toggleTheme(bool isDarkEnabled) => state = isDarkEnabled; } final themeProvider = StateNotifierProvider<ThemeNotifier, bool>((ref) { return ThemeNotifier(); });
0
mirrored_repositories/ost_music_app_ui/lib
mirrored_repositories/ost_music_app_ui/lib/providers/like_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; class LikeNotifier extends StateNotifier<bool> { LikeNotifier() : super(false); like(bool value) => state = value; } final isLiked = StateNotifierProvider<LikeNotifier, bool>((ref) => LikeNotifier());
0
mirrored_repositories/ost_music_app_ui
mirrored_repositories/ost_music_app_ui/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:ost_music_app_ui/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/users-profile-ui
mirrored_repositories/users-profile-ui/lib/main.dart
import 'package:flutter/material.dart'; import 'package:users_profile_ui/screens/home_screen.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return const MaterialApp( debugShowCheckedModeBanner: false, title: 'Users Profile UI', home: homeScreen(), ); } } /* Thanks for using this UI Contact us using github - https://github.com/yoni-tad Or linkedin - https://linkedin.com/in/yoni-tad */
0
mirrored_repositories/users-profile-ui/lib
mirrored_repositories/users-profile-ui/lib/utils/video_card.dart
import 'package:flutter/material.dart'; class videoCard extends StatelessWidget { final image; const videoCard({super.key, required this.image}); @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 1.5 / 1, child: Container( margin: const EdgeInsets.only(right: 20), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), image: DecorationImage( image: AssetImage(image), fit: BoxFit.cover, ), ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), gradient: LinearGradient( begin: Alignment.bottomRight, colors: [ Colors.blue.withOpacity(0.9), Colors.blue.withOpacity(0.3), ], ), ), child: const Align( child: Icon( Icons.play_arrow, color: Colors.white, size: 70, ), ), ), ), ); } }
0
mirrored_repositories/users-profile-ui/lib
mirrored_repositories/users-profile-ui/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; import 'package:users_profile_ui/utils/video_card.dart'; class homeScreen extends StatefulWidget { const homeScreen({super.key}); @override State<homeScreen> createState() => _homeScreenState(); } class _homeScreenState extends State<homeScreen> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, body: Stack( children: [ CustomScrollView( slivers: [ SliverAppBar( expandedHeight: 500, backgroundColor: Colors.black, flexibleSpace: FlexibleSpaceBar( collapseMode: CollapseMode.pin, background: Container( decoration: const BoxDecoration( image: DecorationImage( image: AssetImage( 'assets/images/rophnan.png', ), fit: BoxFit.cover, ), ), child: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomRight, colors: [ Colors.black, Colors.black.withOpacity(0.3), ], ), ), child: const Padding( padding: EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'Rophnan Nuri', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 40, ), ), Padding( padding: EdgeInsets.symmetric(vertical: 20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "28 Videos", style: TextStyle( color: Colors.grey, fontSize: 16, ), ), Text( "237k Subscribers", style: TextStyle( color: Colors.grey, fontSize: 16, ), ) ], ), ) ], ), ), ), ), ), ), SliverList( delegate: SliverChildListDelegate( [ Padding( padding: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Rophnan was born and raised in Addis Ababa, Ethiopia. He is the ninth child out of 10 children in his family. His father named him Rophnan after having a revelation during deep prayer, the name Rophnan is not in Amharic nor does it have roots in any other language. When he was 10 years old, Rophnan started recording tapes in his classroom, singing and improvising drums to entertain his friends. His music style uniquely merges traditional Ethiopian instruments with contemporary electronic music.', style: TextStyle( color: Colors.grey, height: 1.4, ), ), const Padding( padding: EdgeInsets.only(top: 20), child: Text( 'Born', style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, ), ), ), const Text( 'June, 22th 1990, Addis Ababa, Ethiopia', style: TextStyle( color: Colors.grey, ), ), const Padding( padding: EdgeInsets.only(top: 20), child: Text( 'Nationality', style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, ), ), ), const Text( 'Ethiopia', style: TextStyle( color: Colors.grey, ), ), const Padding( padding: EdgeInsets.symmetric(vertical: 20), child: Text( 'Videos', style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, ), ), ), Container( height: 200, child: ListView( scrollDirection: Axis.horizontal, children: const [ videoCard( image: 'assets/images/03.png', ), videoCard( image: 'assets/images/06.png', ), videoCard( image: 'assets/images/09.png', ), ], ), ), const SizedBox(height: 120), ], ), ) ], ), ), ], ), Positioned.fill( bottom: 50, child: Container( child: Align( alignment: Alignment.bottomCenter, child: Container( margin: const EdgeInsets.symmetric(horizontal: 30), height: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), color: Colors.yellow[700], ), child: const Align( child: Text( 'Follow', style: TextStyle( color: Colors.white, ), ), ), ), ), ), ) ], ), ); } }
0
mirrored_repositories/users-profile-ui
mirrored_repositories/users-profile-ui/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:users_profile_ui/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/damian_go
mirrored_repositories/damian_go/lib/main.dart
import 'package:damian_go/view/screens/home_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) .then((value) => runApp(const AppState())); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.blueGrey.shade900, systemNavigationBarDividerColor: Colors.transparent)); return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blueGrey, textTheme: GoogleFonts.varelaRoundTextTheme(), ), home: const HomeScreen(), ); } } /// Takes care of the state of the app class AppState extends StatelessWidget { const AppState({super.key}); @override Widget build(BuildContext context) { // TODO: implement build return const MyApp(); } }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/view/views.dart
/// Screen exports here : export 'package:damian_go/view/screens/user/not_signed_in_profile_screen.dart'; export 'package:damian_go/view/screens/user/signed_in_profile_screen.dart'; export 'package:damian_go/view/screens/home_screen.dart'; export 'package:damian_go/view/screens/star_level_screen.dart'; export 'package:damian_go/view/screens/user/top_users_screen.dart'; export 'package:damian_go/view/screens/user/user_search_delegate_screen.dart'; export 'package:damian_go/view/screens/user/user_detail_screen.dart'; export 'package:damian_go/view/screens/about_app_screen.dart'; /// Components exports here : // Profile export 'package:damian_go/view/components/user/clout.dart'; export 'package:damian_go/view/components/user/user_star_level.dart'; export 'package:damian_go/view/components/user/verified_username.dart'; export 'package:damian_go/view/components/user/zone_count.dart'; export 'package:damian_go/view/components/dialogs.dart'; // Map export 'package:damian_go/view/components/map/google_map_widget.dart';
0
mirrored_repositories/damian_go/lib/view
mirrored_repositories/damian_go/lib/view/components/dialogs.dart
import 'package:damian_go/utils/navigator_util.dart'; import 'package:flutter/material.dart'; /// Class for some custom message dialogs to be used throughout the app class Dialogs{ static Future showMessage({Icon? messageIcon,required BuildContext context, required String title,required String message}){ return showDialog( context: context, builder: (context) { return AlertDialog( title: Row( children: [ messageIcon ?? const Icon(Icons.info_outline), Text(title) ], ), content: Text(message), ); }, ); } /// Show a dialog with a body for Animation of any other widget static Future showIcon({Icon? messageIcon,required BuildContext context, required String title,required Widget content}){ return showDialog( context: context, builder: (context) { return AlertDialog( title: Row( children: [ messageIcon ?? const Icon(Icons.info_outline), Text(title) ], ), content: content, ); }, ); } /// Shows a dialog to confirm if the user wants to carry-out the action /// Return 1 if the user clicks 'Yes' and 0 for 'No' static Future<int> confirmAction({required BuildContext context,required String actionTitle, required String content}) async { int returnValue = 0; await showDialog( context: context, builder: (_) => AlertDialog( title: Text(actionTitle), content: Text(content), actions: [ TextButton( onPressed: () { Navigator.pop( context, 'Return value'); //Return value to the caller }, child: Text( 'No', style: TextStyle(color: Colors.red), )), TextButton( onPressed: () { returnValue = 1; Navigator.pop(context); }, child: Text( 'Yes', style: TextStyle(color: Colors.green), )) ], )); return Future.value(returnValue); } static Future authPrompt(BuildContext context) { return showDialog( context: context, builder: (context) { return AlertDialog( title: Row( children: [ Icon(Icons.login,color: Colors.green), Text(' Sign in') ], ), content: Text('You must be registered to carry out that action. Sign ' 'in if you already have an account or Sign up and create your account in few seconds'), actions: [ TextButton( onPressed: (){ //Navigator.of(context).pop(); //Navigator.of(context).pushReplacement( // NavigatorUtil.createRouteWithSlideAnimation(newPage: SignInPage()) //); }, child: Text('Sign In',style: TextStyle(color: Colors.black87),), style: TextButton.styleFrom(backgroundColor: Colors.lightGreenAccent), ), TextButton( onPressed: (){ //Navigator.of(context).pop(); //Navigator.of(context).pushReplacement( // NavigatorUtil.createRouteWithSlideAnimation(newPage: SignUpPage()) //); }, child: Text('Sign Up',style: TextStyle(color: Colors.white),), style: TextButton.styleFrom(backgroundColor: Colors.black87) ) ], ); }, ); } }
0
mirrored_repositories/damian_go/lib/view/components
mirrored_repositories/damian_go/lib/view/components/user/user_star_level.dart
import 'package:damian_go/utils/constants.dart'; import 'package:damian_go/utils/star_level_util.dart'; import 'package:flutter/material.dart'; class UserStarLevel extends StatefulWidget { const UserStarLevel({super.key, required this.starLevel}); @override _UserStarLevelState createState() => _UserStarLevelState(); final StarLevel starLevel; } class _UserStarLevelState extends State<UserStarLevel> { late StarLevelDesign starLevelDesign; @override void initState() { super.initState(); starLevelDesign = StarLevelDesign .getStartLevelDesign(widget.starLevel); } @override void dispose() { // TODO: implement dispose super.dispose(); } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.all(5), height: 50, decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(10)), //color: starLevelDesign.backgroundColor color: Colors.blueGrey.shade600 ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '${StarLevelUtil.getStarLevelName(widget.starLevel)}', style: TextStyle(fontSize: 17,color: Colors.white) ), starLevelDesign.icon, ], ), ); } }
0
mirrored_repositories/damian_go/lib/view/components
mirrored_repositories/damian_go/lib/view/components/user/zone_count.dart
import 'package:flutter/material.dart'; class ZoneCount extends StatelessWidget { final int count; const ZoneCount({ Key? key, required this.count, }) : super(key: key); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.place), SizedBox(width: 4), Text('${count.toString()} zones added', style: TextStyle( fontWeight: FontWeight.w200, fontSize: 16, ), ), ], ); } }
0
mirrored_repositories/damian_go/lib/view/components
mirrored_repositories/damian_go/lib/view/components/user/verified_username.dart
import 'package:flutter/material.dart'; class VerifiedUserName extends StatelessWidget { final String name; final bool isVerified; final bool centered; const VerifiedUserName({ Key? key, required this.name, this.isVerified = false, this.centered = false }) : super(key: key); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: centered ? MainAxisAlignment.center : MainAxisAlignment.start, children: [ Text( name, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17, ), ), SizedBox(width: 5), if (isVerified) Icon( Icons.check_circle, color: Colors.blue, size: 20, ), ], ); } }
0
mirrored_repositories/damian_go/lib/view/components
mirrored_repositories/damian_go/lib/view/components/user/clout.dart
import 'package:flutter/material.dart'; class Clout extends StatelessWidget { final int followers; final int following; const Clout({ Key? key, required this.followers, required this.following, }) : super(key: key); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ TextButton( onPressed: () {}, child: Text( '${following.toString()} following', style: TextStyle( fontWeight: FontWeight.w200, fontSize: 16, ), ), ), SizedBox(width: 5), TextButton( onPressed: () {}, child: Text( '${followers.toString()} followers', style: TextStyle( fontWeight: FontWeight.w200, fontSize: 16, ), ), ), ], ); } }
0
mirrored_repositories/damian_go/lib/view/components
mirrored_repositories/damian_go/lib/view/components/map/google_map_widget.dart
import 'dart:async'; import 'package:damian_go/utils/constants.dart'; import 'package:damian_go/utils/countries_util.dart'; import 'package:damian_go/utils/navigator_util.dart'; import 'package:damian_go/view/views.dart'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:loading_indicator/loading_indicator.dart'; import 'package:location/location.dart'; import 'package:url_launcher/url_launcher.dart'; //https://blog.codemagic.io/creating-a-route-calculator-using-google-maps/ class GoogleMapWidget extends StatefulWidget { const GoogleMapWidget({Key? key}) : super(key: key); @override State<GoogleMapWidget> createState() => _GoogleMapWidgetState(); } class _GoogleMapWidgetState extends State<GoogleMapWidget> with AutomaticKeepAliveClientMixin { // Color _startColor = Colors.lightBlue.shade100; Color _endColor = Colors.redAccent.shade100; bool _isForward = true; late Timer timer; // late var location; final Map<String, LatLng> countryLocations = CountriesUtil.getAllCountries(); late LocationData? userLocation; final Set<Marker> _markerList = {}; static const _initialCameraPosition = CameraPosition(target: LatLng(43.362343, -8.411540), zoom: 7.5); //Google Map stuffs CameraPosition _cameraPosition = _initialCameraPosition; bool _mapCreated = false; final bool _mapMoving = false; final bool _compasActivated = true; final bool _toolBarActivated = false; final CameraTargetBounds _cameraTargetBounds = CameraTargetBounds.unbounded; final MinMaxZoomPreference _minMaxZoomPreference = MinMaxZoomPreference.unbounded; final MapType _mapType = MapType.normal; final bool _rotationActivated = true; final bool _scrollActivated = true; final bool _tiltActivated = true; final bool _zoomGestureActivated = true; final bool _zoomControlsActivated = false; final bool _interiorViewActivated = true; final bool _trafficActivated = false; final bool _localizationActivated = true; final bool _localizationButtonActivated = true; late GoogleMapController _mapController; final bool _nightMode = true; @override void initState() { // TODO: implement initState super.initState(); setUserLocation(); loadDamianZones(); initializePeriodicAnimation(); } @override void dispose() { // TODO: implement dispose super.dispose(); timer.cancel(); } initializePeriodicAnimation(){ // initialize the start and end colors timer = Timer.periodic(Duration(seconds: 2), (timer) { setState(() { if (_isForward) { _startColor = _endColor; _endColor = Colors.blue; } else { _startColor = _endColor; _endColor = Colors.red; } _isForward = !_isForward; }); }); } setUserLocation() async{ location = Location().getLocation(); } loadDamianZones() async { final customIcon = await BitmapDescriptor.fromAssetImage( const ImageConfiguration(), 'assets/images/stick_250.png' ); int limit = 0; for (final countryName in countryLocations.keys) { limit ++; final marker = Marker( markerId: MarkerId(countryName), position: countryLocations[countryName]!, infoWindow: InfoWindow( title: 'Country Test', snippet: 'Damian zone in $countryName', ), icon: customIcon, ); _markerList.add(marker); if(limit == 7) break; } } @override Widget build(BuildContext context) { //double screenHeight = MediaQuery.of(context).size.height; return Scaffold( floatingActionButton: floatingActionButton(), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, body: Column( children: [ Container( color: Colors.blueGrey.shade900, height: 60, child: ListView( padding: EdgeInsets.all(5), scrollDirection: Axis.horizontal, children: [ optionButton(text:'Top users ⭐️', onPressed: ()=> Navigator.of(context).push( NavigatorUtil.createRouteWithFadeAnimation(newPage: TopUsersScreen()) ), backgroundColor: Colors.white), optionButton( text:'Search users 🔎', onPressed: () { showSearch( context: context, delegate: UserSearchDelegateScreen(hintText: 'Search users')); }, backgroundColor: Colors.white, ), optionButton( text:'Location 📍', onPressed: ()=> currentLocation(), backgroundColor: Colors.white, ), optionButton( text:'Base (Spain)', onPressed: (){ moveToLocation(countryLocations['Spain']!); }, backgroundColor: Colors.white ), optionButton(text:'Globe view 🌍',onPressed: (){},backgroundColor: Colors.white), ], ), ), Expanded(child: mapWidget()), ], ), appBar: AppBar( // use the leading icon for the drawer leading: InkWell( onTap: () => Navigator.of(context).push(createRouteWithSlideAnimation()), child: Icon(Icons.person), ), //toolbarHeight: 50, centerTitle: true, actions: [ //Icon(Icons.mode_night_outlined), popupMenuButton(), ], elevation: 0, backgroundColor: Colors.blueGrey.shade900, title: const Text('Damian Go'), ), ); } Widget floatingActionButton(){ return InkWell( onTap: () async{ String countryName = await CountriesUtil.getCountryFromLocation( //use Spain as the default value if the userLocation is null LatLng(userLocation!.latitude ?? 40.463667, userLocation!.longitude ?? -3.74922) ); //if (countryLocations.containsKey(countryName)) { // LatLng countryLocation = countryLocations[countryName]!; //} showModalBottomSheet( barrierColor: Colors.black26, backgroundColor: Colors.transparent, context: context, builder: (BuildContext context) { TextEditingController countryNameController = TextEditingController( text: countryName ); return Container( height: 380, padding: const EdgeInsets.all(10), margin: const EdgeInsets.only(left: 7, right: 7), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15), ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Image.asset('assets/images/damian_small.png'), const Text( 'Add a new zone', style: TextStyle( color: Colors.black54, fontSize: 20 ), ), const SizedBox(height: 5), Expanded( child: ListView( //scrollDirection: Axis.horizontal, children: [ TextFormField( controller: countryNameController, decoration: InputDecoration( labelText: "Country", icon: Icon(Icons.place), enabled: false ) ), ElevatedButton( onPressed: () {}, style: TextButton.styleFrom( backgroundColor: Colors.blueGrey.shade900, shape: const StadiumBorder(), fixedSize: const Size(100, 50) ), child: const Text('Submit', style: TextStyle(color: Colors.white),), ), ], ), ), ]), ); }); }, child: AnimatedContainer( duration: Duration(milliseconds: 1500), curve: Curves.easeInOut, //width: 200, margin: EdgeInsets.all(5), height: 70, width: 90, decoration: BoxDecoration( gradient: LinearGradient( colors: [_startColor, _endColor], begin: Alignment.centerLeft, end: Alignment.centerRight, ), boxShadow: [ BoxShadow( color: Colors.white, blurRadius: 4, //offset: Offset(0,0), spreadRadius: 0.9 ) ], borderRadius: const BorderRadius.all(Radius.circular(15)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 70, width: 90, child: Image.asset('assets/images/piny.png'), ), /* Text( 'Add zone', style: TextStyle(fontSize: 15,color: Colors.white) ), */ ], ), ), ); } /// The app bar actions to view a simple menu PopupMenuButton popupMenuButton(){ return PopupMenuButton<String>( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)), itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ PopupMenuItem<String>( value: 'menu_item_1', child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon(Icons.info_outline,color: Colors.blueGrey,), SizedBox(width: 5,), Text('About app'), ], ), ), PopupMenuItem<String>( value: 'menu_item_2', child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon(Icons.help_outline,color: Colors.blueGrey,), SizedBox(width: 5), Text('Help'), ], ), ), ], onSelected: (String value) { // Handle menu item selection switch (value) { case 'menu_item_1': Navigator.of(context).push( NavigatorUtil.createRouteWithSlideAnimation( newPage: AboutAppScreen()) ); break; case 'menu_item_2': final url = Uri.parse('https://daumienebi.github.io/yo_nunca/policy.html'); _launchUrl(url); break; } }, ); } Widget optionButton({required String text,Function()? onPressed,Color? backgroundColor}){ return Padding( padding: EdgeInsets.all(7), child: Row( children: [ ElevatedButton( onPressed: onPressed, style: TextButton.styleFrom( backgroundColor: backgroundColor, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)) ), child: Text(text,style: TextStyle(color: Colors.black),), ), ], ) ); } Widget getMap(double latitude, double longitude) { final GoogleMap googleMap = GoogleMap( initialCameraPosition: CameraPosition( target: LatLng(latitude, longitude), zoom: 1, tilt: 20, ), compassEnabled: _compasActivated, mapToolbarEnabled: _toolBarActivated, cameraTargetBounds: _cameraTargetBounds, minMaxZoomPreference: _minMaxZoomPreference, mapType: _mapType, rotateGesturesEnabled: _rotationActivated, scrollGesturesEnabled: _scrollActivated, tiltGesturesEnabled: _tiltActivated, zoomControlsEnabled: _zoomControlsActivated, zoomGesturesEnabled: _zoomGestureActivated, //myLocationButtonEnabled: _localizationButtonActivated, //myLocationEnabled: _localizationActivated, onMapCreated: onMapCreate, onCameraMove: _updateCameraPosition, trafficEnabled: _trafficActivated, markers: _markerList, ); return googleMap; } /// method to navigate to the users current location void currentLocation() async { final GoogleMapController controller = _mapController; LocationData? currentLocation; var location = Location(); try { currentLocation = await location.getLocation(); } on Exception { currentLocation = null; } if (currentLocation != null) { controller.animateCamera(CameraUpdate.newCameraPosition( CameraPosition( bearing: 0, target: LatLng(currentLocation.latitude!, currentLocation.longitude!), zoom: 7.0, ), )); } } void moveToLocation(LatLng latLng) async { final GoogleMapController controller = _mapController; controller.animateCamera(CameraUpdate.newCameraPosition( CameraPosition( bearing: 0, target: LatLng(latLng.latitude, latLng.longitude), zoom: 7.0, ), )); } Widget mapWidget() { //the current location of the user has to be fetched return FutureBuilder( future: location, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { final position = snapshot.data; userLocation = snapshot.data; _mapCreated = true; //_userLocation = position; return getMap(position.latitude, position.longitude); } else { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 50, width: 100, child: LoadingIndicator( indicatorType: Indicator.ballPulseRise, colors: Constants.loadingIndicatorColors, ), ), Text('Loading map...') ], ) ); } }); } void _updateCameraPosition(CameraPosition position) { setState(() { _cameraPosition = position; }); } void onMapCreate(GoogleMapController mapController) { setState(() { _mapController = mapController; }); } Route createRouteWithSlideAnimation() { return PageRouteBuilder( settings: RouteSettings(name: 'signInUserScreen',), pageBuilder: (context, animation, secondaryAnimation) => SignedInProfileScreen(), transitionsBuilder: (context, animation, secondaryAnimation, child) { const begin = Offset(-1.5, 1); const end = Offset.zero; final tween = Tween(begin: begin, end: end); final offsetAnimation = animation.drive(tween); return SlideTransition( position: offsetAnimation, child: child, ); }, ); } _launchUrl(Uri url) async{ await launchUrl(url,mode:LaunchMode.externalApplication); } @override // TODO: implement wantKeepAlive //https://stackoverflow.com/questions/56632225/google-maps-dequeuebuffer-bufferqueue-has-been-abandoned bool get wantKeepAlive => true; }
0
mirrored_repositories/damian_go/lib/view
mirrored_repositories/damian_go/lib/view/screens/home_screen.dart
import 'package:damian_go/view/views.dart'; import 'package:flutter/material.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { @override Widget build(BuildContext context) { // TODO: implement build return const GoogleMapWidget(); } }
0
mirrored_repositories/damian_go/lib/view
mirrored_repositories/damian_go/lib/view/screens/star_level_screen.dart
import 'package:damian_go/view/views.dart'; import 'package:damian_go/utils/constants.dart'; import 'package:damian_go/utils/star_level_util.dart'; import 'package:flutter/material.dart'; class StarLevelScreen extends StatelessWidget{ @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( appBar: AppBar( backgroundColor: Colors.blueGrey.shade900, title: Text('Star levels'), ), body: starLevels(context), ); } Widget starLevels(BuildContext context){ return ListView( padding: EdgeInsets.all(5), children: [ _LevelListTile( description: 'From 1 to 50 zones', starLevel: StarLevel.Beginner, starLevelDesign: StarLevelDesign.beginnerStarLevelDesign, ), _LevelListTile( description: 'From 51 to 100 zones', starLevel: StarLevel.Explorer, starLevelDesign: StarLevelDesign.explorerStarLevelDesign ), _LevelListTile( description: 'From 101 to 150 zones', starLevel: StarLevel.Adventurer, starLevelDesign: StarLevelDesign.adventurerStarLevelDesign ), _LevelListTile( description: 'From 151 to 200 zones', starLevel: StarLevel.Discoverer, starLevelDesign: StarLevelDesign.discovererStarLevelDesign ), _LevelListTile( description: 'From 201 to 250 zones', starLevel: StarLevel.Navigator, starLevelDesign: StarLevelDesign.navigatorStarLevelDesign ), _LevelListTile( description: 'From 251 to 300 zones', starLevel: StarLevel.Pioneer, starLevelDesign: StarLevelDesign.pioneerStarLevelDesign ), _LevelListTile( description: 'From 301 to 350 zones', starLevel: StarLevel.Trekker, starLevelDesign: StarLevelDesign.trekkerStarLevelDesign ), _LevelListTile( description: 'From 351 to 400 zones', starLevel: StarLevel.Master_Explorer, starLevelDesign: StarLevelDesign.masterExplorerStarLevelDesign ) ] ); } } class _LevelListTile extends StatelessWidget { final String description; final StarLevel starLevel; final StarLevelDesign starLevelDesign; const _LevelListTile({ Key? key, required this.description, required this.starLevel, required this.starLevelDesign, }) : super(key: key); @override Widget build(BuildContext context) { return ListTile( leading: starLevelDesign.icon, subtitle: Text(description,style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.w500)), trailing: InkWell( child: Icon(Icons.info_outline), onTap:(){ showDialog( barrierColor: Colors.black26, context: context, builder: (context){ return Container( child: AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), content: SizedBox( height: 120, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Insert the star level description here in few words, not too much text'), UserStarLevel(starLevel: starLevel), ] ), ), ), ); } ); }, ), title: Text('${StarLevelUtil.getStarLevelName(starLevel)}'), ); } }
0
mirrored_repositories/damian_go/lib/view
mirrored_repositories/damian_go/lib/view/screens/about_app_screen.dart
import 'package:damian_go/utils/constants.dart'; import 'package:damian_go/utils/navigator_util.dart'; import 'package:damian_go/view/views.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:url_launcher/url_launcher.dart'; class AboutAppScreen extends StatelessWidget{ @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.blueGrey.shade900, title: Text('About app'), ), body: Column( children: [ Expanded(child: settings(context)), //Display the current app version Padding( padding: EdgeInsets.only(top:10,bottom: 15), child: FutureBuilder( future: getVersion(), builder: (context, snapshot) { if(snapshot.hasData){ return Container( child: Text( 'Version : ${snapshot.data}', style: TextStyle( fontSize: 16, color: Colors.black38 ), ), ); }else return Text(""); }), ), ] ), ); } Widget settings(BuildContext context){ return ListView( children: [ _AboutAppListTile( title: 'Stars Level', subtitle: 'Available star levels', iconData: Icons.star, onTap: (){ Navigator.of(context).push( NavigatorUtil.createRouteWithSlideAnimation(newPage: StarLevelScreen())); } ), _AboutAppListTile( title: 'Share app', subtitle: 'Share the app with a friend', iconData: Icons.share, onTap: () { showModalBottomSheet( backgroundColor: Colors.transparent, barrierColor: Colors.black26, context: context, builder: (BuildContext context) { return Container( padding: const EdgeInsets.all(10), margin: const EdgeInsets.only(left: 7, right: 7), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15) ), height: 120, child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Text( 'Share the app',textAlign: TextAlign.left, style: TextStyle( color: Colors.black54, fontSize: 20 ), ), SizedBox(height: 5), Expanded( child: ListView( scrollDirection: Axis.horizontal, children: socialMediaButtons(context), ), ), ]), ); }); }, ), _AboutAppListTile( title: 'Rate app', subtitle: 'Rate the app on Playstore', iconData: FontAwesomeIcons.googlePlay, onTap: () async{ String appId = Constants.playStoreId; final url = Uri.parse('https://play.google.com/store/apps/details?id=$appId'); print(url); await launchUrl(url,mode: LaunchMode.externalApplication); }, ), _AboutAppListTile( title: 'Privacy Policy', subtitle: 'App privacy policy', iconData: Icons.privacy_tip_outlined, onTap: () async{ final url = Uri.parse('https://daumienebi.github.io/yo_nunca/policy.html'); await launchUrl(url,mode: LaunchMode.externalApplication); }, ), _AboutAppListTile( title: 'Terms & Conditions', subtitle: 'App Terms and Conditions', iconData: Icons.file_present, onTap: () async{ final url = Uri.parse('https://daumienebi.github.io/yo_nunca/policy.html'); await launchUrl(url,mode: LaunchMode.externalApplication); }, ), ], ); } /// Method to launch each share option for the [SocialMedia] Future share(SocialMedia platform,BuildContext context) async { String text = 'Test text'; String appId = 'com.devdaumienebi.yonunca'; final urlString = 'https://play.google.com/store/apps/details?id=$appId'; final urlShare = Uri.encodeComponent(urlString); final urls = { SocialMedia.Facebook: 'https://www.facebook.com/sharer/sharer.php?u=$urlShare&t=$text', SocialMedia.Twitter: 'https://twitter.com/intent/tweet?url=$urlShare&text=$text', SocialMedia.Whatsapp: 'https://api.whatsapp.com/send?text=$text $urlShare', }; final url = Uri.parse(urls[platform]!); await launchUrl(url,mode: LaunchMode.externalApplication); } List<Widget> socialMediaButtons(context) { //Very shitty work around // TODO : Change it later on List<Widget> items = []; items.add(SizedBox( width: 10, )); items.add(socialButton( socialMedia: SocialMedia.Whatsapp.name, icon: Icon( FontAwesomeIcons.whatsapp, color: Colors.green, size: 40, ), onClicked: (){ Navigator.pop(context); share(SocialMedia.Whatsapp,context); })); items.add(SizedBox( width: 15, )); items.add(socialButton( socialMedia: SocialMedia.Twitter.name, icon: Icon( FontAwesomeIcons.twitter, color: Colors.lightBlueAccent, size: 40, ), onClicked: (){ Navigator.pop(context); share(SocialMedia.Twitter,context); })); items.add(SizedBox( width: 15, )); items.add(socialButton( socialMedia: SocialMedia.Email.name, icon: Icon( Icons.email, color: Colors.redAccent, size: 40, ), onClicked: (){ Navigator.pop(context); share(SocialMedia.Facebook,context); })); items.add(SizedBox( width: 15, )); items.add(socialButton( socialMedia: SocialMedia.Facebook.name, icon: Icon( FontAwesomeIcons.facebook, color: Colors.indigo, size: 40, ), onClicked: (){ Navigator.pop(context); share(SocialMedia.Facebook,context); })); items.add(SizedBox( width: 15, )); items.add( socialButton( socialMedia: 'Copy link', icon: Icon( Icons.copy, color: Colors.grey, size: 40, ), onClicked: () async{ String appId = 'com.devdaumienebi.yonunca'; final urlString = 'https://play.google.com/store/apps/details?id=$appId'; await Clipboard.setData(ClipboardData(text:urlString)); Navigator.pop(context); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('Link copied'), duration: Duration(seconds: 2) ) ); } ) ); return items; } socialButton({required String socialMedia,required Icon icon, Function()? onClicked}) { final listTextStyle = TextStyle(color: Colors.black54); return Container( child: Column( children: [ InkWell( child: icon, onTap: onClicked, ), Text(socialMedia, style: listTextStyle,), ], ), ); } Future<String> getVersion() async{ PackageInfo packageInfo = await PackageInfo.fromPlatform(); String version = packageInfo.version; return Future.value(version); } } class _AboutAppListTile extends StatelessWidget{ final String title; final String subtitle; final IconData iconData; final bool dangerZone; final Function()? onTap; const _AboutAppListTile({super.key, required this.title, required this.subtitle, required this.iconData, this.onTap, this.dangerZone = false}); @override Widget build(BuildContext context) { final titleStyle = TextStyle(fontSize: 16,color: dangerZone ? Colors.red : Colors.black87); final Color iconColor = Colors.blueGrey.shade500; // TODO: implement build return ListTile( title: Text(title,style: titleStyle), subtitle: Text(subtitle), leading: Icon(iconData,color: iconColor), trailing: Icon(Icons.arrow_forward_ios_sharp,size: 10), onTap: onTap ?? (){} ); } }
0
mirrored_repositories/damian_go/lib/view/screens
mirrored_repositories/damian_go/lib/view/screens/user/user_detail_screen.dart
import 'package:damian_go/utils/constants.dart'; import 'package:damian_go/view/views.dart'; import 'package:flutter/material.dart'; class UserDetailScreen extends StatelessWidget{ @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.blueGrey.shade900, title: Text('User Profile'), actions: [ followUserButton() ], ), body: Padding( padding: EdgeInsets.all(10), child: Column( children: [ profileWidget(context), moreUserDetails() ], ), ), ); } Widget followUserButton(){ return Container( padding: EdgeInsets.all(10), child: TextButton( style: TextButton.styleFrom(backgroundColor: Colors.white), child: Text('Follow',style: TextStyle(color: Colors.black87)), onPressed: (){ }, ), ); } Widget profileWidget(BuildContext context){ return Container( padding: EdgeInsets.all(7), width: double.infinity, decoration: BoxDecoration( color: Colors.black12, borderRadius: BorderRadius.circular(10), ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ CircleAvatar( radius: 60, // or any other size you want backgroundImage: AssetImage('assets/images/damian.png'), backgroundColor: Colors.transparent, ), VerifiedUserName(name: '@derick',isVerified: true,centered: true), Clout(followers: 10,following: 0), //ZoneCount(count: 15), UserStarLevel(starLevel:StarLevel.Adventurer), ], ), ); } Widget moreUserDetails() { final date = DateTime.now(); final trailingStyle = TextStyle(color: Colors.black87, fontWeight: FontWeight.w500,fontSize: 16); return Expanded( child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: ListView( //crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( leading: Icon(Icons.person), title: Text('Username '), trailing: Text('derick', style: trailingStyle), ), ListTile( leading: Icon(Icons.location_on), title: Text('Nº of Zones '), trailing: Text('15', style: trailingStyle), ), ListTile( leading: Icon(Icons.date_range), title: Text('Joined '), trailing: Text('${date.day}/${date.month}/${date.year}', style: trailingStyle), ), ], ), ), ); } }
0
mirrored_repositories/damian_go/lib/view/screens
mirrored_repositories/damian_go/lib/view/screens/user/user_search_delegate_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:lottie/lottie.dart'; // ignore_for_file: prefer_const_constructors class UserSearchDelegateScreen extends SearchDelegate { //Add a hint text to override the default one final String? hintText; UserSearchDelegateScreen({required this.hintText}); @override String? get searchFieldLabel => hintText; @override TextStyle get searchFieldStyle => TextStyle( fontSize: 16, color: Colors.grey[800], ); @override TextInputType get keyboardType => TextInputType.name; @override TextInputAction get textInputAction => TextInputAction.search; @override ThemeData appBarTheme(BuildContext context) { final ThemeData theme = Theme.of(context); final ColorScheme colorScheme = theme.colorScheme; return theme.copyWith( appBarTheme: AppBarTheme( systemOverlayStyle: SystemUiOverlayStyle( statusBarBrightness: Brightness.light ), backgroundColor: colorScheme.brightness == Brightness.dark ? Colors.grey[900] : Colors.white, iconTheme: theme.primaryIconTheme.copyWith(color: Colors.grey), toolbarTextStyle: theme.textTheme.bodyText2, titleTextStyle: theme.textTheme.headline6, ), inputDecorationTheme: searchFieldDecorationTheme ?? InputDecorationTheme( hintStyle: searchFieldStyle ?? theme.inputDecorationTheme.hintStyle, border: InputBorder.none, ), ); } @override List<Widget>? buildActions(BuildContext context) { return [ IconButton( onPressed: () { query = ''; }, icon: Icon(Icons.clear), tooltip: 'Close', ) ]; } @override Widget? buildLeading(BuildContext context) { return IconButton( icon: Icon(Icons.arrow_back), onPressed: () { close(context, null); //close the search bar }, ); } @override Widget buildResults(BuildContext context) { return Container(); } @override Widget buildSuggestions(BuildContext context) { return Container(); //NOTE : snapshot.data.length ~/ 2 (Integer truncate value). //Round up to the nearest int without remainders } Widget resultNotFoundWidget() { return Center( child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ Lottie.asset( 'assets/lottie_animations/search-not-found.json', ), const Text( 'No results found.', textAlign: TextAlign.center, style: TextStyle(fontSize: 17, color: Colors.black87), ), ]), ); } }
0
mirrored_repositories/damian_go/lib/view/screens
mirrored_repositories/damian_go/lib/view/screens/user/signed_in_profile_screen.dart
import 'package:damian_go/utils/navigator_util.dart'; import 'package:damian_go/utils/constants.dart'; import 'package:damian_go/view/views.dart'; import 'package:flutter/material.dart'; class SignedInProfileScreen extends StatelessWidget{ const SignedInProfileScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( appBar: AppBar( elevation: 0, title: Text('Profile'), backgroundColor: Colors.blueGrey.shade900, actions: [ IconButton( onPressed: (){ showModalBottomSheet( barrierColor: Colors.black26, backgroundColor: Colors.transparent, context: context, builder: (BuildContext context) { double height = MediaQuery.of(context).size.height; return Container( height: height * 0.3, padding: const EdgeInsets.all(10), margin: const EdgeInsets.only(left: 7, right: 7), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15), ), child: Expanded( child: ListView( //scrollDirection: Axis.horizontal, children: [ _SettingsListTile( title: 'Help', subtitle: 'Help about the app', iconData: Icons.logout, ), _SettingsListTile( title: 'Delete account', subtitle: 'Permanently delete your account', iconData: Icons.delete, dangerZone: true, ), _SettingsListTile( title: 'Log out', subtitle: '', iconData: Icons.logout, dangerZone: true, ), ], ), ), ); }); }, icon: Icon(Icons.settings ) ) ], ), body: body(context) ); } Widget body(context){ return Container( margin: EdgeInsets.only(top: 15,left: 10, right: 10), child: Column( children: [ profileWidget(context), SizedBox(height:10), moreUserDetails(), ], ), ); } Widget moreUserDetails() { final date = DateTime.now(); final trailingStyle = TextStyle(color: Colors.black54, fontWeight: FontWeight.w400,fontSize: 16); final leadingStyle = TextStyle(color: Colors.black87); return Expanded( child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), child: ListView( //crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( leading: Icon(Icons.person), title: Text('Username ',style: leadingStyle,), trailing: Text('derick', style: trailingStyle), ), ListTile( leading: Icon(Icons.location_on), title: Text('Nº of Zones ',style: leadingStyle), trailing: Text('15', style: trailingStyle), ), ListTile( leading: Icon(Icons.date_range), title: Text('Joined ',style: leadingStyle,), trailing: Text('${date.day}/${date.month}/${date.year}', style: trailingStyle), ), ListTile( leading: Icon(Icons.date_range), title: Text('Birthday ',style: leadingStyle,), trailing: Text('${date.day}/${date.month}/${date.year}', style: trailingStyle), ), ], ), ), ); } Widget profileWidget(BuildContext context){ return Container( padding: EdgeInsets.all(7), width: double.infinity, decoration: BoxDecoration( color: Colors.black12, borderRadius: BorderRadius.circular(10), ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ CircleAvatar( radius: 60, // or any other size you want backgroundImage: AssetImage('assets/images/damian.png'), backgroundColor: Colors.transparent, ), VerifiedUserName(name: '@derick',isVerified: true,centered: true), Clout(followers: 10,following: 0), UserStarLevel(starLevel:StarLevel.Adventurer), ], ), ); } } class _SettingsListTile extends StatelessWidget{ final String title; final String subtitle; final IconData iconData; final bool dangerZone; final Function()? onTap; const _SettingsListTile({super.key, required this.title, required this.subtitle, required this.iconData, this.onTap, this.dangerZone = false}); @override Widget build(BuildContext context) { final titleStyle = TextStyle(fontSize: 16,color: dangerZone ? Colors.red : Colors.black87); final Color iconColor = Colors.blueGrey.shade500; // TODO: implement build return ListTile( title: Text(title,style: titleStyle), subtitle: Text(subtitle), leading: Icon(iconData,color: iconColor), trailing: Icon(Icons.arrow_forward_ios_sharp,size: 10), onTap: onTap ?? (){} ); } }
0
mirrored_repositories/damian_go/lib/view/screens
mirrored_repositories/damian_go/lib/view/screens/user/not_signed_in_profile_screen.dart
import 'package:flutter/material.dart'; class NotSignedInProfileScreen extends StatelessWidget{ @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( appBar: AppBar( backgroundColor: Colors.blueGrey.shade900, title: Text('Not Signed in drawer'), ), body: Center(child: Text('Top user')), ); } }
0
mirrored_repositories/damian_go/lib/view/screens
mirrored_repositories/damian_go/lib/view/screens/user/top_users_screen.dart
import 'package:damian_go/utils/navigator_util.dart'; import 'package:damian_go/view/views.dart'; import 'package:flutter/material.dart'; class TopUsersScreen extends StatelessWidget{ @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( appBar: AppBar( backgroundColor: Colors.blueGrey.shade900, title: Text('Top users'), ), body: ListView( children: [ UserListTile(username: 'derick',image:'assets/images/piny.png',tempStarLevel:Icon(Icons.star,color: Colors.red,size: 35),verified: false), UserListTile(username: 'damian',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.cyan,size: 35),verified: true), UserListTile(username: 'xalo',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.green,size: 35),verified: false), UserListTile(username: 'john',image:'assets/images/piny.png',tempStarLevel:Icon(Icons.star,color: Colors.amber,size: 35,),verified: true), UserListTile(username: 'papilo',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.indigo,size: 35),verified: true), UserListTile(username: 'mary',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.brown,size: 35),verified: true), UserListTile(username: 'myron',image:'assets/images/pin.png',tempStarLevel:Icon(Icons.star,color: Colors.red,size: 35),verified: false), UserListTile(username: 'xalo',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.pink,size: 35),verified: false), UserListTile(username: 'john',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.red,size: 35),verified: true), UserListTile(username: 'papilo',image:'assets/images/piny.png',tempStarLevel:Icon(Icons.star,color: Colors.red,size: 35),verified: false), UserListTile(username: 'mary',image:'assets/images/damian.png',tempStarLevel:Icon(Icons.star,color: Colors.lightBlue,size: 35),verified: true), UserListTile(username: 'myron',image:'assets/images/pin.png',tempStarLevel:Icon(Icons.star,color: Colors.red,size:35),verified: false), ], ), ); } } class UserListTile extends StatelessWidget{ const UserListTile({super.key, required this.username, required this.image, required this.tempStarLevel, required this.verified}); final String username; final String image; final Icon tempStarLevel; final bool verified; @override Widget build(BuildContext context) { // TODO: implement build return Container( //padding: EdgeInsets.all(5), child: ListTile( onTap: (){ Navigator.of(context).push( NavigatorUtil.createRouteWithSlideAnimation(newPage: UserDetailScreen()) ); }, leading: Image.asset(image), title: VerifiedUserName(name: username,isVerified:verified), subtitle: Row( children: [ Text('15 zones added',style: TextStyle(fontSize:15)), ], ), trailing: tempStarLevel ), ); } } /* *Leading with ranking * leading: SizedBox( width: 70, height: 70, child: Row( children: [ Text('#1',style: TextStyle(fontWeight: FontWeight.bold,color: Colors.white,backgroundColor: Colors.black87),), Image.asset(image), ], ), ), * */
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/model/damian_zone.dart
import 'package:damian_go/model/user.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; class DamianZone{ final int id; final LatLng latLng; final DateTime zoneDate; final User user; DamianZone(this.id, this.latLng, this.zoneDate, this.user); // fromMap method to create a DamianZone object from a map factory DamianZone.fromMap(Map<String, dynamic> json) => DamianZone( json['id'] as int, LatLng(json['latLng']['latitude'] as double, json['latLng']['longitude'] as double), DateTime.parse(json['zoneDate'] as String), User.fromMap(json['user'] as Map<String, dynamic>), ); // toMap method to convert a DamianZone object to a map Map<String, dynamic> toMap() => <String, dynamic>{ 'id': id, 'latLng': {'latitude': latLng.latitude, 'longitude': latLng.longitude}, 'zoneDate': zoneDate.toIso8601String(), 'user': user.toMap(), }; }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/model/user.dart
import 'package:damian_go/model/damian_zone.dart'; /// Class to take care of the users class User { final String _id; final String _username; final String _email; final bool _isVerified; final DateTime _registrationDate; final List<DamianZone> _damianZones; final List<User> _followers; final List<User> _following; /// Create the constructor User(this._id, this._username, this._registrationDate, this._damianZones, this._followers, this._following, this._email, this._isVerified); // Getters String get id => _id; String get username => _username; String get email => _email; bool get isVerified => _isVerified; DateTime get registrationDate => _registrationDate; List<DamianZone> get damianZones => _damianZones; List<User> get followers => _followers; List<User> get following => _following; // fromMap method to create a User object from a map factory User.fromMap(Map<String, dynamic> json) { final damianZones = List<DamianZone>.from((json['damianZones'] as List<dynamic>) .map((dynamic item) => DamianZone.fromMap(item as Map<String, dynamic>))); final followers = List<User>.from((json['followers'] as List<dynamic>).map((dynamic item) => User.fromMap(item as Map<String, dynamic>))); final following = List<User>.from((json['following'] as List<dynamic>).map((dynamic item) => User.fromMap(item as Map<String, dynamic>))); return User( json['id'] as String, json['username'] as String, DateTime.parse(json['registrationDate']), damianZones, followers, following, json['email'] as String, json['isVerified'] as bool, ); } // toMap method to convert a User object to a map Map<String, dynamic> toMap() => <String, dynamic>{ 'id': id, 'username': username, 'email': email, 'isVerified': isVerified, 'registrationDate': registrationDate.toIso8601String(), 'damianZones': List<dynamic>.from(damianZones.map((DamianZone item) => item.toMap())), 'followers': List<dynamic>.from(followers.map((User item) => item.toMap())), 'following': List<dynamic>.from(following.map((User item) => item.toMap())), }; }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/utils/countries_util.dart
import 'package:geocoding/geocoding.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; class CountriesUtil{ static final Map<String, LatLng> _countryLocations = { // Africa 'Algeria': const LatLng(28.033886, 1.659626), 'Angola': const LatLng(-11.202692, 17.873887), 'Benin': const LatLng(9.30769, 2.315834), 'Botswana': const LatLng(-22.328474, 24.684866), 'Burkina Faso': const LatLng(12.238333, -1.561593), 'Burundi': const LatLng(-3.373056, 29.918886), 'Cameroon': const LatLng(7.369722, 12.354722), 'Cape Verde': const LatLng(15.120142, -23.605172), 'Central African Republic': const LatLng(6.611111, 20.939444), 'Chad': const LatLng(15.454166, 18.732207), 'Comoros': const LatLng(-11.875001, 43.872219), 'Democratic Republic of the Congo': const LatLng(-4.038333, 21.758664), 'Djibouti': const LatLng(11.825138, 42.590275), 'Egypt': const LatLng(26.820553, 30.802498), 'Equatorial Guinea': const LatLng(1.650801, 10.267895), 'Eritrea': const LatLng(15.179384, 39.782334), 'Eswatini (Swaziland)': const LatLng(-26.522503, 31.465866), 'Ethiopia': const LatLng(9.145, 40.489673), 'Gabon': const LatLng(-0.803689, 11.609444), 'Gambia': const LatLng(13.443182, -15.310139), 'Ghana': const LatLng(7.946527, -1.023194), 'Guinea': const LatLng(9.945587, -9.696645), 'Guinea-Bissau': const LatLng(11.803749, -15.180413), 'Ivory Coast (Côte d\'Ivoire)': const LatLng(7.539989, -5.54708), 'Kenya': const LatLng(-0.023559, 37.906193), 'Lesotho': const LatLng(-29.609988, 28.233608), 'Liberia': const LatLng(6.428055, -9.429499), 'Libya': const LatLng(26.3351, 17.228331), 'Madagascar': const LatLng(-18.766947, 46.869107), 'Malawi': const LatLng(-13.254308, 34.301525), 'Mali': const LatLng(17.570692, -3.996166), 'Mauritania': const LatLng(21.00789, -10.940835), 'Mauritius': const LatLng(-20.348404, 57.552152), 'Morocco': const LatLng(31.791702, -7.09262), 'Mozambique': const LatLng(-18.665695, 35.529562), 'Namibia': const LatLng(-22.95764, 18.49041), 'Niger': const LatLng(17.607789, 8.081666), 'Nigeria': const LatLng(9.081999, 8.675277), 'Rwanda': const LatLng(-1.940278, 29.873888), 'Sao Tome and Principe': const LatLng(0.18636, 6.61308), 'Senegal': const LatLng(14.497401, -14.452362), 'Seychelles': const LatLng(-4.679574, 55.491977), 'Sierra Leone': const LatLng(8.460555, -11.779889), 'Somalia': const LatLng(5.152149, 46.199616), 'South Africa': const LatLng(-30.559482, 22.937506), 'South Sudan': const LatLng(6.876992, 31.306979), 'Sudan': const LatLng(12.862807, 30.217636), 'Tanzania': const LatLng(-6.369028, 34.888822), 'Togo': const LatLng(8.619543, 0.824782), 'Tunisia': const LatLng(33.886917, 9.537499), 'Uganda': const LatLng(1.373333, 32.290275), 'Zambia': const LatLng(-13.133897, 27.849332), 'Zimbabwe': const LatLng(-19.015438, 29.154857), //Europe 'Albania': const LatLng(41.153332, 20.168331), 'Andorra': const LatLng(42.546245, 1.601554), 'Austria': const LatLng(47.516231, 14.550072), 'Belarus': const LatLng(53.709807, 27.953389), 'Belgium': const LatLng(50.503887, 4.469936), 'Bosnia and Herzegovina': const LatLng(43.915886, 17.679076), 'Bulgaria': const LatLng(42.733883, 25.48583), 'Croatia': const LatLng(45.1, 15.2), 'Cyprus': const LatLng(35.126413, 33.429859), 'Czech Republic': const LatLng(49.817492, 15.472962), 'Denmark': const LatLng(56.26392, 9.501785), 'Estonia': const LatLng(58.595272, 25.013607), 'Finland': const LatLng(61.92411, 25.748151), 'France': const LatLng(46.227638, 2.213749), 'Germany': const LatLng(51.165691, 10.451526), 'Greece': const LatLng(39.074208, 21.824312), 'Hungary': const LatLng(47.162494, 19.503304), 'Iceland': const LatLng(64.963051, -19.020835), 'Ireland': const LatLng(53.41291, -8.24389), 'Italy': const LatLng(41.87194, 12.56738), 'Kosovo': const LatLng(42.602636, 20.902977), 'Latvia': const LatLng(56.879635, 24.603189), 'Liechtenstein': const LatLng(47.166, 9.555373), 'Lithuania': const LatLng(55.169438, 23.881275), 'Luxembourg': const LatLng(49.815273, 6.129583), 'Malta': const LatLng(35.937496, 14.375416), 'Moldova': const LatLng(47.411631, 28.369885), 'Monaco': const LatLng(43.750298, 7.412841), 'Montenegro': const LatLng(42.708678, 19.37439), 'Netherlands': const LatLng(52.132633, 5.291266), 'North Macedonia': const LatLng(41.608635, 21.745275), 'Norway': const LatLng(60.472024, 8.468946), 'Poland': const LatLng(51.919438, 19.145136), 'Portugal': const LatLng(39.399872, -8.224454), 'Romania': const LatLng(45.943161, 24.96676), 'Russia': const LatLng(61.52401, 105.318756), 'San Marino': const LatLng(43.94236, 12.457777), 'Serbia': const LatLng(44.016521, 21.005859), 'Slovakia': const LatLng(48.669026, 19.699024), 'Slovenia': const LatLng(46.151241, 14.995463), 'Spain': const LatLng(40.463667, -3.74922), 'Armenia': const LatLng(40.069099, 45.038189), 'Georgia': const LatLng(42.315407, 43.356892), 'Greenland': const LatLng(71.706936, -42.604303), 'Kazakhstan': const LatLng(48.019573, 66.923684), 'Kyrgyzstan': const LatLng(41.20438, 74.766098), 'Macedonia': const LatLng(41.608635, 21.745275), 'Turkmenistan': const LatLng(38.969719, 59.556278), 'Ukraine': const LatLng(48.379433, 31.16558), 'Uzbekistan': const LatLng(41.377491, 64.585262), //Asia 'Afghanistan': const LatLng(33.93911, 67.709953), 'Bahrain': const LatLng(26.0667, 50.5577), 'Bangladesh': const LatLng(23.685, 90.3563), 'Bhutan': const LatLng(27.5142, 90.4336), 'Brunei': const LatLng(4.5353, 114.7277), 'Cambodia': const LatLng(12.5657, 104.991), 'China': const LatLng(35.8617, 104.1954), 'India': const LatLng(20.5937, 78.9629), 'Indonesia': const LatLng(-0.7893, 113.9213), 'Iran': const LatLng(32.4279, 53.688), 'Iraq': const LatLng(33.2232, 43.6793), 'Israel': const LatLng(31.0461, 34.8516), 'Japan': const LatLng(36.2048, 138.2529), 'Jordan': const LatLng(30.5852, 36.2384), 'Kuwait': const LatLng(29.3117, 47.4818), 'Laos': const LatLng(19.8563, 102.4955), 'Lebanon': const LatLng(33.8547, 35.8623), 'Thailand': const LatLng(15.870032, 100.992541), 'South Korea': const LatLng(35.907757, 127.766922), 'Vietnam': const LatLng(14.058324, 108.277199), 'Oman': const LatLng(21.512583, 55.923255), 'Pakistan': const LatLng(30.375321, 69.345116), 'Palestine': const LatLng(31.952162, 35.233154), 'Philippines': const LatLng(12.879721, 121.774017), 'Qatar': const LatLng(25.354826, 51.183884), 'Saudi Arabia': const LatLng(23.885942, 45.079162), 'Singapore': const LatLng(1.352083, 103.819836), 'Sri Lanka': const LatLng(7.873054, 80.771797), 'Syria': const LatLng(34.802075, 38.996815), 'Tajikistan': const LatLng(38.861034, 71.276093), 'Turkey': const LatLng(38.963745, 35.243322), 'United Arab Emirates': const LatLng(23.424076, 53.847818), 'Azerbaijan': const LatLng(40.1431, 47.5769), 'Maldives': const LatLng(3.2028, 73.2207), 'Mongolia': const LatLng(46.8625, 103.8467), 'Myanmar': const LatLng(21.9162, 95.956), 'Nepal': const LatLng(28.3949, 84.124), 'North Korea': const LatLng(40.3399, 127.5101), 'Taiwan': const LatLng(23.6978, 120.9605), 'Timor-Leste': const LatLng(-8.874217, 125.727539), //South - America 'Argentina': const LatLng(-38.416097, -63.616672), 'Brazil': const LatLng(-14.235004, -51.925280), 'Colombia': const LatLng(4.570868, -74.297333), 'Peru': const LatLng(-9.189967, -75.015152), 'Chile': const LatLng(-35.675147, -71.542969), 'Ecuador': const LatLng(-1.831239, -78.183406), 'Uruguay': const LatLng(-32.522779, -55.765835), 'Bolivia': const LatLng(-16.290154, -63.588653), 'Guyana': const LatLng(4.860416, -58.93018), 'Paraguay': const LatLng(-23.442503, -58.443832), 'Suriname': const LatLng(3.919305, -56.027783), 'Venezuela': const LatLng(6.42375, -66.58973), //North - America 'Canada': const LatLng(56.130366, -106.346771), 'United States': const LatLng(37.09024, -95.712891), 'Mexico': const LatLng(23.634501, -102.552784), 'Guatemala': const LatLng(15.783471, -90.230759), 'Honduras': const LatLng(15.199999, -86.241905), 'El Salvador': const LatLng(13.794185, -88.89653), 'Nicaragua': const LatLng(12.865416, -85.207229), 'Costa Rica': const LatLng(9.748917, -83.753428), 'Panama': const LatLng(8.537981, -80.782127), 'Belize': const LatLng(17.189877, -88.49765), 'Bahamas': const LatLng(25.03428, -77.39628), 'Cuba': const LatLng(21.521757, -77.781167), 'Dominican Republic': const LatLng(18.735693, -70.162651), 'Haiti': const LatLng(18.971187, -72.285215), 'Jamaica': const LatLng(18.109581, -77.297508), 'Puerto Rico': const LatLng(18.220833, -66.590149), 'Trinidad and Tobago': const LatLng(10.691803, -61.222503), 'Saint Kitts and Nevis': const LatLng(17.357822, -62.782998), 'Saint Lucia': const LatLng(13.909444, -60.978893), 'Saint Vincent and the Grenadines': const LatLng(13.252817, -61.197098), 'Barbados': const LatLng(13.193887, -59.543198), 'Grenada': const LatLng(12.262776, -61.604171), //Oceania 'Australia': const LatLng(-25.274398, 133.775136), 'Fiji': const LatLng(-17.713371, 178.065032), 'Kiribati': const LatLng(-3.370417, -168.734039), 'Marshall Islands': const LatLng(7.131474, 171.184478), 'Micronesia': const LatLng(7.425554, 150.550812), 'Nauru': const LatLng(-0.522778, 166.931503), 'New Zealand': const LatLng(-40.900558, 174.885971), 'Palau': const LatLng(7.514980, 134.582520), 'Papua New Guinea': const LatLng(-6.314993, 143.955550), 'Samoa': const LatLng(-13.759029, -172.104629), 'Solomon Islands': const LatLng(-9.645710, 160.156194), 'Tonga': const LatLng(-21.178986, -175.198242), 'Tuvalu': const LatLng(-7.478269, 178.679413), 'Vanuatu': const LatLng(-15.376706, 166.959158), }; static LatLng? getCountryLatLng(String countryName){ return _countryLocations[countryName]; } static Map<String,LatLng> getAllCountries() { return _countryLocations; } static Future<String> getCountryFromLocation(LatLng location) async { try { List<Placemark> placeMarks = await placemarkFromCoordinates(location.latitude, location.longitude); if (placeMarks != null && placeMarks.isNotEmpty) { Placemark countryPlacemark = placeMarks.firstWhere((placeMark) => placeMark.country != null,); if (countryPlacemark != null) { return countryPlacemark.country!; } } } catch (e) { print('Error getting country from location: $e'); } return 'No-country'; } }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/utils/star_level_util.dart
import 'package:damian_go/utils/constants.dart'; import 'package:flutter/material.dart'; class StarLevelUtil{ static String getStarLevelName(StarLevel starLevel){ String starLevelText; switch(starLevel){ case StarLevel.Beginner:{ starLevelText = 'Beginner'; } break; case StarLevel.Explorer: starLevelText = 'Explorer'; break; case StarLevel.Adventurer: starLevelText = 'Adventurer'; break; case StarLevel.Discoverer: starLevelText = 'Discoverer'; break; case StarLevel.Navigator: starLevelText = 'Navigator'; break; case StarLevel.Pioneer: starLevelText = 'Pioneer'; break; case StarLevel.Trekker: starLevelText = 'Trekker'; break; case StarLevel.Master_Explorer: starLevelText = 'Master Explorer'; break; } return starLevelText; } } /// The design for each star level class StarLevelDesign{ StarLevelDesign({required this.starLevel,required this.backgroundColor,required this.icon}); static double iconSize = 40; // define the values final StarLevel starLevel; final Color backgroundColor; final Icon icon; static var beginnerStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Beginner, backgroundColor: Colors.white, icon: Icon(Icons.star,color: Colors.red,size: iconSize) ); static var explorerStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Explorer, backgroundColor: Colors.blueGrey.shade700, icon: Icon(Icons.star,color: Colors.lightBlue,size: iconSize) ); static var adventurerStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Adventurer, backgroundColor: Colors.amber, icon: Icon(Icons.star,color: Colors.green,size: iconSize) ); static var discovererStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Discoverer, backgroundColor: Colors.red.shade700, icon: Icon(Icons.star,color: Colors.amber,size: iconSize) ); static var navigatorStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Navigator, backgroundColor: Colors.white, icon: Icon(Icons.star,color: Colors.indigo,size: iconSize) ); static var pioneerStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Pioneer, backgroundColor: Colors.yellow, icon: Icon(Icons.star,color: Colors.brown,size: iconSize) ); static var trekkerStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Trekker, backgroundColor: Colors.white, icon: Icon(Icons.star,color:Colors.pink,size: iconSize) ); static var masterExplorerStarLevelDesign = StarLevelDesign( starLevel: StarLevel.Master_Explorer, backgroundColor: Colors.cyanAccent.shade200, icon: Icon(Icons.star,color: Colors.blueGrey.shade900,size: iconSize) ); // Add one for Damian too static StarLevelDesign getStartLevelDesign(StarLevel starLevel){ StarLevelDesign starLevelDesign; switch(starLevel){ case StarLevel.Beginner :{ starLevelDesign = beginnerStarLevelDesign; } break; case StarLevel.Explorer :{ starLevelDesign = explorerStarLevelDesign; } break; case StarLevel.Adventurer :{ starLevelDesign = adventurerStarLevelDesign; } break; case StarLevel.Discoverer :{ starLevelDesign = discovererStarLevelDesign; } break; case StarLevel.Navigator :{ starLevelDesign = navigatorStarLevelDesign; } break; case StarLevel.Pioneer :{ starLevelDesign = pioneerStarLevelDesign; } break; case StarLevel.Trekker :{ starLevelDesign = trekkerStarLevelDesign; } break; case StarLevel.Master_Explorer :{ starLevelDesign = masterExplorerStarLevelDesign; } break; } return starLevelDesign; } } class StarLevelCode{ int get Beginner => 1; int get Explorer => 2; int get Adventurer => 3; int get Discoverer => 4; int get Navigator => 5; int get Pioneer => 6; int get Trekker => 7; int get Master_Explorer => 8; }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/utils/default_data.dart
import 'package:damian_go/model/damian_zone.dart'; import 'package:damian_go/model/user.dart'; /// Test data to properly construct the ui before switching to firestore /// and other data sources class DefaultData{ List<DamianZone> _damianZones = []; List<User> _users = []; List<DamianZone> get getDamianZones => _getDamianZones(); List<DamianZone> get getUsers => _getUsers(); _getDamianZones(){ return _damianZones = damianZones.map((element) => DamianZone.fromMap(element)).toList(); } _getUsers(){ return _users = users.map((element) => User.fromMap(element)).toList(); } final damianZones = []; final users = []; }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/utils/constants.dart
import 'package:flutter/material.dart'; enum SocialMedia {Facebook,Twitter,Instagram,Email,Whatsapp,Enlace} enum StarLevel {Beginner,Explorer,Adventurer,Discoverer,Navigator,Pioneer,Trekker,Master_Explorer} class Constants{ static String playStoreId = 'com.devdaumienebi.yonunca';//for now static List<Color> loadingIndicatorColors = [ Colors.blueGrey.shade200, Colors.cyan, Colors.redAccent.shade700, Colors.orangeAccent, Colors.blueGrey.shade700 ]; }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/utils/navigator_util.dart
import 'package:flutter/material.dart'; /// Util page to navigate through out the app with different types of /// animations class NavigatorUtil{ /// Simple PageRouteBuilder to navigate to another page with a FadeTransition /// /// [arguments] : The arguments to be passed to the new page /// /// [routeName] : The name of the new page in "String" format, for example /// [AppRoutes.routeStrings.wishListPage] i.e 'wishListPage' or any other way /// the route String is implemented. The newPage and arguments values are /// enough to navigate to the new page. /// /// [newPage] : The new page to be passed,a Widget.For example [WishListPage] static Route createRouteWithSlideAnimation({Object? arguments,String? routeName, required Widget newPage}) { return PageRouteBuilder( settings: RouteSettings( name: routeName, arguments: arguments ), pageBuilder: (context, animation, secondaryAnimation) => newPage, transitionsBuilder: (context, animation, secondaryAnimation, child) { var begin = const Offset(1.0, 0.0); var end = Offset.zero; var tween = Tween(begin: begin, end: end); var curvedAnimation = CurvedAnimation( parent: animation, curve: Curves.easeOut, reverseCurve: Curves.easeOut.flipped, ); return SlideTransition( position: tween.animate(curvedAnimation), //opacity: animation, child: child, ); }, ); } /// Simple PageRouteBuilder to navigate to another page with a FadeTransition /// /// [arguments] : The arguments to be passed to the new page /// /// [routeName] : The name of the new page in "String" format, for example /// [AppRoutes.routeStrings.wishListPage] i.e 'wishListPage' or any other way /// the route String is implemented. The newPage and arguments values are /// enough to navigate to the new page. /// /// [newPage] : The new page to be passed,a Widget.For example [WishListPage] static Route createRouteWithFadeAnimation({Object? arguments,String? routeName, required Widget newPage}) { return PageRouteBuilder( settings: RouteSettings( name: routeName, arguments: arguments ), pageBuilder: (context, animation, secondaryAnimation) => newPage, transitionsBuilder: (context, animation, secondaryAnimation, child) { return FadeTransition( opacity: animation, child: child, ); }, ); } }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/services/google_sheet_service.dart
/// Maybe to store the locations and the user separately class GoogleSheetService{ }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/services/firestore_service.dart
class FirestoreService{ }
0
mirrored_repositories/damian_go/lib
mirrored_repositories/damian_go/lib/providers/user_provider.dart
class UserProvider{ }
0
mirrored_repositories/damian_go
mirrored_repositories/damian_go/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:damian_go/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/databasehelper.dart
import 'dart:async'; import 'dart:io'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; import 'package:sqflite/sqflite.dart'; class DatabaseHelper { static final DatabaseHelper _instance = new DatabaseHelper.internal(); factory DatabaseHelper() => _instance; final String tableUser = "favorite"; final String columnId = "id"; final String favId="favId"; final String cat="cat"; final String url="url"; static Database _db; Future<Database> get db async { if (_db != null) { return _db; } _db = await initDb(); return _db; } DatabaseHelper.internal(); initDb() async { Directory documentDirectory = await getApplicationDocumentsDirectory(); String path = join( documentDirectory.path, "favorite.db"); //home://directory/files/maindb.db var ourDb = await openDatabase(path, version: 2, onCreate: _onCreate); return ourDb; } /* id | username | password ------------------------ 1 | Paulo | paulo 2 | James | bond */ void _onCreate(Database db, int newVersion) async { await db.execute( "CREATE TABLE $tableUser($columnId INTEGER PRIMARY KEY, $favId TEXT, $cat TEXT, $url TEXT)");} //CRUD - CREATE, READ, UPDATE , DELETE //Insertion Future<int> saveUser(String user,String url,String cat) async { var dbClient = await db; var map={ "favId":user, "cat":cat, "url":url }; int res = await dbClient.insert("$tableUser", map); return res; } //Get Users Future<List> getAllUsers() async { var dbClient = await db; var result = await dbClient.rawQuery("SELECT * FROM $tableUser"); return result.toList(); } Future<int> getCount(String data) async { var dbClient = await db; return Sqflite.firstIntValue( await dbClient.rawQuery("SELECT COUNT(*) FROM $tableUser WHERE favId='$data'")); } // Future<User> getUser(int id) async { // var dbClient = await db; // // var result = await dbClient.rawQuery("SELECT * FROM $tableUser WHERE $columnId = $id"); // if (result.length == 0) return null; // return new User.fromMap(result.first); // } Future<int> deleteUser(String id) async { var dbClient = await db; return await dbClient.delete(tableUser, where: "$favId = ?", whereArgs: [id]); } // Future<int> updateUser(User user) async { // var dbClient = await db; // return await dbClient.update(tableUser, // user.toMap(), where: "$columnId = ?", whereArgs: [user.id]); // } Future close() async { var dbClient = await db; return dbClient.close(); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/Home.dart
import 'package:flutter/material.dart'; import 'package:gammingwallpaper/games.dart'; import 'package:gammingwallpaper/newwallpaper.dart'; import 'package:simple_permissions/simple_permissions.dart'; import 'package:flutter_share/flutter_share.dart'; import 'package:connectivity/connectivity.dart'; class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> with TickerProviderStateMixin{ TabController tabController; @override void initState() { tabController=new TabController(length: 2, vsync: this); // TODO: implement initState super.initState(); permision(); } permision() async{ if (!(await SimplePermissions .checkPermission(Permission.WriteExternalStorage)) && !(await SimplePermissions .checkPermission(Permission.ReadExternalStorage))) { await SimplePermissions .requestPermission(Permission.WriteExternalStorage); } if(!(await SimplePermissions .checkPermission(Permission.ReadExternalStorage))) { await SimplePermissions .requestPermission(Permission.ReadExternalStorage); } } @override Widget build(BuildContext context) { return Scaffold( appBar: new AppBar( primary: false, flexibleSpace: new SafeArea(child: new TabBar( controller: tabController, labelStyle: TextStyle(fontSize: 10.0), tabs: <Widget>[ new Tab(icon:new Icon(Icons.access_time),text: "NEW",), new Tab(icon:new Icon(Icons.videogame_asset),text: "GAMES",), ], ),), automaticallyImplyLeading: false, ), body: new TabBarView( controller: tabController, children: <Widget>[ new New(), new Games() ], ), ); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/newwallpaper.dart
import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:gammingwallpaper/fullscreen.dart'; import 'package:fluttertoast/fluttertoast.dart'; class New extends StatefulWidget { @override _NewState createState() => _NewState(); } class _NewState extends State<New> { @override void initState() { // TODO: implement initState super.initState(); init(); } init()async{ var connectivityResult = await (new Connectivity().checkConnectivity()); if (connectivityResult == ConnectivityResult.mobile) { debugPrint('mobile'); setState(() { }); } else if (connectivityResult == ConnectivityResult.wifi) { debugPrint('wifi'); setState(() { }); // I am connected to a wifi network. } else { Fluttertoast.showToast( msg: "Check Internet Connection", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIos: 1, bgcolor: "#000000", textcolor: '#ffffff' ); } } @override Widget build(BuildContext context) { return new Container( color: Colors.orange.shade50, child: StreamBuilder( stream: Firestore.instance.collection('image').orderBy("url",descending: true).snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return new Center(child: CircularProgressIndicator()); return new StaggeredGridView.countBuilder( padding: const EdgeInsets.all(0.0), crossAxisCount: 4, itemCount: snapshot.data.documents.length, itemBuilder: (context, i) { String imgPath = snapshot.data.documents[i]['url']; debugPrint(i.toString()+"/////////////"+imgPath); String imagename=snapshot.data.documents[i]['cat']; String id=snapshot.data.documents[i].documentID; return new Material( elevation: 5.0, borderRadius: new BorderRadius.all(new Radius.circular(5.0)), child: new InkWell( onTap: () { var result=Navigator.push( context, new MaterialPageRoute( builder: (context) => new FullScreenImagePage(imgPath,imagename,id))); }, child: new Column( children: <Widget>[ new Hero( tag: imgPath, child: new FadeInImage( image: new NetworkImage(imgPath), height: 282.0, width: MediaQuery.of(context).size.width/2, fit: BoxFit.cover, placeholder: new AssetImage("assets/images.png"), ), ), new Container( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Padding(padding: EdgeInsets.fromLTRB(0.0, 4.0, 0.0, 2.0) ,child: new Text(snapshot.data.documents[i]['cat'],textAlign: TextAlign.start,), ), ], ), ) ], ) ), ); }, staggeredTileBuilder: (i) => new StaggeredTile.count(2, i.isEven ? 3.5 : 3.5), mainAxisSpacing: 5.0, crossAxisSpacing: 5.0, ); }), ); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/fullscreen.dart
import 'dart:io'; import 'databasehelper.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:dio/dio.dart'; import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart' as path; import 'package:simple_permissions/simple_permissions.dart'; import 'package:advanced_share/advanced_share.dart'; import 'package:flutter_share/flutter_share.dart'; import 'package:documents_picker/documents_picker.dart'; class FullScreenImagePage extends StatefulWidget { String imgPath; String imagename; String id; FullScreenImagePage(this.imgPath,this.imagename,this.id); @override _FullScreenImagePageState createState() => _FullScreenImagePageState(); } class _FullScreenImagePageState extends State<FullScreenImagePage> { static const platform = const MethodChannel('samples.flutter.io/battery'); var progressString = ""; var db = new DatabaseHelper(); bool state=false; // Get battery level. String _setWallpaper = ''; bool downloading = false; GlobalKey<ScaffoldState> _scaffold=new GlobalKey<ScaffoldState>(); bool isLoading; @override void initState() { // TODO: implement initState super.initState(); init(); //initPlatformState(); } init() async { int count=await db.getCount(widget.id); debugPrint(count.toString()); if(count>0) { state=true; } else { state=false; } setState(() { }); } Future<void> initPlatformState() async { bool teste; // Platform messages may fail, so we use a try/catch PlatformException. try { List<dynamic> docs = await DocumentsPicker.pickDocuments; teste = await FlutterShare.share(title: 'teste', fileUrl: docs[0] as String); } on PlatformException { } if (!mounted) return; setState(() { }); } @override Widget build(BuildContext context) { return WillPopScope(onWillPop:_onWillPop ,child: new Scaffold( key: _scaffold, body: new SizedBox.expand( child: new Container( decoration: new BoxDecoration(color: Colors.orange.shade50), child: new Stack( children: <Widget>[ new Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, child: new Hero( tag: widget.imgPath, child: new Image.network(widget.imgPath, fit: BoxFit.fill,), ), ), new Align( alignment: Alignment.topCenter, child: new Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ new AppBar( elevation: 0.0, automaticallyImplyLeading: false, backgroundColor: Colors.transparent, title: new Text(widget.imagename), leading: new IconButton( icon: new Icon( Icons.arrow_back, color: Colors.white, ), onPressed: () => Navigator.of(context).pop({"result":true}), ), ) ], ), ), new Padding(padding: EdgeInsets.fromLTRB(00.0, 0.0, 00.0, 30.0), child: new Align( alignment: Alignment.bottomLeft, child: new Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new RaisedButton( splashColor: Colors.yellow, color: Colors.orange.shade900, padding: EdgeInsets.all(12.0), shape: CircleBorder( ), child: state==false?new Icon( Icons.favorite_border, color: Colors.white, ):new Icon( Icons.favorite, color: Colors.white, ), onPressed: () { if(state==false) { addfav(); debugPrint("clcick1"); } else { deletefav(); debugPrint("clcick2"); } }, ), new RaisedButton( splashColor: Colors.yellow, color: Colors.orange.shade900, padding: EdgeInsets.all(12.0), shape: CircleBorder(), child: new Icon( Icons.cloud_download, color: Colors.white, ), onPressed: () { downloadwallpaper(); }, ), new RaisedButton( splashColor: Colors.yellow, color: Colors.orange.shade900, padding: EdgeInsets.all(12.0), shape: CircleBorder(), child: new Icon( Icons.wallpaper, color: Colors.white, ), onPressed: () { debugPrint("clcick"); downloadwallpaper(data:1); }, ), new RaisedButton( splashColor: Colors.yellow, color: Colors.orange.shade900, padding: EdgeInsets.all(12.0), shape: CircleBorder(), child: new Icon( Icons.share, color: Colors.white, ), onPressed: () { debugPrint("clcick"); _shareImage(); }, ), ], ), ),) ], ), ), ), ),); } String text = "whatever"; void downloadwallpaper({int data}) async { if (!(await SimplePermissions .checkPermission(Permission.WriteExternalStorage)) && !(await SimplePermissions .checkPermission(Permission.ReadExternalStorage))) { await SimplePermissions .requestPermission(Permission.WriteExternalStorage); await SimplePermissions .requestPermission(Permission.ReadExternalStorage); } if(data!=null) { _scaffold.currentState.showSnackBar(new SnackBar( content: new Text("Waiting....."),)); } else { _scaffold.currentState.showSnackBar(new SnackBar( content: new Text("Waiting...."),)); } Dio dio=new Dio(); final externalDir = await getExternalStorageDirectory(); final myDir = new Directory("${externalDir}/wallpaper"); myDir.exists().then((isThere) { isThere ? print('exists') : new Directory(externalDir.path+'/'+'wallpaper').create(recursive: true) // The created directory is returned as a Future. .then((Directory directory) { print('Path of New Dir: '+directory.path); }); }); final filePath = path.join(externalDir.path,"wallpaper", widget.id + '.jpeg'); final file = new File(filePath); if(await file.exists()) { debugPrint("already awailible"); if(data!=null) { } else { _scaffold.currentState.showSnackBar(new SnackBar( content: new Text("Wallpaper already Downloaded...."),)); } } else { await dio.download(widget.imgPath, filePath,onProgress: (rec,totle){ print("REC:$rec,TOTLE:$totle"); }); _scaffold.currentState.showSnackBar(new SnackBar(content: new Text("download completed...."),)); } if(data!=null) { _scaffold.currentState.showSnackBar(new SnackBar(content: new Text("Wallpaper Updated..."),)); String setWallpaper; try { await platform.invokeMethod('setWallpaper', filePath); setWallpaper = 'Wallpaer Updated....'; } on PlatformException catch (e) { setWallpaper = "Failed to Set Wallpaer: '${e.message}'."; } _scaffold.currentState.showSnackBar(new SnackBar(content: new Text("Wallpaper Updated..."),)); } } _shareImage() async { if (!(await SimplePermissions .checkPermission(Permission.WriteExternalStorage))) { await SimplePermissions .requestPermission(Permission.WriteExternalStorage); } if(!(await SimplePermissions .checkPermission(Permission.ReadExternalStorage))) { await SimplePermissions .requestPermission(Permission.ReadExternalStorage); } generic(); } void generic() async{ final externalDir = await getExternalStorageDirectory(); final filePath = path.join(externalDir.path,"wallpaper", widget.id + '.jpeg'); //debugPrint(filePath.toString()); final file = new File(filePath); if(await file.exists()) { Uri BASE64IMAGE =Uri.file(filePath); debugPrint(BASE64IMAGE.toString()); bool teste; try { teste = await FlutterShare.share(title: 'wallpaper', fileUrl: filePath as String,message:"hello"); }catch(e) { debugPrint(e.toString()); } if (!mounted) return; setState(() { }); }else { _scaffold.currentState.showSnackBar(new SnackBar( content: new Text("Wallpaper Not Downloaded...."),)); } } Future addfav () async { int res=await db.saveUser(widget.id,widget.imgPath,widget.imagename); debugPrint(res.toString()); setState(() { state=true; }); } void deletefav() async{ int data=await db.deleteUser(widget.id); setState(() { state=false; }); } Future<bool> _onWillPop() { Navigator.of(context).pop({"result":true}); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/games.dart
import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:gammingwallpaper/categorywise.dart'; import 'package:gammingwallpaper/fullscreen.dart'; import 'package:connectivity/connectivity.dart'; import 'package:fluttertoast/fluttertoast.dart'; class Games extends StatefulWidget { @override _GamesState createState() => _GamesState(); } class _GamesState extends State<Games> { @override void initState() { // TODO: implement initState super.initState(); init(); } init()async{ var connectivityResult = await (new Connectivity().checkConnectivity()); if (connectivityResult == ConnectivityResult.mobile) { debugPrint('mobile'); setState(() { }); } else if (connectivityResult == ConnectivityResult.wifi) { debugPrint('wifi'); setState(() { }); // I am connected to a wifi network. } else { Fluttertoast.showToast( msg: "Check Internet Connection", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.CENTER, timeInSecForIos: 1, bgcolor: "#000000", textcolor: '#ffffff' ); } } @override Widget build(BuildContext context) { return new Container( color: Colors.orange.shade50, child: StreamBuilder( stream: Firestore.instance.collection('category').orderBy("url",descending: true).snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return new Center(child: CircularProgressIndicator(),); return new StaggeredGridView.countBuilder( padding: const EdgeInsets.all(0.0), crossAxisCount: 4, itemCount: snapshot.data.documents.length, itemBuilder: (context, i) { String imgPath = snapshot.data.documents[i]['url']; debugPrint(i.toString()+"/////////////"+imgPath); String imagename=snapshot.data.documents[i]['cat']; String id=snapshot.data.documents[i].documentID; return new Material( elevation: 5.0, borderRadius: new BorderRadius.all(new Radius.circular(5.0)), child: new InkWell( onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new CategoryWise(imagename))); }, child: new Column( children: <Widget>[ new Container( height: MediaQuery.of(context).size.height/3-20, width: MediaQuery.of(context).size.width, child: Hero( tag: imgPath, child: new FadeInImage( image: new NetworkImage(imgPath), fit: BoxFit.fill, width: MediaQuery.of(context).size.width/2, placeholder: new AssetImage("assets/images.png"), ), ), ), new Container( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Padding(padding: EdgeInsets.fromLTRB(0.0, 4.0, 0.0, 2.0) ,child: new Text(snapshot.data.documents[i]['cat'],textAlign: TextAlign.start,), ), ], ), ) ], ) ), ); }, staggeredTileBuilder: (i) => new StaggeredTile.count(4, i.isEven ? 2.5 : 2.5), mainAxisSpacing: 5.0, crossAxisSpacing: 5.0, ); }), ); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/model.dart
class model { String id,url,cat; model(this.id,this.url,this.cat); String getid() { return this.id; } String geturl() { return this.url; } String getcat() { return this.cat; } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/main.dart
import 'package:flutter/material.dart'; import 'package:gammingwallpaper/Favorit.dart'; import 'package:gammingwallpaper/Home.dart'; import 'package:launch_review/launch_review.dart'; import 'package:share/share.dart'; main () { Routes(); } class Routes { var routes = <String, WidgetBuilder>{ "/SignUp": (BuildContext context) => new wallpaper(), }; Routes() { runApp(new MaterialApp( debugShowCheckedModeBanner: false, title: "Wallpaper", onGenerateTitle: (BuildContext contex)=>"Wallpaper", home: new wallpaper(), theme: new ThemeData( accentColor: Colors.orange.shade900, primaryColor: Colors.orange.shade800, primaryColorDark: Colors.orange.shade800, indicatorColor: Colors.orange.shade800, backgroundColor: Colors.orange.shade900, inputDecorationTheme: InputDecorationTheme( ) ), routes: routes, )); } } class wallpaper extends StatefulWidget { @override _wallpaperState createState() => _wallpaperState(); } class _wallpaperState extends State<wallpaper> { int index=0; int i=0; setbody(int pos) { switch(pos) { case 0:return Home(); case 1:return Favorit(); } } @override Widget build(BuildContext context) { return Scaffold( drawer: new Drawer( child: new Container( decoration: BoxDecoration(color: Colors.orange.shade800), child: new Column( children: <Widget>[ new Container( decoration: BoxDecoration(color:Colors.orange.shade800), child:new UserAccountsDrawerHeader(accountName: Text("HD Gamming Wallpaper"), accountEmail: Text("Wallpaper for Gammmers") , decoration: BoxDecoration( color: Colors.orange.shade800) ,currentAccountPicture:CircleAvatar( backgroundImage:AssetImage("assets/images.png",) , backgroundColor: Colors.orange, ) ) , ) , new Container( height:MediaQuery.of(context).size.height-193, decoration: BoxDecoration(color: Colors.white), child: new Column( children: <Widget>[ new ListTile( leading: Icon(Icons.home), title: Text("Home"), selected: index==0?true:false, onTap: (){ Navigator.of(context).pop(); setState(() { index=0; }); }, ), new ListTile( leading: Icon(Icons.favorite_border), title: Text("Favorit"), selected: index==1?true:false, onTap: (){ Navigator.of(context).pop(); setState(() { index=1; }); }, ), Divider() , new ListTile( leading: Icon(Icons.star_border), title: Text("Rate the app"), onTap: (){ LaunchReview.launch(androidAppId:"com.wallpaper.gammingwallpaper"); }, ), new ListTile( leading: Icon(Icons.share), title: Text("Share with your friend"), onTap: (){ Share.share("Download This Amazing Gamming Wallpaper App"+"\nhttps://play.google.com/store/apps/details?id=com.wallpaper.gammingwallpaper"); }, ), ], ), ) ], ), ) ), appBar:new PreferredSize(child: new AppBar( title:Text("HD GAMMING WALLPAPER",style: TextStyle(fontSize: 18.0),) , elevation: index==0? 0.0:4.0, ), preferredSize: Size.fromHeight(60.0)), body: setbody(index), ); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/categorywise.dart
import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:connectivity/connectivity.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:gammingwallpaper/fullscreen.dart'; class CategoryWise extends StatefulWidget { String imagename; CategoryWise(this.imagename); @override _CategoryWiseState createState() => _CategoryWiseState(); } class _CategoryWiseState extends State<CategoryWise> { @override void initState() { // TODO: implement initState super.initState(); init(); } init()async{ var connectivityResult = await (new Connectivity().checkConnectivity()); if (connectivityResult == ConnectivityResult.mobile) { debugPrint('mobile'); setState(() { }); } else if (connectivityResult == ConnectivityResult.wifi) { debugPrint('wifi'); setState(() { }); // I am connected to a wifi network. } else { Fluttertoast.showToast( msg: "Check Internet Connection", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.CENTER, timeInSecForIos: 1, bgcolor: "#000000", textcolor: '#ffffff' ); } } @override Widget build(BuildContext context) { return new Scaffold( appBar:AppBar( title: new Text(widget.imagename), ), body: new Container( color: Colors.orange.shade50, child: StreamBuilder( stream: Firestore.instance.collection('image').where("cat",isEqualTo: widget.imagename).orderBy("url",descending: true).snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return new Center(child: CircularProgressIndicator()); return new StaggeredGridView.countBuilder( padding: const EdgeInsets.all(0.0), crossAxisCount: 4, itemCount: snapshot.data.documents.length, itemBuilder: (context, i) { String imgPath = snapshot.data.documents[i]['url']; debugPrint(i.toString()+"/////////////"+imgPath); String imagename=snapshot.data.documents[i]['cat']; String id=snapshot.data.documents[i].documentID; return new Material( elevation: 5.0, borderRadius: new BorderRadius.all(new Radius.circular(5.0)), child: new InkWell( onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new FullScreenImagePage(imgPath,imagename,id))); }, child: new Column( children: <Widget>[ new Hero( tag: imgPath, child: new FadeInImage( image: new NetworkImage(imgPath), height: 282.0, width: MediaQuery.of(context).size.width/2, fit: BoxFit.cover, placeholder: new AssetImage("assets/images.png"), ), ), new Container( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Padding(padding: EdgeInsets.fromLTRB(0.0, 4.0, 0.0, 2.0) ,child: new Text(snapshot.data.documents[i]['cat'],textAlign: TextAlign.start,), ), ], ), ) ], ) ), ); }, staggeredTileBuilder: (i) => new StaggeredTile.count(2, i.isEven ? 3.5 : 3.5), mainAxisSpacing: 5.0, crossAxisSpacing: 5.0, ); }), ), ); } }
0
mirrored_repositories/wallpaper
mirrored_repositories/wallpaper/lib/Favorit.dart
import 'package:flutter/material.dart'; import 'package:gammingwallpaper/databasehelper.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:gammingwallpaper/fullscreen.dart'; import 'package:gammingwallpaper/model.dart'; class Favorit extends StatefulWidget { @override _FavroitState createState() => _FavroitState(); } class _FavroitState extends State<Favorit> { List data=[]; bool flag=false; @override void initState() { // TODO: implement initState getdata(); } getdata() async { //debugPrint(id); var db=new DatabaseHelper(); data = await db.getAllUsers(); for (int i = 0; i < data.length; i++) { debugPrint(i.toString()); } if(data.length==0) { flag=true; } setState(() { }); // setState(() { // _subType=dataaa; // }); } @override Widget build(BuildContext context) { return new Container( color: Colors.orange.shade50, child: data.length!=0?new StaggeredGridView.countBuilder( padding: const EdgeInsets.all(0.0), crossAxisCount: 4, itemCount: data.length, itemBuilder: (context, i) { // getdata(dataa[i]['favId']); String imgPath = data[i]['url']; debugPrint(i.toString()+"/////////////"+imgPath); String imagename=data[i]['cat']; String id=data[i]['favId']; return new Material( elevation: 5.0, borderRadius: new BorderRadius.all(new Radius.circular(5.0)), child: new InkWell( onTap: () async{ Map result=await Navigator.push( context, new MaterialPageRoute( builder: (context) => new FullScreenImagePage(imgPath,imagename,id))); if(result!=null) { getdata(); } debugPrint(result.toString()); }, child: new Column( children: <Widget>[ new Hero( tag: imgPath, child: new FadeInImage( image: new NetworkImage(imgPath), height: 282.0, width: MediaQuery.of(context).size.width/2, fit: BoxFit.cover, placeholder: new AssetImage("assets/images.png"), ), ), new Container( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Padding(padding: EdgeInsets.fromLTRB(0.0, 4.0, 0.0, 2.0) ,child: new Text(data[i]['cat'],textAlign: TextAlign.start,), ), ], ), ) ], ) ), ); }, staggeredTileBuilder: (i) => new StaggeredTile.count(2, i.isEven ? 3.5 : 3.5), mainAxisSpacing: 5.0, crossAxisSpacing: 5.0, ):new Center(child:flag==false?new CircularProgressIndicator():new Text("No Data Found") ) ); } }
0
mirrored_repositories/Signup_Login_UI_in_Flutter
mirrored_repositories/Signup_Login_UI_in_Flutter/lib/main.dart
import 'package:flutter/material.dart'; //import 'package:url_launcher/url_launcher.dart'; void main() { runApp(MaterialApp( debugShowCheckedModeBanner:false, initialRoute: '/', routes: { '/': (context) => HomeRoute(), '/second': (context) => SecondRoute(), '/third': (context) => ThirdRoute(), }, )); } class HomeRoute extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('SignUp/LogIn Screen'), centerTitle:true, backgroundColor: Colors.grey[900], elevation: 0, ), body: Center( child: Column( children: <Widget>[ new Padding(padding: EdgeInsets.only(top: 40.0)), Center( child: CircleAvatar( backgroundImage: AssetImage('assets/Profile5.JPG'), radius:40.0, ), ), Divider( height: 80.0, color:Colors.amberAccent, ), new Text("Made By:"), Text("Habibullah", style: new TextStyle(color: Colors.blue, decoration: TextDecoration.underline),), new Padding(padding: EdgeInsets.only(top: 120.0)), ElevatedButton( child: Text('Sign Up'), onPressed: () { Navigator.pushNamed(context, '/second'); }, style: ElevatedButton.styleFrom( primary: Colors.orangeAccent[100], padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), textStyle: TextStyle( fontSize: 30, fontWeight: FontWeight.bold)), ), new Padding(padding: EdgeInsets.only(top: 27.0)), new Text("OR"), new Padding(padding: EdgeInsets.only(top: 25.0)), ElevatedButton( child: Text('Log In'), onPressed: () { Navigator.pushNamed(context, '/third'); }, style: ElevatedButton.styleFrom( primary: Colors.orangeAccent[100], padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20), textStyle: TextStyle( fontSize: 30, fontWeight: FontWeight.bold)), ), ], )), ); } } class SecondRoute extends StatelessWidget { @override Widget build(BuildContext context) { Color hexToColor(String code) { return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000); } return MaterialApp( debugShowCheckedModeBanner: false, title: "Welcome to Flutter", home: new Material( child: new Container ( padding: const EdgeInsets.all(30.0), color: Colors.white, child: new Container( child: new Center( child: new Column( children: [ new Padding(padding: EdgeInsets.only(top: 140.0)), new Text('Sign Up', style: new TextStyle(color: hexToColor("#F2A03D"), fontSize: 25.0),), new Padding(padding: EdgeInsets.only(top: 50.0)), new TextFormField( decoration: new InputDecoration( labelText: "Enter Email", prefixIcon: Icon(Icons.email), fillColor: Colors.white, border: new OutlineInputBorder( borderRadius: new BorderRadius.circular(25.0), borderSide: new BorderSide( ), ), //fillColor: Colors.green ), validator: (val) { if (val!.length == 0) { return "Email cannot be empty"; } else { return null; } }, keyboardType: TextInputType.emailAddress, style: new TextStyle( fontFamily: "Poppins", ), ), new Padding(padding: EdgeInsets.only(top: 35.0)), new TextFormField( obscureText: true, decoration: new InputDecoration( labelText: "Enter Password", prefixIcon: Icon(Icons.security), fillColor: Colors.white, border: new OutlineInputBorder( borderRadius: new BorderRadius.circular(25.0), borderSide: new BorderSide( ), ), //fillColor: Colors.green ), validator: (val) { if (val!.length == 0) { return "Password cannot be empty"; } else { return null; } }, //keyboardType: TextInputType.visiblePassword, style: new TextStyle( fontFamily: "Poppins", ), ), new Padding(padding: EdgeInsets.only(top: 35.0)), new TextFormField( obscureText: true, decoration: new InputDecoration( labelText: "Confirm Password", prefixIcon: Icon(Icons.security), fillColor: Colors.white, border: new OutlineInputBorder( borderRadius: new BorderRadius.circular(25.0), borderSide: new BorderSide( ), ), //fillColor: Colors.green ), validator: (val) { if (val!.length == 0) { return "Password cannot be empty"; } else { return null; } }, //keyboardType: TextInputType.visiblePassword, style: new TextStyle( fontFamily: "Poppins", ), ), new Padding(padding: EdgeInsets.only(top: 35.0)), ElevatedButton( onPressed: () {}, child: Text('Sign Up'), //style: new TextStyle(color: hexToColor("#F2A03D"), fontSize: 25.0),), style: ElevatedButton.styleFrom( primary: Colors.orangeAccent[100], shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 12), // <-- Radius ), textStyle: TextStyle( fontSize: 30, fontWeight: FontWeight.bold)), ), ] ) ), ) ) ) ); } } class ThirdRoute extends StatelessWidget { @override Widget build(BuildContext context) { Color hexToColor(String code) { return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000); } return MaterialApp( debugShowCheckedModeBanner: false, title: "Welcome to Flutter", home: new Material( child: new Container ( padding: const EdgeInsets.all(30.0), color: Colors.white, child: new Container( child: new Center( child: new Column( children: [ new Padding(padding: EdgeInsets.only(top: 140.0)), new Text('Log In', style: new TextStyle(color: hexToColor("#F2A03D"), fontSize: 25.0),), new Padding(padding: EdgeInsets.only(top: 50.0)), new TextFormField( decoration: new InputDecoration( labelText: "Enter Email", prefixIcon: Icon(Icons.email), fillColor: Colors.white, border: new OutlineInputBorder( borderRadius: new BorderRadius.circular(25.0), borderSide: new BorderSide( ), ), //fillColor: Colors.green ), validator: (val) { if (val!.length == 0) { return "Email cannot be empty"; } else { return null; } }, keyboardType: TextInputType.emailAddress, style: new TextStyle( fontFamily: "Poppins", ), ), new Padding(padding: EdgeInsets.only(top: 35.0)), new TextFormField( obscureText: true, decoration: new InputDecoration( labelText: "Enter Password", prefixIcon: Icon(Icons.security), fillColor: Colors.white, border: new OutlineInputBorder( borderRadius: new BorderRadius.circular(25.0), borderSide: new BorderSide( ), ), //fillColor: Colors.green ), validator: (val) { if (val!.length == 0) { return "Password cannot be empty"; } else { return null; } }, //keyboardType: TextInputType.visiblePassword, style: new TextStyle( fontFamily: "Poppins", ), ), new Padding(padding: EdgeInsets.only(top: 35.0)), ElevatedButton( onPressed: () {}, child: Text('Log In'), //style: new TextStyle(color: hexToColor("#F2A03D"), fontSize: 25.0),), style: ElevatedButton.styleFrom( primary: Colors.orangeAccent[100], shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 12), // <-- Radius ), textStyle: TextStyle( fontSize: 30, fontWeight: FontWeight.bold)), ), ] ) ), ) ) ) ); } }
0
mirrored_repositories/Signup_Login_UI_in_Flutter
mirrored_repositories/Signup_Login_UI_in_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:textfield3/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/bytebank_2_alura
mirrored_repositories/bytebank_2_alura/lib/main.dart
import 'package:bytebank_2/dao/contact_dao.dart'; import 'package:bytebank_2/http/webclients/transaction_webclient.dart'; import 'package:bytebank_2/route/routes.dart'; import 'package:bytebank_2/theme/theme.dart'; import 'package:bytebank_2/widgets/app_dependencies.dart'; import 'package:flutter/material.dart'; void main() { runApp(BytebankApp( contactDao: ContactDao(), transactionWebClient: TransactionWebClient(), )); } class BytebankApp extends StatelessWidget { final ContactDao contactDao; final TransactionWebClient transactionWebClient; BytebankApp({ @required this.contactDao, @required this.transactionWebClient, }); // This widget is the root of your application. @override Widget build(BuildContext context) { return AppDependencies( transactionWebClient: transactionWebClient, contactDao: contactDao, child: MaterialApp( initialRoute: '/', routes: routeList(), theme: appTheme(), darkTheme: darkTheme()), ); //MaterialApp } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/dao/contact_dao.dart
import 'package:bytebank_2/database/app_database.dart'; import 'package:bytebank_2/models/contact.dart'; import 'package:sqflite/sqflite.dart'; class ContactDao { static const String _tablSql = 'CREATE TABLE $_tableName(' '$_id INTEGER PRIMARY KEY, ' '$_name TEXT, ' '$_accountNumber INTEGER)'; static const String _tableName = 'contacts'; static const String _id = 'id'; static const String _name = 'name'; static const String _accountNumber = 'account_number'; Future<int> save(Contact contact) async { final Database db = await getDatabase(_tablSql); Map<String, dynamic> contactMap = _toMap(contact); return db.insert(_tableName, contactMap); } Future<List<Contact>> findAll() async { final Database db = await getDatabase(_tablSql); final List<Map<String, dynamic>> result = await db.query(_tableName); final List<Contact> contacts = List(); _toList(result, contacts); return contacts; } Future<int> update(Contact contact) async { final Database db = await getDatabase(_tablSql); final Map<String, dynamic> contactMap = _toMap(contact); return db.update( _tableName, contactMap, where: 'id = ?', whereArgs: [contact.id], ); } Future<int> delete(int id) async { final Database db = await getDatabase(_tablSql); return db.delete( _tableName, where: 'id = ?', whereArgs: [id], ); } void _toList(List<Map<String, dynamic>> result, List<Contact> contacts) { for (Map<String, dynamic> row in result) { final Contact contact = Contact( row[_name], row[_accountNumber], id: row[_id], ); contacts.add(contact); } } Map<String, dynamic> _toMap(Contact contact) { final Map<String, dynamic> contactMap = Map(); contactMap[_name] = contact.name; contactMap[_accountNumber] = contact.accountNumber; return contactMap; } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/widgets/app_dependencies.dart
import 'package:bytebank_2/dao/contact_dao.dart'; import 'package:bytebank_2/http/webclients/transaction_webclient.dart'; import 'package:flutter/cupertino.dart'; class AppDependencies extends InheritedWidget { final ContactDao contactDao; final TransactionWebClient transactionWebClient; AppDependencies({ @required this.contactDao, @required this.transactionWebClient, @required Widget child, }) : super(child: child); static AppDependencies of(BuildContext context) => context.dependOnInheritedWidgetOfExactType<AppDependencies>(); @override bool updateShouldNotify(AppDependencies oldWidget) { return contactDao != oldWidget.contactDao || transactionWebClient != oldWidget.transactionWebClient; } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/database/app_database.dart
import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; Future<Database> getDatabase(String table) async { final String path = join(await getDatabasesPath(), 'bytebank.db'); return openDatabase( path, onCreate: (db, version) { db.execute(table); }, version: 1, // onDowngrade: onDatabaseDowngradeDelete, ); }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/components/response_dialog.dart
import 'package:flutter/material.dart'; class ResponseDialog extends StatelessWidget { final String title; final String message; final String buttonText; final IconData icon; final Color colorIcon; ResponseDialog({ this.title = "", this.message = "", this.icon, this.buttonText = 'Ok', this.colorIcon = Colors.black, }); @override Widget build(BuildContext context) { return AlertDialog( title: Visibility( child: Text(title), visible: title.isNotEmpty, ), content: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Visibility( child: Padding( padding: const EdgeInsets.only(top: 16.0), child: Icon( icon, size: 64, color: colorIcon, ), ), visible: icon != null, ), Visibility( child: Padding( padding: const EdgeInsets.only(top: 16.0), child: Text( message, textAlign: TextAlign.center, style: TextStyle( fontSize: 24.0, ), ), ), visible: message.isNotEmpty, ) ], ), actions: <Widget>[ FlatButton( child: Text(buttonText), onPressed: () => Navigator.pop(context), ) ], ); } } class SuccessDialog extends StatelessWidget { final String title; final String message; final IconData icon; SuccessDialog( this.message, { this.title = 'Success', this.icon = Icons.done, }); @override Widget build(BuildContext context) { return ResponseDialog( title: title, message: message, icon: icon, colorIcon: Colors.green, ); } } class FailureDialog extends StatelessWidget { final String title; final String message; final IconData icon; FailureDialog( this.message, { this.title = 'Failure', this.icon = Icons.warning, }); @override Widget build(BuildContext context) { return ResponseDialog( title: title, message: message, icon: icon, colorIcon: Colors.red, ); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/components/progress.dart
import 'package:flutter/material.dart'; class Progress extends StatelessWidget { final String message; Progress({this.message = 'Loading'}); @override Widget build(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ CircularProgressIndicator(), Padding( padding: const EdgeInsets.only(top: 8.0), child: Text( message, style: TextStyle( fontSize: 16, ), ), ), ], ), ); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/components/editor.dart
import 'package:flutter/material.dart'; class Editor extends StatelessWidget { final TextEditingController _controller; final String label; final String hint; final IconData icon; final TextInputType inputType; const Editor(this._controller, {this.label, this.hint, this.icon, this.inputType}); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(16.0), child: TextField( controller: _controller, style: TextStyle( fontSize: 20.0, ), decoration: InputDecoration( labelText: label, hintText: hint, icon: icon != null ? Icon(icon) : null, ), keyboardType: inputType != null ? inputType : null, ), ); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/components/transaction_auth_dialog.dart
import 'package:flutter/material.dart'; const Key transactionAuthField = Key('transactionAuthField'); class TransactionAuthDialog extends StatefulWidget { final Function(String password) onConfirm; TransactionAuthDialog({ @required this.onConfirm, }); @override _TransactionAuthDialogState createState() => _TransactionAuthDialogState(); } class _TransactionAuthDialogState extends State<TransactionAuthDialog> { final TextEditingController _passwordController = TextEditingController(); @override Widget build(BuildContext context) { return AlertDialog( title: Text('Authenticate'), content: TextField( key: transactionAuthField, controller: _passwordController, obscureText: true, maxLength: 4, decoration: InputDecoration( border: OutlineInputBorder(), ), textAlign: TextAlign.center, style: TextStyle( fontSize: 56, letterSpacing: 24, ), keyboardType: TextInputType.number, ), actions: <Widget>[ FlatButton( child: Text('Cancel'), onPressed: () => Navigator.pop(context), ), FlatButton( child: Text('Confirm'), onPressed: () { widget.onConfirm(_passwordController.text); Navigator.pop(context); }, ), ], ); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/components/centered_message.dart
import 'package:flutter/material.dart'; class CenteredMessage extends StatelessWidget { final String message; final IconData icon; final double iconSize; final double fontSize; CenteredMessage( this.message, { this.icon, this.iconSize = 64, this.fontSize = 24, }); @override Widget build(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Visibility( child: Icon( icon, size: iconSize, ), visible: icon != null, ), Padding( padding: const EdgeInsets.only(top: 24.0), child: Text( message, style: TextStyle(fontSize: fontSize), ), ), ], ), ); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/components/delete_contact_dialog.dart
import 'package:bytebank_2/widgets/app_dependencies.dart'; import 'package:flutter/material.dart'; import 'package:bytebank_2/models/contact.dart'; class DeleteContactDialog extends StatefulWidget { final Contact contact; const DeleteContactDialog({ Key key, @required this.contact, }) : super(key: key); @override _DeleteContactDialogState createState() => _DeleteContactDialogState(); } class _DeleteContactDialogState extends State<DeleteContactDialog> { @override Widget build(BuildContext context) { final dependencies = AppDependencies.of(context); return AlertDialog( title: Text('AlertDialog Title'), content: SingleChildScrollView( child: ListBody( children: <Widget>[ Text('Would you like to delete this Account?'), SizedBox( height: 25, ), Text( widget.contact.accountNumber.toString(), style: TextStyle( color: Colors.green[900], fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), Text( widget.contact.name, style: TextStyle( color: Colors.green[900], fontWeight: FontWeight.bold, fontSize: 24.0, ), textAlign: TextAlign.center, ), ], ), ), actions: <Widget>[ FlatButton( child: Text( 'CANCEL', style: TextStyle( color: Colors.green[900], ), ), onPressed: () { Navigator.of(context).pop(); }, ), RaisedButton( child: Text('DELETE'), onPressed: () { dependencies.contactDao.delete(widget.contact.id).then((value) { Navigator.of(context).pop(); }); }, ), ], ); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/models/transaction.dart
import 'contact.dart'; class Transaction { final String id; final double value; final Contact contact; Transaction( this.id, this.value, this.contact, ) : assert(value > 0); Transaction.fromJson(Map<String, dynamic> json) : id = json['id'], value = json['value'], contact = Contact.fromJson(json['contact']); Map<String, dynamic> toJson() => { 'id': id, 'value': value, 'contact': contact.toJson(), }; @override String toString() { return 'Transaction{value: $value, contact: $contact}'; } @override bool operator ==(Object other) => identical(this, other) || other is Transaction && runtimeType == other.runtimeType && other.value == value && other.contact == contact; @override int get hashCode => value.hashCode ^ contact.hashCode; }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/models/contact.dart
class Contact { final int id; final String name; final int accountNumber; Contact(this.name, this.accountNumber, {this.id}); @override String toString() { return 'Contact{name: $name, accountNumber: $accountNumber, id: $id}'; } Contact.fromJson(Map<String, dynamic> json) : name = json['name'], accountNumber = json['accountNumber'], id = json['id']; Map<String, dynamic> toJson() => { 'name': name, 'accountNumber': accountNumber, }; @override bool operator ==(Object other) => identical(this, other) || other is Contact && runtimeType == other.runtimeType && other.name == name && other.accountNumber == accountNumber; @override int get hashCode => name.hashCode ^ accountNumber.hashCode; }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/http/webclient.dart
import 'package:http/http.dart'; import 'package:http_interceptor/http_interceptor.dart'; import 'interceptors/logging_interceptor.dart'; final Client client = HttpClientWithInterceptor.build( interceptors: [LoggingInterceptor()], requestTimeout: Duration(seconds: 5), );
0
mirrored_repositories/bytebank_2_alura/lib/http
mirrored_repositories/bytebank_2_alura/lib/http/interceptors/logging_interceptor.dart
import 'package:http_interceptor/http_interceptor.dart'; class LoggingInterceptor implements InterceptorContract { @override Future<RequestData> interceptRequest({RequestData data}) async { // print('url ${data.baseUrl}'); // print('headers ${data.headers}'); // print('body ${data.body}'); return data; } @override Future<ResponseData> interceptResponse({ResponseData data}) async { // print('headers ${data.headers}'); // print('status code ${data.statusCode}'); // print('body ${data.body}'); // print(data); return data; } }
0
mirrored_repositories/bytebank_2_alura/lib/http
mirrored_repositories/bytebank_2_alura/lib/http/webclients/transaction_webclient.dart
import 'dart:convert'; import 'package:bytebank_2/models/transaction.dart'; import 'package:http/http.dart'; import 'package:bytebank_2/http/webclient.dart'; class TransactionWebClient { static const String baseUrl = 'http://192.168.15.15:8080/transactions'; Future<List<Transaction>> findAll() async { final Response response = await client.get(baseUrl); final List<dynamic> decodedJson = jsonDecode(response.body); return decodedJson .map((dynamic transactionJson) => Transaction.fromJson(transactionJson)) .toList(); } Future<Transaction> save(Transaction transaction, String password) async { final String transactionJson = jsonEncode(transaction.toJson()); final Response response = await client .post( baseUrl, headers: { 'Content-type': 'application/json', 'password': password, }, body: transactionJson, ) .timeout(Duration(seconds: 5)); if ([200, 201, 202, 203, 204].contains(response.statusCode)) { return Transaction.fromJson(jsonDecode(response.body)); } else { final String exceptionMessage = _statusCodeResponses[response.statusCode]; print(exceptionMessage); print(response.statusCode); if (exceptionMessage != null) { throw HttpExceptionDif(_statusCodeResponses[response.statusCode]); } else { throw Exception('Unkown error'); } } } static final Map<int, String> _statusCodeResponses = { 404: 'Page not found', 400: 'There was an error submitting transaction', 401: 'Authentication failed', 409: 'Duplicate entry for this transaction', }; } class HttpExceptionDif implements Exception { final String message; HttpExceptionDif(this.message); }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/extensions/string_extension.dart
extension StringExtension on String { String capitalize() { return (this.length > 0 ? "${this[0].toUpperCase()}${this.substring(1)}" : ""); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/theme/theme.dart
import 'package:flutter/material.dart'; ThemeData appTheme() { return ThemeData( backgroundColor: Color(0xff7a297a), primaryColor: Color(0xff993399), accentColor: Color(0xff993399), buttonTheme: ButtonThemeData( buttonColor: Color(0xff993399), highlightColor: Color(0xff993399), splashColor: Color(0xff993399), textTheme: ButtonTextTheme.primary, ), ); } ThemeData darkTheme() { return ThemeData( brightness: Brightness.dark, primaryColor: Color(0xff993399), ); }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/route/routes.dart
import 'package:bytebank_2/screens/contact_form.dart'; import 'package:bytebank_2/screens/contacts_list.dart'; import 'package:bytebank_2/screens/dashboard.dart'; import 'package:bytebank_2/screens/transaction_form.dart'; import 'package:bytebank_2/screens/transactions_list.dart'; routeList() { return { // When navigating to the "/" route, build the FirstScreen widget. '/': (context) => Dashboard(), // When navigating to the "/second" route, build the SecondScreen widget. '/contacts_list': (context) => ContactsList(), '/contact_form': (context) => ContactForm(), '/transactions_list': (context) => TransactionsList(), '/transaction_form': (context) => TransactionForm() }; }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/route/new_routes.dart
import 'package:bytebank_2/route/route_handlers.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; class Routes { static String root = "/"; static String contactsList = '/contacts_list'; static String contactForm = '/contact_form'; static String transactionsLits = '/transactions_list'; static String transactionForm = '/transaction_form'; static void configureRoutes(Router router) { router.notFoundHandler = Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { print("ROUTE WAS NOT FOUND !!!"); }); router.define(root, handler: rootHandler); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/route/route_handlers.dart
import 'package:bytebank_2/screens/dashboard.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; var rootHandler = Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return Dashboard(); });
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/screens/contact_form.dart
import 'package:bytebank_2/components/editor.dart'; import 'package:bytebank_2/dao/contact_dao.dart'; import 'package:bytebank_2/models/contact.dart'; import 'package:bytebank_2/widgets/app_dependencies.dart'; import 'package:flutter/material.dart'; class ContactForm extends StatefulWidget { @override _ContactFormState createState() => _ContactFormState(); } class _ContactFormState extends State<ContactForm> { final String _contactFormTitle = 'New contact'; final TextEditingController _controllerFullName = TextEditingController(); final String _labelFieldFullName = 'Full name'; final String _hintFieldFullName = 'Your name here'; final TextEditingController _controllerAccountNumber = TextEditingController(); final String _labelFieldAccountNumber = 'Account Number'; final String _hintFieldAccountNumber = 'Your account here'; final TextInputType _inputTypeFieldAccountNumber = TextInputType.number; @override Widget build(BuildContext context) { final dependencies = AppDependencies.of(context); return Scaffold( appBar: AppBar( title: Text(_contactFormTitle), ), body: Padding( padding: const EdgeInsets.all(4.0), child: Column( children: [ Editor( _controllerFullName, label: _labelFieldFullName, hint: _hintFieldFullName, ), Editor( _controllerAccountNumber, label: _labelFieldAccountNumber, hint: _hintFieldAccountNumber, inputType: _inputTypeFieldAccountNumber, ), Padding( padding: const EdgeInsets.all(8.0), child: SizedBox( width: double.maxFinite, height: 50.00, child: RaisedButton( child: Text( 'Create', style: TextStyle(fontSize: 16.00), ), onPressed: () { final String name = _controllerFullName.text; final int accountNumber = int.tryParse(_controllerAccountNumber.text); final Contact newContact = Contact(name, accountNumber, id: 1); _save(dependencies.contactDao, newContact, context); }, ), ), ) ], ), ), ); } void _save( ContactDao contactDao, Contact newContact, BuildContext context) async { await contactDao.save(newContact); Navigator.pop(context, newContact); } }
0
mirrored_repositories/bytebank_2_alura/lib
mirrored_repositories/bytebank_2_alura/lib/screens/contacts_list.dart
import 'package:bytebank_2/components/delete_contact_dialog.dart'; import 'package:bytebank_2/components/progress.dart'; import 'package:bytebank_2/models/contact.dart'; import 'package:bytebank_2/screens/transaction_form.dart'; import 'package:bytebank_2/widgets/app_dependencies.dart'; import 'package:flutter/material.dart'; class ContactsList extends StatefulWidget { @override _ContactsListState createState() => _ContactsListState(); } class _ContactsListState extends State<ContactsList> { @override Widget build(BuildContext context) { final dependencies = AppDependencies.of(context); return Scaffold( appBar: AppBar( title: Text('Transfer'), ), body: FutureBuilder<List<Contact>>( initialData: List(), future: dependencies.contactDao.findAll(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.none: break; case ConnectionState.waiting: return Progress(); break; case ConnectionState.active: break; case ConnectionState.done: final List<Contact> contacts = snapshot.data; return ListView.builder( itemBuilder: (context, index) { final Contact contact = contacts[index]; return ContactItem( contact, showDeleteDialog: () { showDialog( context: context, builder: (BuildContext context) { return DeleteContactDialog(contact: contact); }).then((value) => setState(() => {})); }, onClick: () { Navigator.pushNamed( context, '/transaction_form', arguments: TransactionFormArguments(contact), ).then((newTransaction) { setState(() { if (newTransaction != null) { final snackbar = SnackBar( content: Text(newTransaction.toString())); Scaffold.of(context).showSnackBar(snackbar); } print(newTransaction); }); }); }, ); }, itemCount: contacts.length, ); break; } return Center( child: Text('Unknown error'), ); }, ), floatingActionButton: Builder( builder: (context) => FloatingActionButton( child: Icon(Icons.add), onPressed: () { Navigator.pushNamed(context, '/contact_form').then((newContact) { setState(() { final snackbar = SnackBar(content: Text(newContact.toString())); Scaffold.of(context).showSnackBar(snackbar); }); }); }, ), ), ); } } class ContactItem extends StatelessWidget { final Contact contact; final Function onClick; final Function showDeleteDialog; ContactItem( this.contact, { @required this.onClick, @required this.showDeleteDialog, }); @override Widget build(BuildContext context) { var listTile = ListTile( onLongPress: () => showDeleteDialog(), onTap: () => onClick(), title: Text( contact.name, style: TextStyle( fontSize: 24.00, ), ), subtitle: Text( contact.accountNumber.toString(), style: TextStyle(fontSize: 16.00), ), ); return Card( child: Draggable( child: listTile, feedback: Material( child: ConstrainedBox( constraints: BoxConstraints( maxWidth: MediaQuery.of(context).size.width - 10.00), child: listTile, ), elevation: 4.0, ), childWhenDragging: Container(), ), ); } }
0