repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/widgets/coming_soon_widget.dart
// ignore_for_file: sized_box_for_whitespace import 'package:flutter/material.dart'; import 'package:netflix/core/extension/context_extension.dart'; class ComingSoonWidget extends StatelessWidget { final List? comingSoon; final int index; const ComingSoonWidget( {super.key, required this.comingSoon, required this.index}); @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; const String imageUrl = 'https://image.tmdb.org/t/p/w500'; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox( height: 15, ), Padding( padding: const EdgeInsets.only(left: 10), child: Image.network( (imageUrl + comingSoon?[index]["poster_path"]), width: context.width, height: context.height * 0.3, fit: BoxFit.contain, alignment: Alignment.centerLeft, ), ), Padding( padding: const EdgeInsets.only(left: 10, top: 15), child: Text( comingSoon?[index]['release_date'] ?? "", style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w700), ), ), Padding( padding: const EdgeInsets.only(left: 10, top: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( comingSoon?[index]['original_title'] ?? "", style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w700, fontSize: 24, ), ), ), Padding( padding: const EdgeInsets.only(left: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Column( children: const [ Icon( Icons.notification_add_outlined, color: Colors.white, ), SizedBox( height: 8, ), Text( "Remind me", style: TextStyle( color: Colors.white, fontSize: 13, fontWeight: FontWeight.w600, ), ) ], ), const SizedBox( width: 20, ), Column( children: const [ Icon( Icons.info_outline, color: Colors.white, ), SizedBox( height: 8, ), Text( "Info", style: TextStyle( color: Colors.white, fontSize: 13, fontWeight: FontWeight.w600, ), ) ], ), const SizedBox( width: 12, ) ], ), ), ], ), ), Padding( padding: const EdgeInsets.only(left: 10, top: 5, right: 5, bottom: 5), child: Text( comingSoon?[index]['overview'] ?? "", style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w700), ), ), Padding( padding: const EdgeInsets.only(left: 10, top: 5, right: 5), child: Text( comingSoon?[index]['vote_average'].toString() ?? "", style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w700), ), ), const SizedBox( height: 15, ), const SizedBox( height: 20, ) ], ); } }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/widgets/homepage_appbar.dart
import 'package:flutter/material.dart'; import 'package:netflix/core/extension/context_extension.dart'; import '../uitlity/profile.dart'; class HomePageAppBar extends StatelessWidget { const HomePageAppBar({super.key}); @override Widget build(BuildContext context) { return Padding( padding: context.paddingLowHorizontal, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( onPressed: () {}, icon: Image.asset( "assets/images/logo.png", height: context.height * 0.05, ), ), Row( children: [ IconButton( onPressed: () {}, icon: const Icon( Icons.collections_bookmark_rounded, color: Colors.white, ), ), IconButton( onPressed: () {}, icon: const CircleAvatar( foregroundColor: Colors.transparent, backgroundColor: Colors.transparent, foregroundImage: AssetImage(profileUrl), )), ], ) ], ), ); } }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/widgets/durationcount.dart
import 'package:flutter/material.dart'; class DurationCount extends StatelessWidget { const DurationCount({super.key}); @override Widget build(BuildContext context) { return Row( children: [ Stack( alignment: Alignment.centerLeft, children: [ Container( height: 2.5, width: MediaQuery.of(context).size.width- 45, color: Colors.grey, ), Container( height: 2.5, width: MediaQuery.of(context).size.width * 0.30, color: Colors.red, ), ], ), ], ); } }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/widgets/searched_item.dart
// ignore_for_file: sized_box_for_whitespace import 'package:flutter/material.dart'; import 'package:netflix/core/extension/context_extension.dart'; class SearchedItems extends StatelessWidget { final List? searched; final int index; const SearchedItems({super.key, required this.searched, required this.index}); @override Widget build(BuildContext context) { const String imageUrl = 'https://image.tmdb.org/t/p/w500'; var size = MediaQuery.of(context).size; return Padding( padding: const EdgeInsets.only(left: 20, bottom: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), ), child: Image.network( (imageUrl + searched?[index]["poster_path"]), width: context.width * 0.4, fit: BoxFit.cover, ), ), const SizedBox( width: 8, ), Container( width: (size.width - 30) * 0.4, child: Text( searched?[index]['original_title'] ?? "", style: const TextStyle( color: Colors.white, fontSize: 15, ), ), ), Padding( padding: const EdgeInsets.only(right: 20), child: Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.black, border: Border.all(color: Colors.white, width: 2), ), child: const Icon( Icons.play_arrow, color: Colors.white, ), ), ), ], ), ], ), ); } }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/widgets/helper.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:netflix/view/download/view/download_view.dart'; import '../../view/coming_soon/view/coming_soon_view.dart'; import '../../view/home/view/home_view.dart'; import '../../view/search/view/search_view.dart'; import '../uitlity/profile.dart'; List<Widget> screens = <Widget>[ const HomeView(), const ComingSoonView(), const SearchView(), const DownloadView(), ]; class Helper { static final comingSoonAppBar = AppBar( backgroundColor: Colors.black, centerTitle: false, title: const Text( "Coming Soon", style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: Colors.white, ), ), actions: [ IconButton( onPressed: () {}, icon: const Icon( Icons.collections_bookmark, color: Colors.white, size: 25, ), ), IconButton( onPressed: () {}, icon: const CircleAvatar( foregroundColor: Colors.transparent, backgroundColor: Colors.transparent, foregroundImage: AssetImage(profileUrl), )), const SizedBox( width: 5, ) ], ); static final downloadAppBar = AppBar( backgroundColor: Colors.black, centerTitle: false, title: const Text( "My Downloads", style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: Colors.white, ), ), actions: [ IconButton( onPressed: () {}, icon: const Icon( Icons.collections_bookmark, color: Colors.white, size: 25, ), ), IconButton( onPressed: () {}, icon: const CircleAvatar( foregroundColor: Colors.transparent, backgroundColor: Colors.transparent, foregroundImage: AssetImage(profileUrl), )), const SizedBox( width: 5, ) ], ); static final downloadBar = Row( children: const [ Padding( padding: EdgeInsets.only(left: 10), child: Icon( Icons.info_outline, color: Colors.white, ), ), SizedBox( width: 10, ), Text( "Smart Downloads", style: TextStyle( color: Colors.white, fontSize: 15, fontWeight: FontWeight.bold, ), ), SizedBox( width: 10, ), Text( "ON", style: TextStyle( color: Color.fromARGB(255, 24, 175, 245), fontSize: 15, fontWeight: FontWeight.bold, ), ) ], ); static final detailsAppBar = AppBar( backgroundColor: Colors.black, centerTitle: false, actions: [ IconButton( onPressed: () {}, icon: const Icon( Icons.collections_bookmark, color: Colors.white, size: 25, ), ), IconButton( onPressed: () {}, icon: const CircleAvatar( foregroundColor: Colors.transparent, backgroundColor: Colors.transparent, foregroundImage: AssetImage(profileUrl), )), const SizedBox( width: 5, ) ], ); static final videoPreview = Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Preview", style: TextStyle( color: Colors.white.withOpacity(0.9), fontSize: 15, ), ), const Icon( Icons.volume_mute, color: Colors.white, size: 25, ), ], ); }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/model/movie_model.dart
class Movie { bool? adult; String? backdropPath; List<int>? genreIds; int? id; String? originalLanguage; String? originalTitle; String? overview; double? popularity; String? posterPath; String? releaseDate; String? title; bool? video; double? voteAverage; int? voteCount; Movie( {this.adult, this.backdropPath, this.genreIds, this.id, this.originalLanguage, this.originalTitle, this.overview, this.popularity, this.posterPath, this.releaseDate, this.title, this.video, this.voteAverage, this.voteCount}); Movie.fromJson(Map<String, dynamic> json) { adult = json['adult']; backdropPath = json['backdrop_path']; genreIds = json['genre_ids'].cast<int>(); id = json['id']; originalLanguage = json['original_language']; originalTitle = json['original_title']; overview = json['overview']; popularity = json['popularity']; posterPath = json['poster_path']; releaseDate = json['release_date']; title = json['title']; video = json['video']; voteAverage = json['vote_average']; voteCount = json['vote_count']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = <String, dynamic>{}; data['adult'] = adult; data['backdrop_path'] = backdropPath; data['genre_ids'] = genreIds; data['id'] = id; data['original_language'] = originalLanguage; data['original_title'] = originalTitle; data['overview'] = overview; data['popularity'] = popularity; data['poster_path'] = posterPath; data['release_date'] = releaseDate; data['title'] = title; data['video'] = video; data['vote_average'] = voteAverage; data['vote_count'] = voteCount; return data; } }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/uitlity/profile.dart
const String profileUrl = "assets/images/profile.jpeg";
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/uitlity/coming_soon_json.dart
const List comingSoonJson = [ { "img": "assets/images/banner.webp", "title_img": "assets/images/title_img.webp", "title": "Sentinelle", "description": "Considered a fool and unfit to lead, Nobunaga rises to power as the head of the Oda clan, spurring dissent among those in his family vying for control.", "type": "Gritty - Dark - Action Thriller - Action & Adventure - Drama", "date": "Coming Friday", "duration": true }, { "img": "assets/images/banner_1.webp", "title_img": "assets/images/title_img_1.webp", "title": "Vincenzo", "description": "During a visit to his motherland, a Korean-Italian mafia lawyer gives an unrivaled conglomerate a taste of its own medicine with a side of justice.", "type": "Gritty - Dark - Action Thriller - Action & Adventure - Drama", "date": "New Episode Coming Saturday", "duration": false }, { "img": "assets/images/banner_2.webp", "title_img": "assets/images/title_img_2.webp", "title": "Peaky Blinders", "description": "A notorious gang in 1919 Birmingham, England, is led by the fierce Tommy Shelby, a crime boss set on moving up in the world no matter the cost.", "type": "Violence, Sex, Nudity, Language, Substances", "date": "2021 June", "duration": true } ];
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/uitlity/home_json.dart
const List mylist = [ {"img": "assets/images/img_1.png"}, {"img": "assets/images/img_2.png"}, {"img": "assets/images/img_3.png"}, {"img": "assets/images/img_4.png"}, ]; const List popularList = [ {"img": "assets/images/img_5.png"}, {"img": "assets/images/img_6.png"}, {"img": "assets/images/img_7.png"}, {"img": "assets/images/img_8.png"}, {"img": "assets/images/img_4.png"}, ]; const List trendingList = [ {"img": "assets/images/img_9.png"}, {"img": "assets/images/img_10.png"}, {"img": "assets/images/img_11.png"}, {"img": "assets/images/img_12.png"}, {"img": "assets/images/img_2.png"}, ]; const List originalList = [ {"img": "assets/images/img_13.png"}, {"img": "assets/images/img_14.png"}, {"img": "assets/images/img_15.png"}, {"img": "assets/images/img_2.png"}, {"img": "assets/images/img_4.png"}, ]; const List animeList = [ {"img": "assets/images/img_16.png"}, {"img": "assets/images/img_17.png"}, {"img": "assets/images/img_18.png"}, {"img": "assets/images/img_19.png"}, ];
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/uitlity/root_app_icons.dart
import 'package:antdesign_icons/antdesign_icons.dart'; List items = [ {"icon": AntIcons.homeOutlined, "text": "Home"}, {"icon": AntIcons.playCircleOutlined, "text": "Coming Soon"}, {"icon": AntIcons.searchOutlined, "text": "Search"}, {"icon": AntIcons.downOutlined, "text": "Downloads"}, ];
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/uitlity/video_detail_json.dart
import 'package:flutter/material.dart'; const List likesList = [ {"icon": Icons.add, "text": "My List"}, {"icon": Icons.thumb_up_alt_outlined, "text": "Rate"}, {"icon": Icons.send_outlined, "text": "Share"} ]; const List episodesList = ["EPISODES", "TRAILERS & MORE", "MORE LIKE THIS"]; const List movieList = [ { "img": "assets/images/detail_1.webp", "title": "1. The Rise of Nobunaga", "description": "Considered a fool and unfit to lead, Nobunaga rises to power as the head of the Oda clan, spurring dissent among those in his family vying for control.", "duration": "42m" }, { "img": "assets/images/detail_2.webp", "title": "2. Seizing Power", "description": "Nobunaga angers warlords when he captures most of the central Japan and ignites a fierce war with Takeda Shingen, a formidable daimyo.", "duration": "42m" }, { "img": "assets/images/detail_3.webp", "title": "3. The Demon King", "description": "As Nobunaga's ambitions intensify, some generals start to question his command, leading to a betrayal that alters the political landscape forever.", "duration": "42m" }, { "img": "assets/images/detail_4.webp", "title": "4. Complete Control", "description": "Toyotomi Hideyoshi ascendes to power as the de facto ruler of Japan. Still, Date Masamune, a young daimyo in the north, ignores his missives.", "duration": "43m" }, { "img": "assets/images/detail_5.webp", "title": "5. Catastrophe", "description": "With the country unified, Hideyoshi plans to expand his regn to China. Logistical chanllenges and fierce opposition in Korea prove to be costly.", "duration": "43m" }, { "img": "assets/images/detail_6.webp", "title": "6. Birth of a Dynasty", "description": "a dying Hideyoshi appoints five agents to govern til his son comes of age, but the power-hungry Tokugawa leyasu declares war on those who oppose him.", "duration": "44m" }, ];
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/uitlity/search_json.dart
const List searchJson = [ { "img": "assets/images/search_1.jpg", "title": "Age of Samurai: Battle for Japan", "video": "assets/videos/video_1.mp4", }, { "img": "assets/images/search_2.jpg", "title": "Aquaman", "video": "assets/videos/video_2.mp4", }, { "img": "assets/images/search_3.jpg", "title": "Animals on the Loose: A You vs. Wild Movie", "video": "assets/videos/video_2.mp4", }, { "img": "assets/images/search_4.jpg", "title": "Tribes of Europa", "video": "assets/videos/video_2.mp4", }, { "img": "assets/images/search_5.jpg", "title": "The Yin-Yang Master: Dream Of Eternity", "video": "assets/videos/video_2.mp4", }, { "img": "assets/images/search_6.jpg", "title": "Space Sweepers", "video": "assets/videos/video_2.mp4", }, { "img": "assets/images/search_7.jpg", "title": "Fate: The Winx Saga", "video": "assets/videos/video_2.mp4", } ];
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/api/api_init.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'api_init.dart'; // ************************************************************************** // StoreGenerator // ************************************************************************** // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers mixin _$Api on _ApiBase, Store { late final _$loadingAtom = Atom(name: '_ApiBase.loading', context: context); @override bool get loading { _$loadingAtom.reportRead(); return super.loading; } @override set loading(bool value) { _$loadingAtom.reportWrite(value, super.loading, () { super.loading = value; }); } late final _$trendingmoviesAtom = Atom(name: '_ApiBase.trendingmovies', context: context); @override List<dynamic>? get trendingmovies { _$trendingmoviesAtom.reportRead(); return super.trendingmovies; } @override set trendingmovies(List<dynamic>? value) { _$trendingmoviesAtom.reportWrite(value, super.trendingmovies, () { super.trendingmovies = value; }); } late final _$topratedmoviesAtom = Atom(name: '_ApiBase.topratedmovies', context: context); @override List<dynamic>? get topratedmovies { _$topratedmoviesAtom.reportRead(); return super.topratedmovies; } @override set topratedmovies(List<dynamic>? value) { _$topratedmoviesAtom.reportWrite(value, super.topratedmovies, () { super.topratedmovies = value; }); } late final _$tvAtom = Atom(name: '_ApiBase.tv', context: context); @override List<dynamic>? get tv { _$tvAtom.reportRead(); return super.tv; } @override set tv(List<dynamic>? value) { _$tvAtom.reportWrite(value, super.tv, () { super.tv = value; }); } late final _$tvEpisodesAtom = Atom(name: '_ApiBase.tvEpisodes', context: context); @override List<dynamic>? get tvEpisodes { _$tvEpisodesAtom.reportRead(); return super.tvEpisodes; } @override set tvEpisodes(List<dynamic>? value) { _$tvEpisodesAtom.reportWrite(value, super.tvEpisodes, () { super.tvEpisodes = value; }); } late final _$trendingmoviesSearchAtom = Atom(name: '_ApiBase.trendingmoviesSearch', context: context); @override List<dynamic>? get trendingmoviesSearch { _$trendingmoviesSearchAtom.reportRead(); return super.trendingmoviesSearch; } @override set trendingmoviesSearch(List<dynamic>? value) { _$trendingmoviesSearchAtom.reportWrite(value, super.trendingmoviesSearch, () { super.trendingmoviesSearch = value; }); } late final _$topratedmoviesSearchAtom = Atom(name: '_ApiBase.topratedmoviesSearch', context: context); @override List<dynamic>? get topratedmoviesSearch { _$topratedmoviesSearchAtom.reportRead(); return super.topratedmoviesSearch; } @override set topratedmoviesSearch(List<dynamic>? value) { _$topratedmoviesSearchAtom.reportWrite(value, super.topratedmoviesSearch, () { super.topratedmoviesSearch = value; }); } late final _$tvSearchAtom = Atom(name: '_ApiBase.tvSearch', context: context); @override List<dynamic>? get tvSearch { _$tvSearchAtom.reportRead(); return super.tvSearch; } @override set tvSearch(List<dynamic>? value) { _$tvSearchAtom.reportWrite(value, super.tvSearch, () { super.tvSearch = value; }); } late final _$tvEpisodesSearchAtom = Atom(name: '_ApiBase.tvEpisodesSearch', context: context); @override List<dynamic>? get tvEpisodesSearch { _$tvEpisodesSearchAtom.reportRead(); return super.tvEpisodesSearch; } @override set tvEpisodesSearch(List<dynamic>? value) { _$tvEpisodesSearchAtom.reportWrite(value, super.tvEpisodesSearch, () { super.tvEpisodesSearch = value; }); } late final _$apiInitAsyncAction = AsyncAction('_ApiBase.apiInit', context: context); @override Future<void> apiInit() { return _$apiInitAsyncAction.run(() => super.apiInit()); } late final _$_ApiBaseActionController = ActionController(name: '_ApiBase', context: context); @override void changeLoading() { final _$actionInfo = _$_ApiBaseActionController.startAction(name: '_ApiBase.changeLoading'); try { return super.changeLoading(); } finally { _$_ApiBaseActionController.endAction(_$actionInfo); } } @override void filterTopRatedMovies(String query) { final _$actionInfo = _$_ApiBaseActionController.startAction( name: '_ApiBase.filterTopRatedMovies'); try { return super.filterTopRatedMovies(query); } finally { _$_ApiBaseActionController.endAction(_$actionInfo); } } @override String toString() { return ''' loading: ${loading}, trendingmovies: ${trendingmovies}, topratedmovies: ${topratedmovies}, tv: ${tv}, tvEpisodes: ${tvEpisodes}, trendingmoviesSearch: ${trendingmoviesSearch}, topratedmoviesSearch: ${topratedmoviesSearch}, tvSearch: ${tvSearch}, tvEpisodesSearch: ${tvEpisodesSearch} '''; } }
0
mirrored_repositories/netflix/lib/product
mirrored_repositories/netflix/lib/product/api/api_init.dart
import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import 'package:netflix/core/base/model/base_view_model.dart'; import 'package:tmdb_api/tmdb_api.dart'; part 'api_init.g.dart'; class Api = _ApiBase with _$Api; abstract class _ApiBase with Store, BaseViewModel { @override void setContext(BuildContext context) {} @override void init() { apiInit(); } @observable bool loading = false; @observable List? trendingmovies; @observable List? topratedmovies; @observable List? tv; @observable List? tvEpisodes; @observable List? trendingmoviesSearch; @observable List? topratedmoviesSearch; @observable List? tvSearch; @observable List? tvEpisodesSearch; @action Future<void> apiInit() async { changeLoading(); final tmdb = TMDB(ApiKeys('', '')); Map trendingresult = await tmdb.v3.trending.getTrending(); Map topratedresult = await tmdb.v3.movies.getTopRated(); Map tvresult = await tmdb.v3.tv.getTopRated(); Map tvEpisodesResult = await tmdb.v3.tv.getTopRated(); trendingmovies = trendingresult['results']; topratedmovies = topratedresult['results']; tv = tvresult['results']; tvEpisodes = tvEpisodesResult['results']; changeLoading(); } @action void changeLoading() { loading = !loading; } @action void filterTopRatedMovies(String query) { Future.delayed(const Duration(seconds: 3)); topratedmoviesSearch = topratedmovies ?.where((item) => item['original_title'] .toLowerCase() .contains(query.toLowerCase())) .toList() ?? topratedmovies; } }
0
mirrored_repositories/netflix
mirrored_repositories/netflix/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:netflix/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/info_covid-19
mirrored_repositories/info_covid-19/lib/main.dart
import 'dart:async'; import 'dart:io'; import 'package:covid/services/messaging_service.dart'; import 'package:covid/ui/app.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; AppConfig appConfig; void main() async { final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized(); /// Override automaticSystemUiAdjustment auto UI color overlay adjustment /// on Android if (Platform.isAndroid) { binding.renderView.automaticSystemUiAdjustment = false; } var enableInDevMode = true; /// Set `enableInDevMode` to true to see reports while in debug mode /// This is only to be used for confirming that reports are being /// submitted as expected. It is not intended to be used for everyday /// development. Crashlytics.instance.enableInDevMode = enableInDevMode; /// Pass all uncaught errors from the framework to Crashlytics. FlutterError.onError = Crashlytics.instance.recordFlutterError; appConfig = AppConfig.prod; /// Init Firebase messaging service await MessagingService.init(); runZoned<Future<void>>(() async { /// Run main app runApp(CovidApp()); }, onError: (e, s) { /// Register and sends error Crashlytics.instance.recordError(e, s); /// for debug: if (enableInDevMode) { logger.e('[Error]: ${e.toString()}'); logger.e('[Stacktrace]: ${s.toString()}'); } }); } enum AppConfig { dev, prod, }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/resources/custom_localization.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class LicensesPageTitleTextLocal extends DefaultMaterialLocalizations { final BuildContext context; LicensesPageTitleTextLocal(Locale locale, this.context) : super(); @override String get licensesPageTitle => "LISENSI OPEN-SOURCE"; } class LicensesPageTitleTextLocalDelegate extends LocalizationsDelegate<MaterialLocalizations> { final BuildContext context; const LicensesPageTitleTextLocalDelegate(this.context); @override Future<LicensesPageTitleTextLocal> load(Locale locale) => SynchronousFuture(LicensesPageTitleTextLocal(locale, context)); @override bool shouldReload(LicensesPageTitleTextLocalDelegate old) => false; @override bool isSupported(Locale locale) => true; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/resources/constants.dart
const String bundle = 'com.benibete.covid'; const String routeSplash = "/"; const String routeHome = "home"; const String routeStatistics = "statistics"; const String routeContacts = "contacts"; const String routeFaqs = "faqs"; const String routeFaqsDetails = "faqs/details"; const String routeAbout = "about"; const String routeVideos = "videos"; const String routeVideoPlayer = "videos/player"; const String routeNotifications = "notifications"; const String routeLicences = "licences"; const String routeProtocol = "protocol"; const String routeProtocolDocument = "protocol/document";
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/resources/icons_svg.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:covid/ui/assets/colors.dart'; mixin SvgIcons { static Widget phoneSvg = SvgPicture.asset( 'assets/icon_action_phone.svg', color: Covid19Colors.green, ); static Widget emailSvg = SvgPicture.asset( 'assets/icon_action_email.svg', color: Covid19Colors.green, ); static Widget linkSvg( {Color color = Covid19Colors.green, double size = 24.0}) => SvgPicture.asset( 'assets/icon_action_link.svg', color: color, width: size, height: size, ); }
0
mirrored_repositories/info_covid-19/lib/resources
mirrored_repositories/info_covid-19/lib/resources/style/text_styles.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; /// Text Styles /// /// A color can be specified for a Text Style: /// /// ``` /// TextStyles.h1(color: Colors.black); /// ``` /// /// If not specified, it will defafult to [Colors.white] class TextStyles { static TextStyle statisticsBig({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 38.0, color: color, )); static TextStyle h1({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 22.0, color: color, )); static TextStyle h2({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 18.0, color: color, )); static TextStyle h3({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 16.0, color: color, )); static TextStyle h4({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( color: color, fontWeight: FontWeight.w900, fontSize: 14.0, )); static TextStyle h5({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 12.0, color: color, )); // This style is named "link" in Figma and Zepplin static TextStyle button({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 16.0, color: color, )); static TextStyle subtitle({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 16.0, color: color, )); static TextStyle tabSelected({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.w900, fontSize: 14.0, color: color, )); static TextStyle tabDeselected({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 16.0, color: color, )); static TextStyle paragraphSmall({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 14.0, color: color, )); static TextStyle paragraphNormal({Color color = Covid19Colors.darkGrey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 16.0, color: color, )); static TextStyle smallCaps({Color color = Covid19Colors.grey}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 15.0, color: color, )); static TextStyle texCustom( {Color color = Covid19Colors.darkGrey, double size = 14.0}) => GoogleFonts.lato( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: size, color: color, )); }
0
mirrored_repositories/info_covid-19/lib/resources
mirrored_repositories/info_covid-19/lib/resources/style/themes.dart
import 'dart:io'; /// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/assets/dimensions.dart'; import 'package:flutter/material.dart'; /// List of ThemeData and TextTheme to be used in the app class Themes { static Color colorPrimary = Covid19Colors.blue; static Color colorAccent = Covid19Colors.green; static Color colorText = Covid19Colors.darkGrey; static Color colorTextLight = Covid19Colors.grey; static TextTheme defaultTextTheme = TextTheme( headline: TextStyles.h1(), caption: TextStyles.paragraphSmall(), body1: TextStyles.paragraphNormal( color: colorText, ), display1: TextStyles.h1( color: colorPrimary, ), display2: TextStyles.h2( color: colorPrimary, ), display3: TextStyles.h3( color: colorText, ), display4: TextStyles.h4( color: colorPrimary, ), title: TextStyles.h2( color: Colors.white, ), subtitle: TextStyles.paragraphSmall( color: colorTextLight, ), button: TextStyles.button( color: Colors.white, )); static ThemeData defaultAppTheme = ThemeData( appBarTheme: AppBarTheme( color: Covid19Colors.blue, elevation: 0.0, brightness: Platform.isAndroid ? Brightness.dark : Brightness.light, textTheme: defaultTextTheme, iconTheme: IconThemeData( color: Covid19Colors.white, ), ), brightness: Platform.isAndroid ? Brightness.dark : Brightness.light, fontFamily: "Lato", primaryColor: colorPrimary, accentColor: colorPrimary, textTheme: defaultTextTheme, unselectedWidgetColor: colorPrimary, scaffoldBackgroundColor: Colors.white, tabBarTheme: TabBarTheme( labelColor: Covid19Colors.green, unselectedLabelColor: Covid19Colors.darkGrey, indicator: UnderlineTabIndicator( borderSide: BorderSide(width: tabIndicatorWeight, color: Covid19Colors.green), insets: EdgeInsets.fromLTRB(tabIndicatorMagin, 0, tabIndicatorMagin, 0), ), ), ); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/bloc/app_bloc.dart
import 'dart:async'; import 'package:covid/model/api_response_model.dart'; import 'package:covid/model/faq_category_model.dart'; import 'package:covid/model/faq_model.dart'; import 'package:covid/model/post_type.dart'; import 'package:covid/model/slider_model.dart'; import 'package:covid/model/stats_model.dart'; import 'package:covid/model/video_model.dart'; import 'package:covid/model/detail_stats_model.dart'; import 'package:covid/model/protocol_model.dart'; import 'package:covid/services/api_service.dart'; import 'package:covid/ui/app.dart'; import 'package:rxdart/subjects.dart'; import 'base_bloc.dart'; class AppBloc implements Bloc { static const String _tag = '.AppBloc'; StreamController onStream = BehaviorSubject<ResultStream>(); AppBloc() { APIService.api.init(); } void getStats() async { final APIResponse response = await APIService.api.getStats(); if (response.isOk) { logger.i('[$_tag] everything went ok!'); onStream.sink.add(StatsResultStream( model: StatsModel.fromJson(response.data), state: StateStream.success)); } else { logger.e('[$_tag] oops...'); // throw some error onStream.sink .add(StatsResultStream(model: null, state: StateStream.fail)); } } void getSlider() async { final postType = PostType(PostTypes.slider); var results = await getPosts<SliderModel>(postType, cacheKey: "SliderModel"); onStream.sink.add( SliderResultStream( model: results, state: results != null ? StateStream.success : StateStream.fail), ); } void getVideos() async { final postType = PostType(PostTypes.videos); var results = await getPosts<VideoModel>(postType, cacheKey: "VideoModel"); onStream.sink.add(VideosResultStream( model: results, state: results != null ? StateStream.success : StateStream.fail)); } Future<List<FaqModel>> getFaqsDetails(int id) async { final postType = PostType(PostTypes.faq); return getPosts<FaqModel>(postType, cacheKey: "FaqModel", id: id); } void getFaqCategories() async { final postType = PostType(PostTypes.faqCategories); var results = await getPosts<FaqCategoryModel>(postType, cacheKey: "FaqCategoryModel"); // fetch all categories if (results != null) { final map = <int, List<FaqModel>>{}; for (var result in results) { logger.i("Getting faqs for: ${result.categoryId}"); map[result.categoryId] = await getFaqsDetails(result.categoryId); } logger.i("FAQS: $map"); onStream.sink.add( FaqResultStream( model: map, state: map.isNotEmpty ? StateStream.success : StateStream.fail, ), ); } else { onStream.sink.add( FaqResultStream( model: null, state: StateStream.fail, ), ); } onStream.sink.add( FaqCategoryResultStream( model: results, state: results != null ? StateStream.success : StateStream.fail), ); } void getDetailStats() async { final postType = PostType(PostTypes.detailStats); var results = await getPosts<DetailStatsModel>(postType, cacheKey: "DetailStats"); onStream.sink.add(DetailStatsResultStream( model: results, state: results != null ? StateStream.success : StateStream.fail)); } void getProtocol() async { final postType = PostType(PostTypes.protocol); var results = await getPosts<ProtocolModel>(postType, cacheKey: "Protocol"); onStream.sink.add(ProtocolResultStream( model: results, state: results != null ? StateStream.success : StateStream.fail)); } Future<List<T>> getPosts<T>(PostType postType, {int id, bool cache = true, String cacheKey = "key"}) async { final APIResponse response = await APIService.api.getPosts<T>(postType, id: id); if (response.isOk) { logger.i('[$_tag] everything went ok!'); /// Cast the response to Map key -> value final data = response.data.cast<Map<String, dynamic>>(); var results = parseData<T>(postType, data); if (cache) { /// TODO: cache results } return results; } else { logger.e('[$_tag] oops...'); // throw some error } return null; } /// Parse the json map into each corresponding Post Model /// /// Both [postType] and [data] are mandatory /// /// Then returns the parsed data parseData<T>(PostType postType, dynamic data) { switch (postType.postTypes) { case PostTypes.slider: /// Data converted to a Map now we need to convert each entry return data.map<T>((json) => /// into a [SliderModel] instance and save into a List SliderModel.fromJson(json)).toList(); case PostTypes.faqCategories: /// Data converted to a Map now we need to convert each entry return data.map<T>((json) => /// into a [FaqCategoryModel] instance and save into a List FaqCategoryModel.fromJson(json)).toList(); break; case PostTypes.faq: /// Data converted to a Map now we need to convert each entry return data.map<T>((json) => /// into a [FaqModel] instance and save into a List FaqModel.fromJson(json)).toList(); break; case PostTypes.videos: /// Data converted to a Map now we need to convert each entry return data.map<T>((json) => /// into a [VideoModel] instance and save into a List VideoModel.fromJson(json)).toList(); break; case PostTypes.detailStats: /// Data converted to a Map now we need to convert each entry return data.map<T>((json) => /// into a [VideoModel] instance and save into a List DetailStatsModel.fromJson(json)).toList(); break; case PostTypes.protocol: /// Data converted to a Map now we need to convert each entry return data.map<T>((json) => /// into a [VideoModel] instance and save into a List ProtocolModel.fromJson(json)).toList(); break; } } @override void dispose() { onStream.close(); } @override Stream<ResultStream> get onListener => onStream.stream; } class SplashBloc implements Bloc { final AppBloc bloc; SplashBloc(this.bloc); @override void dispose() {} @override Stream<ResultStream> get onListener => null; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/bloc/base_bloc.dart
import 'package:covid/model/slider_model.dart'; import 'package:covid/model/video_model.dart'; import 'package:covid/model/faq_category_model.dart'; import 'package:covid/model/detail_stats_model.dart'; import 'package:covid/model/faq_model.dart'; import 'package:covid/model/stats_model.dart'; import 'package:covid/model/protocol_model.dart'; abstract class Bloc { /// Dispose Bloc instance void dispose(); /// A listener to capture the stream events /// /// This stream will be a [ResultStream] data type Stream<ResultStream> get onListener; } /// ResultStream a base class for sending event streams /// /// [S] is the State instance, emum with states /// [M] is the related data to pass on the stream /// this could be a Model instance or other data type class ResultStream<S, M> { /// Data passed to the stream M model; /// Actual State of the stream S state; } /// Enums the different States /// /// [request] on doing the request /// [loading] while doing the request /// [success] if request was successfully /// [fail] if request throw an exception enum StateStream { request, loading, success, fail } /// The ResultStream instance for requesting the case Stats /// /// [StatsResultStream] is extended from [ResultStream] class StatsResultStream extends ResultStream<StateStream, StatsModel> { @override StatsModel model; @override StateStream state; /// Constructor to set the [state], a [StateStream] instance /// and [model] a [StatsModel] instance StatsResultStream({this.state, this.model}); } /// The ResultStream instance for requesting the remote work posts /// /// [VideosResultStream] is extended from [ResultStream] class VideosResultStream extends ResultStream<StateStream, List<VideoModel>> { @override List<VideoModel> model; @override StateStream state; /// Constructor to set the [state], a [StateStream] instance /// and [model] a [List<VideoModel>] instance list VideosResultStream({this.state, this.model}); } /// The ResultStream instance for requesting the remote work posts /// /// [FaqResultStream] is extended from [ResultStream] class FaqResultStream extends ResultStream<StateStream, Map<int, List<FaqModel>>> { @override Map<int, List<FaqModel>> model; @override StateStream state; /// Constructor to set the [state], a [StateStream] instance /// and [model] a [List<FaqModel>] instance list FaqResultStream({this.state, this.model}); } class SliderResultStream extends ResultStream<StateStream, List<SliderModel>> { @override List<SliderModel> model; @override StateStream state; /// and [model] a [Lst<SliderModel>] instance list SliderResultStream({this.state, this.model}); } class FaqCategoryResultStream extends ResultStream<StateStream, List<FaqCategoryModel>> { @override List<FaqCategoryModel> model; @override StateStream state; /// and [model] a [Lst<FaqCategoryModel>] instance list FaqCategoryResultStream({this.state, this.model}); } /// The ResultStream instance for requesting the remote work posts /// /// [SetailStatsStream] is extended from [ResultStream] class DetailStatsResultStream extends ResultStream<StateStream, List<DetailStatsModel>> { @override List<DetailStatsModel> model; @override StateStream state; /// Constructor to set the [state], a [StateStream] instance /// and [model] a [List<DetailStatsModel>] instance list DetailStatsResultStream({this.state, this.model}); } /// The ResultStream instance for requesting the remote work posts /// /// [ProtocolResultStream] is extended from [ResultStream] class ProtocolResultStream extends ResultStream<StateStream, List<ProtocolModel>> { @override List<ProtocolModel> model; @override StateStream state; /// Constructor to set the [state], a [StateStream] instance /// and [model] a [List<ProtocolModel>] instance list ProtocolResultStream({this.state, this.model}); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/sample_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'sample_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** Foo _$FooFromJson(Map<String, dynamic> json) { return Foo( json['someString'] as String, json['myInt'] as int, ); } Map<String, dynamic> _$FooToJson(Foo instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('someString', instance.someString); writeNotNull('myInt', instance.someInt); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/stats_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'stats_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** StatsModel _$StatsModelFromJson(Map<String, dynamic> json) { return StatsModel( json['recovered'] as String, json['confirmed'] as String, json['suspected'] as String, json['awaitingResults'] as String, json['deaths'] as String, json['lastUpdated'] as String, ); } Map<String, dynamic> _$StatsModelToJson(StatsModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('recovered', instance.recovered); writeNotNull('confirmed', instance.confirmed); writeNotNull('suspected', instance.suspected); writeNotNull('awaitingResults', instance.awaitingResults); writeNotNull('deaths', instance.deaths); writeNotNull('lastUpdated', instance.lastUpdated); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/stats_model.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:json_annotation/json_annotation.dart'; part 'stats_model.g.dart'; /// Stats Model @JsonSerializable(includeIfNull: false) class StatsModel { /// Recovered total cases @JsonKey(name: 'recovered') final String recovered; /// Confirmed total cases @JsonKey(name: 'confirmed') final String confirmed; /// Suspected total cases @JsonKey(name: 'suspected') final String suspected; /// Cases awaiting for results @JsonKey(name: 'awaitingResults') final String awaitingResults; /// Total death cases @JsonKey(name: 'deaths') final String deaths; /// Recovered total cases @JsonKey(name: 'lastUpdated') final String lastUpdated; /// Model constructor /// /// All properties are mandatory /// StatsModel(this.recovered, this.confirmed, this.suspected, this.awaitingResults, this.deaths, this.lastUpdated); /// Mapper from Json to Model factory StatsModel.fromJson(Map<String, dynamic> json) => _$StatsModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$StatsModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/post_type.dart
/// Post types enum PostTypes { videos, faq, slider, faqCategories, detailStats, protocol } class PostType { final PostTypes postTypes; PostType(this.postTypes); String getRequestType() { switch (postTypes) { case PostTypes.slider: return '/slider'; case PostTypes.faqCategories: return '/appfaqs'; case PostTypes.faq: return '/faqs'; case PostTypes.videos: return '/videos'; case PostTypes.detailStats: return '/detailstats'; case PostTypes.protocol: return '/protocol'; default: return ''; } } }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/notifications_model.dart
import 'package:flutter/foundation.dart'; /// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. @immutable class NotificationsModel { NotificationsModel({ this.general = false, this.stats = false, this.measures = false, this.questions = false, this.other = false, }); final bool general; final bool stats; final bool measures; final bool questions; final bool other; NotificationsModel copyWith({ bool general, bool stats, bool measures, bool questions, bool other, }) => NotificationsModel( general: general ?? this.general, stats: stats ?? this.stats, measures: measures ?? this.measures, questions: questions ?? this.questions, other: other ?? this.other, ); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/api_response_model.dart
import 'package:covid/generated/l10n.dart'; import 'package:dio/dio.dart'; import 'package:covid/ui/app.dart'; const String bundle = 'com.benibete.covid'; class APIResponse { static final _tag = '$bundle.APIResponse'; dynamic data; Headers headers; DioErrorType dioErrorType; int statusCode; List<int> errors; List<String> errorsDescription(S intl) { Map<int, String> errorsMap = { 1234: 'someError', }; return errors .map((id) => errorsMap[id] != null ? errorsMap[id] : intl.defaultError) .toList(); } APIResponse(this.data, this.statusCode, {this.headers, this.dioErrorType}) : errors = headers != null && headers['errorKey'] != null ? [] // Decode errors to [errors] : null { logger.i(this); } bool get isOk => dioErrorType == null && errors == null && statusCode >= 200 && statusCode < 400; bool get isNotOk => !isOk; @override String toString() => '[$_tag] Code: $statusCode | Body: $data | Headers: $headers | Error: $dioErrorType'; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/slider_model.dart
import 'package:json_annotation/json_annotation.dart'; import 'package:covid/model/base_post_model.dart'; part 'slider_model.g.dart'; /// Slider Model @JsonSerializable(includeIfNull: false) class SliderModel extends BasePostModel { /// Order of this slider @JsonKey(name: 'order') final int order; @JsonKey(name: 'image') final String image; @JsonKey(name: 'post_title') final String title; @JsonKey(name: 'url') final String url; /// Model constructor /// /// All properties are mandatory /// SliderModel({ int id, this.image, this.title, this.url, this.order, }) : super( id: id, ); /// Mapper from Json to Model factory SliderModel.fromJson(Map<String, dynamic> json) => _$SliderModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$SliderModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/sample_model.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:json_annotation/json_annotation.dart'; part 'sample_model.g.dart'; /// This is a place holder model just to demonstrate the use of json_serializable. /// Delete as soon as you create a real one. @JsonSerializable(includeIfNull: false) class Foo { Foo(this.someString, this.someInt); final String someString; @JsonKey(name: 'myInt') final int someInt; factory Foo.fromJson(Map<String, dynamic> json) => _$FooFromJson(json); Map<String, dynamic> toJson() => _$FooToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/video_model.dart
import 'package:json_annotation/json_annotation.dart'; import 'package:covid/model/base_post_model.dart'; part 'video_model.g.dart'; /// Stats Model @JsonSerializable(includeIfNull: false) class VideoModel extends BasePostModel { /// Recovered total cases @JsonKey(name: 'post_title') final String postTitle; /// Confirmed total cases @JsonKey(name: 'video') final String video; /// Suspected total cases @JsonKey(name: 'description') final String description; String getVideoUrl() { var regex = RegExp(r'(?<=src=").*?(?=[?"])'); var videoUrl = regex.firstMatch(video)?.group(0); return videoUrl?.replaceAll("\\", ""); } String getVideoId() { var videoUrl = getVideoUrl(); Uri uri = Uri.parse(videoUrl); return uri.pathSegments.last; } String getVideoThumbnail() { return "https://img.youtube.com/vi/${getVideoId()}/hqdefault.jpg"; } /// Model constructor /// /// All properties are mandatory /// VideoModel({ int id, this.postTitle, this.video, this.description, }) : super( id: id, ); /// Mapper from Json to Model factory VideoModel.fromJson(Map<String, dynamic> json) => _$VideoModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$VideoModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/protocol_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'protocol_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** ProtocolModel _$ProtocolModelFromJson(Map<String, dynamic> json) { return ProtocolModel( json['ID'] as int, json['title'] as String, json['description'] as String, json['url'] as String, ); } Map<String, dynamic> _$ProtocolModelToJson(ProtocolModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('ID', instance.id); writeNotNull('title', instance.title); writeNotNull('description', instance.description); writeNotNull('url', instance.url); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/faq_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'faq_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** FaqModel _$FaqModelFromJson(Map<String, dynamic> json) { return FaqModel( json['ID'] as int, json['question'] as String, json['answer'] as String, json['responsableEntity'] as String, ); } Map<String, dynamic> _$FaqModelToJson(FaqModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('ID', instance.id); writeNotNull('question', instance.question); writeNotNull('answer', instance.answer); writeNotNull('responsableEntity', instance.responsableEntity); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/faq_category_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'faq_category_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** FaqCategoryModel _$FaqCategoryModelFromJson(Map<String, dynamic> json) { return FaqCategoryModel( json['ID'] as int, json['name'] as String, json['category_id'] as int, ); } Map<String, dynamic> _$FaqCategoryModelToJson(FaqCategoryModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('ID', instance.id); writeNotNull('name', instance.name); writeNotNull('category_id', instance.categoryId); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/contact_model.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; enum ContactType { phone, link, email } class ContactModel { ContactType contactType; String title; String description; Widget icon; double textSize; ContactModel( {this.contactType, this.title, this.description, this.icon, this.textSize = 28.0}); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/faq_model.dart
import 'package:json_annotation/json_annotation.dart'; import 'base_post_model.dart'; part 'faq_model.g.dart'; @JsonSerializable(includeIfNull: false) class FaqModel extends BasePostModel { /// Question @JsonKey(name: 'question') final String question; /// Answer @JsonKey(name: 'answer') final String answer; /// Responsable Entity @JsonKey(name: 'responsableEntity') final String responsableEntity; /// Constructor /// /// All Fields are mandatory /// FaqModel( int id, this.question, this.answer, this.responsableEntity, ) : super( id: id, ); /// Mapper from Json to Model factory FaqModel.fromJson(Map<String, dynamic> json) => _$FaqModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$FaqModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/faq_category_model.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:json_annotation/json_annotation.dart'; import 'base_post_model.dart'; part 'faq_category_model.g.dart'; @JsonSerializable(includeIfNull: false) class FaqCategoryModel extends BasePostModel { /// FAQ Title @JsonKey(name: 'name') final String name; /// FAQ Category ID @JsonKey(name: 'category_id') final int categoryId; /// Constructor /// /// All Fields are mandatory /// FaqCategoryModel( int id, this.name, this.categoryId, ) : super( id: id, ); /// Mapper from Json to Model factory FaqCategoryModel.fromJson(Map<String, dynamic> json) => _$FaqCategoryModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$FaqCategoryModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/video_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'video_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** VideoModel _$VideoModelFromJson(Map<String, dynamic> json) { return VideoModel( id: json['ID'] as int, postTitle: json['post_title'] as String, video: json['video'] as String, description: json['description'] as String, ); } Map<String, dynamic> _$VideoModelToJson(VideoModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('ID', instance.id); writeNotNull('post_title', instance.postTitle); writeNotNull('video', instance.video); writeNotNull('description', instance.description); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/detail_stats_model.dart
import 'package:json_annotation/json_annotation.dart'; import 'base_post_model.dart'; part 'detail_stats_model.g.dart'; @JsonSerializable(includeIfNull: false) class DetailStatsModel extends BasePostModel { /// provinceCode @JsonKey(name: 'Kode_Provi') final int provinceCode; /// province @JsonKey(name: 'Provinsi') final String province; /// positiveCase @JsonKey(name: 'Kasus_Posi') final String positiveCase; /// recoceredCase @JsonKey(name: 'Kasus_Semb') final String recoveredCase; /// deathCase @JsonKey(name: 'Kasus_Meni') final String deathCase; /// lastUpdated @JsonKey(name: 'lastUpdated') final String lastUpdated; /// Constructor /// /// All Fields are mandatory /// DetailStatsModel( int id, this.provinceCode, this.province, this.positiveCase, this.recoveredCase, this.deathCase, this.lastUpdated ) : super( id: id, ); /// Mapper from Json to Model factory DetailStatsModel.fromJson(Map<String, dynamic> json) => _$DetailStatsModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$DetailStatsModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/detail_stats_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'detail_stats_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** DetailStatsModel _$DetailStatsModelFromJson(Map<String, dynamic> json) { return DetailStatsModel( json['ID'] as int, json['Kode_Provi'] as int, json['Provinsi'] as String, json['Kasus_Posi'] as String, json['Kasus_Semb'] as String, json['Kasus_Meni'] as String, json['lastUpdated'] as String, ); } Map<String, dynamic> _$DetailStatsModelToJson(DetailStatsModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('ID', instance.id); writeNotNull('Kode_Provi', instance.provinceCode); writeNotNull('Provinsi', instance.province); writeNotNull('Kasus_Posi', instance.positiveCase); writeNotNull('Kasus_Semb', instance.recoveredCase); writeNotNull('Kasus_Meni', instance.deathCase); writeNotNull('lastUpdated', instance.lastUpdated); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/protocol_model.dart
import 'package:json_annotation/json_annotation.dart'; import 'base_post_model.dart'; part 'protocol_model.g.dart'; @JsonSerializable(includeIfNull: false) class ProtocolModel extends BasePostModel { /// title @JsonKey(name: 'title') final String title; /// description @JsonKey(name: 'description') final String description; /// url @JsonKey(name: 'url') final String url; /// Constructor /// /// All Fields are mandatory /// ProtocolModel( int id, this.title, this.description, this.url, ) : super( id: id, ); /// Mapper from Json to Model factory ProtocolModel.fromJson(Map<String, dynamic> json) => _$ProtocolModelFromJson(json); /// Maps Model to Json Map<String, dynamic> toJson() => _$ProtocolModelToJson(this); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/base_post_model.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:json_annotation/json_annotation.dart'; /// Base Post Model /// /// To use this model as a base, this must be extended AND the constructor needs /// to be updated with the correct models: /// /// ```dart /// @JsonSerializable(includeIfNull: false) /// class ExampleModel extends BasePostModel { /// /// ExampleModel( /// int id, /// String author, /// String date, /// String postDateGmt, /// String postExcerpt, /// String postStatus, /// String commentStatus, /// String pingStatus, /// String postPassword, /// String postName, /// String toPing, /// String pinged, /// String postModified, /// String postModifiedGMT, /// String postContentFiltered, /// int postParent, /// String guid, /// int menuOrder, /// String postType, /// String postMimeType, /// String commentCount, /// String filter, /// this.recovered, // Class property /// this.confirmed, // Class property /// this.suspected, // Class property /// this.awaitingResults, // Class property /// this.deaths) // Class property /// : super( /// id: id, /// author: author, /// date: date, /// postDateGmt: postDateGmt, /// postExcerpt: postExcerpt, /// postStatus: postStatus, /// commentStatus: commentStatus, /// pingStatus: pingStatus, /// postPassword: postPassword, /// postName: postName, /// toPing: toPing, /// pinged: pinged, /// postModified: postModified, /// postModifiedGMT: postModifiedGMT, /// postContentFiltered: postContentFiltered, /// postParent: postParent, /// guid: guid, /// menuOrder: menuOrder, /// postType: postType, /// postMimeType: postMimeType, /// commentCount: commentCount, /// filter: filter, /// ); /// ``` /// /// This can be copied and used in new models abstract class BasePostModel { /// ID of the measure publication ppost @JsonKey(name: 'ID') final int id; /// Author of this mmeasure information @JsonKey(name: 'post_author') final String author; /// Publication time @JsonKey(name: 'post_date') final String date; /// Publication time in GMT @JsonKey(name: 'post_date_gmt') final String postDateGmt; /// Shortened information about this measure @JsonKey(name: 'post_excerpt') final String postExcerpt; /// Status of the measure post @JsonKey(name: 'post_status') final String postStatus; /// Status of the comments for this measure post @JsonKey(name: 'comment_status') final String commentStatus; /// Status of the ping of this measure post @JsonKey(name: 'ping_status') final String pingStatus; /// Password hash for this post if exists @JsonKey(name: 'post_password') final String postPassword; /// Name of the publication measure @JsonKey(name: 'post_name') final String postName; /// Ping post @JsonKey(name: 'to_ping') final String toPing; /// If this post was pinged @JsonKey(name: 'pinged') final String pinged; /// When whas the ping modified @JsonKey(name: 'post_modified') final String postModified; /// Date for when post was modified in GMT @JsonKey(name: 'post_modified_gmt') final String postModifiedGMT; /// The post filtered by string @JsonKey(name: 'post_content_filtered') final String postContentFiltered; /// What is the post parent, if exists @JsonKey(name: 'post_parent') final int postParent; /// Unique URL identifier of this post @JsonKey(name: 'guid') final String guid; /// Order in the menu if needed @JsonKey(name: 'menu_order') final int menuOrder; /// Post type @JsonKey(name: 'post_type') final String postType; /// PostMIME Type @JsonKey(name: 'post_mime_type') final String postMimeType; /// Number ƒof comments the post has @JsonKey(name: 'comment_count') final String commentCount; /// What is the filter @JsonKey(name: 'filter') final String filter; /// Model constructor /// /// All properties are mandatory /// BasePostModel({ this.id, this.author, this.date, this.postDateGmt, this.postExcerpt, this.postStatus, this.commentStatus, this.pingStatus, this.postPassword, this.postName, this.toPing, this.pinged, this.postModified, this.postModifiedGMT, this.postContentFiltered, this.postParent, this.guid, this.menuOrder, this.postType, this.postMimeType, this.commentCount, this.filter, }); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/model/slider_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'slider_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** SliderModel _$SliderModelFromJson(Map<String, dynamic> json) { return SliderModel( id: json['ID'] as int, image: json['image'] as String, title: json['post_title'] as String, url: json['url'] as String, order: json['order'] as int, ); } Map<String, dynamic> _$SliderModelToJson(SliderModel instance) { final val = <String, dynamic>{}; void writeNotNull(String key, dynamic value) { if (value != null) { val[key] = value; } } writeNotNull('ID', instance.id); writeNotNull('order', instance.order); writeNotNull('image', instance.image); writeNotNull('post_title', instance.title); writeNotNull('url', instance.url); return val; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/extensions/date_extensions.dart
extension StringExtension on String { String capitalize() { return "${this[0].toUpperCase()}${substring(1)}"; } }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/generated/l10n.dart
// GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin // Made by Localizely // ************************************************************************** class S { S(); static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); static Future<S> load(Locale locale) { final String name = (locale.countryCode?.isEmpty ?? false) ? locale.languageCode : locale.toString(); final String localeName = Intl.canonicalizedLocale(name); return initializeMessages(localeName).then((_) { Intl.defaultLocale = localeName; return S(); }); } static S of(BuildContext context) { return Localizations.of<S>(context, S); } String get checkDetails { return Intl.message( 'Lihat detail', name: 'checkDetails', desc: '', args: [], ); } String get contactsPageMNEEmail { return Intl.message( '0318430313', name: 'contactsPageMNEEmail', desc: '', args: [], ); } String get contactsPageMNEEmailText { return Intl.message( 'Pusat Informasi Covid-19 Provinsi Jawa Timur', name: 'contactsPageMNEEmailText', desc: '', args: [], ); } String get contactsPageMNENumber { return Intl.message( '0243580713', name: 'contactsPageMNENumber', desc: '', args: [], ); } String get contactsPageMNENumberText { return Intl.message( 'Hotline Dinas Kesehatan Provinsi Jawa Tengah', name: 'contactsPageMNENumberText', desc: '', args: [], ); } String get contactsPageMSWeb { return Intl.message( '08112093306', name: 'contactsPageMSWeb', desc: '', args: [], ); } String get contactsPageMSWebText { return Intl.message( 'Hotline Dinas Kesehatan Provinsi Jawa Barat', name: 'contactsPageMSWebText', desc: '', args: [], ); } String get contactsPageSNSEmail { return Intl.message( '0274 555585', name: 'contactsPageSNSEmail', desc: '', args: [], ); } String get contactsPageSNSEmailText { return Intl.message( 'Hotline Covid-19 Provinsi DI Yogyakarta', name: 'contactsPageSNSEmailText', desc: '', args: [], ); } String get contactsPageSNSNumber { return Intl.message( '119', name: 'contactsPageSNSNumber', desc: '', args: [], ); } String get contactsPageSNSNumberText { return Intl.message( 'Panggilan Darurat', name: 'contactsPageSNSNumberText', desc: '', args: [], ); } String get contactsPageSSNumber { return Intl.message( '081388376955', name: 'contactsPageSSNumber', desc: '', args: [], ); } String get contactsPageSSNumberText { return Intl.message( 'Hotline Dinas Kesehatan Provinsi DKI Jakarta', name: 'contactsPageSSNumberText', desc: '', args: [], ); } String get contactsPageTitle { return Intl.message( 'Kontak Penting', name: 'contactsPageTitle', desc: '', args: [], ); } String get defaultError { return Intl.message( 'Sebuah kesalahan terjadi', name: 'defaultError', desc: '', args: [], ); } String get faqPageResponsableEntity { return Intl.message( 'Sumber', name: 'faqPageResponsableEntity', desc: '', args: [], ); } String get faqPageTitle { return Intl.message( 'Tanya Jawab', name: 'faqPageTitle', desc: '', args: [], ); } String get notificationsPageDescription { return Intl.message( 'Notifikasi terkait informasi penting tentang pembaharuan data yang terkandung dalam aplikasi ini dan dari entitas resmi.', name: 'notificationsPageDescription', desc: '', args: [], ); } String get notificationsPageReceiveNotifcations { return Intl.message( 'Notifikasi', name: 'notificationsPageReceiveNotifcations', desc: '', args: [], ); } String get notificationsPagePermissionsMissing { return Intl.message( 'Harap diberikan izin untuk mengaktifkan notifikasi.', name: 'notificationsPagePermissionsMissing', desc: '', args: [], ); } String get notificationsPageOpenSettings { return Intl.message( 'Buka pengaturan', name: 'notificationsPageOpenSettings', desc: '', args: [], ); } String get screenAboutBuilt { return Intl.message( '', name: 'screenAboutBuilt', desc: '', args: [], ); } String get screenAboutContent1 { return Intl.message( 'Aplikasi Info Covid-19 dibuat untuk memberikan informasi terkini terkait Covid-19 di Indonesia.', name: 'screenAboutContent1', desc: '', args: [], ); } String get screenAboutContent2 { return Intl.message( 'Sumber data diambil dari https://kawalcorona.com/ yang menyediakan data kasus Covid-19 secara realtime dan terpercaya.', name: 'screenAboutContent2', desc: '', args: [], ); } String get screenAboutContent3 { return Intl.message( 'Berita dan informasi terkait Covid-19 diambil dari sumber yang terpercaya yaitu https://www.covid19.go.id/.', name: 'screenAboutContent3', desc: '', args: [], ); } String get screenAboutContent4 { return Intl.message( 'Video diambil dari kanal Youtube Presiden Joko Widodo yang berkaitan dengan penanganan Covid-19.', name: 'screenAboutContent4', desc: '', args: [], ); } String get screenAboutContent5 { return Intl.message( '', name: 'screenAboutContent5', desc: '', args: [], ); } String get screenAboutFooter1 { return Intl.message( 'Info Covid-19 © 2020 Benidiktus BT', name: 'screenAboutFooter1', desc: '', args: [], ); } String get screenAboutFooter2 { return Intl.message( 'Email: [email protected]', name: 'screenAboutFooter2', desc: '', args: [], ); } String get screenAboutHashtag { return Intl.message( '#InfoCovid-19', name: 'screenAboutHashtag', desc: '', args: [], ); } String get screenAboutTitle { return Intl.message( 'Tentang Aplikasi', name: 'screenAboutTitle', desc: '', args: [], ); } String get screenNotificationsTitle { return Intl.message( 'Notifikasi', name: 'screenNotificationsTitle', desc: '', args: [], ); } String get statisticsPageAwaitingResults { return Intl.message( 'Menunggu Hasil', name: 'statisticsPageAwaitingResults', desc: '', args: [], ); } String get statisticsPageConfirmed { return Intl.message( 'Positif', name: 'statisticsPageConfirmed', desc: '', args: [], ); } String get statisticsPageDataLabel { return Intl.message( 'Data dari Kawal Corona', name: 'statisticsPageDataLabel', desc: '', args: [], ); } String get statisticsPageRecovered { return Intl.message( 'Sembuh', name: 'statisticsPageRecovered', desc: '', args: [], ); } String get statisticsPageStatistics { return Intl.message( 'Statistik', name: 'statisticsPageStatistics', desc: '', args: [], ); } String get statisticsPageSuspects { return Intl.message( 'Suspek', name: 'statisticsPageSuspects', desc: '', args: [], ); } String get statisticsPageDeath { return Intl.message( 'Meninggal', name: 'statisticsPageDeath', desc: '', args: [], ); } String get screenAboutButtonReport { return Intl.message( 'Laporkan Masalah', name: 'screenAboutButtonReport', desc: '', args: [], ); } String get screenAboutButtonOpenSource { return Intl.message( 'Lisensi Open-Source', name: 'screenAboutButtonOpenSource', desc: '', args: [], ); } String get homePageTitle { return Intl.message( 'Informasi Covid-19', name: 'homePageTitle', desc: '', args: [], ); } String get screenVideosTitle { return Intl.message( 'Video', name: 'screenVideosTitle', desc: '', args: [], ); } String get lastUpdated { return Intl.message( 'Data per: ', name: 'lastUpdated', desc: '', args: [], ); } String get homePageConfirmedCases { return Intl.message( 'Kasus COVID-19 yang terkonfirmasi di Indonesia', name: 'homePageConfirmedCases', desc: '', args: [], ); } String get licensesPageTitle { return Intl.message( 'Lisensi Open-Source', name: 'licensesPageTitle', desc: '', args: [], ); } String get licencesPageTitle { return Intl.message( 'Lisensi Open-Source', name: 'licencesPageTitle', desc: '', args: [], ); } String get protocolPageTitle { return Intl.message( 'Protokol', name: 'protocolPageTitle', desc: '', args: [], ); } String get noConnection { return Intl.message( 'Tidak ada koneksi', name: 'noConnection', desc: '', args: [], ); } String get buttonTryAgain { return Intl.message( 'Coba lagi', name: 'buttonTryAgain', desc: '', args: [], ); } String get cannotConnectInternetDescription { return Intl.message( 'Kami tidak dapat mengakses Internet untuk mendapatkan data terbaru. Periksa koneksi Anda.', name: 'cannotConnectInternetDescription', desc: '', args: [], ); } } class AppLocalizationDelegate extends LocalizationsDelegate<S> { const AppLocalizationDelegate(); List<Locale> get supportedLocales { return const <Locale>[ Locale.fromSubtags(languageCode: 'en'), ]; } @override bool isSupported(Locale locale) => _isSupported(locale); @override Future<S> load(Locale locale) => S.load(locale); @override bool shouldReload(AppLocalizationDelegate old) => false; bool _isSupported(Locale locale) { if (locale != null) { for (Locale supportedLocale in supportedLocales) { if (supportedLocale.languageCode == locale.languageCode) { return true; } } } return false; } }
0
mirrored_repositories/info_covid-19/lib/generated
mirrored_repositories/info_covid-19/lib/generated/intl/messages_en.dart
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart // This is a library that provides messages for a en locale. All the // messages from the main program should be duplicated here with the same // function name. // Ignore issues from commonly used lints in this file. // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; final messages = new MessageLookup(); typedef String MessageIfAbsent(String messageStr, List<dynamic> args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; final messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => <String, Function> { "buttonTryAgain" : MessageLookupByLibrary.simpleMessage("Coba lagi"), "cannotConnectInternetDescription" : MessageLookupByLibrary.simpleMessage("Kami tidak dapat mengakses Internet untuk mendapatkan data terbaru. Periksa koneksi Anda."), "checkDetails" : MessageLookupByLibrary.simpleMessage("Lihat detail"), "contactsPageMNEEmail" : MessageLookupByLibrary.simpleMessage("0318430313"), "contactsPageMNEEmailText" : MessageLookupByLibrary.simpleMessage("Pusat Informasi Covid-19 Provinsi Jawa Timur"), "contactsPageMNENumber" : MessageLookupByLibrary.simpleMessage("0243580713"), "contactsPageMNENumberText" : MessageLookupByLibrary.simpleMessage("Hotline Dinas Kesehatan Provinsi Jawa Tengah"), "contactsPageMSWeb" : MessageLookupByLibrary.simpleMessage("08112093306"), "contactsPageMSWebText" : MessageLookupByLibrary.simpleMessage("Hotline Dinas Kesehatan Provinsi Jawa Barat"), "contactsPageSNSEmail" : MessageLookupByLibrary.simpleMessage("0274 555585"), "contactsPageSNSEmailText" : MessageLookupByLibrary.simpleMessage("Hotline Covid-19 Provinsi DI Yogyakarta"), "contactsPageSNSNumber" : MessageLookupByLibrary.simpleMessage("119"), "contactsPageSNSNumberText" : MessageLookupByLibrary.simpleMessage("Panggilan Darurat"), "contactsPageSSNumber" : MessageLookupByLibrary.simpleMessage("081388376955"), "contactsPageSSNumberText" : MessageLookupByLibrary.simpleMessage("Hotline Dinas Kesehatan Provinsi DKI Jakarta"), "contactsPageTitle" : MessageLookupByLibrary.simpleMessage("Kontak Penting"), "defaultError" : MessageLookupByLibrary.simpleMessage("Sebuah kesalahan terjadi"), "faqPageResponsableEntity" : MessageLookupByLibrary.simpleMessage("Sumber"), "faqPageTitle" : MessageLookupByLibrary.simpleMessage("Tanya Jawab"), "homePageConfirmedCases" : MessageLookupByLibrary.simpleMessage("Kasus COVID-19 yang terkonfirmasi di Indonesia"), "homePageTitle" : MessageLookupByLibrary.simpleMessage("Informasi Covid-19"), "lastUpdated" : MessageLookupByLibrary.simpleMessage("Data per: "), "licencesPageTitle" : MessageLookupByLibrary.simpleMessage("Lisensi Open-Source"), "licensesPageTitle" : MessageLookupByLibrary.simpleMessage("Lisensi Open-Source"), "noConnection" : MessageLookupByLibrary.simpleMessage("Tidak ada koneksi"), "notificationsPageDescription" : MessageLookupByLibrary.simpleMessage("Notifikasi terkait informasi penting tentang pembaharuan data yang terkandung dalam aplikasi ini dan dari entitas resmi."), "notificationsPageOpenSettings" : MessageLookupByLibrary.simpleMessage("Buka pengaturan"), "notificationsPagePermissionsMissing" : MessageLookupByLibrary.simpleMessage("Harap diberikan izin untuk mengaktifkan notifikasi."), "notificationsPageReceiveNotifcations" : MessageLookupByLibrary.simpleMessage("Notifikasi"), "protocolPageTitle" : MessageLookupByLibrary.simpleMessage("Protokol"), "screenAboutBuilt" : MessageLookupByLibrary.simpleMessage(""), "screenAboutButtonOpenSource" : MessageLookupByLibrary.simpleMessage("Lisensi Open-Source"), "screenAboutButtonReport" : MessageLookupByLibrary.simpleMessage("Laporkan Masalah"), "screenAboutContent1" : MessageLookupByLibrary.simpleMessage("Aplikasi Info Covid-19 dibuat untuk memberikan informasi terkini terkait Covid-19 di Indonesia."), "screenAboutContent2" : MessageLookupByLibrary.simpleMessage("Sumber data diambil dari https://kawalcorona.com/ yang menyediakan data kasus Covid-19 secara realtime dan terpercaya."), "screenAboutContent3" : MessageLookupByLibrary.simpleMessage("Berita dan informasi terkait Covid-19 diambil dari sumber yang terpercaya yaitu https://www.covid19.go.id/."), "screenAboutContent4" : MessageLookupByLibrary.simpleMessage("Video diambil dari kanal Youtube Presiden Joko Widodo yang berkaitan dengan penanganan Covid-19."), "screenAboutContent5" : MessageLookupByLibrary.simpleMessage(""), "screenAboutFooter1" : MessageLookupByLibrary.simpleMessage("Info Covid-19 © 2020 Benidiktus BT"), "screenAboutFooter2" : MessageLookupByLibrary.simpleMessage("Email: [email protected]"), "screenAboutHashtag" : MessageLookupByLibrary.simpleMessage("#InfoCovid-19"), "screenAboutTitle" : MessageLookupByLibrary.simpleMessage("Tentang Aplikasi"), "screenNotificationsTitle" : MessageLookupByLibrary.simpleMessage("Notifikasi"), "screenVideosTitle" : MessageLookupByLibrary.simpleMessage("Video"), "statisticsPageAwaitingResults" : MessageLookupByLibrary.simpleMessage("Menunggu Hasil"), "statisticsPageConfirmed" : MessageLookupByLibrary.simpleMessage("Positif"), "statisticsPageDataLabel" : MessageLookupByLibrary.simpleMessage("Data dari Kawal Corona"), "statisticsPageDeath" : MessageLookupByLibrary.simpleMessage("Meninggal"), "statisticsPageRecovered" : MessageLookupByLibrary.simpleMessage("Sembuh"), "statisticsPageStatistics" : MessageLookupByLibrary.simpleMessage("Statistik"), "statisticsPageSuspects" : MessageLookupByLibrary.simpleMessage("Suspek") }; }
0
mirrored_repositories/info_covid-19/lib/generated
mirrored_repositories/info_covid-19/lib/generated/intl/messages_all.dart
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart // This is a library that looks up messages for specific locales by // delegating to the appropriate library. // Ignore issues from commonly used lints in this file. // ignore_for_file:implementation_imports, file_names, unnecessary_new // ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering // ignore_for_file:argument_type_not_assignable, invalid_assignment // ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases // ignore_for_file:comment_references import 'dart:async'; import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; import 'messages_en.dart' as messages_en; typedef Future<dynamic> LibraryLoader(); Map<String, LibraryLoader> _deferredLibraries = { 'en': () => new Future.value(null), }; MessageLookupByLibrary _findExact(String localeName) { switch (localeName) { case 'en': return messages_en.messages; default: return null; } } /// User programs should call this before using [localeName] for messages. Future<bool> initializeMessages(String localeName) async { var availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new Future.value(false); } var lib = _deferredLibraries[availableLocale]; await (lib == null ? new Future.value(false) : lib()); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); return new Future.value(true); } bool _messagesExistFor(String locale) { try { return _findExact(locale) != null; } catch (e) { return false; } } MessageLookupByLibrary _findGeneratedMessagesFor(String locale) { var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/utils/launch_url.dart
import 'package:url_launcher/url_launcher.dart'; launchURL(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/ui/app.dart
import 'dart:io'; import 'package:covid/bloc/app_bloc.dart'; import 'package:covid/generated/l10n.dart'; import 'package:covid/providers/faq_category_provider.dart'; import 'package:covid/providers/faq_provider.dart'; import 'package:covid/providers/notifications_provider.dart'; import 'package:covid/providers/slider_provider.dart'; import 'package:covid/providers/stats_provider.dart'; import 'package:covid/providers/videos_provider.dart'; import 'package:covid/providers/detail_stats_provider.dart'; import 'package:covid/providers/protocol_provider.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/resources/custom_localization.dart'; import 'package:covid/resources/style/themes.dart'; import 'package:covid/ui/screens/about/about_page.dart'; import 'package:covid/ui/screens/contacts/contacts_page.dart'; import 'package:covid/ui/screens/faqs/faqs_page.dart'; import 'package:covid/ui/screens/faqs_details/faq_details_page.dart'; import 'package:covid/ui/screens/home/home_page.dart'; import 'package:covid/ui/screens/notifications/notifications_page.dart'; import 'package:covid/ui/screens/protocol/protocol_document.dart'; import 'package:covid/ui/screens/splash/splash_page.dart'; import 'package:covid/ui/screens/statistics/statistics_page.dart'; import 'package:covid/ui/screens/video_player/video_player_page.dart'; import 'package:covid/ui/screens/videos/videos_page.dart'; import 'package:covid/ui/screens/protocol/protocol_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:logger/logger.dart'; import 'package:provider/provider.dart'; import 'package:package_info/package_info.dart'; /// Used to log all the events happening final Logger logger = Logger(printer: PrettyPrinter(methodCount: 0)); /// Starting class for the project class CovidApp extends StatelessWidget { final AppBloc appBloc = AppBloc(); final statsProvider = StatsProvider(); final faqProvider = FaqProvider(); final videosProvider = VideosProvider(); final notificationsProvider = NotificationsProvider(); final sliderProvider = SliderProvider(); final faqsCategoryProvider = FaqCategoryProvider(); final detailStatsProvider = DetailStatsProvider(); final protocolProvider = ProtocolProvider(); @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); String appVersion = ''; /// If is an Android then change the status bar color /// to dark and text to white if (Platform.isAndroid) { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.light )); } PackageInfo.fromPlatform().then((PackageInfo packageInfo) { appVersion = packageInfo.version + '+' + packageInfo.buildNumber; }); return MultiProvider( providers: [ Provider<AppBloc>.value(value: appBloc), ProxyProvider<AppBloc, SplashBloc>( update: (_, __, splashBloc) => SplashBloc(appBloc), ), ChangeNotifierProvider<StatsProvider>.value(value: statsProvider), ChangeNotifierProvider<FaqProvider>.value(value: faqProvider), ChangeNotifierProvider<VideosProvider>.value( value: videosProvider, ), ChangeNotifierProvider<NotificationsProvider>.value( value: notificationsProvider, ), ChangeNotifierProvider<SliderProvider>.value( value: sliderProvider, ), ChangeNotifierProvider<FaqCategoryProvider>.value( value: faqsCategoryProvider, ), ChangeNotifierProvider<DetailStatsProvider>.value( value: detailStatsProvider, ), ChangeNotifierProvider<ProtocolProvider>.value( value: protocolProvider, ), ], child: MaterialApp( title: 'Info Covid-19', localizationsDelegates: [ S.delegate, LicensesPageTitleTextLocalDelegate(context), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], theme: Themes.defaultAppTheme, debugShowCheckedModeBanner: false, initialRoute: routeSplash, onGenerateRoute: (settings) { var page; switch (settings.name) { case routeSplash: page = SplashPage(); break; case routeHome: page = HomePage(title: 'Info Covid-19'); break; case routeStatistics: page = StatisticsPage(); break; case routeContacts: page = ContactsPage(); break; case routeProtocol: page = ProtocolPage(title: 'Protokol'); break; case routeProtocolDocument: page = ProtocolDocumentPage(url: settings.arguments); break; case routeFaqs: page = FaqsPage(title: 'Tanya Jawab'); break; case routeFaqsDetails: page = FaqsDetails(title: 'Tanya Jawab', faqs: settings.arguments); break; case routeVideos: page = VideosPage(title: 'Video'); break; case routeAbout: page = AboutPage(); break; case routeVideoPlayer: page = VideoPlayerPage(); break; case routeNotifications: page = NotificationsPage(); break; case routeLicences: page = LicensePage( applicationName: 'Info Covid-19', applicationVersion: appVersion, applicationIcon: Image.asset("assets/icons/icon_small.png", height: 100, width: 100,), ); break; } return CupertinoPageRoute(builder: (_) => page, settings: settings); }, ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/brand.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; class Brand extends StatelessWidget { @override Widget build(BuildContext context) { return RichText( text: TextSpan( children: <TextSpan>[ TextSpan( text: '#COVID19', style: TextStyle( color: Covid19Colors.red, fontSize: 24.0, ), ), TextSpan( text: 'PT', style: TextStyle( color: Covid19Colors.green, fontSize: 24.0, ), ), ], ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/card_faq.dart
/* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ import 'package:flutter/material.dart'; class CardFAQ extends StatelessWidget { final String text; final String targetRoute; CardFAQ(this.text, this.targetRoute); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.pushNamed(context, targetRoute); }, child: Card( color: Colors.blue, child: Padding( padding: EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Expanded( child: Text( text, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), ), ), Icon( Icons.arrow_forward, size: 30, ) ], ), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/initiatives_item.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/screens/home/components/accordion.dart'; import 'package:covid/utils/launch_url.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:flutter/material.dart'; import 'package:html/dom.dart' as dom; class InitiativesItem extends StatelessWidget { final String title; final String body; final Function(bool) onExpansionChanged; const InitiativesItem( {Key key, this.title, this.body, this.onExpansionChanged}) : super(key: key); @override Widget build(BuildContext context) { return Accordion( key: key, withBorder: false, title: title, contentPadding: const EdgeInsets.only(left: 12, right: 17), padding: const EdgeInsets.all(0.0), margin: const EdgeInsets.all(0.0), childrenPadding: const EdgeInsets.only(left: 12, right: 12), titleTextStyle: Theme.of(context) .textTheme .display3 .copyWith(color: Covid19Colors.green), onExpansionChanged: onExpansionChanged, children: <Widget>[ Html( useRichText: true, data: body.replaceAll("\\n", ""), backgroundColor: Colors.white, defaultTextStyle: Theme.of(context).textTheme.body1, onLinkTap: launchURL, linkStyle: Theme.of(context) .textTheme .body1 .copyWith(color: Theme.of(context).primaryColor), customRender: (node, children) { if (node is dom.Element) { switch (node.localName) { case "custom_tag": return Column(children: children); } } return null; }) ], ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/header_main.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; import 'brand.dart'; class HeaderMain extends StatelessWidget { @override Widget build(BuildContext context) { return Row( children: <Widget>[ Padding( padding: const EdgeInsets.all(8), child: Brand(), ), ], ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/header_tabs.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; class HeaderTabs extends StatelessWidget { final String tab0Text; final Widget tab0Widget; final String tab1Text; final Widget tab1Widget; HeaderTabs(this.tab0Text, this.tab0Widget, this.tab1Text, this.tab1Widget); @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: Scaffold( appBar: AppBar( flexibleSpace: TabBar( tabs: [ Center( child: Text( tab0Text.toUpperCase(), textAlign: TextAlign.center, ), ), Center( child: Text( tab1Text.toUpperCase(), textAlign: TextAlign.center, ), ), ], ), ), body: TabBarView( children: [ tab0Widget, tab1Widget, ], ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/card_files_link.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class CardFilesLink extends StatelessWidget { final String text; final String link; CardFilesLink(this.text, this.link); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { _launchUrl(link); }, child: Card( color: Covid19Colors.green, child: Card( color: Colors.white, child: Padding( padding: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Expanded( child: Text( text, style: TextStyle( color: Covid19Colors.green, fontSize: 18, ), ), ), Icon( Icons.arrow_forward, size: 30, color: Covid19Colors.green, ) ], ), ), ), ), ); } _launchUrl(String link) async { if (await canLaunch(link)) { await launch(link); } else { throw 'Cannot launch $link'; } } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/card_next.dart
/* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ import 'package:flutter/material.dart'; class CardNext extends StatelessWidget { final String text; final String targetRoute; CardNext(this.text, this.targetRoute); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.pushNamed(context, targetRoute); }, child: Card( color: Colors.teal, child: Card( color: Colors.white, child: Padding( padding: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Expanded( child: Text( text.toUpperCase(), style: TextStyle( fontSize: 18, ), ), ), Icon( Icons.arrow_forward, size: 30, ) ], ), ), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/separator.dart
import 'package:covid/ui/assets/dimensions.dart'; import 'package:flutter/material.dart'; import '../assets/colors.dart'; class Separator extends StatelessWidget { Separator({Key key, Color color}) : _color = color ?? Covid19Colors.green, super(key: key); final Color _color; @override Widget build(BuildContext context) { return Divider( color: _color, endIndent: identMargin, indent: identMargin, thickness: 2.0, ); } } class ListSeparator extends StatelessWidget { ListSeparator({Key key, Color color}) : _color = color ?? Covid19Colors.green, super(key: key); final Color _color; @override Widget build(BuildContext context) { return Divider( color: _color, thickness: 2.0, ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/button_background.dart
import 'package:flutter/material.dart'; class ButtonBackground extends StatelessWidget { final Color color; final Widget child; final double border; const ButtonBackground({ Key key, this.color, this.child, this.border = 16.0, }) : super(key: key); @override Widget build(BuildContext context) { return Ink( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(4.0), ), color: color, ), padding: EdgeInsets.all(border), child: child, ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/statistics_number_small.dart
import 'package:flutter/material.dart'; class StatisticsNumberSmall extends StatelessWidget { final int value; final String text; StatisticsNumberSmall(this.value, this.text); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Card( color: Colors.black, child: Card( child: Padding( padding: const EdgeInsets.all(4), child: Text( value.toString().toUpperCase(), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), ), ), ), Text( text, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, ), ) ], ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/loading.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; class Loading extends StatelessWidget { const Loading({Key key}) : super(key: key); @override Widget build(BuildContext context) { return Center(child: CircularProgressIndicator()); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/card_video.dart
import 'package:covid/resources/style/text_styles.dart'; import 'package:flutter/material.dart'; class CardVideo extends StatelessWidget { const CardVideo({ Key key, @required this.backgroundUrl, this.onPressed, this.label, this.labelAlignment = Alignment.bottomCenter, }) : super(key: key); final String backgroundUrl; final String label; final Alignment labelAlignment; final VoidCallback onPressed; @override Widget build(BuildContext context) { final decoration = backgroundUrl == null ? BoxDecoration( borderRadius: BorderRadius.circular(4.0), color: Theme.of(context).primaryColor, ) : BoxDecoration( borderRadius: BorderRadius.circular(4.0), image: DecorationImage( image: NetworkImage(backgroundUrl), fit: BoxFit.cover, ), ); return GestureDetector( onTap: onPressed, child: Container( height: 144.0, margin: const EdgeInsets.all(5.0), padding: const EdgeInsets.all(18.0), alignment: Alignment.center, decoration: decoration, child: Stack( alignment: Alignment.center, children: <Widget>[ Container( width: 38.0, height: 38.0, decoration: BoxDecoration( shape: BoxShape.circle, color: Theme.of(context).primaryColor, ), ), ButtonTheme( minWidth: 0.0, shape: const CircleBorder(), padding: EdgeInsets.zero, buttonColor: Colors.transparent, splashColor: Colors.transparent, highlightColor: Colors.transparent, child: RaisedButton( elevation: 4.0, onPressed: onPressed, disabledColor: Colors.transparent, child: Icon( Icons.play_circle_filled, size: 48.0, color: onPressed != null ? Theme.of(context).textTheme.button.color : Theme.of(context).disabledColor, ), ), ), if (label != null) Align( alignment: labelAlignment, child: Text( label, style: TextStyles.subtitle(color: Colors.white) .copyWith(shadows: [ const Shadow( offset: Offset(0.0, 1.0), blurRadius: 3.0, ), ]), ), ), ], ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/card_border_arrow.dart
import 'package:covid/resources/icons_svg.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; import 'button_border_background.dart'; class CardBorderArrow extends StatelessWidget { final String text; final Color borderColor; final Color textColor; final VoidCallback callback; final Color color; const CardBorderArrow({ Key key, @required this.text, @required this.callback, @required this.textColor, Color color, this.borderColor, }) : color = color ?? Covid19Colors.white, super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: callback, child: ButtonBorderBackground( borderColor: borderColor ?? textColor, color: color, child: Row( children: <Widget>[ Expanded( child: Text( text.toUpperCase(), style: Theme.of(context) .textTheme .display3 .copyWith(color: textColor), ), ), SvgIcons.linkSvg( color: textColor, ), ], ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/statistics_border.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; class StatisticsBorder extends StatelessWidget { final Color color; final Text text; const StatisticsBorder({Key key, this.color, this.text}) : super(key: key); @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(4.0), ), border: Border.all( color: color, width: 2.0, ), ), padding: EdgeInsets.all(4.0), child: text, ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/button_border_background.dart
import 'package:flutter/material.dart'; class ButtonBorderBackground extends StatelessWidget { final Color color; final Color borderColor; final Widget child; const ButtonBorderBackground( {Key key, this.color, this.borderColor, this.child}) : super(key: key); @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( color: color, borderRadius: BorderRadius.all( Radius.circular(4.0), ), border: Border.all( color: borderColor, width: 2.0, ), ), padding: EdgeInsets.all(16.0), child: child, ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/statistics_number_big.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; class StatisticsNumberBig extends StatelessWidget { final int value; final String text; StatisticsNumberBig(this.value, this.text); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Card( color: Colors.black, child: Card( child: Padding( padding: const EdgeInsets.all(4), child: Text( value.toString().toUpperCase(), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 28, ), ), ), ), ), Text( text, style: TextStyle(fontSize: 18), ) ], ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/html_content.dart
import 'package:covid/utils/launch_url.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; class HtmlContent extends StatelessWidget { final String content; const HtmlContent({Key key, @required this.content}) : super(key: key); @override Widget build(BuildContext context) { return Html( data: content, backgroundColor: Colors.white, onLinkTap: launchURL, defaultTextStyle: Theme.of(context).textTheme.body1, linkStyle: Theme.of(context) .textTheme .body1 .copyWith(color: Theme.of(context).primaryColor), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/widgets/play_button.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; class PlayButton extends StatelessWidget { @override Widget build(BuildContext context) { return Container( height: 48, margin: EdgeInsets.only( left: 8, right: 8, ), decoration: BoxDecoration( color: Colors.white, ), child: Container( height: 18.098360061645508, margin: EdgeInsets.only( left: 26.88525390625, right: 26.88525390625, ), decoration: BoxDecoration( color: Covid19Colors.green, borderRadius: BorderRadius.circular(1), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/core/base_stream_service_screen_page.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../bloc/base_bloc.dart'; /// Base abstract class that extends [StatefulWidget] abstract class BasePage extends StatefulWidget { /// Class Constructor /// /// [key] is optional BasePage({Key key}) : super(key: key); } /// BaseStreamServiceScreenPage receives an [Bloc] instance /// /// this will create a listener for every stream events pushed /// into the [StreamSubscription] /// /// then it will call [onStateListener] with the result stream /// of the type [ResultStream] /// /// on dispose from parent class will cancel the [StreamSubscription] /// mixin BaseStreamServiceScreenPage<B extends Bloc> { B _bloc; B get bloc => _bloc; Stream<ResultStream> get onStateListener; StreamSubscription _streamSubscription; StreamSubscription get streamSubscription => _streamSubscription; void _listen(Bloc bloc) { if (onStateListener == null) { return; } _streamSubscription = onStateListener.listen(onStateResultListener); } /// Receive the streams void onStateResultListener(ResultStream result); /// Calls initBloc as soon the Bloc instance of type [B] /// is ready to be used void initBloc(B bloc); void _dispose() { _streamSubscription?.cancel(); } } /// [BaseState] abstract class that receives two types: /// [Page] extends a [BasePage] /// and [B] extends a [Bloc] /// /// that will extends the State, The logic and internal /// state for a [StatefulWidget]. /// /// * The [didChangeDependencies] method will be called again if the /// inherited widgets subsequently change or if the widget moves in the tree. /// /// Get the instance Provider Bloc and call [_listen] to listen to /// the Stream changes /// /// if the Provider Bloc if different from the [_bloc] /// updates to use the new instance of the Provider /// abstract class BaseState<Page extends BasePage, B extends Bloc> extends State<Page> with BaseStreamServiceScreenPage<B> { @override void didChangeDependencies() { super.didChangeDependencies(); /// Gets the Bloc instance final bloc = Provider.of<B>(context, listen: false); if (bloc != _bloc) { _dispose(); _bloc = bloc; initBloc(_bloc); _listen(bloc); } } @override void dispose() { _dispose(); super.dispose(); } }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/assets/images.dart
const String imageCcIcons = "assets/cc_icons.png"; const String logoInfoCovid = "assets/logo_info_covid.png"; const String connectionError = "assets/illustration_error.png";
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/assets/colors.dart
import 'package:flutter/widgets.dart'; /// Style colors for this project, to be use widely in the project class Covid19Colors { /// Green is the main color for the ap static const Color green = Color(0xff358f9a); /// Green with 50% Transparency static const Color green50 = Color(0x80358f9a); /// Color to be used mostly in important messages static const Color red = Color(0xffce3d40); /// Mostly used in backgrounds static const Color lightGrey = Color(0xfff5f7fa); /// For certain letter colors static const Color darkGrey = Color(0xff404040); /// For certain letter colors static const Color darkGreyLight = Color(0xff2d2d2e); /// Mostly used in backgrounds static const Color grey = Color(0xffbcbcbc); /// White color, plane and FFF static const Color white = Color(0xffffffff); /// Used less but equaly importante static const Color blue = Color(0xff1637cf); /// Stats blue static const Color statsBlue = Color(0xffd7e5fa); /// Stats green static const Color statsGreen = Color(0xffe5f5e3); /// Stats red static const Color statsRed = Color(0xfff9e8e6); /// Stats yellow static const Color statsYellow = Color(0xfffaecd8); /// Stats grey static const Color statsGrey = Color(0xffeceef0); /// Contact Card Background Color grey static const Color contactCardBackgroundGrey = Color(0xffeceef0); /// For use in list separator static const Color lightGreyLight = Color(0xffeceef0); }
0
mirrored_repositories/info_covid-19/lib/ui
mirrored_repositories/info_covid-19/lib/ui/assets/dimensions.dart
const identMargin = 10.0; const tabIndicatorMagin = 20.0; const tabIndicatorWeight = 4.0; const marginVidCloseBt = 10.0;
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/statistics/statistics_page.dart
import 'package:covid/bloc/app_bloc.dart'; import 'package:covid/bloc/base_bloc.dart'; import 'package:covid/generated/l10n.dart'; import 'package:covid/providers/detail_stats_provider.dart'; import 'package:covid/model/detail_stats_model.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:covid/ui/screens/statistics/components/stats_widget.dart'; import 'package:covid/ui/widgets/loading.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:expandable/expandable.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; const _itemsMargin = 8.0; class StatisticsPage extends BasePage { @override _StatisticsPageState createState() => _StatisticsPageState(); } class _StatisticsPageState extends BaseState<StatisticsPage, AppBloc> { List<DetailStatsModel> _detailStats = []; final ScrollController scrollController = ScrollController(); RefreshController _refreshController = RefreshController(initialRefresh: false); void _onRefresh() async{ bloc.getDetailStats(); await Future.delayed(Duration(milliseconds: 1000)); _refreshController.refreshCompleted(); } void _onLoading() async{ await Future.delayed(Duration(milliseconds: 1000)); if(mounted) { setState(() { }); } _refreshController.loadComplete(); } @override Widget build(BuildContext context) { _detailStats = Provider.of<DetailStatsProvider>(context).detailStats ?? ModalRoute.of(context).settings.arguments; var hasData = _detailStats != null && _detailStats.isNotEmpty; return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( S.of(context).statisticsPageStatistics.toUpperCase(), style: Theme.of(context) .textTheme .display2 .copyWith(color: Covid19Colors.white), ), backgroundColor: Covid19Colors.blue, elevation: 0.0, ), body: hasData ? Scrollbar( child: Container( child: SmartRefresher( controller: _refreshController, onRefresh: _onRefresh, onLoading: _onLoading, header: WaterDropMaterialHeader( backgroundColor: Covid19Colors.blue, ), child: ListView.builder( physics: BouncingScrollPhysics(), controller: scrollController, itemCount: _detailStats.length, itemBuilder: (context, index) { return ExpandableNotifier( child: Padding( padding: EdgeInsets.fromLTRB(10, 10, 10, 0), child: Card( color: Covid19Colors.white, clipBehavior: Clip.antiAlias, child: Column( children: <Widget>[ ScrollOnExpand( scrollOnExpand: true, scrollOnCollapse: false, child: ExpandablePanel( theme: const ExpandableThemeData( headerAlignment: ExpandablePanelHeaderAlignment.center, tapBodyToCollapse: true, iconColor: Covid19Colors.green, ), header: Padding( padding: EdgeInsets.all(10), child: Text( _detailStats[index].province.toUpperCase(), style: Theme.of(context).textTheme.display3.copyWith( color: Covid19Colors.green, letterSpacing: 0.2 ), ) ), expanded: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Container( height: 130, child: StatsWidget( color: Covid19Colors.statsBlue, number: _detailStats[index].positiveCase, numberStyle: TextStyles.statisticsBig(color: Covid19Colors.darkGrey), text: S.of(context).statisticsPageConfirmed.toUpperCase(), textStyle: Theme.of(context) .textTheme .display1 .copyWith(color: Covid19Colors.darkGrey), ), ), const SizedBox( height: _itemsMargin, ), Container( height: 90, child: Row( children: <Widget>[ Expanded( child: StatsWidget( color: Covid19Colors.statsGreen, number: _detailStats[index].recoveredCase, numberStyle: Theme.of(context) .textTheme .display1 .copyWith(color: Covid19Colors.darkGrey), text: S.of(context).statisticsPageRecovered.toUpperCase(), textStyle: Theme.of(context) .textTheme .display4 .copyWith(color: Covid19Colors.darkGrey), ), ), const SizedBox( width: _itemsMargin, ), Expanded( child: StatsWidget( color: Covid19Colors.statsRed, number: _detailStats[index].deathCase, numberStyle: Theme.of(context) .textTheme .display1 .copyWith(color: Covid19Colors.darkGrey), text: S.of(context).statisticsPageDeath.toUpperCase(), textStyle: Theme.of(context) .textTheme .display4 .copyWith(color: Covid19Colors.darkGrey), ), ), ], ), ), const SizedBox( height: _itemsMargin, ), Container( margin: EdgeInsets.only(bottom: 10), child: Text( "${S.of(context).lastUpdated.toUpperCase()}${_detailStats[index].lastUpdated}", style: Theme.of(context) .textTheme .subtitle .copyWith(color: Covid19Colors.grey)), ), ], ), builder: (_, collapsed, expanded) { return Padding( padding: EdgeInsets.only(left: 10, right: 10), child: Expandable( collapsed: collapsed, expanded: expanded, theme: const ExpandableThemeData(crossFadePoint: 0), ), ); }, ), ) ] ), ), ), ); } ) ), ) ) : const Loading(), ); } @override void initBloc(AppBloc bloc) { var provider = Provider.of<DetailStatsProvider>(context); if (_detailStats == null || provider.detailStats == null || (provider.detailStats != null && provider.detailStats.isEmpty)) { bloc.getDetailStats(); } } @override Stream<ResultStream> get onStateListener => bloc.onListener; @override void onStateResultListener(ResultStream result) { if (result is DetailStatsResultStream) { /// Updates faqs list on the provider Provider.of<DetailStatsProvider>(context, listen: false) .setDetailStats(result.model); /// Updates videos list _detailStats = result.model; } } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/statistics
mirrored_repositories/info_covid-19/lib/ui/screens/statistics/components/stats_widget.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/widgets/button_background.dart'; import 'package:covid/ui/widgets/statistics_border.dart'; import 'package:flutter/material.dart'; class StatsWidget extends StatelessWidget { final Color color; final String number; final String text; final TextStyle numberStyle; final TextStyle textStyle; const StatsWidget( {Key key, this.color, this.number, this.text, this.numberStyle, this.textStyle}) : super(key: key); @override Widget build(BuildContext context) { return ButtonBackground( border: 0.0, color: color, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Center( child: StatisticsBorder( color: Covid19Colors.darkGrey, text: Text( number, style: numberStyle, textAlign: TextAlign.center, ), ), ), const SizedBox( height: 8.0, ), Text( text, style: textStyle, textAlign: TextAlign.center, ) ], ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/notifications/notifications_page.dart
import 'package:covid/generated/l10n.dart'; import 'package:covid/providers/notifications_provider.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:app_settings/app_settings.dart'; class NotificationsPage extends BasePage { @override _NotificationsPageState createState() => _NotificationsPageState(); } class _NotificationsPageState extends State<NotificationsPage> with WidgetsBindingObserver { Widget _buildToggleOption( BuildContext context, { String text, Function(bool) onChanged, bool value = false, bool withBorder = false, }) => DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(3.0), border: withBorder ? Border.all(color: Colors.black12) : null, ), child: ListTile( title: Text( text.toUpperCase(), style: TextStyles.h4(), ), trailing: Switch.adaptive( value: value, onChanged: onChanged, activeColor: Theme.of(context).primaryColor, ), ), ); @override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); } @override void didChangeDependencies() { super.didChangeDependencies(); Provider.of<NotificationsProvider>(context, listen: false) .checkInitialStatus(); } @override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: Provider.of<NotificationsProvider>(context, listen: false) .checkPermissions(); break; default: break; } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( S.of(context).screenNotificationsTitle.toUpperCase(), style: TextStyles.h2(color: Covid19Colors.white), ), ), body: Padding( padding: const EdgeInsets.symmetric( horizontal: 12.0, vertical: 10.0, ), child: Consumer<NotificationsProvider>( builder: (BuildContext context, NotificationsProvider provider, _) => Column( children: <Widget>[ Text(S.of(context).notificationsPageDescription), const SizedBox(height: 40.0), _buildToggleOption( context, value: provider.notifications.general ?? false, text: S.of(context).notificationsPageReceiveNotifcations, onChanged: provider.notifications.general != null ? (value) => provider.toggleNotification( channel: Channel.general, value: value) : null, withBorder: true, ), if (provider.notifications.general == null) Padding( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ Text( S.of(context).notificationsPagePermissionsMissing, style: Theme.of(context) .textTheme .subtitle .apply(color: Colors.deepOrange), ), CupertinoButton( child: Text( S.of(context).notificationsPageOpenSettings, style: Theme.of(context).textTheme.subtitle, ), onPressed: AppSettings.openNotificationSettings, ), ], ), ) //TODO: Uncomment when new options are available // _buildToggleOption( // context, // text: S.of(context).notificationsPageReceiveStats, // value: false, // ), // _buildToggleOption( // context, // text: S.of(context).notificationsPageReceiveMeasures, // value: false, // ), // _buildToggleOption( // context, // text: S.of(context).notificationsPageReceiveQuestions, // value: false, // ), // _buildToggleOption( // context, // text: S.of(context).notificationsPageReceiveOther, // value: false, // ), ], ), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/videos/videos_page.dart
import 'package:covid/bloc/app_bloc.dart'; import 'package:covid/bloc/base_bloc.dart'; import 'package:covid/model/video_model.dart'; import 'package:covid/providers/videos_provider.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:covid/ui/widgets/card_video.dart'; import 'package:covid/ui/widgets/loading.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class VideosPage extends BasePage { /// Faqs page view VideosPage({Key key, this.title}) : super(key: key); /// Title of the page view final String title; @override _VideosPageState createState() => _VideosPageState(); } class _VideosPageState extends BaseState<VideosPage, AppBloc> { /// For the initial list of faqs List<VideoModel> _videos = []; @override Widget build(BuildContext context) { /// Gets all faqs from the Provider or the Modal Route arguments /// /// If pushing from home and faqs have initial data /// In case of no initial data reverts to fetch faqs /// and update with the Provider _videos = Provider.of<VideosProvider>(context).videos ?? ModalRoute.of(context).settings.arguments; /// Check if have any data to present, if not show [CircularProgressIndicator] /// while wait for data var hasData = _videos != null && _videos.isNotEmpty; return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( widget.title.toUpperCase(), style: TextStyles.h2(color: Covid19Colors.white), ), ), body: Container( child: hasData ? ListView.separated( physics: BouncingScrollPhysics(), itemBuilder: (context, index) => CardVideo( backgroundUrl: _videos[index].getVideoThumbnail(), label: _videos[index].postTitle, onPressed: () => Navigator.of(context).pushNamed( routeVideoPlayer, arguments: _videos[index].getVideoId()), labelAlignment: Alignment.topLeft, ), separatorBuilder: (_, __) { return const SizedBox( height: 12.0, ); }, itemCount: _videos != null ? _videos.length : 0) : const Loading(), ), ); } @override void initBloc(AppBloc bloc) { /// In case [_faqs] is null then fetch if again var provider = Provider.of<VideosProvider>(context); if (_videos == null || provider.videos == null || (provider.videos != null && provider.videos.isEmpty)) { bloc.getVideos(); } } @override Stream<ResultStream> get onStateListener => bloc.onListener; @override void onStateResultListener(ResultStream result) { if (result is VideosResultStream) { /// Updates faqs list on the provider Provider.of<VideosProvider>(context, listen: false) .setVideos(result.model); /// Updates videos list _videos = result.model; } } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/about/about_page.dart
import 'package:covid/generated/l10n.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/widgets/card_border_arrow.dart'; import 'package:flutter/material.dart'; class AboutPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Covid19Colors.white, appBar: AppBar( elevation: 0.0, iconTheme: Theme.of(context).iconTheme.copyWith( color: Covid19Colors.white, ), backgroundColor: Covid19Colors.blue, title: Text( S.of(context).screenAboutTitle.toUpperCase(), style: Theme.of(context) .textTheme .title .copyWith(color: Covid19Colors.white), ), ), body: ListView( children: <Widget>[ Container( color: Colors.white, padding: EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Text( S.of(context).screenAboutContent1, style: Theme.of(context) .textTheme .body1 .copyWith(color: Covid19Colors.darkGrey), textAlign: TextAlign.left, ), const _TextMargin(), Text( S.of(context).screenAboutContent2, style: Theme.of(context) .textTheme .body1 .copyWith(color: Covid19Colors.darkGrey), textAlign: TextAlign.left, ), const _TextMargin(), Text( S.of(context).screenAboutContent3, style: Theme.of(context) .textTheme .body1 .copyWith(color: Covid19Colors.darkGrey), textAlign: TextAlign.left, ), const _TextMargin(), Text( S.of(context).screenAboutContent4, style: Theme.of(context) .textTheme .body1 .copyWith(color: Covid19Colors.darkGrey), textAlign: TextAlign.left, ), /* const _TextMargin(), Text( S.of(context).screenAboutContent5, style: Theme.of(context) .textTheme .body1 .copyWith(color: Covid19Colors.darkGrey), textAlign: TextAlign.left, ), */ const _TextMargin(), Text( S.of(context).screenAboutHashtag, style: Theme.of(context).textTheme.body1.copyWith( color: Covid19Colors.darkGrey, fontWeight: FontWeight.w900, ), textAlign: TextAlign.left, ), const _TextMargin(), /* const _TextMargin(), Text( S.of(context).screenAboutBuilt, style: Theme.of(context).textTheme.body1.copyWith( color: Covid19Colors.darkGrey, ), textAlign: TextAlign.left, ), const SizedBox( height: 22.0, ), CardBorderArrow( text: S.of(context).screenAboutButtonReport, callback: () => print("yey"), textColor: Covid19Colors.darkGrey, borderColor: Covid19Colors.grey, ), */ const _FooterMargin(), CardBorderArrow( text: S.of(context).screenAboutButtonOpenSource, callback: () => Navigator.of(context).pushNamed(routeLicences), textColor: Covid19Colors.darkGrey, borderColor: Covid19Colors.grey, ), ], ), ), Container( color: Covid19Colors.white, child: Padding( padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 24.0, ), child: Column( children: <Widget>[ Text( S.of(context).screenAboutFooter1, style: Theme.of(context).textTheme.subtitle.copyWith( color: Covid19Colors.darkGrey, ), textAlign: TextAlign.center, ), Text( S.of(context).screenAboutFooter2, style: Theme.of(context).textTheme.subtitle.copyWith( color: Covid19Colors.darkGrey, ), textAlign: TextAlign.center, ), const _FooterMargin(), ], ), ), ) ], )); } } class _TextMargin extends StatelessWidget { const _TextMargin({Key key}) : super(key: key); @override Widget build(BuildContext context) { return const SizedBox( height: 8.0, ); } } class _FooterMargin extends StatelessWidget { const _FooterMargin({Key key}) : super(key: key); @override Widget build(BuildContext context) { return const SizedBox( height: 18.0, ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/about/licences_page.dart
import 'dart:async'; import 'package:covid/generated/l10n.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:flutter/material.dart'; class LicencesPage extends StatelessWidget { Future<String> loadAsset() async { return await rootBundle.loadString('assets/licence.txt'); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Covid19Colors.white, appBar: AppBar( elevation: 0.0, iconTheme: Theme.of(context).iconTheme.copyWith( color: Covid19Colors.white, ), backgroundColor: Covid19Colors.blue, title: Text( S.of(context).licencesPageTitle.toUpperCase(), style: Theme.of(context) .textTheme .title .copyWith(color: Covid19Colors.white), ), ), body: FutureBuilder( future: loadAsset(), builder: (context, snapshot) { if (snapshot.hasData) { return Text(snapshot.data); } return Text(""); }, )); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/contacts/contacts_page.dart
import 'package:covid/generated/l10n.dart'; import 'package:covid/model/contact_model.dart'; import 'package:covid/resources/icons_svg.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/screens/contacts/components/contact_card.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class ContactsPage extends StatefulWidget { @override _ContactsPageState createState() => _ContactsPageState(); } class _ContactsPageState extends State<ContactsPage> { final List<ContactModel> _contacts = <ContactModel>[]; @override Widget build(BuildContext context) { if (_contacts.isEmpty) { _initContacts(); } return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( S.of(context).contactsPageTitle.toUpperCase(), style: Theme.of(context) .textTheme .display2 .copyWith(color: Covid19Colors.white), ), backgroundColor: Covid19Colors.blue, elevation: 0.0, ), body: Container( margin: EdgeInsets.all(12.0), child: ListView.builder( itemCount: _contacts.length, itemBuilder: (context, index) { var contact = _contacts[index]; return ContactCard( contact: contact, onTap: _onContactTap, ); }), ), ); } _initContacts() { _contacts ..add(ContactModel( contactType: ContactType.phone, title: S.of(context).contactsPageSNSNumber, description: S.of(context).contactsPageSNSNumberText, icon: SvgIcons.phoneSvg)) ..add(ContactModel( contactType: ContactType.phone, title: S.of(context).contactsPageSSNumber, description: S.of(context).contactsPageSSNumberText, icon: SvgIcons.phoneSvg)) ..add(ContactModel( contactType: ContactType.phone, title: S.of(context).contactsPageMNENumber, description: S.of(context).contactsPageMNENumberText, icon: SvgIcons.phoneSvg)) ..add(ContactModel( contactType: ContactType.phone, title: S.of(context).contactsPageMSWeb, description: S.of(context).contactsPageMSWebText, icon: SvgIcons.phoneSvg)) ..add(ContactModel( contactType: ContactType.phone, title: S.of(context).contactsPageSNSEmail, description: S.of(context).contactsPageSNSEmailText, icon: SvgIcons.phoneSvg)) ..add(ContactModel( contactType: ContactType.phone, title: S.of(context).contactsPageMNEEmail, description: S.of(context).contactsPageMNEEmailText, icon: SvgIcons.phoneSvg)); } _onContactTap(ContactModel contact) { switch (contact.contactType) { case ContactType.phone: _launch("tel:${contact.title.replaceAll(RegExp(r'[^0-9+]'), '')}"); break; case ContactType.link: var urlToOpen = contact.title; if (!(contact.title.startsWith("https://") || contact.title.startsWith("http://"))) { urlToOpen = "https://${contact.title}"; } _launch(urlToOpen); break; case ContactType.email: _launch("mailto: ${contact.title}"); break; } } _launch(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/contacts
mirrored_repositories/info_covid-19/lib/ui/screens/contacts/components/contact_card.dart
import 'package:covid/model/contact_model.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class ContactCard extends StatelessWidget { const ContactCard({Key key, @required this.contact, @required this.onTap}) : super(key: key); final ContactModel contact; final Function(ContactModel) onTap; @override Widget build(BuildContext context) { assert(contact != null, 'contact cannot be null'); return Theme( data: Theme.of(context).copyWith( dividerColor: Colors.transparent, ), child: Card( color: Covid19Colors.contactCardBackgroundGrey, elevation: 0.0, margin: const EdgeInsets.symmetric(vertical: 4.0), child: ListTileTheme( contentPadding: EdgeInsets.zero, child: ListTile( contentPadding: EdgeInsets.all(16.0), onTap: () => onTap(contact), title: Padding( padding: const EdgeInsets.only(top: 4.0, bottom: 8.0), child: Text( contact.title, style: Theme.of(context).textTheme.display2.copyWith( fontSize: contact.textSize, fontWeight: FontWeight.w900, letterSpacing: 0.35, height: 22.6 / 28), ), ), subtitle: Text( contact.description, style: TextStyles.paragraphNormal( color: Covid19Colors.darkGreyLight, ).copyWith(letterSpacing: 0.2, height: 22.4 / 16), ), trailing: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( padding: contact.contactType == ContactType.link ? EdgeInsets.only(top: 8, right: 12) : EdgeInsets.only(top: 8), child: contact.icon), ], ), ), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/home/home_page.dart
import 'package:covid/generated/l10n.dart'; import 'package:covid/providers/stats_provider.dart'; import 'package:covid/providers/slider_provider.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/screens/home/components/card_home_slider.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:covid/ui/screens/home/components/card_home.dart'; import 'package:covid/ui/widgets/card_border_arrow.dart'; import 'package:covid/ui/screens/home/components/silver_bar.dart'; import 'package:covid/bloc/app_bloc.dart'; import 'package:covid/bloc/base_bloc.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import '../../app.dart'; import 'components/statistics_button.dart'; /// Creates an HomePage extending [BasePage] /// that is a StatefulWidget class HomePage extends BasePage { /// Home page view HomePage({Key key, this.title}) : super(key: key); /// Title of the page view final String title; @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends BaseState<HomePage, AppBloc> { RefreshController _refreshController = RefreshController(initialRefresh: false); void _onRefresh() async{ initBloc(bloc); await Future.delayed(Duration(milliseconds: 1000)); _refreshController.refreshCompleted(); } void _onLoading() async{ await Future.delayed(Duration(milliseconds: 1000)); if(mounted) { setState(() { }); } _refreshController.loadComplete(); } @override void initBloc(AppBloc bloc) { bloc.getStats(); bloc.getSlider(); } @override Stream<ResultStream> get onStateListener => bloc.onListener; @override void onStateResultListener(ResultStream result) { if (result is StatsResultStream) { Provider.of<StatsProvider>(context, listen: false).setStats(result.model); } if (result is SliderResultStream) { Provider.of<SliderProvider>(context, listen: false).setSlider(result.model); } } @override Widget build(BuildContext context) { var stats = Provider.of<StatsProvider>(context); logger.i('[StatsProvider] $stats! - ${stats.hashCode}'); return Scaffold( body: SmartRefresher( controller: _refreshController, onRefresh: _onRefresh, onLoading: _onLoading, header: WaterDropMaterialHeader( backgroundColor: Covid19Colors.red, ), child: CustomScrollView( physics: ClampingScrollPhysics(), slivers: <Widget>[ SliverAppBar( leading: Container(), backgroundColor: Covid19Colors.blue, elevation: 0.0, centerTitle: true, expandedHeight: 100.0, pinned: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, title: Text( S.of(context).homePageTitle.toUpperCase(), style: TextStyles.subtitle( color: Covid19Colors.white, ) ), background: Image.asset("assets/welcome_1.png", width: double.infinity, height: 150.0, fit: BoxFit.fill, ), ), ), SliverPersistentHeader( pinned: true, delegate: SliverAppBarDelegate( DecoratedBox( decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/welcome_2.png"), fit: BoxFit.fill ) ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 0.0), child: Column( children: <Widget>[ HomeSlider() ], ), ), ), 140.0 ), ), SliverToBoxAdapter( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ const SizedBox( height: 24.0, ), Container( margin: EdgeInsets.symmetric(horizontal: 16.0), child: Column( children: <Widget>[ StatisticsButton( callback: () => Navigator.of(context).pushNamed(routeStatistics), ), const SizedBox( height: 8, ), CardHome( text: S.of(context).protocolPageTitle.toUpperCase(), callback: () => Navigator.of(context).pushNamed(routeProtocol), ), const SizedBox( height: 8, ), CardHome( text: S.of(context).faqPageTitle.toUpperCase(), callback: () => Navigator.of(context).pushNamed(routeFaqs), ), const SizedBox( height: 8, ), CardHome( text: S.of(context).screenVideosTitle.toUpperCase(), callback: () => Navigator.of(context).pushNamed(routeVideos), ), const SizedBox( height: 8, ), CardHome( text: S.of(context).contactsPageTitle, callback: () => Navigator.of(context).pushNamed(routeContacts), backgroundColor: Covid19Colors.blue, textColor: Covid19Colors.white, ), const SizedBox( height: 8, ), CardBorderArrow( text: S .of(context) .screenNotificationsTitle .toUpperCase(), callback: () => Navigator.of(context) .pushNamed(routeNotifications), textColor: Covid19Colors.darkGrey, borderColor: Covid19Colors.lightGrey, ), const SizedBox( height: 8, ), CardBorderArrow( text: S.of(context).screenAboutTitle.toUpperCase(), callback: () => Navigator.of(context).pushNamed(routeAbout), textColor: Covid19Colors.darkGrey, borderColor: Covid19Colors.lightGrey, ), ], ), ), const SizedBox( height: 20, ), ] ), ), ) ] ) ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/card_home_slider_indicator.dart
import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; /// An indicator showing the currently selected page of a PageController class CardHomeSliderIndicator extends AnimatedWidget { CardHomeSliderIndicator({ this.controller, this.itemCount, this.onPageSelected, this.color = Colors.white, }) : super(listenable: controller); /// The PageController for the indicator. final PageController controller; /// The number of items managed by the PageController final int itemCount; /// Called when a dot is tapped final ValueChanged<int> onPageSelected; /// The color of the indicator. final Color color; Widget _buildLineIndicator(int index) { /// Color to used for slides that are not visible var _color = Covid19Colors.grey; /// In case [controller] is not ready and page is still null /// then set the first indicator to be the [color] /// and the rest use [Covid19Colors.grey] /// /// When [controller] is ready and [index] /// is equal to the [controller.page] then set /// the [color] for the current index, /// rest will use the [Covid19Colors.grey] if ((controller.page == null && index == 0) || (controller.page != null && index == controller.page.toInt())) { _color = color; } return Container( key: Key("Card-Home-Slider-$index"), width: 24, child: Center( child: Material( color: _color, borderRadius: BorderRadius.all(Radius.circular(2.0)), type: MaterialType.canvas, child: Container( width: 14.0, height: 2.0, child: InkWell( onTap: () => onPageSelected(index), ), ), ), ), ); } Widget build(BuildContext context) { return Container( height: 10, margin: EdgeInsets.symmetric(horizontal: 35.0), decoration: BoxDecoration( color: Covid19Colors.white.withAlpha(80), border: Border.all( color: Covid19Colors.white, width: 1, ), borderRadius: BorderRadius.circular(4), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: List<Widget>.generate(itemCount, _buildLineIndicator), ) ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/accordion.dart
/// This program is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program. If not, see <https://www.gnu.org/licenses/>. import 'package:flutter/material.dart'; class Accordion extends StatelessWidget { const Accordion( {Key key, this.title, this.children, this.onExpansionChanged, this.withBorder = true, this.initiallyExpanded = false, this.titleTextStyle, this.padding, this.margin, this.contentPadding, this.childrenPadding}) : super(key: key); final String title; final List<Widget> children; final Function(bool) onExpansionChanged; final bool initiallyExpanded; final bool withBorder; final TextStyle titleTextStyle; final EdgeInsetsGeometry padding; final EdgeInsetsGeometry margin; final EdgeInsetsGeometry contentPadding; final EdgeInsetsGeometry childrenPadding; @override Widget build(BuildContext context) { assert(title != null, 'Title cannot be null'); return Theme( data: Theme.of(context).copyWith( dividerColor: Colors.transparent, ), child: Container( padding: padding ?? const EdgeInsets.symmetric(horizontal: 15.0), margin: margin ?? const EdgeInsets.symmetric(horizontal: 15.0), decoration: withBorder ? BoxDecoration( border: Border.all( color: Theme.of(context).primaryColor, ), borderRadius: BorderRadius.circular(3.0), ) : null, child: ListTileTheme( contentPadding: contentPadding ?? EdgeInsets.zero, child: ExpansionTile( title: Text( title, style: titleTextStyle ?? Theme.of(context).textTheme.display4, ), initiallyExpanded: initiallyExpanded, onExpansionChanged: onExpansionChanged, children: children ?.map( (child) => Padding( padding: childrenPadding ?? const EdgeInsets.symmetric(vertical: 10.0), child: Align( alignment: Alignment.centerLeft, child: child, ), ), ) ?.toList(), ), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/card_home_slider.dart
import 'dart:async'; import 'package:covid/providers/slider_provider.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import 'card_home_slider_indicator.dart'; /// Slider Time for moving to next slide const sliderAutoTimer = 30000; const sliderTransitionTimer = 1000; class HomeSlider extends StatefulWidget { final _sliderAutoTimer; final _sliderTransitionTimer; const HomeSlider({ Key key, /// Use this on Tests to override default timer time @visibleForTesting int timer, /// Use this on Tests to override default transition time @visibleForTesting int transitionTime, }) : _sliderAutoTimer = timer ?? sliderAutoTimer, _sliderTransitionTimer = transitionTime ?? sliderTransitionTimer, super(key: key); @override _HomeSliderState createState() => _HomeSliderState(); } class _HomeSliderState extends State<HomeSlider> { final _controller = PageController( initialPage: 0, viewportFraction: 0.95, ); /// This holds a reference for the Timer to auto slide var sliderTimer; /// Builds the dots Widget _dots(int length) => Center( child: CardHomeSliderIndicator( controller: _controller, itemCount: length, color: Covid19Colors.green, onPageSelected: (int page) { _controller.animateToPage( page, duration: const Duration(milliseconds: 300), curve: Curves.ease, ); }, ), ); /// Builds the PageView Widget _pageView(slides) => PageView.builder( physics: AlwaysScrollableScrollPhysics(), controller: _controller, itemBuilder: (BuildContext context, int index) { if (index >= slides.length) { return null; } var slide = slides[index]; return CardHomeSlide( titleLabel: slide.title, backgroundPath: slide.image, onTap: () => _onSlideTap(slide), ); }, ); Image image; @override void initState() { /// Creates the timer sliderTimer = Timer.periodic( Duration(milliseconds: widget._sliderAutoTimer), _onTimerCallback); super.initState(); } @override Widget build(BuildContext context) { var sliderProvider = Provider.of<SliderProvider>(context); return Container( height: 138, child: sliderProvider.slider != null ? Stack( children: <Widget>[ Positioned( top: 0, left: 0, right: 0, height: 128, child: _pageView(sliderProvider.slider), ), Positioned( bottom: 0.0, left: 0.0, right: 0.0, child: _dots(sliderProvider.slider.length)) ], ) : Container(), ); } /// Callback to open Url on tap _onSlideTap(slide) { var urlToOpen = slide.url; if (urlToOpen.isEmpty) { return; } if (!(slide.url.startsWith("https://") || slide.url.startsWith("http://"))) { urlToOpen = "https://${slide.url}"; } _launch(urlToOpen); } /// Opens Url _launch(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } /// Callback that fires every [sliderAutoTimer] time _onTimerCallback(Timer timer) { if (_controller.hasClients) { /// Gets the total slides length var sliderProvider = Provider.of<SliderProvider>(context, listen: false); /// Get the current page /// If we are at the last page then animate to the /// first page and start over var slideIndex = _controller.page.toInt(); if (slideIndex == sliderProvider.slider.length - 1) { _controller.animateToPage(0, duration: Duration(milliseconds: widget._sliderTransitionTimer), curve: Curves.fastLinearToSlowEaseIn); return; } /// While the current page is less then /// slides length then keep sliding to the next one _controller.nextPage( duration: Duration(milliseconds: widget._sliderTransitionTimer), curve: Curves.fastLinearToSlowEaseIn); } } @override void dispose() { /// Cancel timer on Dispose sliderTimer?.cancel(); super.dispose(); } } class CardHomeSlide extends StatelessWidget { const CardHomeSlide( {Key key, this.titleLabel, this.secondaryLabel, this.backgroundPath, this.onTap}) : super(key: key); final String titleLabel; final String secondaryLabel; final String backgroundPath; final VoidCallback onTap; @override Widget build(BuildContext context) { return GestureDetector( onTap: onTap, child: Card( ////This `color:` is so it doesn't show a black ///background before it has a chance to load. color: Covid19Colors.white, elevation: 4.0, clipBehavior: Clip.hardEdge, child: Stack(fit: StackFit.expand, children: <Widget>[ backgroundPath.isNotEmpty ? Image.network( backgroundPath, fit: BoxFit.cover, alignment: Alignment.topCenter, ) : Container( width: 0, height: 0, ), if (secondaryLabel != null) Container( padding: EdgeInsets.fromLTRB(12, 16, 12, 16), child: Stack( children: <Widget>[ Text( titleLabel.toUpperCase(), overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyles.h1(color: Covid19Colors.white), ), Positioned( bottom: 0, left: 0, child: ClipRRect( borderRadius: BorderRadius.circular(4), child: Row( children: <Widget>[ Container( padding: EdgeInsets.all(5), height: 30, color: Covid19Colors.white, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( secondaryLabel, style: TextStyles.subtitle( color: Covid19Colors.green), ), SizedBox(width: 7), Icon( Icons.arrow_forward, size: 16, color: Covid19Colors.green, ) ], ), ) ], ), ), ) ], )) ]), )); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/card_video.dart
import 'package:covid/resources/style/text_styles.dart'; import 'package:flutter/material.dart'; class CardVideo extends StatelessWidget { const CardVideo({ Key key, @required this.backgroundUrl, this.onPressed, this.label, this.labelAlignment = Alignment.bottomCenter, }) : super(key: key); final String backgroundUrl; final String label; final Alignment labelAlignment; final VoidCallback onPressed; @override Widget build(BuildContext context) { return Container( height: 100.0, margin: const EdgeInsets.all(5.0), padding: const EdgeInsets.all(5.0), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.0), image: DecorationImage( image: NetworkImage(backgroundUrl), fit: BoxFit.cover, ), ), child: Stack( alignment: Alignment.center, children: <Widget>[ ButtonTheme( minWidth: 0.0, shape: const CircleBorder(), padding: EdgeInsets.zero, buttonColor: Colors.transparent, splashColor: Colors.transparent, highlightColor: Colors.transparent, child: RaisedButton( elevation: 4.0, onPressed: () {}, disabledColor: Colors.transparent, child: Icon( Icons.play_circle_filled, size: 48.0, color: onPressed == null ? Theme.of(context).textTheme.button.color : Theme.of(context).disabledColor, ), ), ), if (label != null) Align( alignment: labelAlignment, child: Text( label, style: TextStyles.subtitle(color: Colors.white).copyWith(shadows: [ const Shadow( offset: Offset(0.0, 1.0), blurRadius: 3.0, ), ]), ), ), ], ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/statistics_button.dart
import 'package:covid/generated/l10n.dart'; import 'package:covid/providers/stats_provider.dart'; import 'package:covid/resources/icons_svg.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/widgets/button_background.dart'; import 'package:covid/ui/screens/statistics/components/stats_widget.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class StatisticsButton extends StatelessWidget { final VoidCallback callback; const StatisticsButton({Key key, this.callback}) : super(key: key); @override Widget build(BuildContext context) { return Theme( data: Theme.of(context).copyWith(splashColor: Covid19Colors.green50), child: InkWell( onTap: callback, child: ButtonBackground( color: Covid19Colors.red, child: Column( children: <Widget>[ Row( children: <Widget>[ Expanded( child: Text( S.of(context).homePageConfirmedCases.toUpperCase(), style: Theme.of(context) .textTheme .display2 .copyWith(color: Colors.white), textAlign: TextAlign.center, ), ) ], ), const SizedBox( height: 20.0, ), Container( height: 120, child: StatsWidget( color: Covid19Colors.statsBlue, number: Provider.of<StatsProvider>(context).confirmed, numberStyle: TextStyles.statisticsBig(color: Covid19Colors.darkGrey), text: S.of(context).statisticsPageConfirmed.toUpperCase(), textStyle: Theme.of(context) .textTheme .display1 .copyWith(color: Covid19Colors.darkGrey), ), ), const SizedBox( height: 8.0, ), Container( height: 80, child: Row( children: <Widget>[ Expanded( child: StatsWidget( color: Covid19Colors.statsGreen, number: Provider.of<StatsProvider>(context).recovered, numberStyle: Theme.of(context) .textTheme .display1 .copyWith(color: Covid19Colors.darkGrey), text: S.of(context).statisticsPageRecovered.toUpperCase(), textStyle: Theme.of(context) .textTheme .display4 .copyWith(color: Covid19Colors.darkGrey), ), ), const SizedBox( width: 8, ), Expanded( child: StatsWidget( color: Covid19Colors.statsRed, number: Provider.of<StatsProvider>(context).deaths, numberStyle: Theme.of(context) .textTheme .display1 .copyWith(color: Covid19Colors.darkGrey), text: S.of(context).statisticsPageDeath.toUpperCase(), textStyle: Theme.of(context) .textTheme .display4 .copyWith(color: Covid19Colors.darkGrey), ), ), ], ), ), const SizedBox( height: 20.0, ), Row( children: <Widget>[ Text( S.of(context).checkDetails, style: Theme.of(context) .textTheme .button .copyWith(color: Colors.white), ), SvgIcons.linkSvg( color: Colors.white, ), ], ) ], ), ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/card_home.dart
import 'package:flutter/material.dart'; import 'package:covid/resources/icons_svg.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/widgets/button_background.dart'; class CardHome extends StatelessWidget { final String text; final VoidCallback callback; final Color backgroundColor; final Color textColor; const CardHome({ Key key, @required this.text, @required this.callback, Color backgroundColor, Color textColor, }) : backgroundColor = backgroundColor ?? Covid19Colors.lightGrey, textColor = textColor ?? Covid19Colors.darkGrey, super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: callback, child: ButtonBackground( color: backgroundColor, child: Row( children: <Widget>[ Expanded( child: Text( text.toUpperCase(), style: Theme.of(context) .textTheme .display2 .copyWith(color: textColor), ), ), SizedBox(width: 12.0), SvgIcons.linkSvg( color: textColor, ), ], ), ), ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/home
mirrored_repositories/info_covid-19/lib/ui/screens/home/components/silver_bar.dart
import 'package:flutter/material.dart'; class SliverAppBarDelegate extends SliverPersistentHeaderDelegate { final Widget widget; final double height; SliverAppBarDelegate(this.widget, this.height); @override double get minExtent => height; @override double get maxExtent => height; @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { return widget; } @override bool shouldRebuild(SliverAppBarDelegate oldDelegate) { return true; } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/splash/splash_page.dart
import 'dart:async'; import 'dart:math'; import 'package:covid/generated/l10n.dart'; import 'package:covid/providers/faq_category_provider.dart'; import 'package:covid/providers/faq_provider.dart'; import 'package:covid/providers/slider_provider.dart'; import 'package:covid/providers/stats_provider.dart'; import 'package:covid/providers/videos_provider.dart'; import 'package:covid/providers/detail_stats_provider.dart'; import 'package:covid/providers/protocol_provider.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/resources/icons_svg.dart'; import 'package:covid/ui/app.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/assets/images.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:covid/ui/screens/splash/components/animated_wawe.dart'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; import '../../../bloc/app_bloc.dart'; import '../../../bloc/base_bloc.dart'; /// Creates an HomePage extending [BasePage] /// that is a StatefulWidget class SplashPage extends BasePage { /// Home page view SplashPage({Key key, this.title}) : super(key: key); /// Title of the page view final String title; @override _SplashPageState createState() => _SplashPageState(); } class _SplashPageState extends BaseState<SplashPage, SplashBloc> { final PublishSubject _statsSubject = PublishSubject<bool>(); final PublishSubject _sliderSubject = PublishSubject<bool>(); final PublishSubject _animationComplete = PublishSubject<bool>(); Stream<bool> get _dataLoaded => Rx.combineLatest2( _animationComplete, Rx.zip2(_statsSubject, _sliderSubject, (stats, slider) { logger.i("_statsSubject : $stats"); logger.i("_sliderSubject : $slider"); logger.d("COMBINED: ${stats && slider}"); return stats && slider; }), (animation, api) => animation && api) .timeout(Duration(seconds: 5), onTimeout: (sink) { sink.add(true); }); StreamSubscription<bool> _dataLoadedSubscription; @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) async { _dataLoadedSubscription = _dataLoaded.listen((loaded) async { logger.d("NEW DATA: $loaded"); if (loaded) { logger.i("I'm inside the LOADED part"); _dataLoadedSubscription.cancel(); await Navigator.of(context) .pushNamedAndRemoveUntil(routeHome, (_) => false) .catchError(logger.e); logger.i("After the navigation"); } else { logger.e("NO DATA"); _insertOverlay(context); } }); }); } @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: <Widget>[ /* Center( child: Image.asset( logoInfoCovid, width: MediaQuery.of(context).size.width * 0.4, ), ), */ FlareActor( "assets/info_covid.flr", alignment: Alignment.center, animation: "in", callback: (status) { _animationComplete.add(true); }, ), onBottom(AnimatedWave( height: 130, speed: 1.0, )), onBottom(AnimatedWave( height: 70, speed: 0.9, offset: pi, )), onBottom(AnimatedWave( height: 170, speed: 1.2, offset: pi / 2, )), ] ) ); } onBottom(Widget child) => Positioned.fill( child: Align( alignment: Alignment.bottomCenter, child: child, ), ); @override void initBloc(SplashBloc bloc) { /// Get Case Stats /// bloc.bloc.getStats(); /// Get Slider /// bloc.bloc.getSlider(); scheduleMicrotask(() { /// Get Faq Posts /// bloc.bloc.getFaqCategories(); /// Get Videos Posts /// bloc.bloc.getVideos(); /// Get Detail Stats /// bloc.bloc.getDetailStats(); /// Get Detail Protocol /// bloc.bloc.getProtocol(); }); } @override Stream<ResultStream> get onStateListener => bloc.bloc.onListener; @override void onStateResultListener(ResultStream result) { if (result is StatsResultStream) { Provider.of<StatsProvider>(context, listen: false).setStats(result.model); if (result.state == StateStream.success) { _statsSubject.add(true); } else if (result.state == StateStream.fail) { _statsSubject.add(false); } } if (result is FaqCategoryResultStream) { Provider.of<FaqCategoryProvider>(context, listen: false) .setFaqsCategories(result.model); } if (result is VideosResultStream) { Provider.of<VideosProvider>(context, listen: false) .setVideos(result.model); } if (result is SliderResultStream) { Provider.of<SliderProvider>(context, listen: false) .setSlider(result.model); if (result.state == StateStream.success) { _sliderSubject.add(true); } else if (result.state == StateStream.fail) { _sliderSubject.add(false); } } if (result is FaqResultStream) { Provider.of<FaqProvider>(context, listen: false).setFaqs(result.model); } if (result is DetailStatsResultStream) { Provider.of<DetailStatsProvider>(context, listen: false) .setDetailStats(result.model); } if (result is ProtocolResultStream) { Provider.of<ProtocolProvider>(context, listen: false) .setProtocol(result.model); } } void _insertOverlay(BuildContext context) { logger.e("Called insert overlay"); var entry; entry = OverlayEntry( opaque: false, builder: (context) { return Material( child: Container( color: Colors.black54, child: Center( child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(4.0)), ), margin: EdgeInsets.all(24.0), padding: EdgeInsets.all(24.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text(S.of(context).noConnection, style: Theme.of(context).textTheme.display2.copyWith( color: Covid19Colors.darkGrey, )), const SizedBox( height: 12.0, ), Image.asset( connectionError, width: 120, height: 120, ), const SizedBox( height: 12.0, ), Text( S.of(context).cannotConnectInternetDescription, ), const SizedBox( height: 12.0, ), RaisedButton( onPressed: () { entry.remove(); initBloc(bloc); }, color: Theme.of(context).primaryColor, child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Text( S.of(context).buttonTryAgain, style: TextStyle(color: Colors.white), ), const SizedBox( width: 4.0, ), SvgIcons.linkSvg(color: Colors.white) ], ), ), ], ), ), ), ), ); }); return Overlay.of(context).insert( entry, ); } @override void dispose() { logger.i("Dispose called"); _statsSubject.close(); _sliderSubject.close(); if (_dataLoadedSubscription != null) { _dataLoadedSubscription.cancel(); } super.dispose(); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/splash
mirrored_repositories/info_covid-19/lib/ui/screens/splash/components/animated_wawe.dart
import 'dart:math'; import 'package:covid/ui/assets/colors.dart'; import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; class AnimatedWave extends StatelessWidget { final double height; final double speed; final double offset; AnimatedWave({this.height, this.speed, this.offset = 0.0}); @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { return Container( height: height, width: constraints.biggest.width, child: ControlledAnimation( playback: Playback.LOOP, duration: Duration(milliseconds: (5000 / speed).round()), tween: Tween(begin: 0.0, end: 2 * pi), builder: (context, value) { return CustomPaint( foregroundPainter: CurvePainter(value + offset), ); }), ); }); } } class CurvePainter extends CustomPainter { final double value; CurvePainter(this.value); @override void paint(Canvas canvas, Size size) { final white = Paint()..color = Covid19Colors.blue.withAlpha(60); final path = Path(); final y1 = sin(value); final y2 = sin(value + pi / 2); final y3 = sin(value + pi); final startPointY = size.height * (0.5 + 0.4 * y1); final controlPointY = size.height * (0.5 + 0.4 * y2); final endPointY = size.height * (0.5 + 0.4 * y3); path.moveTo(size.width * 0, startPointY); path.quadraticBezierTo(size.width * 0.5, controlPointY, size.width, endPointY); path.lineTo(size.width, size.height); path.lineTo(0, size.height); path.close(); canvas.drawPath(path, white); } @override bool shouldRepaint(CustomPainter oldDelegate) { return true; } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/faqs/faqs_page.dart
import 'package:covid/bloc/app_bloc.dart'; import 'package:covid/bloc/base_bloc.dart'; import 'package:covid/generated/l10n.dart'; import 'package:covid/model/faq_category_model.dart'; import 'package:covid/model/faq_model.dart'; import 'package:covid/providers/faq_category_provider.dart'; import 'package:covid/providers/faq_provider.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:covid/ui/widgets/card_border_arrow.dart'; import 'package:covid/ui/widgets/loading.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../app.dart'; /// Creates an MeasuresPage extending [BasePage] /// that is a StatefulWidget class FaqsPage extends BasePage { /// Measures page view FaqsPage({Key key, this.title}) : super(key: key); /// Title of the page view final String title; @override _FaqsPageState createState() => _FaqsPageState(); } class _FaqsPageState extends BaseState<FaqsPage, AppBloc> { List<FaqCategoryModel> faqsCategories; Map<int, List<FaqModel>> faqs; @override Widget build(BuildContext context) { var provider = Provider.of<FaqCategoryProvider>(context); var faqsProvider = Provider.of<FaqProvider>(context); logger.i('[FaqCategoryProvider] $provider'); if (provider.faqs != null) { faqsCategories = provider.faqs; } if (faqsProvider.faqs != null) { faqs = faqsProvider.faqs; } /// Check if have any data to present, if not show [CircularProgressIndicator] /// while wait for data var hasData = faqsCategories != null && faqsCategories.length > 0 && faqs != null && faqs.isNotEmpty; return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( S.of(context).faqPageTitle.toUpperCase(), style: Theme.of(context) .textTheme .display2 .copyWith(color: Covid19Colors.white), ), backgroundColor: Covid19Colors.blue, elevation: 0.0, ), body: Container( margin: EdgeInsets.all(16.0), child: hasData ? ListView.separated( itemBuilder: (context, index) => CardBorderArrow( text: faqsCategories[index].name, textColor: Theme.of(context).primaryColor, borderColor: Theme.of(context).primaryColor, callback: () { logger.i( "Id: ${faqsCategories[index].categoryId}. Map: $faqs; specific: ${faqs[faqsCategories[index].categoryId]}"); Navigator.of(context).pushNamed(routeFaqsDetails, arguments: faqs[faqsCategories[index].categoryId]); }, ), separatorBuilder: (_, __) { return const SizedBox( height: 8.0, ); }, itemCount: faqsCategories != null ? faqsCategories.length : 0) : const Loading(), ), ); } @override void initBloc(AppBloc bloc) { /// Get Faqs & Faqs categories /// var provider = Provider.of<FaqCategoryProvider>(context); var faqsProvider = Provider.of<FaqProvider>(context); if ((provider.faqs == null || (provider.faqs != null && provider.faqs.length == 0)) || (faqsProvider.faqs == null || (faqsProvider.faqs != null && faqsProvider.faqs.length == 0))) { bloc.getFaqCategories(); } } @override Stream<ResultStream> get onStateListener => bloc.onListener; @override void onStateResultListener(ResultStream result) { logger.i("New data: ${result.runtimeType}"); if (result is FaqCategoryResultStream) { Provider.of<FaqCategoryProvider>(context, listen: false) .setFaqsCategories(result.model); } if (result is FaqResultStream) { Provider.of<FaqProvider>(context, listen: false).setFaqs(result.model); } } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/faqs_details/faq_details_page.dart
import 'package:covid/model/faq_model.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/utils/launch_url.dart'; import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:html/dom.dart' as dom; class FaqsDetails extends StatefulWidget { /// Faqs page view FaqsDetails({Key key, this.title, this.faqs}) : super(key: key); /// Title of the page view final String title; final List<FaqModel> faqs; @override _FaqsPageState createState() => _FaqsPageState(); } class _FaqsPageState extends State<FaqsDetails> { /// ScrollController for changing the scroll position final ScrollController scrollController = ScrollController(); /// Store the rows index key for calculating the height dynamically Map<int, GlobalKey> expands = <int, GlobalKey>{}; @override Widget build(BuildContext context) { /// TODO: in case of slow connection show loading? /// Gets all faqs from the Provider or the Modal Route arguments /// /// If pushing from home and faqs have initial data /// In case of no initial data reverts to fetch faqs /// and update with the Provider return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( widget.title.toUpperCase(), style: TextStyles.h2(color: Covid19Colors.white), ), backgroundColor: Covid19Colors.blue, elevation: 0.0, ), body: Scrollbar( child: Container( child: ListView.builder( controller: scrollController, itemCount: widget.faqs != null ? widget.faqs.length : 0, itemBuilder: (context, index) { return ExpandableNotifier( child: Padding( padding: EdgeInsets.all(10.0), child: Card( color: Covid19Colors.white, clipBehavior: Clip.antiAlias, child: Column( children: <Widget>[ ScrollOnExpand( scrollOnExpand: true, scrollOnCollapse: false, child: ExpandablePanel( theme: const ExpandableThemeData( headerAlignment: ExpandablePanelHeaderAlignment.center, tapBodyToCollapse: true, iconColor: Covid19Colors.green, ), header: Padding( padding: EdgeInsets.all(10), child: Text( widget.faqs[index].question, style: Theme.of(context).textTheme.display3.copyWith( color: Covid19Colors.green, letterSpacing: 0.2 ), ) ), expanded: Html( data: widget.faqs[index].answer.replaceAll("\\n", ""), backgroundColor: Colors.white, onLinkTap: launchURL, defaultTextStyle: Theme.of(context).textTheme.body1, linkStyle: Theme.of(context) .textTheme .body1 .copyWith(color: Theme.of(context).primaryColor), customTextStyle: (dom.Node node, TextStyle baseStyle) { if (node is dom.Element) { switch (node.localName) { case "b": return TextStyles.subtitle( color: Covid19Colors.darkGrey, ); } } return baseStyle; }, ), builder: (_, collapsed, expanded) { return Padding( padding: EdgeInsets.only(left: 10, right: 10, bottom: 10), child: Expandable( collapsed: collapsed, expanded: expanded, theme: const ExpandableThemeData(crossFadePoint: 0), ), ); }, ), ) ] ), ), ), ); } ) ) ) ); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/protocol/protocol_document.dart
import 'dart:async'; import 'dart:io'; import 'package:covid/ui/assets/dimensions.dart'; import 'package:covid/ui/widgets/loading.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/screens/protocol/component/PDFViewer.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; class ProtocolDocumentPage extends StatefulWidget { ProtocolDocumentPage({Key key, this.url}) : super(key: key); final String url; @override _ProtocolDocumentPageState createState() => _ProtocolDocumentPageState(); } class _ProtocolDocumentPageState extends State<ProtocolDocumentPage> { String pathPDF = ''; bool loading = true; @override void initState() { super.initState(); createFileOfPdfUrl().then((f) { if(this.mounted) { setState(() { loading = false; pathPDF = f.path; print(pathPDF); }); } }); } Future<File> createFileOfPdfUrl() async { String _url = widget.url; final filename = _url.substring(_url.lastIndexOf('/') + 1); String dir = (await getApplicationDocumentsDirectory()).path; File file = new File('$dir/$filename'); if (!await file.exists()) { var request = await HttpClient().getUrl(Uri.parse(_url)); var response = await request.close(); var bytes = await consolidateHttpClientResponseBytes(response); await file.writeAsBytes(bytes); } return file; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( 'DOKUMEN PROTOKOL', style: TextStyles.h2(color: Covid19Colors.white), ), ), body: SafeArea( child: loading ? Loading() : PDFViewer( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( 'DOKUMEN PROTOKOL', style: TextStyles.h2(color: Covid19Colors.white), ), ), path: pathPDF, paddingTop: MediaQuery.of(context).padding.top, ), ), ); } @override void dispose() { super.dispose(); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/protocol/protocol_page.dart
import 'package:covid/bloc/app_bloc.dart'; import 'package:covid/bloc/base_bloc.dart'; import 'package:covid/model/protocol_model.dart'; import 'package:covid/providers/protocol_provider.dart'; import 'package:covid/resources/constants.dart'; import 'package:covid/resources/style/text_styles.dart'; import 'package:covid/ui/assets/colors.dart'; import 'package:covid/ui/core/base_stream_service_screen_page.dart'; import 'package:covid/ui/widgets/loading.dart'; import 'package:covid/ui/widgets/card_border_arrow.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:expandable/expandable.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:html/dom.dart' as dom; class ProtocolPage extends BasePage { /// Faqs page view ProtocolPage({Key key, this.title}) : super(key: key); /// Title of the page view final String title; @override _ProtocolPageState createState() => _ProtocolPageState(); } class _ProtocolPageState extends BaseState<ProtocolPage, AppBloc> { /// For the initial list of faqs List<ProtocolModel> _protocol = []; @override Widget build(BuildContext context) { /// Gets all faqs from the Provider or the Modal Route arguments /// /// If pushing from home and faqs have initial data /// In case of no initial data reverts to fetch faqs /// and update with the Provider _protocol = Provider.of<ProtocolProvider>(context).protocol ?? ModalRoute.of(context).settings.arguments; final ScrollController scrollController = ScrollController(); /// Check if have any data to present, if not show [CircularProgressIndicator] /// while wait for data var hasData = _protocol != null && _protocol.isNotEmpty; return Scaffold( appBar: AppBar( iconTheme: Theme.of(context).iconTheme.copyWith(color: Covid19Colors.white), title: Text( widget.title.toUpperCase(), style: TextStyles.h2(color: Covid19Colors.white), ), ), body: Container( child: hasData ? ListView.builder( controller: scrollController, itemCount: _protocol != null ? _protocol.length : 0, itemBuilder: (context, index) { return ExpandableNotifier( child: Padding( padding: EdgeInsets.all(10.0), child: Card( color: Covid19Colors.white, clipBehavior: Clip.antiAlias, child: Column( children: <Widget>[ ScrollOnExpand( scrollOnExpand: true, scrollOnCollapse: false, child: ExpandablePanel( theme: const ExpandableThemeData( headerAlignment: ExpandablePanelHeaderAlignment.center, tapBodyToCollapse: true, iconColor: Covid19Colors.darkGrey, ), header: Padding( padding: EdgeInsets.all(10), child: Text( _protocol[index].title, style: Theme.of(context).textTheme.display3.copyWith( color: Covid19Colors.darkGrey, letterSpacing: 0.2 ), ) ), expanded: Column( children: <Widget>[ Html( data: _protocol[index].description.replaceAll("\\n", ""), backgroundColor: Colors.white, defaultTextStyle: Theme.of(context).textTheme.body1, linkStyle: Theme.of(context) .textTheme .body1 .copyWith(color: Theme.of(context).primaryColor), customTextStyle: (dom.Node node, TextStyle baseStyle) { if (node is dom.Element) { switch (node.localName) { case "b": return TextStyles.subtitle( color: Covid19Colors.darkGrey, ); } } return baseStyle; }, ), const SizedBox( height: 10.0, ), CardBorderArrow( text: 'Lihat Dokumen', textColor: Covid19Colors.green, borderColor: Covid19Colors.lightGrey, callback: () { Navigator.of(context).pushNamed( routeProtocolDocument, arguments: _protocol[index].url ); }, ) ], ), builder: (_, collapsed, expanded) { return Padding( padding: EdgeInsets.only(left: 10, right: 10, bottom: 10), child: Expandable( collapsed: collapsed, expanded: expanded, theme: const ExpandableThemeData(crossFadePoint: 0), ), ); }, ), ) ] ), ), ), ); } ) : const Loading(), ), ); } @override void initBloc(AppBloc bloc) { /// In case [_faqs] is null then fetch if again var provider = Provider.of<ProtocolProvider>(context); if (_protocol == null || provider.protocol == null || (provider.protocol != null && provider.protocol.isEmpty)) { bloc.getProtocol(); } } @override Stream<ResultStream> get onStateListener => bloc.onListener; @override void onStateResultListener(ResultStream result) { if (result is ProtocolResultStream) { /// Updates faqs list on the provider Provider.of<ProtocolProvider>(context, listen: false) .setProtocol(result.model); /// Updates videos list _protocol = result.model; } } }
0
mirrored_repositories/info_covid-19/lib/ui/screens/protocol
mirrored_repositories/info_covid-19/lib/ui/screens/protocol/component/PDFViewer.dart
import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_full_pdf_viewer/full_pdf_viewer_plugin.dart'; class PDFViewer extends StatefulWidget { final PreferredSizeWidget appBar; final String path; final bool primary; final double paddingTop; const PDFViewer({ Key key, this.appBar, @required this.path, this.primary = true, this.paddingTop = 0.0 }) : super(key: key); @override _PDFViewerState createState() => new _PDFViewerState(); } class _PDFViewerState extends State<PDFViewer> { final pdfViwerRef = new PDFViewerPlugin(); Rect _rect; Timer _resizeTimer; @override void initState() { super.initState(); pdfViwerRef.close(); } @override void dispose() { super.dispose(); pdfViwerRef.close(); pdfViwerRef.dispose(); } @override Widget build(BuildContext context) { if (_rect == null) { _rect = _buildRect(context); pdfViwerRef.launch( widget.path, rect: _rect, ); } else { final rect = _buildRect(context); if (_rect != rect) { _rect = rect; _resizeTimer?.cancel(); _resizeTimer = new Timer(new Duration(milliseconds: 300), () { pdfViwerRef.resize(_rect); }); } } return new Scaffold( appBar: widget.appBar, body: const Center(child: const CircularProgressIndicator()) ); } Rect _buildRect(BuildContext context) { final fullscreen = widget.appBar == null; final mediaQuery = MediaQuery.of(context); final topPadding = widget.primary ? widget.paddingTop : 0.0; final top = fullscreen ? 0.0 : widget.appBar.preferredSize.height + topPadding; var height = mediaQuery.size.height - top; if (height < 0.0) { height = 0.0; } return new Rect.fromLTWH(0.0, top, mediaQuery.size.width, height); } }
0
mirrored_repositories/info_covid-19/lib/ui/screens
mirrored_repositories/info_covid-19/lib/ui/screens/video_player/video_player_page.dart
import 'package:covid/ui/assets/dimensions.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; class VideoPlayerPage extends StatefulWidget { const VideoPlayerPage({Key key}) : super(key: key); @override _VideoPlayerPageState createState() => _VideoPlayerPageState(); } class _VideoPlayerPageState extends State<VideoPlayerPage> { YoutubePlayerController _controller; String _url; @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, DeviceOrientation.portraitDown, ]); _url = ModalRoute.of(context).settings.arguments; _controller = YoutubePlayerController( initialVideoId: _url, flags: YoutubePlayerFlags( autoPlay: true, ), ); return Scaffold( backgroundColor: Colors.black, body: SafeArea( child: Stack( children: <Widget>[ Center( child: YoutubePlayer( bottomActions: <Widget>[ const SizedBox(width: 14.0), CurrentPosition(), const SizedBox(width: 8.0), ProgressBar(isExpanded: true), ], controller: _controller, onReady: () { _controller.addListener(() {}); }, ), ), Align( alignment: Alignment.topRight, child: Padding( padding: const EdgeInsets.all(marginVidCloseBt), child: Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.black54, ), child: IconButton( icon: Icon(Icons.close, color: Colors.white), onPressed: () => Navigator.of(context).pop(), ), ), ), ), ], ), ), ); } @override void dispose() { _controller.dispose(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); super.dispose(); } }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/services/messaging_service.dart
import 'dart:io'; import 'package:covid/resources/constants.dart'; import 'package:covid/ui/app.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:notification_permissions/notification_permissions.dart'; abstract class MessagingService { MessagingService._(); static final String _tag = '$bundle.PushNotificationsService'; static final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); static bool notificationsEnabledForApp = false; static Future<bool> init({bool force = false}) async { logger.i("$_tag: Initing FCM service..."); PermissionStatus permissionStatus = await NotificationPermissions.getNotificationPermissionStatus(); bool permissionsAllowed = true; if (permissionStatus == PermissionStatus.unknown && !await _firebaseMessaging.requestNotificationPermissions()) { permissionsAllowed = false; } else if (permissionStatus == PermissionStatus.denied) { permissionsAllowed = false; } if (!permissionsAllowed) { notificationsEnabledForApp = null; logger.w( "$_tag: Device has not given notifications permissions for this app."); return false; } logger.i("$_tag: Device has notifications on for this app."); _configureFCMHandlers(); return notificationsEnabledForApp = true; } static void _configureFCMHandlers() async { _firebaseMessaging.onIosSettingsRegistered .listen((IosNotificationSettings settings) { logger.i("$_tag: Push notifications registered for iOS: $settings"); }); _firebaseMessaging.getToken().then((token) { logger.i('$_tag: Device registered for FCM with token: $token'); }); _firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) async { logger.i("$_tag Push (onMessage): $message"); }, onBackgroundMessage: Platform.isIOS ? null : _backgroundNotificationsHandler, onLaunch: (Map<String, dynamic> message) async { logger.i(_tag, "$_tag: Push (onLaunch): $message"); }, onResume: (Map<String, dynamic> message) async { logger.i("$_tag: Push (onResume): $message"); }, ); } static Future<bool> unregister() async { if (await _firebaseMessaging.deleteInstanceID()) { logger.i("$_tag: FCM disabled for current device with success."); return true; } logger.w("$_tag: Could not disable FCM for current device."); return false; } static Future<dynamic> _backgroundNotificationsHandler( Map<String, dynamic> message) { if (message.containsKey('data')) { // final dynamic data = message['data']; logger.i("$_tag: Push (background) data message: $message"); } if (message.containsKey('notification')) { final dynamic notification = message['notification']; logger.i(_tag, "$_tag: Push (background) data message: $notification"); } return null; } }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/services/api.dart
/// Abstract API class abstract class AbstractApi { /// API ex: /// https://dev-covid19.vost.pt/wp-json/vost/v1/stats /// Scheme request format String get scheme; /// Host endpoint String get host; /// Base API path String get baseApi; /// building the path String build({String path = ""}); } /// API config params class _ConfigApi implements AbstractApi { ///https://dev-covid19.vost.pt/wp-json/vost/v1/stats @override String get scheme => "http"; @override String get host => "localhost/covidweb"; @override String get baseApi => "api"; @override String build({String path = ""}) { var base = "$scheme://$host/$baseApi"; if (path.isNotEmpty) { return "$base/$path"; } return base; } } /// Develop API Configuration class DevApi extends _ConfigApi {} /// Production API Configuration class ProductionApi extends _ConfigApi { @override String get scheme => "https"; @override String get host => "covid.benibete.com"; }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/services/api_service.dart
import 'dart:async'; import 'package:covid/main.dart'; import 'package:covid/model/api_response_model.dart'; import 'package:covid/model/post_type.dart'; import 'package:covid/services/api.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import '../ui/app.dart'; enum _RequestType { post, get, put, patch, delete } /// Main APIService /// /// This will create a singleton instance /// class APIService { static const String _tag = '.APIService'; static APIService _apiService = APIService._(); static Dio _client; static bool _initialized = false; static APIService get api => _apiService; static AbstractApi _configApi; APIService._(); @visibleForTesting set setMockInstance(APIService instance) => _apiService = instance; void init([Dio client, AbstractApi api]) async { if (!_initialized) { _configApi = api ?? (appConfig == AppConfig.dev ? DevApi() : ProductionApi()); _client = client ?? Dio(); _client.options.baseUrl = _configApi.build(); _client.options.connectTimeout = 5000; _initialized = true; } } Future<APIResponse> _performRequest( _RequestType type, String resource, { Map<String, dynamic> headers, Map<String, dynamic> queryParams, Map<String, dynamic> body, }) async { if (!_initialized) { init(); } Response response; logger.i( '[$_tag] Requesting: $resource | QueryParams: $queryParams | Body: $body | Method: ${describeEnum(type)}'); if (headers != null) { _client.options.headers.addAll(headers); } queryParams?.removeWhere((k, v) => v == null); try { switch (type) { case _RequestType.post: response = await _client.post(resource, queryParameters: queryParams, data: body); break; case _RequestType.put: response = await _client.put(resource, queryParameters: queryParams, data: body); break; case _RequestType.get: response = await _client.get(resource, queryParameters: queryParams); break; case _RequestType.patch: response = await _client.patch(resource, queryParameters: queryParams, data: body); break; case _RequestType.delete: response = await _client.delete(resource, queryParameters: queryParams, data: body); break; } return APIResponse( response?.data, response?.statusCode, headers: response?.headers, ); } on DioError catch (e) { logger.e( '[$_tag] Request error: ${e.error} | Status Code: ${e.response?.statusCode} | Response: ${e.response} | Request: ${e.request?.uri} | Type: ${e.type} | Headers:${e.response?.headers?.map}'); return APIResponse( e.response?.data, e.response?.statusCode, headers: e.response?.headers, dioErrorType: e?.type, ); } } /// Gets the updated case stats Future<APIResponse> getStats() async { return await _performRequest( _RequestType.get, '/stats', ); } /// Gets the posts accordingly by [postType] Future<APIResponse> getPosts<T>(PostType postType, {int id}) async { Map<String, int> queryParams; if (id != null) { queryParams = {"categories": id}; } return await _performRequest( _RequestType.get, postType.getRequestType(), queryParams: queryParams, ); } }
0
mirrored_repositories/info_covid-19/lib
mirrored_repositories/info_covid-19/lib/providers/protocol_provider.dart
import 'package:flutter/material.dart'; import 'package:covid/model/protocol_model.dart'; class ProtocolProvider extends ChangeNotifier { List<ProtocolModel> _protocol; List<ProtocolModel> get protocol => _protocol; void setProtocol(List<ProtocolModel> values) { _protocol = values; notifyListeners(); } }
0