repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/firebase_list
mirrored_repositories/firebase_list/lib/main_app.dart
import 'package:flutter/material.dart'; import 'package:firebase_list/pages/home/home_page.dart'; class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Firebase', theme: ThemeData( primarySwatch: Colors.blue, ), home: const HomePage(), ); } }
0
mirrored_repositories/firebase_list
mirrored_repositories/firebase_list/lib/main.dart
import 'firebase_options.dart'; import 'package:flutter/material.dart'; import 'package:firebase_list/main_app.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; FirebaseMessaging messaging = FirebaseMessaging.instance; final fcmToken = await messaging.getToken(); NotificationSettings settings = await messaging.requestPermission( alert: true, announcement: false, badge: true, carPlay: false, criticalAlert: false, provisional: false, sound: true, ); FirebaseMessaging.onMessage.listen((RemoteMessage message) { print('Got a message whilst in the foreground!'); print('Message data: ${message.data}'); if (message.notification != null) { print('Message also contained a notification: ${message.notification}'); } }); if (fcmToken != null) { print("fcmToken: " + fcmToken); } FirebaseMessaging.instance.onTokenRefresh.listen((fcmToken) { print("Obtendo novamente: fcmToken: " + fcmToken); }).onError((err) { // Error getting token. }); final remoteConfig = FirebaseRemoteConfig.instance; await remoteConfig.setConfigSettings(RemoteConfigSettings( fetchTimeout: const Duration(minutes: 1), minimumFetchInterval: const Duration(minutes: 0), )); await remoteConfig.setDefaults(const { "example_param_1": 42, "example_param_2": 3.14159, "example_param_3": true, "example_param_4": "Hello, world!", }); //Colocar pra recarregar os valores. await remoteConfig.fetchAndActivate(); print(remoteConfig.getString("example_param_4")); runApp(const MainApp()); }
0
mirrored_repositories/firebase_list/lib/shared/widgets
mirrored_repositories/firebase_list/lib/shared/widgets/drawer/drawer.dart
import 'package:flutter/material.dart'; import 'package:firebase_list/pages/home/home_page.dart'; class CustonDrawer extends StatelessWidget { const CustonDrawer({super.key}); @override Widget build(BuildContext context) { return Drawer( child: ListView( children: [ ListTile( leading: const Icon(Icons.task), title: const Text("Tarefas"), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => const HomePage(), ), ); }, ), ListTile( leading: const Icon(Icons.chat), title: const Text("Chat"), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => const HomePage(), ), ); }, ), ListTile( leading: const Icon(Icons.bug_report), title: const Text("Crashlytics"), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => const HomePage(), ), ); }, ), ], ), ); } }
0
mirrored_repositories/firebase_list/lib/shared/widgets
mirrored_repositories/firebase_list/lib/shared/widgets/chat/chat_widget.dart
import 'package:flutter/material.dart'; import 'package:firebase_list/models/text_model.dart'; class ChatWidget extends StatelessWidget { final bool souEu; final TextModel textModel; const ChatWidget({ super.key, required this.textModel, required this.souEu, }); @override Widget build(BuildContext context) { return Container( alignment: souEu ? Alignment.centerRight : Alignment.centerLeft, child: Container( margin: const EdgeInsets.symmetric( vertical: 8, horizontal: 8, ), padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 16, ), decoration: BoxDecoration( color: souEu ? Colors.blue : Colors.orange, borderRadius: BorderRadius.circular( 10, ), ), child: Column( children: [ Text( textModel.nickname, style: const TextStyle( color: Colors.white, ), ), Text( textModel.text, style: const TextStyle( color: Colors.white, ), ), ], ), ), ); } }
0
mirrored_repositories/firebase_list/lib/pages
mirrored_repositories/firebase_list/lib/pages/spalsh_screen/splash_screen.dart
import 'dart:js'; import 'package:uuid/uuid.dart'; import 'package:flutter/material.dart'; import 'package:firebase_list/pages/home/home_page.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @override State<SplashScreen> createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); carregarHome(); } carregarHome() async { FirebaseAnalytics analytics = FirebaseAnalytics.instance; analytics.logEvent(name: "SplashScreenOepn"); final prefs = await SharedPreferences.getInstance(); var userId = prefs.getString('user_id'); if (userId == null) { var uuid = const Uuid(); userId = uuid.v4(); await prefs.setString('user_id', userId); } Future.delayed( const Duration(seconds: 2), () { Navigator.pushReplacement( context as BuildContext, MaterialPageRoute( builder: (_) => const HomePage(), ), ); }, ); } @override Widget build(BuildContext context) { return Scaffold( body: Container(), ); } }
0
mirrored_repositories/firebase_list/lib/pages
mirrored_repositories/firebase_list/lib/pages/chat/chat_page.dart
import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_list/models/text_model.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:firebase_list/shared/widgets/chat/chat_widget.dart'; class ChatPage extends StatefulWidget { final String nickName; const ChatPage({super.key, required this.nickName}); @override State<ChatPage> createState() => _ChatPageState(); } class _ChatPageState extends State<ChatPage> { final db = FirebaseFirestore.instance; final textoController = TextEditingController(text: ''); String userId = ""; @override void initState() { super.initState(); carregarUsuario(); } carregarUsuario() async { final prefs = await SharedPreferences.getInstance(); userId = prefs.getString('user_id')!; setState(() {}); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: const Text("Chat"), ), body: Container( child: Column( children: [ Expanded( child: StreamBuilder<QuerySnapshot>( stream: db.collection("chats").snapshots(), builder: (context, snapshot) { return !snapshot.hasData ? const CircularProgressIndicator() : ListView( children: snapshot.data!.docs.map((e) { var textModel = TextModel.fromJson( (e.data() as Map<String, dynamic>), ); return ChatWidget( textModel: textModel, souEu: textModel.userId == userId, ); }).toList(), ); }), ), Container( margin: const EdgeInsets.symmetric( vertical: 4, horizontal: 16, ), padding: const EdgeInsets.symmetric( vertical: 0, horizontal: 16, ), decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular( 20, ), ), border: Border.all(color: Colors.black), ), child: Row( children: [ Expanded( child: TextField( controller: textoController, decoration: const InputDecoration( focusedBorder: InputBorder.none, ), style: const TextStyle( fontSize: 18, ), )), IconButton( onPressed: () async { var textModel = TextModel( nickname: widget.nickName, text: textoController.text, userId: userId); await db.collection("chats").add( textModel.toJson(), ); textoController.text = ''; }, icon: const Icon( Icons.send, ), ), ], ), ) ], ), ), ), ); } }
0
mirrored_repositories/firebase_list/lib/pages
mirrored_repositories/firebase_list/lib/pages/home/home_page.dart
import 'package:flutter/material.dart'; import 'package:firebase_list/shared/widgets/drawer/drawer.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { final remoteConfig = FirebaseRemoteConfig.instance; return SafeArea( child: Scaffold( drawer: const CustonDrawer(), backgroundColor: Color( int.parse( "0xff${remoteConfig.getString("COR_FUNDO_TELA")}", ), ), appBar: AppBar( title: const Text("Home"), ), ), ); } }
0
mirrored_repositories/firebase_list/lib/pages
mirrored_repositories/firebase_list/lib/pages/tasks/tarefa_page.dart
import 'package:uuid/uuid.dart'; import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_list/models/tarefa_model.dart'; import 'package:shared_preferences/shared_preferences.dart'; class TarefaPage extends StatefulWidget { TarefaPage({super.key}); @override State<TarefaPage> createState() => _TarefaPageState(); } class _TarefaPageState extends State<TarefaPage> { final db = FirebaseFirestore.instance; String userId = ""; final descricaoContoller = TextEditingController(); var apenasNaoConcluido = false; @override void initState() { // TODO: implement initState super.initState(); carregarUsuario(); } carregarUsuario() async { final prefs = await SharedPreferences.getInstance(); userId = prefs.getString('user_id')!; setState(() {}); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: const Text("Tarefas"), ), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add), onPressed: () { descricaoContoller.text = ""; showDialog( context: context, builder: (BuildContext bc) { return AlertDialog( title: const Text("Adicionar tarefa"), content: TextField( controller: descricaoContoller, ), actions: [ TextButton( onPressed: () { Navigator.pop(context); }, child: const Text("Cancelar")), TextButton( onPressed: () async { var tarefa = TarefaModel( descricao: descricaoContoller.text, concluido: false, userId: userId); await db.collection("tarefas").add(tarefa.toJson()); Navigator.pop(context); }, child: const Text("Salvar")) ], ); }, ); }, ), body: Container( margin: const EdgeInsets.symmetric( vertical: 8, horizontal: 16, ), child: Column( children: [ Container( margin: const EdgeInsets.symmetric( vertical: 8, horizontal: 12, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( "Apenas não concluídos", style: TextStyle( fontSize: 18, ), ), Switch( value: apenasNaoConcluido, onChanged: (bool value) { apenasNaoConcluido = value; setState( () {}, ); }, ) ], ), ), Expanded( child: StreamBuilder<QuerySnapshot>( stream: apenasNaoConcluido ? db .collection("tarefas") .where( 'concluido', isEqualTo: false, ) .where( 'user_id', isEqualTo: userId, ) .snapshots() : db .collection( "tarefas", ) .where( 'user_id', isEqualTo: userId, ) .snapshots(), builder: (context, snapshot) { return !snapshot.hasData ? const CircularProgressIndicator() : ListView( children: snapshot.data!.docs.map( (e) { var tarefa = TarefaModel.fromJson( (e.data() as Map<String, dynamic>), ); return Dismissible( onDismissed: (DismissDirection dismissDirection) async { await db .collection("tarefas") .doc(e.id) .delete(); }, key: Key(e.id), child: ListTile( title: Text( tarefa.descricao, ), trailing: Switch( onChanged: (bool value) async { tarefa.concluido = value; tarefa.dataAlteracao = DateTime.now(); await db .collection("tarefas") .doc(e.id) .update(tarefa.toJson()); }, value: tarefa.concluido, ), ), ); }, ).toList(), ); }, ), ), ], ), ), ), ); } }
0
mirrored_repositories/firebase_list/lib
mirrored_repositories/firebase_list/lib/models/tarefa_model.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class TarefaModel { String descricao = ""; bool concluido = false; DateTime dataCriacao = DateTime.now(); DateTime dataAlteracao = DateTime.now(); String userId = ""; TarefaModel( {required this.descricao, required this.concluido, required this.userId}); TarefaModel.fromJson(Map<String, dynamic> json) { descricao = json['descricao']; concluido = json['concluido']; dataCriacao = (json['data_criacao'] as Timestamp).toDate(); dataAlteracao = (json['data_alteracao'] as Timestamp).toDate(); userId = json['user_id']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['descricao'] = this.descricao; data['concluido'] = this.concluido; data['data_criacao'] = Timestamp.fromDate(this.dataCriacao); data['data_alteracao'] = Timestamp.fromDate(this.dataAlteracao); data['user_id'] = this.userId; return data; } }
0
mirrored_repositories/firebase_list/lib
mirrored_repositories/firebase_list/lib/models/text_model.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class TextModel { DateTime dataHora = DateTime.now(); String text = ""; String userId = ""; String nickname = ""; TextModel({required this.text, required this.userId, required this.nickname}); TextModel.fromJson(Map<String, dynamic> json) { dataHora = (json['data_hora'] as Timestamp).toDate(); text = json['text']; userId = json['user_id']; nickname = json['nickname']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['data_hora'] = Timestamp.fromDate(this.dataHora); data['text'] = this.text; data['user_id'] = this.userId; data['nickname'] = this.nickname; return data; } }
0
mirrored_repositories/firebase_list
mirrored_repositories/firebase_list/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:firebase_list/main_app.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MainApp()); // 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/travis_ci
mirrored_repositories/travis_ci/lib/main.dart
/* * main.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'pages/ci_selection.dart'; import 'store/main_store/main_store.dart'; void main() async { mainStore = MainStore(); WidgetsFlutterBinding.ensureInitialized(); mainStore.prefs = await SharedPreferences.getInstance(); mainStore.brightness = (mainStore.prefs.getBool("isDark") ?? false) ? Brightness.dark : Brightness.light; runApp(TravisCI()); } MainStore mainStore; class TravisCI extends StatefulWidget { @override _TravisCIState createState() => _TravisCIState(); } class _TravisCIState extends State<TravisCI> { @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, )); return Observer( builder: (_) => MaterialApp( title: 'Travis CI', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.teal, fontFamily: 'SourceSansPro', brightness: mainStore.brightness ?? Brightness.light), home: InitializationPage(), )); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/init/init.dart
/* * init.dart * * Created by Amit Khairnar on 09/10/2020. */ import '../store/token_store/token_store.dart'; /// Base url for all the apis String baseUrl; /// Boolean to check if selected CI server is org or not bool isOrg; /// Stores token TokenStore kTokenStore;
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/widgets/restart_cancel_button.dart
/* * restart_cancel_button.dart * * Created by Amit Khairnar on 08/12/2020. */ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import '../store/restart_cancel_store/restart_cancel_store.dart'; import '../utils/dialog.dart'; class RestartCancelBuildButton extends StatefulWidget { final String buildId; final bool isRestart; final ValueChanged<bool> onChanged; const RestartCancelBuildButton( {Key key, this.buildId, this.onChanged, this.isRestart = true}) : super(key: key); @override _RestartCancelBuildButtonState createState() => _RestartCancelBuildButtonState(); } class _RestartCancelBuildButtonState extends State<RestartCancelBuildButton> { final RestartCancelBuildStore _store = RestartCancelBuildStore(); ReactionDisposer _restartCancelBuildDisposer; @override void dispose() { _restartCancelBuildDisposer(); super.dispose(); } @override void initState() { super.initState(); _restartCancelBuildDisposer = reaction( (_) => _store.restartCancelBuildFuture.status, (result) => _store.restartCancelBuildFuture.status == FutureStatus.rejected && _store.hasErrors ? _showError() : _store.restartCancelBuildFuture.status == FutureStatus.fulfilled && !_store.hasErrors ? _update() : null, ); } _showError() { TravisDialog.showWarning(context: context, text: _store.errorMessage); _store.errorMessage = ''; } _update() { widget.onChanged(true); } @override Widget build(BuildContext context) { return Observer( builder: (_) => _store.restartCancelBuildFuture != null && _store.restartCancelBuildFuture.status == FutureStatus.pending ? CircularProgressIndicator( strokeWidth: 1.5, ) : ActionChip( avatar: Icon( widget.isRestart ? Icons.refresh : Icons.close, color: Theme.of(context).iconTheme.color.withOpacity(0.6), ), label: Text( '${widget.isRestart ? "Restart" : "Cancel"} build', style: TextStyle( color: Theme.of(context).iconTheme.color.withOpacity(0.6)), ), //backgroundColor: Colors.white30, //shape: StadiumBorder(side: BorderSide(color: Colors.grey[200])), onPressed: () { _store.restartCancelBuild( widget.buildId, widget.isRestart, CancelToken()); //TravisCIApi().restartBuild(buildData.jobs.first.id.toString(), CancelToken()); // TravisCIApi() // .restartBuild(buildData.id.toString(), CancelToken()); })); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/widgets/repo_list_tile.dart
/* * repo_list_tile.dart * * Created by Amit Khairnar on 08/12/2020. */ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import '../models/repo.dart'; import '../pages/details.dart'; import '../store/repo_listtile_store/repo_listtile_store.dart'; import '../utils/dialog.dart'; import '../utils/icon_fonts.dart'; class RepoListTile extends StatefulWidget { final RepositoriesModel repositoriesModel; const RepoListTile({Key key, this.repositoriesModel}) : super(key: key); @override _RepoListTileState createState() => _RepoListTileState(); } class _RepoListTileState extends State<RepoListTile> { final RepoListTileStore _repoListTileStore = RepoListTileStore(); final CancelToken _cancelToken = CancelToken(); ReactionDisposer _activateDeactivateDisposer; @override Widget build(BuildContext context) { return ListTile( contentPadding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0), leading: Icon( TravisLogos.source_repository, color: Colors.grey, ), title: Text(widget.repositoriesModel.name, style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500)), subtitle: Text(widget.repositoriesModel.owner, style: TextStyle(color: Colors.blue, fontSize: 15.0)), trailing: Observer( builder: (_) => _repoListTileStore.activateDeactivateRepoFuture != null && _repoListTileStore.activateDeactivateRepoFuture.status == FutureStatus.pending ? CircularProgressIndicator( strokeWidth: 1.5, ) : Switch( value: widget.repositoriesModel.active, onChanged: widget.repositoriesModel.permissions.activate || widget.repositoriesModel.permissions.deactivate ? (value) { _repoListTileStore.activateDeactivateRepo( widget.repositoriesModel.id.toString(), !widget.repositoriesModel.active, _cancelToken); } : null, )), onTap: () { Navigator.of(context) .push(MaterialPageRoute(builder: (BuildContext context) { return Details( repositoriesModel: widget.repositoriesModel, ); })); }, ); } @override void dispose() { _activateDeactivateDisposer(); super.dispose(); } @override void initState() { super.initState(); _activateDeactivateDisposer = reaction( (_) => _repoListTileStore.activateDeactivateRepoFuture.status, (result) => _repoListTileStore.activateDeactivateRepoFuture.status == FutureStatus.rejected && _repoListTileStore.hasErrors ? _showError() : _repoListTileStore.activateDeactivateRepoFuture.status == FutureStatus.fulfilled && !_repoListTileStore.hasErrors ? _update() : null, ); } _showError() { TravisDialog.showWarning( context: context, text: _repoListTileStore.errorMessage); _repoListTileStore.errorMessage = ''; } _update() { widget.repositoriesModel.active = _repoListTileStore.repositoriesModel.active; } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/widgets/openhub_logo.dart
/* * openhub_logo.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; import 'package:travis_ci/utils/open_url.dart'; /// Flutter OpenHub logo class OpenHubLogo extends StatelessWidget { @override Widget build(BuildContext context) { return InkWell( child: Container( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ FlutterLogo( size: 40.0, ), Text( 'OpenHub', style: TextStyle(fontSize: 20.0), textAlign: TextAlign.center, ), ], ), ), onTap: () { OpenUrl.launchURL("https://github.com/Flutter-OpenHub"); }, ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/home_page.dart
/* * home_page.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:feather_icons_flutter/feather_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:responsive_builder/responsive_builder.dart'; import '../fragments/home_fragment.dart'; import '../fragments/my_builds.dart'; import '../fragments/repo_fragment.dart'; import '../store/form_store/form_store.dart'; import '../utils/icon_fonts.dart'; import 'my_account.dart'; import 'settings.dart'; class HomePage extends StatefulWidget { final FormStore store; const HomePage({Key key, this.store}) : super(key: key); @override HomePageState createState() => HomePageState(); } class HomePageState extends State<HomePage> { int _index = 0; String _title = "Active Repos"; Widget _selectedWidget; @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (context, sizingInformation) => Scaffold( //backgroundColor: Color.fromRGBO(242, 242, 247, 1.0), appBar: AppBar( title: Text( sizingInformation.deviceScreenType == DeviceScreenType.mobile ? _title : "Travis CI", style: TextStyle( fontWeight: FontWeight.w600, fontFamily: 'SourceSansPro'), ), elevation: 0.0, centerTitle: false, ), drawer: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? Drawer( child: SafeArea( child: Column( children: [ DrawerHeader( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ CircleAvatar( radius: 28.0, backgroundImage: NetworkImage( widget.store.userStore.user.avatarUrl), ), ListTile( title: Text(widget.store.userStore.user.name), subtitle: Text(widget.store.userStore.user.login), trailing: Icon(Icons.keyboard_arrow_right), contentPadding: const EdgeInsets.only(), onTap: () { Navigator.of(context).pop(); Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { return MyAccount( formStore: widget.store, ); })); }, ) ], ), )), Expanded( child: ListView( padding: const EdgeInsets.only(), shrinkWrap: true, children: [ ListTile( leading: Icon(TravisLogos.source_repository), title: Text("Active Repos"), selected: _index == 0, onTap: () { Navigator.of(context).pop(); setState(() { _index = 0; _title = "Active Repos"; _selectedWidget = HomeFragment(); }); }, ), ListTile( leading: Icon(TravisLogos.source_repository_multiple), title: Text("All Repos"), selected: _index == 1, onTap: () { Navigator.of(context).pop(); setState(() { _index = 1; _title = "All Repos"; _selectedWidget = RepoFragment(); }); }, ), ListTile( leading: Icon(FeatherIcons.settings), title: Text("Builds"), selected: _index == 2, onTap: () { Navigator.of(context).pop(); setState(() { _index = 2; _title = "Builds"; _selectedWidget = MyBuilds(); }); }, ), ], ), ), Divider( height: 0.0, ), ListTile( leading: Icon(FeatherIcons.settings), title: Text("Settings"), onTap: () { Navigator.of(context).pop(); Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { return SettingsPage( showAppBar: true, ); })); }, ), ], )), ) : null, body: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? _selectedWidget : Row( children: [ Expanded(flex: 3, child: _drawer(sizingInformation)), VerticalDivider( width: 1.0, ), Expanded(flex: 5, child: _selectedWidget) ], )), ); } // _showDialog() { // showDialog( // context: context, // builder: (_) => AlertDialog( // contentPadding: const EdgeInsets.all(0), // content: SizedBox( // width: MediaQuery.of(context).size.width * 0.7, // height: MediaQuery.of(context).size.height * 0.7, // child: MyAccount( // formStore: widget.store, // ), // ), // )); // } _drawer(SizingInformation sizingInformation) { return Drawer( elevation: 0.0, child: Container( //color: Color.fromRGBO(242, 242, 247, 1.0), //color: Theme.of(context).cardColor, child: SafeArea( child: Column( children: [ DrawerHeader( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ CircleAvatar( radius: 28.0, backgroundImage: NetworkImage(widget.store.userStore.user.avatarUrl), ), ListTile( title: Text(widget.store.userStore.user.name), subtitle: Text(widget.store.userStore.user.login), trailing: Icon(Icons.keyboard_arrow_right), contentPadding: const EdgeInsets.only(), onTap: () { //_showDialog(); if (sizingInformation.deviceScreenType == DeviceScreenType.mobile) Navigator.of(context).pop(); Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { return MyAccount( formStore: widget.store, ); })); }, ) ], ), )), Expanded( child: ListView( padding: const EdgeInsets.only(), shrinkWrap: true, children: [ ListTile( leading: Icon(TravisLogos.source_repository), title: Text("Active Repos"), selected: _index == 0, onTap: () { if (sizingInformation.deviceScreenType == DeviceScreenType.mobile) Navigator.of(context).pop(); setState(() { _index = 0; _title = "Active Repos"; _selectedWidget = HomeFragment(); }); }, ), ListTile( leading: Icon(TravisLogos.source_repository_multiple), title: Text("All Repos"), selected: _index == 1, onTap: () { if (sizingInformation.deviceScreenType == DeviceScreenType.mobile) Navigator.of(context).pop(); setState(() { _index = 1; _title = "All Repos"; _selectedWidget = RepoFragment(); }); }, ), ListTile( leading: Icon(FeatherIcons.settings), title: Text("Builds"), selected: _index == 2, onTap: () { if (sizingInformation.deviceScreenType == DeviceScreenType.mobile) Navigator.of(context).pop(); setState(() { _index = 2; _title = "Builds"; _selectedWidget = MyBuilds(); }); }, ), if (sizingInformation.deviceScreenType != DeviceScreenType.mobile) _settingsWidget(sizingInformation) ], ), ), if (sizingInformation.deviceScreenType == DeviceScreenType.mobile) _settingsWidget(sizingInformation) ], )), ), ); } _settingsWidget(SizingInformation sizingInformation) { return Column( children: [ Divider( height: 0.0, ), ListTile( leading: Icon(FeatherIcons.settings), title: Text("Settings"), onTap: () { if (sizingInformation.deviceScreenType == DeviceScreenType.mobile) { Navigator.of(context).pop(); Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { return SettingsPage( showAppBar: true, ); })); } else { setState(() { _index = 3; _title = "Settings"; _selectedWidget = SettingsPage( showAppBar: false, ); }); } }, ), ], ); } @override void initState() { super.initState(); _selectedWidget = HomeFragment(); } // Image.asset( // 'assets/TravisCI-Full-Color.png', // height: kToolbarHeight - 24.0, // ) }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/details.dart
/* * details.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:dio/dio.dart'; import 'package:feather_icons_flutter/feather_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import '../models/repo.dart'; import '../pages/build_details.dart'; import '../store/builds_store/builds_store.dart'; import '../utils/dialog.dart'; import '../utils/get_icon.dart'; import '../utils/get_state_color.dart'; class Details extends StatefulWidget { final RepositoriesModel repositoriesModel; const Details({Key key, this.repositoriesModel}) : super(key: key); @override _DetailsState createState() => _DetailsState(); } class _DetailsState extends State<Details> with SingleTickerProviderStateMixin { BuildsStore _buildsStore = BuildsStore(); TabController _tabController; ReactionDisposer _starUnStarDisposer; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0.0, title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.repositoriesModel.owner, style: TextStyle(fontSize: 14.0), ), Text( widget.repositoriesModel.name, style: TextStyle(fontSize: 16.0), ) ], ), centerTitle: false, actions: <Widget>[ Observer( builder: (_) => _buildsStore.starUnStarRepoFuture != null && _buildsStore.starUnStarRepoFuture.status == FutureStatus.pending ? Padding( padding: const EdgeInsets.all(16.0), child: SizedBox( width: 24.0, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation(Colors.white), strokeWidth: 1.5, ), ), ) : IconButton( icon: Icon(widget.repositoriesModel.starred ? Icons.star : Icons.star_border), color: widget.repositoriesModel.starred ? Colors.orange : null, tooltip: widget.repositoriesModel.permissions.star || widget.repositoriesModel.permissions.unStar ? "Star repo" : "Insufficient Permissions", onPressed: widget.repositoriesModel.permissions.star || widget.repositoriesModel.permissions.unStar ? () { _buildsStore.starUnStarRepo( widget.repositoriesModel.id.toString(), !widget.repositoriesModel.starred, CancelToken()); } : null)) ], bottom: TabBar(controller: _tabController, tabs: [ Tab( text: 'Current', ), Tab( text: 'Build History', ), ]), ), body: Observer( builder: (_) => _buildsStore.getBuildsFuture.status == FutureStatus.fulfilled ? TabBarView(controller: _tabController, children: [ _current(), _history(), ]) : _buildsStore.getBuildsFuture.status == FutureStatus.rejected ? Center( child: Text(_buildsStore.errorMessage), ) : Center( child: CircularProgressIndicator(), )), ); } @override void dispose() { _starUnStarDisposer(); super.dispose(); } @override void initState() { super.initState(); _tabController = TabController(length: 2, vsync: this); _starUnStarDisposer = reaction( (_) => _buildsStore.starUnStarRepoFuture.status, (result) => _buildsStore.starUnStarRepoFuture.status == FutureStatus.rejected && _buildsStore.hasErrors ? _showError() : _buildsStore.starUnStarRepoFuture.status == FutureStatus.fulfilled && !_buildsStore.hasErrors ? _navigate(true) : null, ); _buildsStore.getBuilds( widget.repositoriesModel.id.toString(), CancelToken()); } Widget _current() { return _buildsStore.builds.isNotEmpty ? BuildDetails( buildData: _buildsStore.builds.first, showAppbar: false, onChanged: (value) { _buildsStore.getBuilds( widget.repositoriesModel.id.toString(), CancelToken()); }, ) : Center( child: Text("No builds for this repository"), ); } Widget _history() { return _buildsStore.builds.isNotEmpty ? ListView.separated( padding: const EdgeInsets.symmetric(vertical: 16.0), itemBuilder: (_, index) => ListTile( title: Text( _buildsStore.builds[index].commit.message, //maxLines: 1, //overflow: TextOverflow.ellipsis, style: TextStyle(fontWeight: FontWeight.w500, fontSize: 14.0), ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 8.0, ), Row( children: [ GetIcon.getIcon(_buildsStore.builds[index].state, size: 16.0), SizedBox( width: 4.0, ), Text( _buildsStore.builds[index].state != null ? _buildsStore.builds[index].state .toString() .split('.') .last : 'received', style: TextStyle( color: GetStateColor.getStateColor( _buildsStore.builds[index].state), fontWeight: FontWeight.bold), ), ], ), SizedBox( height: 4.0, ), Row( children: [ Expanded( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.gitCommit, color: Colors.teal, size: 16.0, ), SizedBox( width: 8.0, ), Text( "${_buildsStore.builds[index].commit.sha.substring(0, 7)}", style: TextStyle(fontWeight: FontWeight.w500), ) ], )), Expanded( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.clock, color: Colors.teal, size: 14.0, ), SizedBox( width: 8.0, ), Text( _buildsStore.builds[index].duration != null ? "${_buildsStore.builds[index].duration ~/ 60} min " "${_buildsStore.builds[index].duration % 60} sec" : "-", style: TextStyle(fontWeight: FontWeight.w500), ) ], )) ], ) ], ), leading: Text( "#${_buildsStore.builds[index].number}", style: TextStyle( color: GetStateColor.getStateColor( _buildsStore.builds[index].state), fontWeight: FontWeight.bold), ), trailing: IconButton(icon: Icon(Icons.refresh), onPressed: () {}), onTap: () { showModalBottomSheet( context: context, isScrollControlled: true, builder: (_) => BuildDetails( buildData: _buildsStore.builds[index], showAppbar: true, )); }, ), separatorBuilder: (_, index) => Divider(), itemCount: _buildsStore.builds.length) : Center( child: Text("No builds for this repository"), ); } _navigate(bool isUpdate) { widget.repositoriesModel.starred = _buildsStore.repositoriesModel.starred; } _showError() { TravisDialog.showWarning(context: context, text: _buildsStore.errorMessage); _buildsStore.errorMessage = ''; } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/user_data_widget.dart
/* * user_data_widget.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:travis_ci/store/get_user_store/get_user_store.dart'; class UserDataWidget extends StatefulWidget { final String id; final String token; const UserDataWidget({Key key, this.id, this.token}) : super(key: key); @override _UserDataWidgetState createState() => _UserDataWidgetState(); } class _UserDataWidgetState extends State<UserDataWidget> { final GetUserStore _getUserStore = GetUserStore(); @override void initState() { super.initState(); _getUserStore.getUser(widget.id, CancelToken()); } @override Widget build(BuildContext context) { return Observer( builder: (_) => _getUserStore.getUserFuture.status == FutureStatus.fulfilled ? Row( children: [ CircleAvatar( backgroundImage: NetworkImage(_getUserStore.user.avatarUrl), radius: 12.0, ), SizedBox( width: 8.0, ), Expanded( child: Text(_getUserStore.user.login, style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16.0, color: Theme.of(context).textTheme.headline2.color, ))) ], ) : _getUserStore.getUserFuture.status == FutureStatus.rejected ? Text(_getUserStore.errorMessage) : Padding( padding: const EdgeInsets.all(6.0), child: SizedBox( width: 12.0, height: 12.0, child: CircularProgressIndicator( strokeWidth: 1.0, ), ), )); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/show_logs.dart
/* * show_logs.dart * * Created by Amit Khairnar on 11/10/2020. */ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import '../store/logs_store/logs_store.dart'; class ShowLogs extends StatefulWidget { final int jobId; const ShowLogs({Key key, this.jobId}) : super(key: key); @override _ShowLogsState createState() => _ShowLogsState(); } class _ShowLogsState extends State<ShowLogs> { final LogsStore _logsStore = LogsStore(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Log"), ), body: Observer( builder: (_) => _logsStore.getBuildLogFuture != null ? _logsStore.getBuildLogFuture.status == FutureStatus.fulfilled ? Container( color: Colors.black, child: _buildLog(_logsStore.buildLog['content'].toString()), ) : _logsStore.getBuildLogFuture.status == FutureStatus.rejected ? Text(_logsStore.errorMessage) : Center( child: CircularProgressIndicator(), ) : Container(), ), ); } @override void initState() { super.initState(); _logsStore.getBuildLog(widget.jobId.toString(), CancelToken()); } Widget _buildLog(String log) { List<String> _data = log.split("\n"); return ListView.builder( itemCount: _data.length, padding: const EdgeInsets.all(16.0), itemBuilder: (_, index) => (_data[index].contains("travis_fold:start:") && _data[index].contains("[0K")) || (_data[index].startsWith("") && _data[index].contains("")) ? Text( (_data[index].contains("travis_fold:start:") && _data[index].contains("[0K")) ? _data[index] .split("[0K") .last .split("") .first .trim() : _data[index] .split("") .last .split("") .first .trim(), style: TextStyle( fontWeight: FontWeight.w600, fontFamily: 'Cousine', fontSize: 10.0, color: Color.fromRGBO(255, 255, 145, 1.0)), ) : _data[index].startsWith("+ ") ? RichText( text: TextSpan( text: '+ ', style: TextStyle( color: Colors.green, fontFamily: "Cousine", fontSize: 10.0), children: [ TextSpan( text: _data[index] .split("+ ") .last .split("") .first .split("[1m") .last .replaceAll("", "") .trimLeft(), style: TextStyle( fontSize: 10.0, color: Colors.white, fontWeight: FontWeight.w500, fontFamily: "Cousine", )), if (_data[index] .split("+ ") .last .contains("[36m") && _data[index] .split("+ ") .last .contains("[39m")) TextSpan( text: _data[index] .split("+ ") .last .split("[36m") .last .replaceAll("", "") .trimLeft(), style: TextStyle( fontSize: 10.0, fontFamily: "Cousine", color: Colors.lightBlueAccent)) ]), ) : Text( _data[index].contains("[34m") ? _data[index] .split("[34m") .last .split("") .first .trimLeft() : _data[index], style: TextStyle( color: _data[index].contains("[34m") ? Colors.lightBlueAccent : Colors.white, fontSize: 10.0, fontWeight: _data[index].contains("[34m") ? FontWeight.w600 : FontWeight.normal, fontFamily: 'Cousine', //fontWeight: FontWeight.w500, ), )); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/ci_login.dart
/* * ci_login.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:responsive_builder/responsive_builder.dart'; import '../init/init.dart'; import '../store/form_store/form_store.dart'; import '../store/token_store/token_store.dart'; import '../utils/open_url.dart'; import 'home_page.dart'; class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { static final _formKey = GlobalKey<FormState>(); final FormStore store = FormStore(); bool _obscurePassword = true; final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); ReactionDisposer _disposer; @override Widget build(BuildContext context) { return ResponsiveBuilder( builder: (BuildContext context, SizingInformation sizingInformation) => Scaffold( //backgroundColor: Colors.white, key: _scaffoldKey, appBar: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? AppBar(title: Text("Login"), centerTitle: true) : null, bottomNavigationBar: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? BottomAppBar( child: ListTile( leading: Icon(Icons.help_outline), title: Text('How to generate access token?', style: TextStyle(fontWeight: FontWeight.w500)), onTap: _showInstructions, ), ) : null, body: _buildUI(sizingInformation)), ); } @override void dispose() { _disposer(); store.dispose(); super.dispose(); } @override void initState() { super.initState(); store.setupValidations(); _disposer = reaction( (_) => store.authUserFuture.status, (result) => store.authUserFuture.status == FutureStatus.rejected && store.hasError ? _showError() : store.authUserFuture.status == FutureStatus.fulfilled && !store.hasError ? _navigate() : null, ); } _buildForm(SizingInformation sizingInformation) { return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Padding( padding: EdgeInsets.only( top: (sizingInformation.deviceScreenType == DeviceScreenType.mobile) ? 24.0 : 32.0), child: Hero( tag: isOrg ? 'org' : 'com', child: Image.asset( 'assets/TravisCI-Mascot-${isOrg ? "1" : "2"}.png', width: 80.0, height: 80.0, )), ), Padding( padding: const EdgeInsets.only(top: 20.0, bottom: 8.0), child: Text( '${isOrg ? 'Org' : 'Com'} Server', style: TextStyle(fontWeight: FontWeight.w600, fontSize: 22.0), )), Text( 'https://travis-ci.${isOrg ? "org" : "com"}', style: TextStyle(color: Colors.blue), ), Container( padding: const EdgeInsets.only( left: 16.0, right: 16.0, top: 16.0, bottom: 16.0), child: Form( key: _formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Observer( builder: (_) => TextField( maxLength: 22, onChanged: (value) => store.token = value, onSubmitted: (value) { store.validateAll(); if (!store.errorState.hasErrors) { kTokenStore = TokenStore(); kTokenStore.token = store.token; store.authUser(); } }, decoration: InputDecoration( labelText: 'Enter access token', errorText: store.errorState.token, suffix: IconButton( icon: _obscurePassword ? Icon(Icons.visibility_off) : Icon(Icons.visibility), onPressed: _toggle, padding: EdgeInsets.all(0.0), ), filled: true), keyboardType: TextInputType.text, obscureText: _obscurePassword, )), SizedBox( height: 16.0, ), Observer( builder: (_) => store.authUserFuture != null && store.authUserFuture.status == FutureStatus.pending ? CircularProgressIndicator() : FloatingActionButton( onPressed: () { store.validateAll(); if (!store.errorState.hasErrors) { kTokenStore = TokenStore(); kTokenStore.token = store.token; store.authUser(); } }, child: Icon(Icons.check), tooltip: 'Login', )) ], )), ) ], ); } _buildInstructionsUI() { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'To authenticate against the Travis CI API, you need an API access token generated by the Travis CI command line client.', style: TextStyle(), ), ActionChip( label: Text('Command line client'), onPressed: () { OpenUrl.launchURL( 'https://github.com/travis-ci/travis.rb#installation'); }, ), SizedBox( height: 16.0, ), Row( children: <Widget>[ Text( 'For more details ', style: TextStyle(fontWeight: FontWeight.w500), ), InkWell( onTap: () { OpenUrl.launchURL( 'https://developer.travis-ci.com/authentication'); }, child: Text( 'click here', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.blue), ), ) ], ), SizedBox( height: 24.0, ), Text( 'Tokens for open source projects, private projects and enterprise installations of Travis CI are not interchangeable.', style: TextStyle(color: Colors.red, fontWeight: FontWeight.w600), ), ], ); } _buildUI(SizingInformation sizingInformation) { return sizingInformation.deviceScreenType == DeviceScreenType.mobile ? SingleChildScrollView(child: _buildForm(sizingInformation)) : Center( child: SizedBox( width: 500.0, child: Card( elevation: 5.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0)), child: Container( padding: const EdgeInsets.symmetric( horizontal: 24.0, vertical: 0.0), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ AppBar( title: Text( "Login", style: TextStyle( color: Theme.of(context).iconTheme.color), ), centerTitle: false, iconTheme: IconThemeData( color: Theme.of(context).iconTheme.color), backgroundColor: Theme.of(context).cardColor, elevation: 0.0, ), _buildForm(sizingInformation), SizedBox( height: 32.0, ), ListTile( leading: Icon(Icons.help_outline), title: Text('How to generate access token?', style: TextStyle(fontWeight: FontWeight.w500)), onTap: _showInstructionsDialog, ), SizedBox( height: 16.0, ), ], ), ), ), ), ), ); } _navigate() { // Init TokenStore kTokenStore = TokenStore(); kTokenStore.token = store.token; Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => HomePage(store: store))); } _showError() { //TODO Snackbar is not visible if bottomsheet is active _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text(store.errorMessage), behavior: SnackBarBehavior.floating, )); store.errorMessage = ''; } _showInstructions() { showModalBottomSheet( context: context, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)), builder: (_) => Container( padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 24.0), child: _buildInstructionsUI(), )); } _showInstructionsDialog() { showDialog( context: context, builder: (_) => AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0)), title: Text( 'How to generate access token?', ), content: _buildInstructionsUI(), actions: [ FlatButton( onPressed: () { Navigator.of(context).pop(); }, child: Text("CLOSE")), ], )); } void _toggle() { setState(() { _obscurePassword = !_obscurePassword; }); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/show_user_repos.dart
/* * show_user_repos.dart * * Created by Amit Khairnar on 08/12/2020. */ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pagewise/flutter_pagewise.dart'; import '../api/travis_ci_api.dart'; import '../models/repo.dart'; import '../widgets/repo_list_tile.dart'; class ShowUserRepos extends StatefulWidget { final String login; final String title; const ShowUserRepos({Key key, this.login, this.title}) : super(key: key); @override _ShowUserReposState createState() => _ShowUserReposState(); } class _ShowUserReposState extends State<ShowUserRepos> { PagewiseLoadController<RepositoriesModel> _pageWiseLoadController; @override Widget build(BuildContext context) { return Scaffold( //backgroundColor: Colors.white, appBar: AppBar( title: Text(widget.title), ), body: PagewiseListView( itemBuilder: _builder, shrinkWrap: true, showRetry: false, padding: const EdgeInsets.symmetric(horizontal: 2.0), pageLoadController: _pageWiseLoadController, noItemsFoundBuilder: (context) { return Chip(label: Text('No repositories found!')); }, errorBuilder: (context, error) { return Text(error.toString()); }, loadingBuilder: (context) { return CircularProgressIndicator( strokeWidth: 2.0, ); }, ), ); } @override void initState() { super.initState(); _pageWiseLoadController = PagewiseLoadController( pageSize: 10, pageFuture: (pageIndex) { return TravisCIApi.getOrganizationRepos( widget.login, (pageIndex * 10), 10, CancelToken()); }); } Widget _builder( BuildContext context, RepositoriesModel repositoriesModel, int index) { return RepoListTile(repositoriesModel: repositoriesModel); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/settings.dart
/* * settings.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:dio/dio.dart'; import 'package:feather_icons_flutter/feather_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import '../init/init.dart'; import '../main.dart'; import '../store/settings_store/settings_store.dart'; import '../utils/open_url.dart'; import '../widgets/openhub_logo.dart'; class SettingsPage extends StatefulWidget { final bool showAppBar; const SettingsPage({Key key, @required this.showAppBar}) : super(key: key); @override _SettingsPageState createState() => _SettingsPageState(); } class _SettingsPageState extends State<SettingsPage> { final SettingsStore _settingsStore = SettingsStore(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); ReactionDisposer _updateBuildEmailsDisposer; ReactionDisposer _updatePrivateInsightsDisposer; @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, //backgroundColor: Colors.white, appBar: widget.showAppBar ? AppBar( title: Text( 'Settings', style: TextStyle( fontWeight: FontWeight.w600, fontFamily: 'SourceSansPro'), ), textTheme: TextTheme(headline6: TextStyle(fontSize: 20.0)), elevation: 0.0, ) : null, body: _buildUI(), ); } @override void dispose() { _updateBuildEmailsDisposer(); _updatePrivateInsightsDisposer(); super.dispose(); } @override void initState() { super.initState(); _settingsStore.loadPrefs(); _settingsStore.getPreferences(CancelToken()); _updateBuildEmailsDisposer = reaction( (_) => _settingsStore.updateSettingsFuture.status, (result) => _settingsStore.updateSettingsFuture.status == FutureStatus.rejected && _settingsStore.hasErrors ? _showError() : _settingsStore.updateSettingsFuture.status == FutureStatus.fulfilled && !_settingsStore.hasErrors ? _saveEmailPrefs() : null, ); _updatePrivateInsightsDisposer = reaction( (_) => _settingsStore.updatePrivateInsightsFuture.status, (result) => _settingsStore.updatePrivateInsightsFuture.status == FutureStatus.rejected && _settingsStore.hasErrors ? _showError() : _settingsStore.updatePrivateInsightsFuture.status == FutureStatus.fulfilled && !_settingsStore.hasErrors ? _savePrivateInsightsPrefs() : null, ); } _buildUI() { return Observer( builder: (_) => _settingsStore.getPreferencesFuture.status == FutureStatus.fulfilled ? ListView( padding: const EdgeInsets.symmetric(vertical: 8.0), children: <Widget>[ Observer( builder: (_) => _settingsStore.updateSettingsFuture == null || (_settingsStore.updateSettingsFuture != null && (_settingsStore.updateSettingsFuture.status == FutureStatus.fulfilled || _settingsStore .updateSettingsFuture.status == FutureStatus.rejected)) ? SwitchListTile( value: _settingsStore.buildEmails, title: Text( 'Build notifications', style: TextStyle(fontWeight: FontWeight.w500), ), onChanged: (bool value) { _settingsStore.updateEmailSettings( value, CancelToken()); }, subtitle: Text( 'The status of your builds straight to your inbox'), secondary: Icon(Icons.notifications), ) : ListTile( leading: Icon(Icons.notifications), trailing: Padding( padding: const EdgeInsets.only( left: 12.0, right: 12.0), child: SizedBox( width: 20.0, height: 20.0, child: CircularProgressIndicator( strokeWidth: 2.0, ), ), ), title: Text( 'Build notifications', style: TextStyle(fontWeight: FontWeight.w500), ), subtitle: Text( 'The status of your builds straight to your inbox'), )), SwitchListTile( secondary: Icon(Icons.color_lens), title: Text("Dark Theme"), onChanged: (value) => mainStore.toggleTheme(), value: mainStore.brightness == Brightness.dark, ), if (!isOrg) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( title: Text( 'Insights Visibility Settings', style: TextStyle(fontWeight: FontWeight.w500), ), leading: Icon(Icons.visibility), ), Container( margin: const EdgeInsets.only( left: 16.0, right: 16.0, bottom: 8.0), decoration: BoxDecoration( color: Color.fromRGBO(245, 251, 251, 1.0), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ RadioListTile( value: "private", groupValue: _settingsStore.privateInsightsVisibility, onChanged: (value) => _settingsStore .privateInsightsVisibility = value, title: Text( "Do not allow everyone to see insights from your private builds", style: TextStyle( color: Colors.blueGrey, fontSize: 14.0), ), ), RadioListTile( value: "public", groupValue: _settingsStore.privateInsightsVisibility, onChanged: (value) => _settingsStore .privateInsightsVisibility = value, title: Text( "Allow everyone to see insights from your private builds", style: TextStyle( color: Colors.blueGrey, fontSize: 14.0), ), ), Padding( padding: const EdgeInsets.only( left: 28.0, top: 8.0, bottom: 16.0), child: _settingsStore .updatePrivateInsightsFuture == null || (_settingsStore .updatePrivateInsightsFuture != null && (_settingsStore .updatePrivateInsightsFuture .status == FutureStatus.fulfilled || _settingsStore .updatePrivateInsightsFuture .status == FutureStatus.rejected)) ? Material( child: InkWell( onTap: () { _settingsStore .updatePrivateInsightsVisibility( CancelToken()); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.0), border: Border.all( color: Colors.grey)), padding: const EdgeInsets.symmetric( vertical: 4.0, horizontal: 16.0), child: Text( "SAVE", style: TextStyle( color: Colors.blueGrey), ), ), ), ) : SizedBox( width: 24.0, height: 24.0, child: CircularProgressIndicator( strokeWidth: 2.0, ), ), ) ], ), ), ], ), Divider( indent: 16.0, endIndent: 16.0, ), ListTile( leading: Icon(Icons.show_chart), title: Text( 'Travis CI Status', style: TextStyle(fontWeight: FontWeight.w500), ), subtitle: Text("Check Travis CI status and incident history"), onTap: () { OpenUrl.launchURL('https://www.traviscistatus.com/'); }, ), ListTile( leading: Icon(FeatherIcons.github), title: Text( 'GitHub repo', style: TextStyle(fontWeight: FontWeight.w500), ), subtitle: Text("Check out the GitHub repo of this app"), onTap: () { OpenUrl.launchURL( 'https://github.com/Flutter-OpenHub/travis_ci'); }, ), Divider( indent: 16.0, endIndent: 16.0, ), Container( margin: const EdgeInsets.symmetric(vertical: 24.0), child: Column( children: [ Text( "Developed by", style: TextStyle(fontWeight: FontWeight.w500), ), SizedBox( height: 16.0, ), OpenHubLogo() ], ), ) ], ) : _settingsStore.getPreferencesFuture.status == FutureStatus.rejected ? Center( child: Padding( padding: const EdgeInsets.all(8.0), child: Text(_settingsStore.errorMessage), ), ) : Center( child: CircularProgressIndicator(), )); } _saveEmailPrefs() async { _settingsStore.buildEmails = _settingsStore.buildEmailsResponse.value; _settingsStore.sharedPreferences .setBool("notification", _settingsStore.buildEmails); } _savePrivateInsightsPrefs() async { _settingsStore.privateInsightsVisibility = _settingsStore.privateInsightsVisibilityResponse.value; _settingsStore.sharedPreferences.setString( "private_insights", _settingsStore.privateInsightsVisibility); } _showError() { _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text(_settingsStore.errorMessage), behavior: SnackBarBehavior.floating, )); _settingsStore.errorMessage = ''; } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/build_details.dart
/* * build_details.dart * * Created by Amit Khairnar on 11/10/2020. */ import 'package:feather_icons_flutter/feather_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:timeago/timeago.dart' as timeago; import '../enum/build_status.dart'; import '../models/build_model.dart'; import '../utils/get_icon.dart'; import '../utils/get_state_color.dart'; import '../utils/open_url.dart'; import '../widgets/restart_cancel_button.dart'; import 'show_logs.dart'; import 'user_data_widget.dart'; class BuildDetails extends StatelessWidget { final BuildsModel buildData; final bool showAppbar; final ValueChanged<bool> onChanged; const BuildDetails({Key key, this.buildData, this.showAppbar, this.onChanged}) : super(key: key); @override Widget build(BuildContext context) { return SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ showAppbar ? AppBar( automaticallyImplyLeading: false, elevation: 0.0, title: Text("Build #${buildData.number}"), actions: [ IconButton( icon: Icon(Icons.cancel), onPressed: () { Navigator.of(context).pop(); }) ], centerTitle: false, ) : Container(), ListTile( leading: buildData.state != null ? GetIcon.getIcon(buildData.state) : Icon( Icons.more_horiz, color: Colors.grey, ), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.gitCommit, size: 16.0, ), Text( [ " #${buildData.number}", buildData.state != null ? buildData.state.toString().split('.').last : 'received' ].join(" "), style: TextStyle( color: GetStateColor.getStateColor(buildData.state), fontWeight: FontWeight.bold), ), ], ), title: Text( buildData.commit.message, maxLines: 1, style: TextStyle( fontWeight: FontWeight.w500, color: GetStateColor.getStateColor(buildData.state)), ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0), child: Row( children: [ Expanded( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.gitCommit, color: Theme.of(context).iconTheme.color.withOpacity(0.6), size: 16.0, ), SizedBox( width: 8.0, ), Text( "Commit ${buildData.commit.sha.substring(0, 7)}", style: TextStyle(fontWeight: FontWeight.w500), ) ], )), Expanded( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.clock, color: Theme.of(context).iconTheme.color.withOpacity(0.6), size: 16.0, ), SizedBox( width: 8.0, ), Text( buildData.duration != null ? "Ran for ${buildData.duration ~/ 60} min " "${buildData.duration % 60} sec" : '-', style: TextStyle(fontWeight: FontWeight.w500), ) ], )) ], ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0), child: InkWell( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.gitPullRequest, color: Theme.of(context).iconTheme.color.withOpacity(0.6), size: 16.0, ), SizedBox( width: 8.0, ), Text( [ "Compare", buildData.commit.compareUrl .split('/') .last .split('...') .length > 1 ? buildData.commit.compareUrl .split('/') .last .split('...') .map((e) => e.substring(0, 7)) .join("...") : buildData.commit.compareUrl.split('/').last ].join(" "), style: TextStyle(fontWeight: FontWeight.w500), ) ], ), onTap: () { OpenUrl.launchURL(buildData.commit.compareUrl); }, ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0), child: InkWell( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( buildData.tag != null ? FeatherIcons.tag : FeatherIcons.gitBranch, color: Theme.of(context).iconTheme.color.withOpacity(0.6), size: 16.0, ), SizedBox( width: 8.0, ), Text( [ buildData.tag != null ? "Tag" : "Branch", buildData.branch.name ].join(" "), style: TextStyle(fontWeight: FontWeight.w500), ) ], ), onTap: () { //TODO: Show the branch in web page //OpenUrl.launchURL("url"); }, ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0), child: Row( children: [ Icon( FeatherIcons.calendar, color: Theme.of(context).iconTheme.color.withOpacity(0.6), size: 16.0, ), SizedBox( width: 8.0, ), Text( buildData.createdAt != null ? timeago.format(DateTime.parse(buildData.createdAt)) : "-", style: TextStyle(fontWeight: FontWeight.w500), ) ], ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 12.0), child: UserDataWidget( id: buildData.createdBy.id.toString(), ), ), // Align( // alignment: Alignment.centerRight, // child: Padding( // padding: const EdgeInsets.all(8.0), // child: ActionChip( // avatar: Icon( // Icons.refresh, // color: Colors.teal, // ), // label: Text( // 'Restart build', // style: TextStyle(color: Colors.teal), // ), // backgroundColor: Colors.white30, // shape: // StadiumBorder(side: BorderSide(color: Colors.grey[200])), // onPressed: () { // //TravisCIApi().restartBuild(buildData.jobs.first.id.toString(), CancelToken()); // TravisCIApi() // .restartBuild(buildData.id.toString(), CancelToken()); // }), // ), // ), Align( alignment: Alignment.centerRight, child: Padding( padding: const EdgeInsets.all(8.0), child: RestartCancelBuildButton( buildId: buildData.id.toString(), onChanged: onChanged, isRestart: buildData.state == BuildState.passed || buildData.state == BuildState.failed || buildData.state == BuildState.errored || buildData.state == BuildState.canceled, ), ), ), Divider( indent: 16.0, endIndent: 16.0, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), child: Text( "Jobs", style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600), ), ), ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: buildData.jobs.length, itemBuilder: (_, index) => ListTile( title: Text(buildData.jobs.length == 1 ? 'View build log' : "#${buildData.jobs[index].id} log"), leading: Icon(FeatherIcons.fileText), trailing: Icon(Icons.keyboard_arrow_right), onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (_) => ShowLogs( jobId: buildData.jobs[index].id, ))); }, ), ) ], ), ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/my_account.dart
/* * my_account.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'dart:async'; import 'package:animations/animations.dart'; import 'package:dio/dio.dart'; import 'package:feather_icons_flutter/feather_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_pagewise/flutter_pagewise.dart'; import 'package:intl/intl.dart'; import 'package:mobx/mobx.dart'; import '../api/travis_ci_api.dart'; import '../models/organization.dart'; import '../pages/show_user_repos.dart'; import '../store/form_store/form_store.dart'; class MyAccount extends StatefulWidget { final FormStore formStore; const MyAccount({Key key, this.formStore}) : super(key: key); @override _MyAccountState createState() => _MyAccountState(); } class _MyAccountState extends State<MyAccount> { PagewiseLoadController<Organization> _pageWiseLoadController; CancelToken cancelToken = CancelToken(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); ReactionDisposer _disposer; Timer _timer; @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, appBar: AppBar( elevation: 0.0, title: Text('My Account'), ), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ ListTile( leading: CircleAvatar( backgroundImage: NetworkImage(widget.formStore.userStore.user.avatarUrl), backgroundColor: Colors.transparent, ), title: Text( widget.formStore.userStore.user.name, //style: TextStyle(fontWeight: FontWeight.bold), ), subtitle: Text( widget.formStore.userStore.user.login, ), ), Observer( builder: (_) => ListTile( leading: Icon(FeatherIcons.rotateCw), title: Text( 'Sync account', //style: TextStyle(fontWeight: FontWeight.w600),2020-01-26T07:49:01Z ), subtitle: widget.formStore.userStore.user.isSyncing ? Text('Syncing...') : Text('synced at: ' + DateFormat().format( DateFormat('yyyy-MM-ddTHH:mm:ssZ') .parse( widget.formStore.userStore.user .lastSynced, true) .toLocal())), trailing: widget.formStore.userStore.user.isSyncing ? SizedBox( width: 20.0, height: 20.0, child: CircularProgressIndicator( strokeWidth: 2.0, ), ) : Container( width: 1, ), onTap: () { if (!widget.formStore.userStore.user.isSyncing) { widget.formStore.userStore.syncAccount(cancelToken); } }, )), Divider( height: 24.0, indent: 16.0, endIndent: 16.0, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), child: Text( 'ORGANIZATIONS', style: TextStyle(fontWeight: FontWeight.bold), ), ), PagewiseListView( itemBuilder: _builder, shrinkWrap: true, showRetry: false, physics: NeverScrollableScrollPhysics(), padding: const EdgeInsets.symmetric(horizontal: 2.0), pageLoadController: _pageWiseLoadController, noItemsFoundBuilder: (context) { return Chip(label: Text('No data found')); }, errorBuilder: (context, error) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Text( error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.toString(), textAlign: TextAlign.center, ), ); }, loadingBuilder: (context) { return CircularProgressIndicator( strokeWidth: 2.0, ); }, ) ], ), ), ); } @override void dispose() { _disposer(); super.dispose(); } @override void initState() { super.initState(); _pageWiseLoadController = PagewiseLoadController( pageSize: 10, pageFuture: (pageIndex) { return TravisCIApi.getOrganizationList( (pageIndex * 10), 10, cancelToken); }); _disposer = reaction( (_) => widget.formStore.userStore.syncAccountFuture.status, (result) => widget.formStore.userStore.syncAccountFuture.status == FutureStatus.rejected && widget.formStore.userStore.hasApiError ? _showError() : widget.formStore.userStore.syncAccountFuture.status == FutureStatus.fulfilled && !widget.formStore.userStore.hasApiError ? _fetchStatus() : null, ); } Widget _builder(BuildContext context, Organization organization, int index) { return OpenContainer( closedColor: Theme.of(context).canvasColor, openColor: Theme.of(context).canvasColor, closedBuilder: (BuildContext _, VoidCallback openContainer) { return ListTile( leading: CircleAvatar( backgroundImage: NetworkImage(organization.avatarUrl), backgroundColor: Colors.transparent, ), title: Text(organization.name), onTap: openContainer, ); }, openBuilder: (BuildContext _, VoidCallback openContainer) { return ShowUserRepos( login: organization.login, title: organization.name, ); }, closedElevation: 0, transitionDuration: Duration(milliseconds: 500), ); } /// Fetch user data for sync status. _fetchStatus() { Future.delayed( Duration(seconds: 3), () => _timer = Timer.periodic(Duration(seconds: 3), (tick) { if (widget.formStore.userStore.user.isSyncing) { widget.formStore.userStore.getUser(cancelToken); } else { _timer.cancel(); } })); } _showError() { widget.formStore.userStore.user.isSyncing = false; _scaffoldKey.currentState.showSnackBar( SnackBar(content: Text(widget.formStore.userStore.errorMessage))); widget.formStore.userStore.errorMessage = ''; } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/pages/ci_selection.dart
/* * ci_selection.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; import '../api/api_urls.dart'; import '../init/init.dart'; import '../utils/dialog.dart'; import 'ci_login.dart'; class InitializationPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( //backgroundColor: Theme.of(context).cardColor, body: Container( width: double.maxFinite, child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 0.0, bottom: 20.0), child: Text( 'Select CI Server', style: TextStyle(fontWeight: FontWeight.w600, fontSize: 22.0), )), Card( elevation: 0.0, shape: RoundedRectangleBorder( side: BorderSide(color: Theme.of(context).splashColor), borderRadius: BorderRadius.circular(8.0)), child: InkWell( onTap: () { isOrg = true; baseUrl = ApiUrls.orgUrl; Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => LoginPage())); }, child: Container( padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 16.0), width: 200.0, child: Column( children: <Widget>[ Hero( tag: 'org', child: Image.asset( 'assets/TravisCI-Mascot-1.png', width: 40.0, height: 40.0, )), SizedBox( height: 16.0, ), Text('Travis CI (.org)', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 15.0)), ], ), ), ), ), Card( elevation: 0.0, shape: RoundedRectangleBorder( side: BorderSide(color: Theme.of(context).splashColor), borderRadius: BorderRadius.circular(8.0)), child: InkWell( onTap: () { isOrg = false; baseUrl = ApiUrls.comUrl; Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => LoginPage())); }, child: Container( padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 16.0), width: 200.0, child: Column( children: <Widget>[ Hero( tag: 'com', child: Image.asset( 'assets/TravisCI-Mascot-2.png', width: 40.0, height: 40.0, )), SizedBox( height: 16.0, ), Text('Travis CI (.com)', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16.0)), ], ), ), ), ), Card( elevation: 0.0, shape: RoundedRectangleBorder( side: BorderSide(color: Theme.of(context).splashColor), borderRadius: BorderRadius.circular(8.0)), child: InkWell( onTap: () { TravisDialog.showWarning( context: context, text: "This option has been disabled"); }, child: Container( padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 16.0), width: 200.0, child: Column( children: <Widget>[ Hero( tag: 'enterprise', child: Image.asset( 'assets/TravisCI-Mascot-1.png', width: 40.0, height: 40.0, )), SizedBox( height: 16.0, ), Text('Travis CI Enterprise', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16.0)), ], ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/repo.dart
/* * repo.dart * * Created by Amit Khairnar on 09/10/2020. */ class PageModel { int limit; int offset; PageModel(this.limit, this.offset); PageModel.fromJson(Map<String, dynamic> json) : limit = json['limit'], offset = json['offset']; } class Pagination { var first; var next; var prev; var last; int limit; int count; int offset; bool isFirst; bool isLast; Pagination(this.first, this.next, this.prev, this.last, this.limit, this.count, this.offset, this.isFirst, this.isLast); Pagination.fromJson(Map<String, dynamic> json) : first = json['first'], next = json['next'], prev = json['prev'], last = json['last'], limit = json['limit'], count = json['count'], offset = json['offset'], isFirst = json['is_first'], isLast = json['is_last']; } class PaginationModel { var pages; PaginationModel(this.pages); PaginationModel.fromJson(Map<String, dynamic> json) : pages = json['@pagination']; } class Repositories { final List<RepositoriesModel> repos; Repositories(this.repos); static List<RepositoriesModel> getListFromJson(List<dynamic> parsedJson) { return parsedJson.map((i) => RepositoriesModel.fromJson(i)).toList(); } } class RepositoriesModel { int id; bool starred; bool active; String name; String slug; String owner; String description; RepoPermissions permissions; RepositoriesModel(this.id, this.starred, this.active, this.name, this.slug, this.description, this.owner, this.permissions); factory RepositoriesModel.fromJson(Map<String, dynamic> parsedJson) { return RepositoriesModel( parsedJson['id'], parsedJson['starred'], parsedJson['active'], parsedJson['name'], parsedJson['slug'], parsedJson['description'], parsedJson['owner']['login'], RepoPermissions.fromJson(parsedJson['@permissions']), ); } } class RepoPermissions { bool read; bool deleteKeyPair; bool createRequest; bool admin; bool activate; bool deactivate; bool migrate; bool star; bool createCron; bool unStar; bool createKeyPair; bool createEnvVar; RepoPermissions( {this.read, this.deleteKeyPair, this.createRequest, this.admin, this.activate, this.deactivate, this.migrate, this.star, this.createCron, this.unStar, this.createKeyPair, this.createEnvVar}); factory RepoPermissions.fromJson(Map<String, dynamic> parsedJson) { return RepoPermissions( read: parsedJson['read'], star: parsedJson['star'], admin: parsedJson['admin'], unStar: parsedJson['unstar'], migrate: parsedJson['migrate'], activate: parsedJson['activate'], deactivate: parsedJson['deactivate'], createCron: parsedJson['create_cron'], createEnvVar: parsedJson['create_env_var'], createRequest: parsedJson['create_request'], createKeyPair: parsedJson['create_key_pair'], deleteKeyPair: parsedJson['delete_key_pair'], ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/organization.dart
/* * organization.dart * * Created by Amit Khairnar on 09/10/2020. */ class Organization { String name; String login; String avatarUrl; Organization(this.name, this.login, this.avatarUrl); factory Organization.fromJson(Map<String, dynamic> json) { return Organization(json['name'], json['login'], json['avatar_url']); } } class Organizations { final List<Organization> organizations; Organizations(this.organizations); static List<Organization> getListFromJson(List<dynamic> parsedJson) { return parsedJson.map((i) => Organization.fromJson(i)).toList(); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/build_emails_response.dart
/* * build_emails_response.dart * * Created by Amit Khairnar on 13/10/2020. */ class BuildEmailsResponse { final String name; final bool value; BuildEmailsResponse({this.name, this.value}); factory BuildEmailsResponse.fromJson(Map<String, dynamic> parsedJson) => BuildEmailsResponse(name: parsedJson['name'], value: parsedJson['value']); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/repository.dart
/* * repository.dart * * Created by Amit Khairnar on 09/10/2020. */ class Repository { final int id; final String name; final String slug; Repository(this.id, this.name, this.slug); factory Repository.fromJson(Map<String, dynamic> parsedJson) => Repository(parsedJson['id'], parsedJson['name'], parsedJson['slug']); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/branch.dart
/* * branch.dart * * Created by Amit Khairnar on 09/10/2020. */ class Branch { final String name; Branch(this.name); factory Branch.fromJson(Map<String, dynamic> parsedJson) => Branch(parsedJson['name']); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/build_model.dart
/* * build_model.dart * * Created by Amit Khairnar on 09/10/2020. */ import '../enum/build_status.dart'; import 'branch.dart'; import 'tag.dart'; import 'repository.dart'; class BuildsModel { final int id; final String number; final BuildState state; final int duration; final String previousState; final String updatedAt; final String createdAt; final CreatedBy createdBy; final Commit commit; final Repository repository; final Branch branch; final Tag tag; final List<Job> jobs; BuildsModel( {this.id,this.number, this.state, this.duration, this.previousState, this.createdBy, this.updatedAt, this.createdAt, this.commit, this.repository, this.branch, this.jobs, this.tag}); factory BuildsModel.fromJson(Map<String, dynamic> parsedJson) { List<dynamic> _jobs = parsedJson['jobs']; return BuildsModel( id: parsedJson['id'], state: enumFromString<BuildState>(BuildState.values, parsedJson['state']), number: parsedJson['number'], duration: parsedJson['duration'], updatedAt: parsedJson['updated_at'], createdAt: parsedJson['started_at'], repository: parsedJson['repository'] != null ? Repository.fromJson(parsedJson['repository']) : null, branch: parsedJson['branch'] != null ? Branch.fromJson(parsedJson['branch']) : null, tag: parsedJson['tag'] != null ? Tag.fromJson(parsedJson['tag']) : null, previousState: parsedJson['previous_state'], commit: Commit.fromJson(parsedJson['commit']), createdBy: CreatedBy.fromJson(parsedJson['created_by']), jobs: _jobs != null ? _jobs.map((e) => Job.fromJson(e)).toList() : null); } } class Commit { final int id; final String sha; final String ref; final String message; final String compareUrl; final String committedAt; Commit( {this.id, this.sha, this.ref, this.message, this.committedAt, this.compareUrl}); factory Commit.fromJson(Map<String, dynamic> parsedJson) { return Commit( id: parsedJson['id'], sha: parsedJson['sha'], ref: parsedJson['ref'], message: parsedJson['message'], compareUrl: parsedJson['compare_url'], committedAt: parsedJson['committed_at']); } } class CreatedBy { final int id; final String login; final String type; final String href; CreatedBy({this.id, this.login, this.type, this.href}); factory CreatedBy.fromJson(Map<String, dynamic> parsedJson) { return CreatedBy( id: parsedJson['id'], login: parsedJson['login'], href: parsedJson['@href'], type: parsedJson['@type']); } } class Job { final int id; final String type; final String href; Job({this.id, this.type, this.href}); factory Job.fromJson(Map<String, dynamic> parsedJson) { return Job( id: parsedJson['id'], href: parsedJson['@href'], type: parsedJson['@type']); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/user.dart
/* * user.dart * * Created by Amit Khairnar on 09/10/2020. */ class User { int id; bool isSyncing; String name; String login; String avatarUrl; String lastSynced; User(this.id, this.isSyncing, this.name, this.login, this.avatarUrl); User.fromJson(Map<String, dynamic> json) : name = json['name'], id = json['id'], isSyncing = json['is_syncing'], lastSynced = json['synced_at'], login = json['login'], avatarUrl = json['avatar_url']; }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/tag.dart
/* * tag.dart * * Created by Amit Khairnar on 11/10/2020. */ class Tag { final String name; Tag(this.name); factory Tag.fromJson(Map<String, dynamic> parsedJson) => Tag(parsedJson['name']); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/models/private_insights_visibility.dart
/* * private_insights_visibility.dart * * Created by Amit Khairnar on 13/10/2020. */ class PrivateInsightsVisibilityResponse { final String name; final String value; PrivateInsightsVisibilityResponse({this.name, this.value}); factory PrivateInsightsVisibilityResponse.fromJson( Map<String, dynamic> parsedJson) => PrivateInsightsVisibilityResponse( name: parsedJson['name'], value: parsedJson['value']); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/fragments/repo_fragment.dart
/* * repo_fragment.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:animations/animations.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pagewise/flutter_pagewise.dart'; import '../api/travis_ci_api.dart'; import '../models/repo.dart'; import '../pages/details.dart'; import '../utils/icon_fonts.dart'; class RepoFragment extends StatefulWidget { @override _RepoFragmentState createState() => _RepoFragmentState(); } class _RepoFragmentState extends State<RepoFragment> { PagewiseLoadController<RepositoriesModel> _pageWiseLoadController; @override Widget build(BuildContext context) { return Scaffold( //backgroundColor: Colors.white, body: PagewiseListView( itemBuilder: _builder, shrinkWrap: true, showRetry: false, padding: const EdgeInsets.symmetric(horizontal: 2.0), pageLoadController: _pageWiseLoadController, noItemsFoundBuilder: (context) { return Chip(label: Text('No active repositories found!')); }, errorBuilder: (context, error) { return Text(error.toString()); }, loadingBuilder: (context) { return CircularProgressIndicator( strokeWidth: 2.0, ); }, ), ); } @override void initState() { super.initState(); _pageWiseLoadController = PagewiseLoadController( pageSize: 10, pageFuture: (pageIndex) { return TravisCIApi.getRepoList((pageIndex * 10), 10, CancelToken(), isActive: false); }); } Widget _builder( BuildContext context, RepositoriesModel repositoriesModel, int index) { return OpenContainer( closedColor: Theme.of(context).canvasColor, openColor: Theme.of(context).canvasColor, closedBuilder: (BuildContext _, VoidCallback openContainer) { return ListTile( contentPadding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0), leading: Icon( TravisLogos.source_repository, color: Colors.grey, ), title: Text( repositoriesModel.name, style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500), ), subtitle: Text( repositoriesModel.owner, style: TextStyle(color: Colors.blue, fontSize: 15.0), ), onTap: openContainer, ); }, openBuilder: (BuildContext _, VoidCallback openContainer) { return Details(repositoriesModel: repositoriesModel); }, closedElevation: 0, transitionDuration: Duration(milliseconds: 500), ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/fragments/home_fragment.dart
/* * home_fragment.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:animations/animations.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pagewise/flutter_pagewise.dart'; import '../api/travis_ci_api.dart'; import '../models/repo.dart'; import '../pages/details.dart'; import '../utils/icon_fonts.dart'; class HomeFragment extends StatefulWidget { @override _ActiveRepoState createState() => _ActiveRepoState(); } class _ActiveRepoState extends State<HomeFragment> { CancelToken cancelToken = CancelToken(); PagewiseLoadController<RepositoriesModel> _pageWiseLoadController; @override Widget build(BuildContext context) { return Scaffold( //backgroundColor: Colors.white, body: PagewiseListView( itemBuilder: _builder, shrinkWrap: true, showRetry: false, padding: const EdgeInsets.symmetric(horizontal: 2.0), pageLoadController: _pageWiseLoadController, noItemsFoundBuilder: (context) { return Chip(label: Text('No active repositories found!')); }, errorBuilder: (context, error) { return Text(error.toString()); }, loadingBuilder: (context) { return CircularProgressIndicator( strokeWidth: 2.0, ); }, ), ); } @override void initState() { super.initState(); _pageWiseLoadController = PagewiseLoadController( pageSize: 10, pageFuture: (pageIndex) { return TravisCIApi.getRepoList((pageIndex * 10), 10, cancelToken, isActive: true); }); } Widget _builder( BuildContext context, RepositoriesModel repositoriesModel, int index) { return OpenContainer( closedColor: Theme.of(context).canvasColor, openColor: Theme.of(context).canvasColor, closedBuilder: (BuildContext _, VoidCallback openContainer) { return ListTile( trailing: Icon( repositoriesModel.starred ? Icons.star : Icons.star_border, color: repositoriesModel.starred ? Colors.orange : Theme.of(context).dividerColor, ), leading: Icon( TravisLogos.source_repository, color: Colors.grey, ), title: Text( repositoriesModel.name, style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500), ), subtitle: Text( repositoriesModel.owner, style: TextStyle( color: repositoriesModel.active ? Colors.blue : Colors.teal, fontSize: 15.0, ), ), onTap: openContainer, ); }, openBuilder: (BuildContext _, VoidCallback openContainer) { return Details(repositoriesModel: repositoriesModel); }, closedElevation: 0, transitionDuration: Duration(milliseconds: 500), ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/fragments/my_builds.dart
/* * my_builds.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:dio/dio.dart'; import 'package:feather_icons_flutter/feather_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pagewise/flutter_pagewise.dart'; import 'package:timeago/timeago.dart' as timeago; import '../api/travis_ci_api.dart'; import '../models/build_model.dart'; import '../pages/build_details.dart'; import '../utils/get_icon.dart'; import '../utils/get_state_color.dart'; import '../utils/icon_fonts.dart'; class MyBuilds extends StatefulWidget { @override _MyBuildsState createState() => _MyBuildsState(); } class _MyBuildsState extends State<MyBuilds> { PagewiseLoadController<BuildsModel> _pageWiseLoadController; @override Widget build(BuildContext context) { return Scaffold( //backgroundColor: Colors.white, body: _buildUI(), ); } @override void initState() { super.initState(); _pageWiseLoadController = PagewiseLoadController( pageSize: 10, pageFuture: (pageIndex) { return TravisCIApi.getMyBuilds((pageIndex * 10), 10, CancelToken()); }); } Widget _builder(BuildContext context, BuildsModel buildsModel, int index) { return Column( children: [ ListTile( title: Text( buildsModel.repository.slug, //maxLines: 1, //overflow: TextOverflow.ellipsis, style: TextStyle( fontWeight: FontWeight.w500, ), ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 16.0, ), Row( children: [ Icon( FeatherIcons.gitBranch, color: Colors.teal, size: 14.0, ), SizedBox( width: 8.0, ), Text( buildsModel.branch.name, style: TextStyle(fontWeight: FontWeight.w500), ) ], ), SizedBox( height: 4.0, ), Row( children: [ Expanded( child: Row( children: [ GetIcon.getIcon(buildsModel.state, size: 16.0), SizedBox( width: 4.0, ), Text( [ "#${buildsModel.number}", buildsModel.state != null ? buildsModel.state.toString().split('.').last : 'received' ].join(" "), style: TextStyle( color: GetStateColor.getStateColor( buildsModel.state), fontWeight: FontWeight.bold, fontSize: 13.0), ), ], ), ), Expanded( child: Row( children: [ Icon( FeatherIcons.calendar, color: Colors.teal, size: 14.0, ), SizedBox( width: 8.0, ), Text( buildsModel.createdAt != null ? timeago .format(DateTime.parse(buildsModel.createdAt)) : "-", style: TextStyle(fontWeight: FontWeight.w500), ) ], ), ) ], ), SizedBox( height: 4.0, ), Row( children: [ Expanded( child: InkWell( onTap: () {}, child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.gitCommit, color: Colors.teal, size: 16.0, ), SizedBox( width: 8.0, ), Text( "${buildsModel.commit.sha.substring(0, 7)}", style: TextStyle(fontWeight: FontWeight.w500), ), SizedBox( width: 4.0, ), Icon( Icons.open_in_new, size: 12.0, ) ], ), )), Expanded( child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( FeatherIcons.clock, color: Colors.teal, size: 14.0, ), SizedBox( width: 8.0, ), Text( buildsModel.duration != null ? "${buildsModel.duration ~/ 60} min " "${buildsModel.duration % 60} sec" : '-', style: TextStyle(fontWeight: FontWeight.w500), ) ], )) ], ), SizedBox( height: 16.0, ), // InkWell( // child: Container( // padding: const EdgeInsets.only( // right: 8.0, left: 4.0, top: 4.0, bottom: 4.0), // decoration: BoxDecoration( // color: Colors.grey[200], // borderRadius: BorderRadius.circular(20.0)), // child: Row( // mainAxisSize: MainAxisSize.min, // children: [ // Icon( // Icons.refresh, // color: Colors.teal, // size: 16.0, // ), // SizedBox( // width: 8.0, // ), // Text( // "Restart build", // style: TextStyle( // color: Colors.teal, // fontSize: 12.0, // fontWeight: FontWeight.w500), // ) // ], // ), // ), // onTap: () { // // if (!_restarted) { // // TravisCIApi() // // .restartBuild(buildsModel.id.toString(), CancelToken()); // // setState(() { // // _restarted = true; // // }); // // } else { // // TravisCIApi() // // .cancelBuild(buildsModel.id.toString(), CancelToken()); // // setState(() { // // _restarted = false; // // }); // // } // }, // ), ], ), leading: Icon(TravisLogos.source_repository), onTap: () { showModalBottomSheet( context: context, isScrollControlled: true, builder: (_) => BuildDetails( buildData: buildsModel, showAppbar: true, onChanged: (value) { Navigator.of(context).pop(); setState(() { _pageWiseLoadController = PagewiseLoadController( pageSize: 10, pageFuture: (pageIndex) { return TravisCIApi.getMyBuilds( (pageIndex * 10), 10, CancelToken()); }); }); }, )); }, ), Divider( indent: 72.0, ), ], ); } _buildUI() { return PagewiseListView( itemBuilder: _builder, shrinkWrap: true, showRetry: false, padding: const EdgeInsets.symmetric(vertical: 16.0), pageLoadController: _pageWiseLoadController, noItemsFoundBuilder: (context) { return Chip(label: Text('No builds found!')); }, errorBuilder: (context, error) { return Text(error.toString()); }, loadingBuilder: (context) { return CircularProgressIndicator( strokeWidth: 2.0, ); }, ); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/api/travis_ci_api.dart
/* * travis_ci_api.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:dio/dio.dart'; import '../init/init.dart'; import '../models/build_emails_response.dart'; import '../models/build_model.dart'; import '../models/organization.dart'; import '../models/private_insights_visibility.dart'; import '../models/repo.dart'; import '../models/user.dart'; import '../utils/network_util.dart'; import 'api_urls.dart'; class TravisCIApi { /// Headers required in each api call static Map<String, String> get headers => { "Travis-API-Version": "3", "Authorization": kTokenStore.authorizationToken }; NetworkUtil _netUtil = NetworkUtil(); /// Fetches the build log Future<Map> getBuildLog(String id, CancelToken cancelToken) async { var res = await _netUtil.get(ApiUrls.jobUrl + id + '/log', cancelToken, headers: headers); return res; } /// Fetches the build log as txt Future<String> getBuildLogAsTxt(String id, CancelToken cancelToken) async { var res = await _netUtil.get(ApiUrls.jobUrl + id + '/log.txt', cancelToken, headers: headers); if (res.statusCode < 200 || res.statusCode > 400) { throw Exception( "Error while fetching data: ${res.statusCode} ${res.statusMessage}"); } return res.data.toString(); } /// Fetches the [List] of Builds Future<List<BuildsModel>> getBuilds( String id, CancelToken cancelToken) async { var res = await _netUtil.get(ApiUrls.repoUrl + id + '/builds', cancelToken, headers: headers); List<dynamic> _builds = res['builds']; return _builds != null ? _builds.map((e) => BuildsModel.fromJson(e)).toList() : []; } /// Fetches the [List] of preferences Future<List<dynamic>> getPreferences(CancelToken cancelToken) async { var res = await _netUtil.get("/preferences", cancelToken, headers: headers); return res['preferences']; } /// Gets the data of the User Future<User> getUser(CancelToken cancelToken, {String id}) async { var res = await _netUtil.get( ApiUrls.userUrl + (id != null ? '/$id' : ''), cancelToken, headers: headers); return User.fromJson(res); } /// Restart or Cancel the selected Build Future<Map> restartCancelBuild( String id, bool isRestart, CancelToken cancelToken) async { //print(ApiUrls.jobUrl + id + '/restart'); //print(ApiUrls.buildUrl + '/' + id + (isRestart ? '/restart' : '/cancel')); var res = await _netUtil.post( ApiUrls.buildUrl + '/' + id + (isRestart ? '/restart' : '/cancel'), cancelToken, headers: headers, ); //print(res); return res; } // Future<Map> cancelBuild(String id, CancelToken cancelToken) async { // //print(ApiUrls.jobUrl + id + '/restart'); // print(ApiUrls.buildUrl + '/' + id + '/cancel'); // var res = await _netUtil.post( // ApiUrls.buildUrl + '/' + id + '/cancel', cancelToken, // headers: headers); // print(res); // return res; // } /// Star or Unstar repo Future<RepositoriesModel> starUnStarRepo( String id, bool isStar, CancelToken cancelToken) async { var res = await _netUtil.post( ApiUrls.repoUrl + '$id/${isStar ? 'star' : 'unstar'}', cancelToken, headers: headers); return RepositoriesModel.fromJson(res); } /// Activates or Deactivates the repository on the CI Future<RepositoriesModel> activateDeactivateRepo( String id, bool isActivate, CancelToken cancelToken) async { var res = await _netUtil.post( ApiUrls.repoUrl + '$id/${isActivate ? 'activate' : 'deactivate'}', cancelToken, headers: headers); return RepositoriesModel.fromJson(res); } /// Syncs the account of current user Future<User> syncAccount(String id, CancelToken cancelToken) async { var res = await _netUtil.post(ApiUrls.userUrl + '/$id/sync', cancelToken, headers: headers); return User.fromJson(res); } /// Updates build email setting for the current user Future<BuildEmailsResponse> updateBuildEmails( bool value, CancelToken cancelToken) async { var res = await _netUtil.patch("/preference/build_emails", cancelToken, headers: headers, body: {"value": "$value"}); return BuildEmailsResponse.fromJson(res); } /// Updates Private insight visibility setting /// /// Available only for `com` server users Future<PrivateInsightsVisibilityResponse> updatePrivateInsightVisibility( String value, CancelToken cancelToken) async { var res = await _netUtil.patch( "/preference/private_insights_visibility", cancelToken, headers: headers, body: {"value": "$value"}); return PrivateInsightsVisibilityResponse.fromJson(res); } /// Fetches [List] of Builds static Future<List<BuildsModel>> getMyBuilds( int offset, int limit, CancelToken cancelToken) async { return NetworkUtil() .get( ApiUrls.myBuildsUrl + '?limit=$limit&offset=$offset&sort_by=created_at:desc', cancelToken, headers: headers) .then((dynamic res) { List<dynamic> _builds = res['builds']; return _builds != null ? _builds.map((e) => BuildsModel.fromJson(e)).toList() : []; }); } /// Fetches [List] of [Organization] the user has access to static Future<List<Organization>> getOrganizationList( int offset, int limit, CancelToken cancelToken) async { return NetworkUtil() .get(ApiUrls.organizationsUrl + '?limit=$limit&offset=$offset', cancelToken, headers: headers) .then((dynamic res) { return Organizations.getListFromJson(res['organizations']); }); } /// Fetches [List] of Repositories of an org or user static Future<List<RepositoriesModel>> getOrganizationRepos( String orgLogin, int offset, int limit, CancelToken cancelToken) async { return NetworkUtil() .get( "/owner/$orgLogin" + ApiUrls.reposUrl + '?limit=$limit&offset=$offset', cancelToken, headers: headers) .then((dynamic res) { return Repositories.getListFromJson(res['repositories']); }); } /// Fetches [List] of Repositories of current user static Future<List<RepositoriesModel>> getRepoList( int offset, int limit, CancelToken cancelToken, {bool isActive = false}) async { return NetworkUtil() .get( ApiUrls.reposUrl + '?limit=$limit${isActive ? '&repository.active=true' : ''}&offset=$offset&sort_by=default_branch.last_build:desc', cancelToken, headers: headers) .then((dynamic res) { return Repositories.getListFromJson(res['repositories']); }); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/api/api_urls.dart
/* * api_urls.dart * * Created by Amit Khairnar on 09/10/2020. */ class ApiUrls { static const String orgUrl = "https://api.travis-ci.org"; static const String comUrl = "https://api.travis-ci.com"; static const String userUrl = "/user"; static const String reposUrl = "/repos"; static const String repoUrl = "/repo/"; static const String organizationsUrl = "/orgs"; static const String myBuildsUrl = "/builds"; static const String buildUrl = "/build"; static const String jobUrl = "/job/"; }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/utils/get_state_color.dart
/* * get_state_color.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; import 'package:travis_ci/enum/build_status.dart'; class GetStateColor { static getStateColor(BuildState state) { switch (state) { case BuildState.started: return Colors.orange; case BuildState.passed: return Colors.green; case BuildState.errored: return Colors.red; case BuildState.failed: return Colors.redAccent; case BuildState.canceled: return Colors.grey; default: return Colors.teal; } } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/utils/icon_fonts.dart
/* * icon_fonts.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/widgets.dart'; class TravisLogos { TravisLogos._(); static const _kFontFam = 'TravisLogos'; static const IconData source_repository = const IconData(0xe800, fontFamily: _kFontFam); static const IconData source_repository_multiple = const IconData(0xe801, fontFamily: _kFontFam); static const IconData briefcase_outline = const IconData(0xe802, fontFamily: _kFontFam); static const IconData home_outline = const IconData(0xe803, fontFamily: _kFontFam); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/utils/open_url.dart
/* * open_url.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:url_launcher/url_launcher.dart'; class OpenUrl { static launchURL(url) async { //print('Opening url: $url'); if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/utils/network_util.dart
/* * network_util.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'dart:async'; import 'dart:convert'; import 'package:dio/dio.dart'; import '../init/init.dart'; class NetworkUtil with NetworkUtilMixin { // next three lines makes this class a Singleton static NetworkUtil _instance = NetworkUtil.internal(); final Dio _dio = Dio(); factory NetworkUtil() => _instance; NetworkUtil.internal(); @override Future<dynamic> get(String url, CancelToken cancelToken, {Map<String, String> headers}) async { try { Response response = await _dio.get(baseUrl + url, options: Options(headers: headers, responseType: ResponseType.plain), cancelToken: cancelToken); final res = jsonDecode(response.data.toString()); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode > 400 || json == null) { throw Exception( "Error while fetching data: ${response.statusCode} ${response.statusMessage}"); } return res; } on DioError catch (e) { //print(e.error); if (e.response != null) { //print(e.response.data); if (e.response.statusCode == 401) { throw Exception("Unauthorized"); } else if (e.response.statusCode == 403) { throw Exception("Access Denied"); } else if (e.response.statusCode == 500) { throw Exception("Internal server error"); } else { throw Exception( "Error: [${e.response.statusCode}], ${e.error}, \n${e.message}"); } } else { throw Exception(e.message.contains('SocketException') ? 'Please check your internet connection' : e.message); } } } @override Future patch(String url, CancelToken cancelToken, {Map<String, String> headers, body, encoding}) async { try { Response response = await _dio.patch(baseUrl + url, options: Options(headers: headers, responseType: ResponseType.plain), cancelToken: cancelToken, data: body); //print(response.data); final res = jsonDecode(response.data.toString()); //final res = response.data; //print('Res: $res'); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode > 400 || res == null) { throw Exception( "Error : ${response.statusCode} ${response.statusMessage}"); } return res; } on DioError catch (e) { //print(e.error); if (e.response != null) { //print(e.response.data); if (e.response.statusCode == 401) { throw Exception("Unauthorized"); } else if (e.response.statusCode == 403) { throw Exception("Access Denied"); } else if (e.response.statusCode == 500) { throw Exception("Internal server error"); } else { throw Exception( "Error: [${e.response.statusCode}], ${e.error}, \n${e.message}"); } } else { throw Exception(e.message.contains('SocketException') ? 'Please check your internet connection' : e.message); } } } @override Future<dynamic> post(String url, CancelToken cancelToken, {Map<String, String> headers, body, encoding}) async { try { Response response = await _dio.post(baseUrl + url, options: Options(headers: headers, responseType: ResponseType.plain), cancelToken: cancelToken, data: body); //print(response.data); final res = jsonDecode(response.data.toString()); //final res = response.data; //print('Res: $res'); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode > 400 || res == null) { throw Exception( "Error while fetching data: ${response.statusCode} ${response.statusMessage}"); } return res; } on DioError catch (e) { //print(e.error); if (e.response != null) { //print(e.response.data); if (e.response.statusCode == 401) { throw Exception("Unauthorized"); } else if (e.response.statusCode == 403) { throw Exception("Access Denied"); } else if (e.response.statusCode == 500) { throw Exception("Internal server error"); } else { throw Exception( "Error: [${e.response.statusCode}], ${e.error}, \n${e.message}"); } } else { throw Exception(e.message.contains('SocketException') ? 'Please check your internet connection' : e.message); } } } } mixin NetworkUtilMixin { Future<dynamic> get(String url, CancelToken cancelToken, {Map<String, String> headers}); Future<dynamic> patch(String url, CancelToken cancelToken, {Map<String, String> headers, body, encoding}); Future<dynamic> post(String url, CancelToken cancelToken, {Map<String, String> headers, body, encoding}); }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/utils/get_icon.dart
/* * get_icon.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; import 'package:travis_ci/enum/build_status.dart'; class GetIcon { static getIcon(BuildState state, {double size}) { switch (state) { case BuildState.started: return Icon( Icons.more_horiz, color: Colors.grey, size: size, ); case BuildState.passed: return Icon( Icons.check, color: Colors.green, size: size, ); case BuildState.errored: return Icon( Icons.priority_high, color: Colors.red, size: size, ); case BuildState.failed: return Icon( Icons.close, color: Colors.redAccent, size: size, ); case BuildState.canceled: return Icon( Icons.not_interested, color: Colors.grey, size: size, ); default: return Icon( Icons.more_horiz, color: Colors.grey, size: size, ); } } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/utils/dialog.dart
/* * dialog.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:flutter/material.dart'; class TravisDialog { TravisDialog._(); static showLoading( {@required String message, @required BuildContext context}) { return showDialog<Null>( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( content: ListTile( leading: SizedBox( width: 20.0, height: 20.0, child: CircularProgressIndicator( strokeWidth: 2.0, ), ), title: Text( '$message', style: TextStyle(fontSize: 18.0), ), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0)), ); }); } static showWarningWithTitle( {@required String title, @required String message, @required BuildContext context}) { return showDialog<Null>( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( content: Text( '$message', style: TextStyle(color: Colors.red), ), title: Text('$title'), contentPadding: const EdgeInsets.only(left: 24.0, right: 24.0, top: 24.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0)), actions: <Widget>[ MaterialButton( onPressed: () { Navigator.of(context).pop(); }, child: Text('Close'), ) ], ); }); } static showWarning({@required String text, @required BuildContext context}) { return showDialog<Null>( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( content: Text( '$text', style: TextStyle(color: Colors.red), ), contentPadding: const EdgeInsets.only(left: 24.0, right: 24.0, top: 24.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0)), actions: <Widget>[ MaterialButton( onPressed: () { Navigator.of(context).pop(); }, child: Text('Close'), ) ], ); }); } }
0
mirrored_repositories/travis_ci/lib
mirrored_repositories/travis_ci/lib/enum/build_status.dart
/* * build_status.dart * * Created by Amit Khairnar on 09/10/2020. */ enum BuildState { passed, failed, canceled, started, errored } T enumFromString<T>(Iterable<T> values, String value) { return values.firstWhere((type) => type.toString().split(".").last == value, orElse: () => null); }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/form_store/form_error_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'form_error_store.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 mixin _$FormErrorState on _FormErrorState, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_FormErrorState.hasErrors')) .value; final _$tokenAtom = Atom(name: '_FormErrorState.token'); @override String get token { _$tokenAtom.reportRead(); return super.token; } @override set token(String value) { _$tokenAtom.reportWrite(value, super.token, () { super.token = value; }); } @override String toString() { return ''' token: ${token}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/form_store/form_error_store.dart
/* * form_error_store.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:mobx/mobx.dart'; part 'form_error_store.g.dart'; class FormErrorState = _FormErrorState with _$FormErrorState; abstract class _FormErrorState with Store { @observable String token; @computed bool get hasErrors => token != null; }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/form_store/form_store.dart
/* * form_store.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import 'package:validators/validators.dart'; import '../../api/travis_ci_api.dart'; import '../../models/user.dart'; import '../user_store/user_store.dart'; import 'form_error_store.dart'; part 'form_store.g.dart'; class FormStore = _FormStore with _$FormStore; abstract class _FormStore with Store { final FormErrorState errorState = FormErrorState(); final UserStore userStore = UserStore(); final TravisCIApi _authUser = TravisCIApi(); final CancelToken cancelToken = CancelToken(); @observable String token = ''; @observable String errorMessage = ''; List<ReactionDisposer> _disposers; @observable ObservableFuture<User> authUserFuture; @computed bool get hasError => errorMessage.isNotEmpty; @action Future authUser() async { final future = _authUser.getUser(cancelToken); authUserFuture = ObservableFuture(future); future.then((value) { userStore.user = value; }).catchError((error) { errorMessage = error.message.toString(); }); } void dispose() { for (final d in _disposers) { d(); } } void setupValidations() { _disposers = [ reaction((_) => token, validateToken), ]; } void validateAll() { validateToken(token); } @action void validateToken(String value) { errorState.token = isNull(value) || value.isEmpty ? 'Enter token' : value.length < 22 ? 'Token is too short' : null; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/form_store/form_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'form_store.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 mixin _$FormStore on _FormStore, Store { Computed<bool> _$hasErrorComputed; @override bool get hasError => (_$hasErrorComputed ??= Computed<bool>(() => super.hasError, name: '_FormStore.hasError')) .value; final _$tokenAtom = Atom(name: '_FormStore.token'); @override String get token { _$tokenAtom.reportRead(); return super.token; } @override set token(String value) { _$tokenAtom.reportWrite(value, super.token, () { super.token = value; }); } final _$errorMessageAtom = Atom(name: '_FormStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$authUserFutureAtom = Atom(name: '_FormStore.authUserFuture'); @override ObservableFuture<User> get authUserFuture { _$authUserFutureAtom.reportRead(); return super.authUserFuture; } @override set authUserFuture(ObservableFuture<User> value) { _$authUserFutureAtom.reportWrite(value, super.authUserFuture, () { super.authUserFuture = value; }); } final _$authUserAsyncAction = AsyncAction('_FormStore.authUser'); @override Future<dynamic> authUser() { return _$authUserAsyncAction.run(() => super.authUser()); } final _$_FormStoreActionController = ActionController(name: '_FormStore'); @override void validateToken(String value) { final _$actionInfo = _$_FormStoreActionController.startAction( name: '_FormStore.validateToken'); try { return super.validateToken(value); } finally { _$_FormStoreActionController.endAction(_$actionInfo); } } @override String toString() { return ''' token: ${token}, errorMessage: ${errorMessage}, authUserFuture: ${authUserFuture}, hasError: ${hasError} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/restart_cancel_store/restart_cancel_store.dart
/* * restart_cancel_store.dart * * Created by Amit Khairnar on 08/12/2020. */ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import '../../api/travis_ci_api.dart'; part 'restart_cancel_store.g.dart'; class RestartCancelBuildStore = _RestartCancelBuildStore with _$RestartCancelBuildStore; abstract class _RestartCancelBuildStore with Store { final TravisCIApi _travisCIApi = TravisCIApi(); @observable Map data; @observable String errorMessage = ''; @observable ObservableFuture<Map> restartCancelBuildFuture; @computed bool get hasErrors => errorMessage.isNotEmpty; @action Future restartCancelBuild( String id, bool isRestart, CancelToken cancelToken) async { final future = _travisCIApi.restartCancelBuild(id, isRestart, cancelToken); restartCancelBuildFuture = ObservableFuture(future); future.then((value) { data = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/restart_cancel_store/restart_cancel_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'restart_cancel_store.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 mixin _$RestartCancelBuildStore on _RestartCancelBuildStore, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_RestartCancelBuildStore.hasErrors')) .value; final _$dataAtom = Atom(name: '_RestartCancelBuildStore.data'); @override Map<dynamic, dynamic> get data { _$dataAtom.reportRead(); return super.data; } @override set data(Map<dynamic, dynamic> value) { _$dataAtom.reportWrite(value, super.data, () { super.data = value; }); } final _$errorMessageAtom = Atom(name: '_RestartCancelBuildStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$restartCancelBuildFutureAtom = Atom(name: '_RestartCancelBuildStore.restartCancelBuildFuture'); @override ObservableFuture<Map<dynamic, dynamic>> get restartCancelBuildFuture { _$restartCancelBuildFutureAtom.reportRead(); return super.restartCancelBuildFuture; } @override set restartCancelBuildFuture(ObservableFuture<Map<dynamic, dynamic>> value) { _$restartCancelBuildFutureAtom .reportWrite(value, super.restartCancelBuildFuture, () { super.restartCancelBuildFuture = value; }); } final _$restartCancelBuildAsyncAction = AsyncAction('_RestartCancelBuildStore.restartCancelBuild'); @override Future<dynamic> restartCancelBuild( String id, bool isRestart, CancelToken cancelToken) { return _$restartCancelBuildAsyncAction .run(() => super.restartCancelBuild(id, isRestart, cancelToken)); } @override String toString() { return ''' data: ${data}, errorMessage: ${errorMessage}, restartCancelBuildFuture: ${restartCancelBuildFuture}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/logs_store/logs_store.dart
/* * logs_store.dart * * Created by Amit Khairnar on 11/10/2020. */ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import '../../api/travis_ci_api.dart'; part 'logs_store.g.dart'; class LogsStore = _LogsStore with _$LogsStore; abstract class _LogsStore with Store { final TravisCIApi _buildsApi = TravisCIApi(); @observable Map buildLog; @observable String buildLogTxt; @observable String errorMessage = ''; @observable ObservableFuture<Map> getBuildLogFuture; @observable ObservableFuture<String> getBuildLogTxtFuture; @computed bool get hasErrors => errorMessage.isNotEmpty; @action Future getBuildLog(String id, CancelToken cancelToken) async { final future = _buildsApi.getBuildLog(id, cancelToken); getBuildLogFuture = ObservableFuture(future); future.then((value) { buildLog = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } @action Future getBuildLogTxt(String id, CancelToken cancelToken) async { final future = _buildsApi.getBuildLogAsTxt(id, cancelToken); getBuildLogTxtFuture = ObservableFuture(future); future.then((value) { buildLogTxt = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/logs_store/logs_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'logs_store.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 mixin _$LogsStore on _LogsStore, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_LogsStore.hasErrors')) .value; final _$buildLogAtom = Atom(name: '_LogsStore.buildLog'); @override Map<dynamic, dynamic> get buildLog { _$buildLogAtom.reportRead(); return super.buildLog; } @override set buildLog(Map<dynamic, dynamic> value) { _$buildLogAtom.reportWrite(value, super.buildLog, () { super.buildLog = value; }); } final _$buildLogTxtAtom = Atom(name: '_LogsStore.buildLogTxt'); @override String get buildLogTxt { _$buildLogTxtAtom.reportRead(); return super.buildLogTxt; } @override set buildLogTxt(String value) { _$buildLogTxtAtom.reportWrite(value, super.buildLogTxt, () { super.buildLogTxt = value; }); } final _$errorMessageAtom = Atom(name: '_LogsStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$getBuildLogFutureAtom = Atom(name: '_LogsStore.getBuildLogFuture'); @override ObservableFuture<Map<dynamic, dynamic>> get getBuildLogFuture { _$getBuildLogFutureAtom.reportRead(); return super.getBuildLogFuture; } @override set getBuildLogFuture(ObservableFuture<Map<dynamic, dynamic>> value) { _$getBuildLogFutureAtom.reportWrite(value, super.getBuildLogFuture, () { super.getBuildLogFuture = value; }); } final _$getBuildLogTxtFutureAtom = Atom(name: '_LogsStore.getBuildLogTxtFuture'); @override ObservableFuture<String> get getBuildLogTxtFuture { _$getBuildLogTxtFutureAtom.reportRead(); return super.getBuildLogTxtFuture; } @override set getBuildLogTxtFuture(ObservableFuture<String> value) { _$getBuildLogTxtFutureAtom.reportWrite(value, super.getBuildLogTxtFuture, () { super.getBuildLogTxtFuture = value; }); } final _$getBuildLogAsyncAction = AsyncAction('_LogsStore.getBuildLog'); @override Future<dynamic> getBuildLog(String id, CancelToken cancelToken) { return _$getBuildLogAsyncAction .run(() => super.getBuildLog(id, cancelToken)); } final _$getBuildLogTxtAsyncAction = AsyncAction('_LogsStore.getBuildLogTxt'); @override Future<dynamic> getBuildLogTxt(String id, CancelToken cancelToken) { return _$getBuildLogTxtAsyncAction .run(() => super.getBuildLogTxt(id, cancelToken)); } @override String toString() { return ''' buildLog: ${buildLog}, buildLogTxt: ${buildLogTxt}, errorMessage: ${errorMessage}, getBuildLogFuture: ${getBuildLogFuture}, getBuildLogTxtFuture: ${getBuildLogTxtFuture}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/main_store/main_store.dart
import 'dart:ui'; import 'package:mobx/mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; part 'main_store.g.dart'; class MainStore = _MainStore with _$MainStore; abstract class _MainStore with Store { @observable Brightness brightness; @observable SharedPreferences prefs; Future toggleTheme() async { brightness = brightness == Brightness.light ? Brightness.dark : Brightness.light; await _updatePreferences(); } Future _updatePreferences() async { await prefs.setBool("isDark", brightness == Brightness.dark); //print(prefs.getBool("isDark")); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/main_store/main_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'main_store.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 mixin _$MainStore on _MainStore, Store { final _$brightnessAtom = Atom(name: '_MainStore.brightness'); @override Brightness get brightness { _$brightnessAtom.reportRead(); return super.brightness; } @override set brightness(Brightness value) { _$brightnessAtom.reportWrite(value, super.brightness, () { super.brightness = value; }); } final _$prefsAtom = Atom(name: '_MainStore.prefs'); @override SharedPreferences get prefs { _$prefsAtom.reportRead(); return super.prefs; } @override set prefs(SharedPreferences value) { _$prefsAtom.reportWrite(value, super.prefs, () { super.prefs = value; }); } @override String toString() { return ''' brightness: ${brightness}, prefs: ${prefs} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/user_store/user_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'user_store.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 mixin _$UserStore on _UserStore, Store { Computed<bool> _$hasApiErrorComputed; @override bool get hasApiError => (_$hasApiErrorComputed ??= Computed<bool>(() => super.hasApiError, name: '_UserStore.hasApiError')) .value; Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_UserStore.hasErrors')) .value; final _$userAtom = Atom(name: '_UserStore.user'); @override User get user { _$userAtom.reportRead(); return super.user; } @override set user(User value) { _$userAtom.reportWrite(value, super.user, () { super.user = value; }); } final _$errorMessageAtom = Atom(name: '_UserStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$syncAccountFutureAtom = Atom(name: '_UserStore.syncAccountFuture'); @override ObservableFuture<User> get syncAccountFuture { _$syncAccountFutureAtom.reportRead(); return super.syncAccountFuture; } @override set syncAccountFuture(ObservableFuture<User> value) { _$syncAccountFutureAtom.reportWrite(value, super.syncAccountFuture, () { super.syncAccountFuture = value; }); } final _$getUserFutureAtom = Atom(name: '_UserStore.getUserFuture'); @override ObservableFuture<User> get getUserFuture { _$getUserFutureAtom.reportRead(); return super.getUserFuture; } @override set getUserFuture(ObservableFuture<User> value) { _$getUserFutureAtom.reportWrite(value, super.getUserFuture, () { super.getUserFuture = value; }); } final _$getUserAsyncAction = AsyncAction('_UserStore.getUser'); @override Future<dynamic> getUser(CancelToken cancelToken) { return _$getUserAsyncAction.run(() => super.getUser(cancelToken)); } final _$syncAccountAsyncAction = AsyncAction('_UserStore.syncAccount'); @override Future<dynamic> syncAccount(CancelToken cancelToken) { return _$syncAccountAsyncAction.run(() => super.syncAccount(cancelToken)); } @override String toString() { return ''' user: ${user}, errorMessage: ${errorMessage}, syncAccountFuture: ${syncAccountFuture}, getUserFuture: ${getUserFuture}, hasApiError: ${hasApiError}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/user_store/user_store.dart
/* * user_store.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'dart:async'; import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import '../../api/travis_ci_api.dart'; import '../../models/user.dart'; part 'user_store.g.dart'; class UserStore = _UserStore with _$UserStore; abstract class _UserStore with Store { final TravisCIApi _userAccountApi = TravisCIApi(); @observable User user; @observable String errorMessage = ''; @observable ObservableFuture<User> syncAccountFuture; @observable ObservableFuture<User> getUserFuture; @computed bool get hasApiError => errorMessage.isNotEmpty; @computed bool get hasErrors => user != null; @action Future getUser(CancelToken cancelToken) async { final future = _userAccountApi.getUser(cancelToken); getUserFuture = ObservableFuture(future); future.then((value) { user = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } @action Future syncAccount(CancelToken cancelToken) async { final future = _userAccountApi.syncAccount(user.id.toString(), cancelToken); syncAccountFuture = ObservableFuture(future); future.then((value) { user = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/builds_store/builds_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'builds_store.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 mixin _$BuildsStore on _BuildsStore, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_BuildsStore.hasErrors')) .value; final _$buildsAtom = Atom(name: '_BuildsStore.builds'); @override ObservableList<BuildsModel> get builds { _$buildsAtom.reportRead(); return super.builds; } @override set builds(ObservableList<BuildsModel> value) { _$buildsAtom.reportWrite(value, super.builds, () { super.builds = value; }); } final _$repositoriesModelAtom = Atom(name: '_BuildsStore.repositoriesModel'); @override RepositoriesModel get repositoriesModel { _$repositoriesModelAtom.reportRead(); return super.repositoriesModel; } @override set repositoriesModel(RepositoriesModel value) { _$repositoriesModelAtom.reportWrite(value, super.repositoriesModel, () { super.repositoriesModel = value; }); } final _$errorMessageAtom = Atom(name: '_BuildsStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$getBuildsFutureAtom = Atom(name: '_BuildsStore.getBuildsFuture'); @override ObservableFuture<List<BuildsModel>> get getBuildsFuture { _$getBuildsFutureAtom.reportRead(); return super.getBuildsFuture; } @override set getBuildsFuture(ObservableFuture<List<BuildsModel>> value) { _$getBuildsFutureAtom.reportWrite(value, super.getBuildsFuture, () { super.getBuildsFuture = value; }); } final _$starUnStarRepoFutureAtom = Atom(name: '_BuildsStore.starUnStarRepoFuture'); @override ObservableFuture<RepositoriesModel> get starUnStarRepoFuture { _$starUnStarRepoFutureAtom.reportRead(); return super.starUnStarRepoFuture; } @override set starUnStarRepoFuture(ObservableFuture<RepositoriesModel> value) { _$starUnStarRepoFutureAtom.reportWrite(value, super.starUnStarRepoFuture, () { super.starUnStarRepoFuture = value; }); } final _$getBuildsAsyncAction = AsyncAction('_BuildsStore.getBuilds'); @override Future<dynamic> getBuilds(String id, CancelToken cancelToken) { return _$getBuildsAsyncAction.run(() => super.getBuilds(id, cancelToken)); } final _$starUnStarRepoAsyncAction = AsyncAction('_BuildsStore.starUnStarRepo'); @override Future<dynamic> starUnStarRepo( String id, bool isStar, CancelToken cancelToken) { return _$starUnStarRepoAsyncAction .run(() => super.starUnStarRepo(id, isStar, cancelToken)); } @override String toString() { return ''' builds: ${builds}, repositoriesModel: ${repositoriesModel}, errorMessage: ${errorMessage}, getBuildsFuture: ${getBuildsFuture}, starUnStarRepoFuture: ${starUnStarRepoFuture}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/builds_store/builds_store.dart
/* * builds_store.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import '../../api/travis_ci_api.dart'; import '../../models/build_model.dart'; import '../../models/repo.dart'; part 'builds_store.g.dart'; class BuildsStore = _BuildsStore with _$BuildsStore; abstract class _BuildsStore with Store { final TravisCIApi _buildsApi = TravisCIApi(); @observable ObservableList<BuildsModel> builds = ObservableList<BuildsModel>(); @observable RepositoriesModel repositoriesModel; @observable String errorMessage = ''; @observable ObservableFuture<List<BuildsModel>> getBuildsFuture; @observable ObservableFuture<RepositoriesModel> starUnStarRepoFuture; @computed bool get hasErrors => errorMessage.isNotEmpty; @action Future getBuilds(String id, CancelToken cancelToken) async { final future = _buildsApi.getBuilds(id, cancelToken); getBuildsFuture = ObservableFuture(future); future.then((value) { builds = ObservableList.of(value); }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } @action Future starUnStarRepo(String id, bool isStar, CancelToken cancelToken) async { final future = _buildsApi.starUnStarRepo(id, isStar, cancelToken); starUnStarRepoFuture = ObservableFuture(future); future.then((value) { repositoriesModel = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/get_user_store/get_user_store.dart
/* * get_user_store.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'dart:async'; import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import '../../api/travis_ci_api.dart'; import '../../models/user.dart'; part 'get_user_store.g.dart'; class GetUserStore = _GetUserStore with _$GetUserStore; abstract class _GetUserStore with Store { final TravisCIApi _userAccountApi = TravisCIApi(); @observable User user; @observable String errorMessage = ''; @observable ObservableFuture<User> getUserFuture; @computed bool get hasErrors => errorMessage.isNotEmpty; @action Future getUser(String id, CancelToken cancelToken) async { final future = _userAccountApi.getUser(cancelToken, id: id); getUserFuture = ObservableFuture(future); future.then((value) { user = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/get_user_store/get_user_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'get_user_store.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 mixin _$GetUserStore on _GetUserStore, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_GetUserStore.hasErrors')) .value; final _$userAtom = Atom(name: '_GetUserStore.user'); @override User get user { _$userAtom.reportRead(); return super.user; } @override set user(User value) { _$userAtom.reportWrite(value, super.user, () { super.user = value; }); } final _$errorMessageAtom = Atom(name: '_GetUserStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$getUserFutureAtom = Atom(name: '_GetUserStore.getUserFuture'); @override ObservableFuture<User> get getUserFuture { _$getUserFutureAtom.reportRead(); return super.getUserFuture; } @override set getUserFuture(ObservableFuture<User> value) { _$getUserFutureAtom.reportWrite(value, super.getUserFuture, () { super.getUserFuture = value; }); } final _$getUserAsyncAction = AsyncAction('_GetUserStore.getUser'); @override Future<dynamic> getUser(String id, CancelToken cancelToken) { return _$getUserAsyncAction.run(() => super.getUser(id, cancelToken)); } @override String toString() { return ''' user: ${user}, errorMessage: ${errorMessage}, getUserFuture: ${getUserFuture}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/token_store/token_store.dart
/* * token_store.dart * * Created by Amit Khairnar on 09/10/2020. */ import 'package:mobx/mobx.dart'; part 'token_store.g.dart'; class TokenStore = _TokenStore with _$TokenStore; abstract class _TokenStore with Store { @observable String token; @computed String get authorizationToken => "token $token"; }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/token_store/token_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'token_store.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 mixin _$TokenStore on _TokenStore, Store { Computed<String> _$authorizationTokenComputed; @override String get authorizationToken => (_$authorizationTokenComputed ??= Computed<String>(() => super.authorizationToken, name: '_TokenStore.authorizationToken')) .value; final _$tokenAtom = Atom(name: '_TokenStore.token'); @override String get token { _$tokenAtom.reportRead(); return super.token; } @override set token(String value) { _$tokenAtom.reportWrite(value, super.token, () { super.token = value; }); } @override String toString() { return ''' token: ${token}, authorizationToken: ${authorizationToken} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/repo_listtile_store/repo_listtile_store.dart
/* * repo_listtile_store.dart * * Created by Amit Khairnar on 08/12/2020. */ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import '../../api/travis_ci_api.dart'; import '../../models/repo.dart'; part 'repo_listtile_store.g.dart'; class RepoListTileStore = _RepoListTileStore with _$RepoListTileStore; abstract class _RepoListTileStore with Store { final TravisCIApi _buildsApi = TravisCIApi(); @observable RepositoriesModel repositoriesModel; @observable String errorMessage = ''; @observable ObservableFuture<RepositoriesModel> activateDeactivateRepoFuture; @computed bool get hasErrors => errorMessage.isNotEmpty; @action Future activateDeactivateRepo( String id, bool isActivate, CancelToken cancelToken) async { final future = _buildsApi.activateDeactivateRepo(id, isActivate, cancelToken); activateDeactivateRepoFuture = ObservableFuture(future); future.then((value) { repositoriesModel = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/repo_listtile_store/repo_listtile_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'repo_listtile_store.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 mixin _$RepoListTileStore on _RepoListTileStore, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_RepoListTileStore.hasErrors')) .value; final _$repositoriesModelAtom = Atom(name: '_RepoListTileStore.repositoriesModel'); @override RepositoriesModel get repositoriesModel { _$repositoriesModelAtom.reportRead(); return super.repositoriesModel; } @override set repositoriesModel(RepositoriesModel value) { _$repositoriesModelAtom.reportWrite(value, super.repositoriesModel, () { super.repositoriesModel = value; }); } final _$errorMessageAtom = Atom(name: '_RepoListTileStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$activateDeactivateRepoFutureAtom = Atom(name: '_RepoListTileStore.activateDeactivateRepoFuture'); @override ObservableFuture<RepositoriesModel> get activateDeactivateRepoFuture { _$activateDeactivateRepoFutureAtom.reportRead(); return super.activateDeactivateRepoFuture; } @override set activateDeactivateRepoFuture(ObservableFuture<RepositoriesModel> value) { _$activateDeactivateRepoFutureAtom .reportWrite(value, super.activateDeactivateRepoFuture, () { super.activateDeactivateRepoFuture = value; }); } final _$activateDeactivateRepoAsyncAction = AsyncAction('_RepoListTileStore.activateDeactivateRepo'); @override Future<dynamic> activateDeactivateRepo( String id, bool isActivate, CancelToken cancelToken) { return _$activateDeactivateRepoAsyncAction .run(() => super.activateDeactivateRepo(id, isActivate, cancelToken)); } @override String toString() { return ''' repositoriesModel: ${repositoriesModel}, errorMessage: ${errorMessage}, activateDeactivateRepoFuture: ${activateDeactivateRepoFuture}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/settings_store/settings_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'settings_store.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 mixin _$SettingsStore on _SettingsStore, Store { Computed<bool> _$hasErrorsComputed; @override bool get hasErrors => (_$hasErrorsComputed ??= Computed<bool>(() => super.hasErrors, name: '_SettingsStore.hasErrors')) .value; final _$buildEmailsAtom = Atom(name: '_SettingsStore.buildEmails'); @override bool get buildEmails { _$buildEmailsAtom.reportRead(); return super.buildEmails; } @override set buildEmails(bool value) { _$buildEmailsAtom.reportWrite(value, super.buildEmails, () { super.buildEmails = value; }); } final _$privateInsightsVisibilityAtom = Atom(name: '_SettingsStore.privateInsightsVisibility'); @override String get privateInsightsVisibility { _$privateInsightsVisibilityAtom.reportRead(); return super.privateInsightsVisibility; } @override set privateInsightsVisibility(String value) { _$privateInsightsVisibilityAtom .reportWrite(value, super.privateInsightsVisibility, () { super.privateInsightsVisibility = value; }); } final _$buildEmailsResponseAtom = Atom(name: '_SettingsStore.buildEmailsResponse'); @override BuildEmailsResponse get buildEmailsResponse { _$buildEmailsResponseAtom.reportRead(); return super.buildEmailsResponse; } @override set buildEmailsResponse(BuildEmailsResponse value) { _$buildEmailsResponseAtom.reportWrite(value, super.buildEmailsResponse, () { super.buildEmailsResponse = value; }); } final _$privateInsightsVisibilityResponseAtom = Atom(name: '_SettingsStore.privateInsightsVisibilityResponse'); @override PrivateInsightsVisibilityResponse get privateInsightsVisibilityResponse { _$privateInsightsVisibilityResponseAtom.reportRead(); return super.privateInsightsVisibilityResponse; } @override set privateInsightsVisibilityResponse( PrivateInsightsVisibilityResponse value) { _$privateInsightsVisibilityResponseAtom .reportWrite(value, super.privateInsightsVisibilityResponse, () { super.privateInsightsVisibilityResponse = value; }); } final _$errorMessageAtom = Atom(name: '_SettingsStore.errorMessage'); @override String get errorMessage { _$errorMessageAtom.reportRead(); return super.errorMessage; } @override set errorMessage(String value) { _$errorMessageAtom.reportWrite(value, super.errorMessage, () { super.errorMessage = value; }); } final _$updateSettingsFutureAtom = Atom(name: '_SettingsStore.updateSettingsFuture'); @override ObservableFuture<BuildEmailsResponse> get updateSettingsFuture { _$updateSettingsFutureAtom.reportRead(); return super.updateSettingsFuture; } @override set updateSettingsFuture(ObservableFuture<BuildEmailsResponse> value) { _$updateSettingsFutureAtom.reportWrite(value, super.updateSettingsFuture, () { super.updateSettingsFuture = value; }); } final _$updatePrivateInsightsFutureAtom = Atom(name: '_SettingsStore.updatePrivateInsightsFuture'); @override ObservableFuture<PrivateInsightsVisibilityResponse> get updatePrivateInsightsFuture { _$updatePrivateInsightsFutureAtom.reportRead(); return super.updatePrivateInsightsFuture; } @override set updatePrivateInsightsFuture( ObservableFuture<PrivateInsightsVisibilityResponse> value) { _$updatePrivateInsightsFutureAtom .reportWrite(value, super.updatePrivateInsightsFuture, () { super.updatePrivateInsightsFuture = value; }); } final _$getPreferencesFutureAtom = Atom(name: '_SettingsStore.getPreferencesFuture'); @override ObservableFuture<List<dynamic>> get getPreferencesFuture { _$getPreferencesFutureAtom.reportRead(); return super.getPreferencesFuture; } @override set getPreferencesFuture(ObservableFuture<List<dynamic>> value) { _$getPreferencesFutureAtom.reportWrite(value, super.getPreferencesFuture, () { super.getPreferencesFuture = value; }); } final _$getPreferencesAsyncAction = AsyncAction('_SettingsStore.getPreferences'); @override Future<dynamic> getPreferences(CancelToken cancelToken) { return _$getPreferencesAsyncAction .run(() => super.getPreferences(cancelToken)); } final _$updateEmailSettingsAsyncAction = AsyncAction('_SettingsStore.updateEmailSettings'); @override Future<dynamic> updateEmailSettings(bool value, CancelToken cancelToken) { return _$updateEmailSettingsAsyncAction .run(() => super.updateEmailSettings(value, cancelToken)); } final _$updatePrivateInsightsVisibilityAsyncAction = AsyncAction('_SettingsStore.updatePrivateInsightsVisibility'); @override Future<dynamic> updatePrivateInsightsVisibility(CancelToken cancelToken) { return _$updatePrivateInsightsVisibilityAsyncAction .run(() => super.updatePrivateInsightsVisibility(cancelToken)); } @override String toString() { return ''' buildEmails: ${buildEmails}, privateInsightsVisibility: ${privateInsightsVisibility}, buildEmailsResponse: ${buildEmailsResponse}, privateInsightsVisibilityResponse: ${privateInsightsVisibilityResponse}, errorMessage: ${errorMessage}, updateSettingsFuture: ${updateSettingsFuture}, updatePrivateInsightsFuture: ${updatePrivateInsightsFuture}, getPreferencesFuture: ${getPreferencesFuture}, hasErrors: ${hasErrors} '''; } }
0
mirrored_repositories/travis_ci/lib/store
mirrored_repositories/travis_ci/lib/store/settings_store/settings_store.dart
/* * settings_store.dart * * Created by Amit Khairnar on 13/10/2020. */ import 'dart:async'; import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:mobx/mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../../api/travis_ci_api.dart'; import '../../models/build_emails_response.dart'; import '../../models/private_insights_visibility.dart'; part 'settings_store.g.dart'; class SettingsStore = _SettingsStore with _$SettingsStore; abstract class _SettingsStore with Store { static Future<SharedPreferences> _prefs = SharedPreferences.getInstance(); final TravisCIApi _travisCIApi = TravisCIApi(); SharedPreferences sharedPreferences; @observable bool buildEmails = false; @observable String privateInsightsVisibility = "private"; @observable BuildEmailsResponse buildEmailsResponse; @observable PrivateInsightsVisibilityResponse privateInsightsVisibilityResponse; @observable String errorMessage = ''; @observable ObservableFuture<BuildEmailsResponse> updateSettingsFuture; @observable ObservableFuture<PrivateInsightsVisibilityResponse> updatePrivateInsightsFuture; @observable ObservableFuture<List<dynamic>> getPreferencesFuture; @computed bool get hasErrors => errorMessage.isNotEmpty; @action Future getPreferences(CancelToken cancelToken) async { final future = _travisCIApi.getPreferences(cancelToken); getPreferencesFuture = ObservableFuture(future); future.then((value) { buildEmails = value.singleWhere( (element) => element.containsValue("build_emails"))['value']; privateInsightsVisibility = value.singleWhere((element) => element.containsValue("private_insights_visibility"))['value']; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } void loadPrefs() async { sharedPreferences = await _prefs; buildEmails = sharedPreferences.getBool('notification') ?? false; privateInsightsVisibility = sharedPreferences.getString('private_insights') ?? "private"; } @action Future updateEmailSettings(bool value, CancelToken cancelToken) async { final future = _travisCIApi.updateBuildEmails(value, cancelToken); updateSettingsFuture = ObservableFuture(future); future.then((value) { buildEmailsResponse = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } @action Future updatePrivateInsightsVisibility(CancelToken cancelToken) async { final future = _travisCIApi.updatePrivateInsightVisibility( privateInsightsVisibility, cancelToken); updatePrivateInsightsFuture = ObservableFuture(future); future.then((value) { privateInsightsVisibilityResponse = value; }).catchError((error) { errorMessage = error.toString().contains('SocketException:') ? 'Connection to server failed! Please check your internet connection and try again.' : error.response != null ? jsonDecode(error.response.data.toString())['error_message'] : error.message.toString(); }); } }
0
mirrored_repositories/travis_ci
mirrored_repositories/travis_ci/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:travis_ci/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(TravisCI()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/ContactPage.dart
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:system_setting/system_setting.dart'; import 'PasswordList.dart'; class ContactPage extends StatefulWidget { @override _ContactPageState createState() => _ContactPageState(); } class _ContactPageState extends State<ContactPage> { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return new WillPopScope( onWillPop: (){ Navigator.push(context, MaterialPageRoute(builder: (context) => PwdList())); }, child: new Scaffold( appBar: new AppBar( title: new Text("Contact", style: TextStyle(color: Colors.white)), iconTheme: IconThemeData(color: Colors.white), leading: new IconButton( icon: new Icon(Icons.arrow_back), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => PwdList())); }, ), ), backgroundColor: Color(0xF6F6F7FF), body: SafeArea( child: ListView( children: <Widget>[ contactInfo(context), ], ), ), ), ); } Widget contactInfo(BuildContext context){ return Container( child: Stack( children: <Widget>[ Column( children: <Widget>[ Container( height: 110, margin: EdgeInsets.only(top: 40), child: Image.asset('assets/PasswordKeeperLogo.png',height: 115,width: 115,), ), Padding(padding: EdgeInsets.all(4),), Container( margin: EdgeInsets.only(top: 20), padding: EdgeInsets.all(10), child: Card( color: Colors.black, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Column( children: <Widget>[ Container( padding:EdgeInsets.only(top: 15, bottom: 15), child: Text('PASSWORDS KEEPER'.toUpperCase(), style: TextStyle(color: Colors.tealAccent,fontWeight: FontWeight.bold,fontSize: 18.0,letterSpacing: 2) ) ), ], ), ], ), ), ), Container( padding: EdgeInsets.all(10), child: Column( children: <Widget>[ Card( child: Container( alignment: Alignment.topLeft, padding: EdgeInsets.all(15), child: Column( children: <Widget>[ Container( alignment: Alignment.topLeft, child: Text("For Support Please Contact", style: TextStyle(color: Colors.tealAccent,fontWeight: FontWeight.w500,fontSize: 18,), textAlign: TextAlign.left, ), ), Divider(color: Colors.tealAccent), Container( child: Column( children: <Widget>[ GestureDetector( child: ListTile( contentPadding:EdgeInsets.symmetric(horizontal: 12, vertical: 4), leading: Icon(Icons.phone,color: Colors.tealAccent,size: 20,), title: Text("Call",style: TextStyle(color: Colors.tealAccent,fontSize: 18),), trailing: Icon(Icons.arrow_forward,color: Colors.tealAccent,size: 20,), ), onTap: _callMe, ), GestureDetector( child: ListTile( contentPadding:EdgeInsets.symmetric(horizontal: 12, vertical: 4), leading: Icon(Icons.mail,color: Colors.tealAccent,size: 20,), title: Text("Mail",style: TextStyle(color: Colors.tealAccent,fontSize: 18),), trailing: Icon(Icons.arrow_forward,color: Colors.tealAccent,size: 20,), ), onTap: _launchEmail, ), GestureDetector( child: ListTile( contentPadding:EdgeInsets.symmetric(horizontal: 12, vertical: 4), leading: Icon(Icons.language,color: Colors.tealAccent,size: 20,), title: Text("Website",style: TextStyle(color: Colors.tealAccent,fontSize: 18),), trailing: Icon(Icons.arrow_forward,color: Colors.tealAccent,size: 20,), ), onTap: (){ showDialog( context: context, barrierDismissible: true, builder: (context) => AlertDialog( title: Container( height: 40.0, child: Column( children: <Widget>[ Container( child: Row( children: <Widget>[ Container( height: 40, width: 40, child: Image.asset('assets/PasswordKeeperLogo.png'), ), SizedBox(width: 15), Container( child: Text("Passwords Keeper", textAlign: TextAlign.left,style: TextStyle(color: Colors.black),), ), ], ), ), ], ), ), content: Container( height: 85, child: Column( children: <Widget>[ Container( child: Text("In order to open website make sure that your are connected to Network Connection.",textAlign: TextAlign.left,style: TextStyle(fontSize: 16.0),), ), Container( child: Text("\n(If already connected ignore this alert.)",style: TextStyle(fontSize: 12,color: Colors.black),), ) ], ), ), actions: <Widget>[ FlatButton( onPressed: () => Navigator.of(context).pop(false), child: Text('CLOSE',style: TextStyle(color: Colors.black),), ), FlatButton( onPressed: _jumpToSetting, child: Text('SETTINGS',style: TextStyle(color: Colors.black),), ), FlatButton( autofocus: true, onPressed: _launchWebURL, child: Text('OPEN',style: TextStyle(color: Colors.black),), ), ], ), ); }, ), ], ) ) ], ), ),color: Colors.black, ) ], ), ), ], ) ], ) ); } _jumpToSetting() { SystemSetting.goto(SettingTarget.WIFI); } _callMe() async { const uri = 'tel:+91 7774967429'; if (await canLaunch(uri)) { await launch(uri); } else { const uri = 'tel:077-74-967-429'; if (await canLaunch(uri)) { await launch(uri); } else { throw 'Could not launch $uri'; } } } _launchEmail() async { final String subject = "Subject: Passwords Keeper Support"; final String stringText = "Message: Type Your Message Here & Add Screenshots Here To Rectify Issue..."; String uri = 'mailto:mohitagrawal939@gmail.com?subject=${Uri.encodeComponent(subject)}&body=${Uri.encodeComponent(stringText)}'; if (await canLaunch(uri)) { await launch(uri); } else { print("No email client found"); } } _launchWebURL() async { const url = 'https://bit.ly/mohitagrawal'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/SplashScreenPage.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'PasswordList.dart'; class SplashScreenPage extends StatefulWidget { @override _SplashScreenPageState createState() => new _SplashScreenPageState(); } class _SplashScreenPageState extends State<SplashScreenPage> { startTime() async { var _duration = new Duration(seconds: 7); return new Timer(_duration, navigationPage); } void navigationPage() { Navigator.push(context,MaterialPageRoute(builder: (context) => PwdList()),); } @override void initState() { super.initState(); startTime(); } @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.black, body: new Center( child: new Image.asset('assets/PasswordKeeperGifSS.gif'), ), bottomNavigationBar:BottomAppBar( color: Colors.black, child: Padding( padding: EdgeInsets.only(bottom: MediaQuery.of(context).size.height * 0.08,), child: Text("PASSWORDS KEEPER",textAlign: TextAlign.center,style: TextStyle(color: Colors.tealAccent,fontWeight: FontWeight.bold,fontSize: 25),), ) ), ); } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/PasswordList.dart
import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:sqflite/sqflite.dart'; import 'ContactPage.dart'; import 'InstructionsPage.dart'; import 'PasswordModel.dart'; import 'SecurityPage.dart'; import 'database_helper.dart'; import 'PasswordDetail.dart'; class PwdList extends StatefulWidget { @override State<StatefulWidget> createState() { return PwdListState(); } } class PwdListState extends State<PwdList> { DatabaseHelper databaseHelper = DatabaseHelper(); List<Pwd> pwdList; int count = 0; @override void initState(){ super.initState(); WidgetsFlutterBinding.ensureInitialized(); } Future<bool> onWillPop() { return showDialog( context: context, barrierDismissible: true, builder: (context) => AlertDialog( title: Container( height: 40.0, child: Column( children: <Widget>[ Container( child: Row( children: <Widget>[ Container( height: 40, width: 40, child: Image.asset('assets/PasswordKeeperLogo.png'), ), SizedBox(width: 15), Container( child: Text("Passwords Keeper", textAlign: TextAlign.left,style: TextStyle(color: Colors.black),), ), ], ), ), ], ), ), content: Text("Do you want to exit from app?", textAlign: TextAlign.left,style: TextStyle(color: Colors.black),), actions: <Widget>[ FlatButton( onPressed: () => exit(0), child: Text('YES',style: TextStyle(color: Colors.black),), ), FlatButton( autofocus: true, onPressed: () => Navigator.of(context).pop(false), child: Text('NO',style: TextStyle(color: Colors.black),), ), ], ), ) ??false; } @override Widget build(BuildContext context) { if (pwdList == null) { pwdList = List<Pwd>(); updateListView(); } return new WillPopScope( onWillPop: onWillPop, child: new Scaffold( appBar: AppBar( title: Text('Passwords Keeper',style: TextStyle(color: Colors.white),),backgroundColor: Colors.black, automaticallyImplyLeading: false, leading: Image.asset('assets/PasswordKeeperGif.gif',height: 15,width: 15,), ), body: getPwdListView(), backgroundColor: Color(0xF6F6F7FF), floatingActionButton: FloatingActionButton( child: Icon(Icons.add,color: Colors.white,), backgroundColor: Colors.black, mini: false, onPressed: () { navigateToDetail(Pwd('', '', '',''), 'Add Passwords'); }, ), floatingActionButtonLocation: FloatingActionButtonLocation.endDocked, bottomNavigationBar: this._buildBottomAppBar(context), ), ); } ListView getPwdListView() { return ListView.builder( padding: EdgeInsets.all(13.0), itemCount: count, itemBuilder: (BuildContext context, int position) { count=count; int index = position+1; return Card( color: Colors.black, elevation: 5.0, child: ListTile( leading: CircleAvatar( backgroundColor: Colors.tealAccent, child: Text(index.toString(),style: TextStyle(fontWeight: FontWeight.bold,color: Colors.black)), ), title: Text(this.pwdList[position].title,style: TextStyle(fontWeight: FontWeight.bold,color: Colors.white)), subtitle: Text(this.pwdList[position].date,style: TextStyle(color: Colors.white)), trailing: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ GestureDetector( child: Icon(Icons.edit,color: Colors.white,), onTap: () { navigateToDetail(this.pwdList[position], 'Edit Passwords'); }, ), SizedBox(width: 20), GestureDetector( child: Icon(Icons.delete,color: Colors.white,), onTap: () { _delete(context, pwdList[position]); }, ), ], ), onTap: null, ), ); }, ); } void _delete(BuildContext context, Pwd pwd) async { int result = await databaseHelper.deletePwd(pwd.id); if (result != 0) { _showSnackBar(context, 'Password Deleted Successfully.'); updateListView(); } } void _showSnackBar(BuildContext context, String message) { final snackBar = SnackBar(content: Text(message),elevation: 1.0,duration: Duration(seconds: 3),); Scaffold.of(context).removeCurrentSnackBar(); Scaffold.of(context).showSnackBar(snackBar); } void navigateToDetail(Pwd pwd, String title) async { bool result = await Navigator.push(context, MaterialPageRoute( builder: (context) { return PwdDetail(pwd, title); } )); if (result == true) { updateListView(); } } void updateListView() { final Future<Database> dbFuture = databaseHelper.initializeDatabase(); dbFuture.then((database) { Future<List<Pwd>> pwdListFuture = databaseHelper.getPwdList(); pwdListFuture.then((pwdList) { setState(() { this.pwdList = pwdList; this.count = pwdList.length; }); }); }); } BottomAppBar _buildBottomAppBar(BuildContext context) { return BottomAppBar( shape: CircularNotchedRectangle() , color: Colors.black, child: Row( children: <Widget>[ IconButton( icon: Icon(Icons.settings,color: Colors.tealAccent,size: 27,), onPressed: (){ bottomModalSheet(); }, ), GestureDetector( child: Text("SETTINGS",textAlign: TextAlign.left,style: TextStyle(color: Colors.white,fontWeight: FontWeight.bold),), onTap: (){ bottomModalSheet(); }, ), ], ), ); } bottomModalSheet() => showModalBottomSheet( context: context, builder: (context) => Material( clipBehavior: Clip.antiAlias, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: <Widget>[ Ink( color: Colors.black, child: Padding( padding: const EdgeInsets.all(5.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround,mainAxisSize: MainAxisSize.min, children: <Widget>[ CircleAvatar( backgroundColor: Colors.tealAccent,maxRadius: 18, child: Text(count.toString(),style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold,color: Colors.black)), ), Text(" Total Saved Passwords", style: TextStyle(fontSize: 17.0, fontWeight: FontWeight.w700, color: Colors.tealAccent), ), ], ) ), IconButton( icon: Icon(Icons.cancel,color: Colors.tealAccent,size: 28.0,), onPressed: (){ Navigator.pop(context); }, ), ], ), ), ), Expanded( child: ListView( children: <Widget>[ ListTile( leading: Icon(Icons.home,color: Colors.black,size: 22.0,), title: Text('HOME',style:new TextStyle(fontSize: 15.0, color: Colors.black)), onTap: () { Navigator.push(context,MaterialPageRoute(builder: (context) => PwdList()),); }, ), ListTile( leading: Icon(Icons.verified_user,color: Colors.black,size: 22.0,), title: Text('SECURITY',style:new TextStyle(fontSize: 15.0, color: Colors.black)), onTap: () { Navigator.push(context,MaterialPageRoute(builder: (context) => SecurityPage()),); }, ), ListTile( leading: Icon(Icons.assignment_late,color: Colors.black,size: 22.0,), title: Text('INSTRUCTIONS',style:new TextStyle(fontSize: 15.0, color: Colors.black)), onTap: () { Navigator.push(context,MaterialPageRoute(builder: (context) => InstructionsPage()),); }, ), ListTile( leading: Icon(Icons.textsms,color: Colors.black,size: 22.0,), title: Text('CONTACT',style:new TextStyle(fontSize: 15.0, color: Colors.black)), onTap: () { Navigator.push(context,MaterialPageRoute(builder: (context) => ContactPage()),); }, ), Padding( padding: EdgeInsets.only(left: 15,right: 15), child: Divider(color: Colors.black,), ), ListTile( leading: Image.asset('assets/PasswordKeeperLogo.png',height: 40.0,width: 40.0,), title: Text('About Passwords Keeper',style:new TextStyle(fontSize: 15.0, color: Colors.black,fontWeight: FontWeight.bold)), onTap: () { showDialog( context: context, barrierDismissible: true, builder: (context) => AlertDialog( title: Container( height: 40.0, child: Column( children: <Widget>[ Container( child: Row( children: <Widget>[ Container( height: 40, width: 40, child: Image.asset('assets/PasswordKeeperLogo.png'), ), SizedBox(width: 15), Container( child: Text("Passwords Keeper", textAlign: TextAlign.left,style: TextStyle(color: Colors.black),), ), ], ), ), ], ), ), content: Container( height: 45, child: Column( children: <Widget>[ Container( child: Row( children: <Widget>[ Text("Developed By :- ", textAlign: TextAlign.left,style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold),), Text("Mohit Agrawal.", textAlign: TextAlign.left,style: TextStyle(color: Colors.black),), ], ), ), Container( padding: EdgeInsets.only(top:5), child: Row( children: <Widget>[ Text("Version :- ", textAlign: TextAlign.left,style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold),), Text("1.0.0", textAlign: TextAlign.left,style: TextStyle(color: Colors.black),), ], ), ), ], ), ), actions: <Widget>[ FlatButton( autofocus: true, onPressed: () => Navigator.of(context).pop(false), child: Text('CLOSE',style: TextStyle(color: Colors.black),), ), ], ), ); }, ), ], ) ), ], ) ) ); }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/SecurityPage.dart
import 'package:flutter/material.dart'; import 'PasswordList.dart'; class SecurityPage extends StatefulWidget { @override _SecurityPageState createState() => _SecurityPageState(); } class _SecurityPageState extends State<SecurityPage> { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return new WillPopScope( onWillPop: (){ Navigator.push(context, MaterialPageRoute(builder: (context) => PwdList())); }, child: new Scaffold( appBar: new AppBar( title: new Text("Security", style: TextStyle(color: Colors.white)), iconTheme: IconThemeData(color: Colors.white), leading: new IconButton( icon: new Icon(Icons.arrow_back), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => PwdList())); }, ), ), backgroundColor: Color(0xF6F6F7FF), body: SingleChildScrollView( child: Container( child: Stack( children: <Widget>[ Container( padding: EdgeInsets.only(top: 15, bottom: 60, left: 18, right: 0), color: Colors.tealAccent, child: Column( children: <Widget>[ Row( children: <Widget>[ Container( child: Text("Security & Privacy", style: TextStyle( fontSize: 18, color: Colors.black, fontWeight: FontWeight.bold)), ), ], ), ] ), ), Container( margin: EdgeInsets.fromLTRB(16.0, 50.0,16.0,16.0), decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(25.0) ), padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ ListTile( leading: Icon(Icons.security,color: Colors.tealAccent,size: 40,), title: Text("Passwords Keeper Security & Privacy ", style: TextStyle(color: Colors.tealAccent,fontSize: 16,fontWeight: FontWeight.bold),), subtitle: Text("Updated on 15th Mar, 2020",style: TextStyle(color: Colors.tealAccent,fontStyle: FontStyle.italic,fontSize: 14),), ), SizedBox(height: 15.0), Divider(color: Colors.tealAccent,), SizedBox(height: 20.0,), Text(" This application collects personal data but never shares with other person or particular. Although this appliction works totally offline (Works with network connection also) so no worry about data penetration.\n\n This application stores data locally 100% so their is least amount of risk to violate security policy until someone connects mobile with other devices with or without permission of the owner. \n\n Usually accessing local data is not easy but some third party applications tries to collect data. This application doesn't require any permission from mobile or with other application. This application shall replace the visuals used in it against copyright owner request.\n\n The data stored in this application is non transferable and uninstalling application erases all data saved against the application. We recommened you to take backup before uninstalling.", textAlign: TextAlign.justify,style: TextStyle(color: Colors.tealAccent,fontSize: 15),), SizedBox(height: 30.0), Container( child: Row( children: <Widget>[ Icon(Icons.copyright,color: Colors.tealAccent,size: 16,), Text(" 2020 | By Mohit Agrawal",style: TextStyle(color: Colors.tealAccent,fontSize: 15),), ], ), ), SizedBox(height: 10.0), Text("Your Privacy Matters...",textAlign: TextAlign.left,style: TextStyle(color: Colors.tealAccent,fontSize: 15,fontStyle: FontStyle.italic),), ], ), ), ], ), ), ), ), ); } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/PasswordDetail.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'PasswordModel.dart'; import 'database_helper.dart'; import 'package:intl/intl.dart'; class PwdDetail extends StatefulWidget { final String appBarTitle; final Pwd pwd; PwdDetail(this.pwd, this.appBarTitle); @override State<StatefulWidget> createState() { return PwdDetailState(this.pwd, this.appBarTitle); } } class PwdDetailState extends State<PwdDetail> { DatabaseHelper helper = DatabaseHelper(); String appBarTitle; Pwd pwd; TextEditingController titleController = TextEditingController(); TextEditingController usernameController = TextEditingController(); TextEditingController passwordController = TextEditingController(); PwdDetailState(this.pwd, this.appBarTitle); bool _obscureText = true; bool passwordVisible = true; void _toggle() { setState(() { _obscureText = !_obscureText; }); } @override void initState() { passwordVisible = false; } @override Widget build(BuildContext context) { titleController.text = pwd.title; usernameController.text = pwd.username; passwordController.text = pwd.password; return WillPopScope( onWillPop: () { moveToLastScreen(); }, child: Scaffold( appBar: AppBar( title: Text(appBarTitle), leading: IconButton( icon: Icon(Icons.arrow_back), onPressed: () { moveToLastScreen(); } ), ), backgroundColor: Color(0xF6F6F7FF), body: Padding( padding: EdgeInsets.only(top: 15.0, left: 10.0, right: 10.0), child: ListView( children: <Widget>[ Padding( padding: EdgeInsets.only(top: 15.0, bottom: 15.0), child: new TextFormField( controller: titleController, cursorColor: Colors.black, keyboardType: TextInputType.text, autofocus: false, decoration: InputDecoration( hintText: 'TITLE', contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), border: OutlineInputBorder(borderRadius: BorderRadius.circular(32.0)), ), onChanged: (value) { updateTitle(); }, ), ), Padding( padding: EdgeInsets.only(top: 15.0, bottom: 15.0), child: new TextFormField( controller: usernameController, cursorColor: Colors.black, keyboardType: TextInputType.text, autofocus: false, decoration: InputDecoration( hintText: 'USERNAME', contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), border: OutlineInputBorder(borderRadius: BorderRadius.circular(32.0)), ), onChanged: (value) { updateUsername(); }, ), ), Padding( padding: EdgeInsets.only(top: 15.0, bottom: 15.0), child: new TextFormField( controller: passwordController, keyboardType: TextInputType.text, autofocus: false, obscureText: _obscureText, cursorColor: Colors.black, decoration: InputDecoration( hintText: 'PASSWORD', suffixIcon: IconButton( icon: Icon(_obscureText ? Icons.visibility : Icons.visibility_off, color: Colors.black, ), onPressed: _toggle, ), contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), border: OutlineInputBorder(borderRadius: BorderRadius.circular(32.0)), ), onChanged: (value) { updatePassword(); }, ), ), Padding( padding: EdgeInsets.only(top: 15.0, bottom: 15.0), child: Row( children: <Widget>[ Expanded( child:RaisedButton( shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(18.0), ), elevation: 15, color: Colors.tealAccent, textColor: Colors.black, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text("Save ",textScaleFactor: 1.3,), Icon(Icons.done_all), ], ), onPressed: () { if(titleController.text.isEmpty){ showDialog<void>( context: context, barrierDismissible: true, builder: (BuildContext context) { Future.delayed(Duration(seconds: 2), () { Navigator.of(context).pop(true); }); return new WillPopScope( onWillPop: () async => true, child: SimpleDialog( backgroundColor: Colors.black, children: <Widget>[ Center( child: Row( children: [ Icon(Icons.error,color: Colors.tealAccent,), SizedBox(height: 30,width: 10,), Text("Title is required",style: TextStyle(color: Colors.tealAccent),) ], mainAxisAlignment: MainAxisAlignment.center, ), ) ] ) ); } ); }else{ setState(() { _save(); }); } }, ), ), Container(width: 15.0,), Expanded( child:RaisedButton( shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(18.0), ), elevation: 15, color: Colors.black, textColor: Colors.white, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text("Delete ",textScaleFactor: 1.3,), Icon(Icons.delete_forever), ], ), onPressed: () { setState(() { _delete(); }); }, ), ), ], ), ), ], ), ), ) ); } void moveToLastScreen() { Navigator.pop(context, true); } void updateTitle(){ pwd.title = titleController.text; } void updateUsername() { pwd.username = usernameController.text; } void updatePassword() { pwd.password = passwordController.text; } void _save() async { moveToLastScreen(); pwd.date = DateFormat("dd-MM-yyyy / kk:mm").format(DateTime.now()); int result; if (pwd.id != null) { result = await helper.updatePwd(pwd); } else { result = await helper.insertPwd(pwd); } if (result != 0) { _showAlertDialog('Password Saved Successfully'); } else { _showAlertDialog1('Problem Saving Password'); } } void _delete() async { moveToLastScreen(); if (pwd.id == null) { _showAlertDialog('No Password was deleted'); return; } int result = await helper.deletePwd(pwd.id); if (result != 0) { _showAlertDialog('Password Deleted Successfully'); } else { _showAlertDialog1('Error Occured while Deleting Password'); } } void _showAlertDialog(String message) { showDialog<void>( context: context, barrierDismissible: false, builder: (BuildContext context) { Future.delayed(Duration(seconds: 2), () { Navigator.of(context).pop(true); }); return new WillPopScope( onWillPop: () async => false, child: SimpleDialog( backgroundColor: Colors.white, children: <Widget>[ Center( child: Row( children: [ Icon(Icons.check_circle,color: Colors.black,), SizedBox(height: 30,width: 10,), Text("$message",style: TextStyle(color: Colors.black),) ], mainAxisAlignment: MainAxisAlignment.center, ), ) ] ) ); } ); } void _showAlertDialog1(String message) { showDialog<void>( context: context, barrierDismissible: false, builder: (BuildContext context) { Future.delayed(Duration(seconds: 2), () { Navigator.of(context).pop(true); }); return new WillPopScope( onWillPop: () async => false, child: SimpleDialog( backgroundColor: Colors.white, children: <Widget>[ Center( child: Row( children: [ Icon(Icons.error,color: Colors.black,), SizedBox(height: 30,width: 10,), Text("$message",style: TextStyle(color: Colors.black),) ], mainAxisAlignment: MainAxisAlignment.center, ), ) ] ) ); } ); } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/PasswordModel.dart
class Pwd { int _id; String _title; String _username; String _password; String _date; Pwd(this._title, this._date, this._username, this._password ); Pwd.withId(this._id, this._title, this._date, this._username, this._password ); int get id => _id; String get title => _title; String get username => _username; String get password => _password; String get date => _date; set title(String newTitle) { if (newTitle.length <= 255) { this._title = newTitle; } } set username(String newUsername) { if (newUsername.length <= 255) { this._username = newUsername; } } set password(String newPassword) { if (newPassword.length <= 255) { this._password = newPassword; } } set date(String newDate) { this._date = newDate; } Map<String, dynamic> toMap() { var map = Map<String, dynamic>(); if (id != null) { map['id'] = _id; } map['title'] = _title; map['username'] = _username; map['password'] = _password; map['date'] = _date; return map; } Pwd.fromMapObject(Map<String, dynamic> map) { this._id = map['id']; this._title = map['title']; this._username = map['username']; this._password = map['password']; this._date = map['date']; } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/main.dart
import 'package:flutter/material.dart'; import 'SplashScreenPage.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Passwords Keeper', theme: ThemeData( primaryColor: Colors.black, accentColor: Colors.black12, accentColorBrightness: Brightness.light, textSelectionColor: Colors.grey, textSelectionHandleColor: Colors.grey, ), debugShowCheckedModeBanner: false, home: SplashScreenPage(), ); } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/InstructionsPage.dart
import 'package:flutter/material.dart'; import 'package:intro_views_flutter/Models/page_view_model.dart'; import 'package:intro_views_flutter/intro_views_flutter.dart'; import 'PasswordList.dart'; class InstructionsPage extends StatelessWidget { final pages = [ PageViewModel( pageColor: Color(0xF6F6F7FF), bubbleBackgroundColor: Colors.black, title: Container(), body: Column( children: <Widget>[ Text('Welcome to smart passwords Keeper'.toUpperCase(),style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold)), SizedBox(height:7.0), Text('Store your ID\'s, Passwords, ATM Pins, Cards, Account Numbers & Lot More.', style: TextStyle(color: Colors.black54,fontSize: 16.0), ), ], ), mainImage: Image.asset('assets/PasswordKeeper1.png',width: 285.0,alignment: Alignment.center,), textStyle: TextStyle(color: Colors.black), ), PageViewModel( pageColor: Color(0xF6F6F7FF), iconColor: null, bubbleBackgroundColor: Colors.black, title: Container(), body: Column( children: <Widget>[ Text('Works offline completely'.toUpperCase(),style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold)), SizedBox(height:5.0), Text('Store your all important pins along with ID\'s Offline and organize your smart passwords keeper.', style: TextStyle(color: Colors.black54,fontSize: 16.0), ), ], ), mainImage: Image.asset('assets/PasswordKeeper2.png',width: 285.0,alignment: Alignment.center,), textStyle: TextStyle(color: Colors.black), ), PageViewModel( pageColor: Color(0xF6F6F7FF), iconColor: null, bubbleBackgroundColor: Colors.black, title: Container(), body: Column( children: <Widget>[ Text('Stores Locally & 100% secure'.toUpperCase(),style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold)), SizedBox(height:5.0), Text('Organize your ID\'s & Passwords and get access to passwords anytime anywhere.', style: TextStyle(color: Colors.black54,fontSize: 16.0), ), ], ), mainImage: Image.asset('assets/PasswordKeeper3.png',width: 285.0,alignment: Alignment.center), textStyle: TextStyle(color: Colors.black), ), ]; @override Widget build(BuildContext context) { return new WillPopScope( onWillPop: (){ Navigator.push(context, MaterialPageRoute(builder: (context) => PwdList())); }, child: new Scaffold( body: SafeArea( child: Stack( children: <Widget>[ IntroViewsFlutter( pages, onTapDoneButton: (){ Navigator.push(context,MaterialPageRoute(builder: (context) => PwdList()),); }, showSkipButton: false, doneText: Text("DONE",), pageButtonsColor: Colors.black, pageButtonTextStyles: new TextStyle(fontSize: 16.0,fontFamily: "Regular",), ), Positioned( top: 20.0, left: MediaQuery.of(context).size.width/2 - 40, child: Image.asset('assets/PasswordKeeperLogo.png', width: 80,) ) ], ), ), ) ); } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/lib/database_helper.dart
import 'package:sqflite/sqflite.dart'; import 'dart:async'; import 'dart:io'; import 'package:path_provider/path_provider.dart'; import 'PasswordModel.dart'; class DatabaseHelper { static DatabaseHelper _databaseHelper; static Database _database; String pwdTable = 'user_table'; String colId = 'id'; String colTitle = 'title'; String colUsername = 'username'; String colPassword = 'password'; String colDate = 'date'; DatabaseHelper._createInstance(); factory DatabaseHelper() { if (_databaseHelper == null) { _databaseHelper = DatabaseHelper._createInstance(); } return _databaseHelper; } Future<Database> get database async { if (_database == null) { _database = await initializeDatabase(); } return _database; } Future<Database> initializeDatabase() async { Directory directory = await getApplicationDocumentsDirectory(); String path = directory.path + 'users.db'; var pwdDatabase = await openDatabase(path, version: 1, onCreate: _createDb); return pwdDatabase; } void _createDb(Database db, int newVersion) async { await db.execute('CREATE TABLE $pwdTable($colId INTEGER PRIMARY KEY AUTOINCREMENT, $colTitle TEXT, ''$colUsername TEXT, $colPassword TEXT, $colDate TEXT)'); } Future<List<Map<String, dynamic>>> getPwdMapList() async { Database db = await this.database; var result = await db.query(pwdTable, orderBy: '$colDate DESC'); return result; } Future<int> insertPwd(Pwd pwd) async { Database db = await this.database; var result = await db.insert(pwdTable, pwd.toMap()); return result; } Future<int> updatePwd(Pwd pwd) async { var db = await this.database; var result = await db.update(pwdTable, pwd.toMap(), where: '$colId = ?', whereArgs: [pwd.id]); return result; } Future<int> deletePwd(int id) async { var db = await this.database; int result = await db.rawDelete('DELETE FROM $pwdTable WHERE $colId = $id'); return result; } Future<int> getCount() async { Database db = await this.database; List<Map<String, dynamic>> x = await db.rawQuery('SELECT COUNT (*) from $pwdTable'); int result = Sqflite.firstIntValue(x); return result; } Future<List<Pwd>> getPwdList() async { var pwdMapList = await getPwdMapList(); int count = pwdMapList.length; List<Pwd> pwdList = List<Pwd>(); for (int i = 0; i < count; i++) { pwdList.add(Pwd.fromMapObject(pwdMapList[i])); } return pwdList; } }
0
mirrored_repositories/flutter-password-keeper
mirrored_repositories/flutter-password-keeper/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:password_keeper/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Designs
mirrored_repositories/Designs/lib/design1.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:page_transition/page_transition.dart'; // ignore: camel_case_types class d1 extends StatefulWidget { @override _d1State createState() => _d1State(); } // ignore: camel_case_types class _d1State extends State<d1> { @override Widget build(BuildContext context) { final height = MediaQuery.of(context).size.height; return Scaffold( body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Column( children: [ SizedBox( height: 20, ), Stack( children: [ Container( height: height / 3.5, width: double.infinity, decoration: BoxDecoration( color: Colors.yellowAccent, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(35), bottomRight: Radius.circular(35)), ), ), Positioned( top: 1, right: 1, child: IconButton( icon: Icon( Icons.search, size: 30, ), onPressed: () {})), Positioned( top: 1, left: 1, child: IconButton( icon: Icon( Icons.menu, size: 30, ), onPressed: () {})), Positioned( left: 60, top: 100, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ CircleAvatar( radius: 60, backgroundImage: NetworkImage( 'https://image.freepik.com/free-vector/businessman-profile-cartoon_18591-58479.jpg')), SizedBox(width: 30), Column( children: [ Text( 'Ojas Gupta', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 28), ), Text( 'Big Data Developer', style: TextStyle(fontSize: 18), ) ], ) ], ), ) ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( 'My Tasks', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 26), ), ), Padding( padding: const EdgeInsets.all(8.0), child: CircleAvatar( radius: 25, backgroundImage: NetworkImage( 'https://www.freeiconspng.com/thumbs/tasks-icon/tasks-icon-14.png'), ), ), ], ), ListTile( leading: CircleAvatar( radius: 20, backgroundColor: Colors.red, child: Text( 'D', style: TextStyle(color: Colors.white, fontSize: 24), ), ), title: Text( 'To-Do List', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), ), subtitle: Text('What you need to do'), ), ListTile( leading: CircleAvatar( radius: 20, backgroundColor: Colors.yellow, child: Text( 'P', style: TextStyle(color: Colors.white, fontSize: 24), ), ), title: Text( 'In Progress', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), ), subtitle: Text('3 Tasks are in progress'), ), ListTile( leading: CircleAvatar( radius: 20, backgroundColor: Colors.blue, child: Icon(Icons.done_all_outlined)), title: Text( 'Tasks Completed', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), ), subtitle: Text('4 tasks are finished'), ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Card( clipBehavior: Clip.antiAlias, elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(40)), child: Container( width: 190, height: 250, decoration: BoxDecoration(color: Colors.green[500]), ), ), InkWell( child: Card( clipBehavior: Clip.antiAlias, elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(40)), child: Container( width: 190, height: 250, decoration: BoxDecoration(color: Colors.red), ), ), onTap: () { Navigator.push( context, PageTransition( type: PageTransitionType.rightToLeft, child: page(), inheritTheme: true, ctx: context), ); }, ), ], ), SizedBox( height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Card( clipBehavior: Clip.antiAlias, elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(40)), child: Container( width: 190, height: 250, decoration: BoxDecoration(color: Colors.yellow), ), ), Card( clipBehavior: Clip.antiAlias, elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(40)), child: Container( width: 190, height: 250, decoration: BoxDecoration(color: Colors.lightBlue), ), ), ], ) ], ), ), ); } } class page extends StatelessWidget { @override Widget build(BuildContext context) { return Center( child: Text('Ojas'), ); } }
0
mirrored_repositories/Designs
mirrored_repositories/Designs/lib/Shopping.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:date_range_picker/date_range_picker.dart' as DateRangePicker; import 'package:page_transition/page_transition.dart'; // ignore: camel_case_types class shoppingDesign extends StatefulWidget { @override _shoppingDesignState createState() => _shoppingDesignState(); } // ignore: camel_case_types class _shoppingDesignState extends State<shoppingDesign> { @override int val = 0; int price = 536; Widget build(BuildContext context) { return Scaffold( //backgroundColor: Colors.blue.shade100, body: SingleChildScrollView( child: Column( children: [ SizedBox( height: 40, ), Padding( padding: const EdgeInsets.all(12.0), child: Row( children: [ Icon(Icons.arrow_back), Padding( padding: const EdgeInsets.only(left: 15.0), child: Text( 'Create Subscription', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), ), ], ), ), SizedBox( height: 10, ), Container( width: MediaQuery.of(context).size.width, height: 170, color: Colors.green[50], child: Row( children: [ Padding( padding: const EdgeInsets.all(20.0), child: Container( height: 100, child: Image.asset( 'Assets/tata.jpg', height: 60, width: 90, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15)), )), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Tata Tea Gold (1Kg)', style: TextStyle( fontSize: 22, fontWeight: FontWeight.bold), ), SizedBox( height: 30, ), Row( // mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.only(right: 30.0), child: Text( '\u20B9$price', style: TextStyle(fontSize: 18), ), ), Text( '\u20B9635.00', overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 15, decoration: TextDecoration.lineThrough, ), ), SizedBox( width: 5, ), Text( '.1pkt', style: TextStyle(fontSize: 12), ) ], ) ], ) ], ), ), SizedBox( height: 5, ), Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(25.0), child: Row( children: [ Icon(Icons.cases_outlined), SizedBox( width: 20, ), Column( children: [ Text( 'Quantity', style: TextStyle(fontSize: 15), ), SizedBox( height: 5, ), Padding( padding: const EdgeInsets.only(right: 10.0), child: Text('per day'), ) ], ) ], ), ), Padding( padding: const EdgeInsets.only(right: 15.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), border: Border.all(color: Colors.lightGreen)), width: 150, height: 45, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ InkWell( child: Icon( Icons.remove, color: Colors.lightGreen, ), onTap: () { if (val != 0) { setState(() { --val; }); } }, ), Text('$val'), InkWell( child: Icon( Icons.add, color: Colors.lightGreen, ), onTap: () { setState(() { ++val; }); }, ) ], ), ), ), ], )), SizedBox( height: 5, ), Divider( color: Colors.black, ), repeat(context), SizedBox( height: 5, ), Divider( color: Colors.black, ), recharge(context), SizedBox( height: 5, ), Divider( color: Colors.black, ), date(context), ], ), ), ); } Widget recharge(BuildContext context) { return InkWell( onTap: () { Navigator.push( context, PageTransition( type: PageTransitionType.rightToLeft, child: MyStatefulWidget(), inheritTheme: true, ctx: context), ); }, child: Container( child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(25.0), child: Row( children: [ Icon(Icons.payment_outlined), SizedBox( width: 20, ), Column( children: [ Padding( padding: const EdgeInsets.only(right: 10.0), child: Text( 'Recharge/Top Up', style: TextStyle(fontSize: 15), ), ), SizedBox( height: 10, ), Padding( padding: const EdgeInsets.only(right: 10.0), child: Text( '30 Deliveries', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ) ], ), ], ), ), Padding( padding: const EdgeInsets.all(8.0), child: Icon(Icons.arrow_forward), ) ])), ); } Widget date(BuildContext context) { return Column( children: [ InkWell( onTap: () async { final List<DateTime> picked = await DateRangePicker.showDatePicker( context: context, initialFirstDate: new DateTime.now(), initialLastDate: (new DateTime.now()).add(new Duration(days: 7)), firstDate: new DateTime(2015), lastDate: new DateTime(DateTime.now().year + 2)); if (picked != null && picked.length == 2) { print(picked); } }, child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(25.0), child: Row( children: [ Icon(Icons.date_range_outlined), SizedBox( width: 20, ), Column( children: [ Padding( padding: const EdgeInsets.only(right: 35.0), child: Text( 'Start Date', style: TextStyle(fontSize: 15), ), ), SizedBox( height: 10, ), Padding( padding: const EdgeInsets.only(right: 15.0), child: Text( 'Tomorrow', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), ) ], ), ], ), ), Padding( padding: const EdgeInsets.all(8.0), child: Icon(Icons.arrow_forward), ) ])), ), Card( elevation: 15, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), child: Container( color: Colors.white, width: MediaQuery.of(context).size.width, height: 130, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( decoration: BoxDecoration( border: Border.all(color: Colors.green), borderRadius: BorderRadius.circular(10)), width: 150, height: 50, child: Center( child: Text( 'Deliver Once', style: TextStyle(color: Colors.green, fontSize: 20), ), ), ), InkWell( onTap: () { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Your order value is'), content: Text('${val * price * topup}'), ); }); }, child: Container( decoration: BoxDecoration( color: Colors.green.shade500, border: Border.all(color: Colors.green), borderRadius: BorderRadius.circular(10)), width: 150, height: 50, child: Center( child: Text( 'Subscribed', style: TextStyle(color: Colors.white, fontSize: 20), ), ), ), ) ], ), ), ), ], ); } Widget repeat(BuildContext context) { return Container( child: Column( children: [ Padding( padding: const EdgeInsets.all(25.0), child: Row( children: [ Icon(Icons.restore), SizedBox( width: 20, ), Row( children: [ Text( 'Repeat', style: TextStyle(fontSize: 15), ), SizedBox( width: 15, ), Text( "DAILY", style: TextStyle(fontSize: 16, color: Colors.green), ) ], ), ], ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ SizedBox( width: 40, ), Container( height: 40, width: 40, child: Center( child: Text( 'M', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Container( height: 40, width: 40, child: Center( child: Text( 'T', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Container( height: 40, width: 40, child: Center( child: Text( 'W', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Container( height: 40, width: 40, child: Center( child: Text( 'T', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Container( height: 40, width: 40, child: Center( child: Text( 'F', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Container( height: 40, width: 40, child: Center( child: Text( 'S', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Container( height: 40, width: 40, child: Center( child: Text( 'S', style: TextStyle(color: Colors.white, fontSize: 18), ), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.green), ), Icon(Icons.arrow_forward) ], ) ], ), ); } } int topup = 10; /// This is the stateful widget that the main application instantiates. class MyStatefulWidget extends StatefulWidget { const MyStatefulWidget({Key key}) : super(key: key); @override State<MyStatefulWidget> createState() => _MyStatefulWidgetState(); } /// This is the private State class that goes with MyStatefulWidget. class _MyStatefulWidgetState extends State<MyStatefulWidget> { @override Widget build(BuildContext context) { return Scaffold( body: Column( children: <Widget>[ SizedBox( height: 50, ), ListTile( title: const Text('10'), leading: Radio( value: 10, groupValue: topup, onChanged: (value) { setState(() { topup = value; Navigator.of(context).pop(); }); }, ), ), ListTile( title: const Text('20'), leading: Radio( value: 20, groupValue: topup, onChanged: (value) { setState(() { topup = value; Navigator.of(context).pop(); }); }, ), ), ListTile( title: const Text('30'), leading: Radio( value: 30, groupValue: topup, onChanged: (value) { setState(() { topup = value; Navigator.of(context).pop(); }); }, ), ), ], ), ); } }
0
mirrored_repositories/Designs
mirrored_repositories/Designs/lib/Add.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; // ignore: camel_case_types class add extends StatefulWidget { @override _addState createState() => _addState(); } // ignore: camel_case_types class _addState extends State<add> { int val = 0; int val1 = 0; int sum = 0; @override int Sum(int a, int b) { int c = 0; return a + b; } Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey, appBar: AppBar( title: Text( 'Add Numbers', style: TextStyle(color: Colors.white, fontSize: 23), ), centerTitle: true, backgroundColor: Colors.black, ), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ MaterialButton( onPressed: () { setState(() { val++; }); }, hoverColor: Colors.white, hoverElevation: 4, elevation: 5, color: Colors.green.shade400, child: Text('$val'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15)), ), MaterialButton( onPressed: () { setState(() { val1++; }); }, hoverColor: Colors.white, hoverElevation: 4, elevation: 5, color: Colors.pink.shade400, child: Text('$val1'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15)), ), ], ), MaterialButton( onPressed: () { setState(() { sum = Sum(val, val1); }); }, hoverColor: Colors.white, hoverElevation: 4, elevation: 5, color: Colors.pink.shade400, child: Text('$sum'), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), ) ], ), ); } }
0
mirrored_repositories/Designs
mirrored_repositories/Designs/lib/main.dart
import 'package:flutter/material.dart'; import 'package:stateanagement/Shopping.dart'; void main() { runApp(new MaterialApp( debugShowCheckedModeBanner: false, home: shoppingDesign(), )); }
0
mirrored_repositories/myaccountsapp
mirrored_repositories/myaccountsapp/lib/main.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Screens/HomeView.dart'; import 'package:my_accounts/Settings/Routes.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( onGenerateRoute: onGenerateRoute, theme: ThemeData( visualDensity: VisualDensity.adaptivePlatformDensity, ), home: HomeView(), // HomeView is the start screen of our app ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Screens/CardsView.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Models/CardInfo.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; import 'package:my_accounts/Widgets/CardWidget.dart'; class CardsView extends StatefulWidget { static const routeName = '/home'; CardsView({Key key}) : super(key: key); @override _CardsViewState createState() => _CardsViewState(); } class _CardsViewState extends State<CardsView> { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { // Two sample credit cards created CardInfo cardInfo1 = CardInfo(cardNumber: "1234 **** **** 4563", accountType: "Current Account", validityDate: "06/23", balance: "130,000,00", currency: "IQD"); CardInfo cardInfo2 = CardInfo(cardNumber: "4132 **** **** 5578", accountType: "Current Account", validityDate: "06/23", balance: "220,000,00", currency: "IQD"); return Scaffold( body: Container( color: Colors.transparent, child: Column( children: [ // Card Widget takes CardInfo and creates a dynamic card widget CardWidget( cardData: cardInfo1, cardColor: AppConstants.appCardGreenColor, ), CardWidget( cardData: cardInfo2, cardColor: AppConstants.appCardGoldColor, ), ], ), ), ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Screens/HomeView.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Manager/AppDrawer.dart'; import 'package:my_accounts/Manager/TabBarManager.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; class HomeView extends StatefulWidget { static const routeName = '/home'; HomeView({Key key}) : super(key: key); @override _HomeViewState createState() => _HomeViewState(); } // SingleTickerProviderStateMixin is used to help TabManager, it active state of the view class _HomeViewState extends State<HomeView> with SingleTickerProviderStateMixin{ // TabController is required to manage different tabs TabController _controller; AppConstants constants = AppConstants(); @override void initState() { // Passing this class in vsync as delegate of TabController _controller = new TabController(length: 2, vsync: this); super.initState(); } @override Widget build(BuildContext context) { // Initializing the main settings of the application constants.setAppSettings(context); return Scaffold( drawer: AppDrawer(), // To show side menu appBar: AppBar( iconTheme: IconThemeData(color: AppConstants.appDarkGreenColor), centerTitle: false, backgroundColor: AppConstants.appBgColor, shadowColor: Colors.transparent, title: Text(AppConstants.appName, style: TextStyle(color: AppConstants.appDarkGreenColor, fontWeight: FontWeight.w700)), ), floatingActionButton: FloatingActionButton( onPressed: _buttonAction, backgroundColor: AppConstants.appGreenColor, child: Icon(Icons.add) ), body: TabBarManager(_controller), ); } void _buttonAction() { print("Add button tapped"); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Screens/AccountsView.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Models/AccountInfo.dart'; import 'package:my_accounts/Models/CardInfo.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; import 'package:my_accounts/Widgets/AccountInfoWidget.dart'; import 'package:my_accounts/Widgets/ActionRowWidget.dart'; class AccountsView extends StatefulWidget { static const routeName = '/home'; AccountsView({Key key}) : super(key: key); @override _AccountsViewState createState() => _AccountsViewState(); } class _AccountsViewState extends State<AccountsView> { AppConstants constants; @override void initState() { super.initState(); constants = AppConstants.shared; } @override Widget build(BuildContext context) { // Sample credit card object created CardInfo cardInfo1 = CardInfo(cardNumber: "1234 **** **** 4563", accountType: "Current Account", validityDate: "06/23", balance: "130,000,00", currency: "IQD"); // Sample account info object created and card object passed in it AccountInfo accountInfo = AccountInfo(card: cardInfo1, address: "Al Nahda Branch - Dubai UAE", accountType: "Saving Account", currency: "IQD"); return Scaffold( body: Container( color: Colors.transparent, child: Column( children: [ AccountInfoWidget(accountInfo: accountInfo,), Container( padding: EdgeInsets.fromLTRB(constants.edgeDistance, constants.topGap, constants.edgeDistance, constants.topGap), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: EdgeInsets.only(right: 10), width: constants.edgeDistance * 0.8, child: Center( child: Divider( height: 20, color: AppConstants.appGreenColor, thickness: 2.5, ), ), ), Container( child: Text( "Transfer Amount", style: TextStyle( fontSize: 16, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.bold, color: AppConstants.appDarkGreenColor), ), ), ], ), ), // Custom widget to show action rows in accounts view ActionRowWidget( icon: Icons.account_balance_wallet_rounded, actionText: "Cash Transfer", ), ActionRowWidget( icon: Icons.person_pin_rounded, actionText: "Other accounts in same branch", ), ActionRowWidget( icon: Icons.history_rounded, actionText: "Between Own Accounts", ), ], ), ), ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Settings/ScreenManager.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Screens/HomeView.dart'; // Screen manager is used to manage navigation of screen when required enum Screen { HOME_VIEW, } class ScreenManager { static gotoScreen(BuildContext context, Screen screen, [Map<String, String> data]) { Widget screenToGo = getScreenToGo(screen, data); navigateToScreen(context, screenToGo); } // Takes view name to navigate to the view static navigateToScreen(context, Widget screen) { Navigator.push(context, MaterialPageRoute(builder: (context) => screen)); } // Takes route name to navigate to the view static gotoScreenByRouteName(BuildContext context, String routeName, {Object data}) { Navigator.pushNamed( context, routeName, arguments: data, ); } // Manages the basic settings for different view if required to modify or check the data before navigating to a screen static Widget getScreenToGo(Screen screen, [Map<String, String> data]) { Widget screenToGo; switch (screen) { case Screen.HOME_VIEW: { screenToGo = HomeView(); } break; } return screenToGo; } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Settings/Routes.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Screens/HomeView.dart'; // Routes are to manage navigation of the screens Route<dynamic> onGenerateRoute(RouteSettings settings) { var routes = { HomeView.routeName: (context) => HomeView(), }; WidgetBuilder builder = routes[settings.name]; return MaterialPageRoute(builder: (ctx) => builder(ctx)); }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Settings/AppConstants.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // This static class manages all the app constants class AppConstants { // creating singleton static final AppConstants _singleton = AppConstants._internal(); factory AppConstants() => _singleton; AppConstants._internal(); static AppConstants get shared => _singleton; // Screen size constants double screenHeight; double screenWidth; double fieldGap; double topGap; double edgeDistance; // Initializing the settings depending on the app context and device resolution void setAppSettings(BuildContext context) { this.screenHeight = MediaQuery.of(context).size.height; // Screen height this.screenWidth = MediaQuery.of(context).size.width; // Screen width this.fieldGap = screenHeight * 0.0225; // Custom field gap to be used in forms this.topGap = screenHeight * 0.02; // Constant to set top padding or margin of a widget this.edgeDistance = edgeDistance = screenWidth * 0.08; // Constant to space from edges of the widget } // Color constants static Color appBgColor = Colors.white; static Color appBorderGreyColor = const Color(0xFF4E4D51); static Color appGreenColor = const Color(0xFF1F7245); static Color appLightGreenColor = const Color(0xFF098B5C); static Color appDarkGreenColor = const Color(0xFF214134); static Color appBorderYellowColor = const Color(0xFF214134); static Color appCardGreenColor = const Color(0xFF098b5C); static Color appCardGoldColor = const Color(0xFFD1AF5A); static Color bmtWhiteColor50Percent = const Color.fromRGBO(255, 255, 255, 0.5); static Color bmtTransparent = Colors.transparent; // Images Paths static String bmtImageLocationArrow = "assets/home/location_arrow.png"; // General String Constants static String appName = "My Accounts"; static String sAccounts = "Accounts"; static String sCards = "Cards"; //Fonts static String fontTitillium = "Titillium"; }
0
mirrored_repositories/myaccountsapp/lib/Settings
mirrored_repositories/myaccountsapp/lib/Settings/Theme/Theme.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; // Basic theme sample to use for application ThemeData themeData = ThemeData( primaryColor: AppConstants.appBgColor, primaryColorDark: AppConstants.appBorderGreyColor, accentColor: AppConstants.appDarkGreenColor, fontFamily: 'Helvetica', textTheme: TextTheme( headline6: TextStyle( color: AppConstants.appDarkGreenColor, fontWeight: FontWeight.bold, ), headline5: TextStyle( color: AppConstants.appDarkGreenColor, fontWeight: FontWeight.bold, ), headline4: TextStyle( color: AppConstants.appDarkGreenColor, fontWeight: FontWeight.bold, ),headline3: TextStyle( color: AppConstants.appDarkGreenColor, fontWeight: FontWeight.bold, ), subtitle1: TextStyle( fontWeight: FontWeight.bold, ), caption: TextStyle( fontWeight: FontWeight.bold, color: AppConstants.appDarkGreenColor, ), ), );
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Widgets/AccountInfoWidget.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:my_accounts/Models/AccountInfo.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; // Shows the account info for Account tab in home view class AccountInfoWidget extends StatefulWidget { // AccountInfo object should be passed to show the widget dynamically final AccountInfo accountInfo; // accountInfo as a names parameter AccountInfoWidget({this.accountInfo}); _AccountInfoWidgetState createState() => _AccountInfoWidgetState(); } class _AccountInfoWidgetState extends State<AccountInfoWidget> { AppConstants constants = AppConstants(); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.fromLTRB(constants.edgeDistance*0.2, constants.topGap, constants.edgeDistance*0.2, constants.topGap), child: Container( width: constants.screenWidth, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(8)), color: Colors.white, boxShadow: [ BoxShadow( color: const Color(0x29000000), offset: Offset(0, 0), blurRadius: 10, ), ], ), padding: EdgeInsets.fromLTRB(constants.edgeDistance, constants.topGap, constants.edgeDistance, constants.topGap), child: Column( children: [ Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( widget.accountInfo.card.cardNumber, textAlign: TextAlign.center, style: TextStyle( color: AppConstants.appDarkGreenColor, fontSize: 16, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w800, ), ), Text( "Card Valid Through", style: TextStyle( color: AppConstants.appDarkGreenColor, fontSize: 14, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w300, ), ), ], ), ), Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( padding: EdgeInsets.fromLTRB(0, constants.topGap * 0.5, 0, 0), child: Text( widget.accountInfo.address, style: TextStyle( color: AppConstants.appDarkGreenColor, fontSize: 14, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w400, ), ), ), Container( child: Text( widget.accountInfo.card.validityDate, style: TextStyle( color: AppConstants.appDarkGreenColor, fontSize: 14, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w800, ), ), ), ], ), ), Container( padding: EdgeInsets.fromLTRB(0, constants.topGap, 0, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( child: Row( children: [ Text( widget.accountInfo.card.balance, style: TextStyle( color: AppConstants.appGreenColor, fontSize: 20, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w700, ), ), Text( widget.accountInfo.card.currency, style: TextStyle( color: AppConstants.appGreenColor, fontSize: 12, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w700, ), ), ], ), ), Flexible( child: Text( widget.accountInfo.accountType, textAlign: TextAlign.end, style: TextStyle( color: AppConstants.appGreenColor, fontSize: 14, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w600, ), ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Widgets/ActionRowWidget.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; // Action row widget makes a dynamic row for user actions or events to perform on his account class ActionRowWidget extends StatefulWidget { // It takes an icon final IconData icon; // It takes a text to show on the action final String actionText; ActionRowWidget({this.icon, this.actionText}); _ActionRowWidgetState createState() => _ActionRowWidgetState(); } class _ActionRowWidgetState extends State<ActionRowWidget> { double imageSize; AppConstants constants = AppConstants(); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.fromLTRB(constants.edgeDistance*0.2, constants.topGap*0.2, constants.edgeDistance*0.2, constants.topGap), child: Container( width: constants.screenWidth, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(8)), color: Colors.white, boxShadow: [ BoxShadow( color: const Color(0x29000000), offset: Offset(0, 0), blurRadius: 10, ), ], ), padding: EdgeInsets.fromLTRB(constants.edgeDistance*0.5, constants.topGap, constants.edgeDistance, constants.topGap), child: Column( children: [ Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(widget.icon, color: AppConstants.appGreenColor,), Expanded( child: Padding( padding: EdgeInsets.only(left: 10), child: Text( widget.actionText, textAlign: TextAlign.left, style: TextStyle( color: AppConstants.appDarkGreenColor, fontSize: 16, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w600, ), ), ), ), Icon(Icons.arrow_forward_ios_rounded, size: 13, color: AppConstants.appBorderGreyColor,), ], ), ), ], ), ), ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Widgets/CardWidget.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:my_accounts/Models/CardInfo.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; // CardWidget is a dynamic widget, it requires a CardInfo model object class CardWidget extends StatefulWidget { // Takes the CardInfo model object final CardInfo cardData; // Takes the color object for card color final Color cardColor; // Named parameters CardWidget({this.cardData, this.cardColor}); _CardWidgetState createState() => _CardWidgetState(); } class _CardWidgetState extends State<CardWidget> { double imageSize; AppConstants constants = AppConstants(); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.fromLTRB(constants.edgeDistance*0.2, constants.topGap, constants.edgeDistance*0.2, constants.topGap), child: Container( width: constants.screenWidth, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(8)), color: widget.cardColor, boxShadow: [ BoxShadow( color: const Color(0x29000000), offset: Offset(0, 0), blurRadius: 10, ), ], ), padding: EdgeInsets.fromLTRB(constants.edgeDistance*.5, constants.topGap*.5, constants.edgeDistance*.5, constants.topGap), child: Column( children: [ Container( width: constants.screenWidth, child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( child: Text( "Current Account", textAlign: TextAlign.end, style: TextStyle( color: Colors.white, fontSize: 20, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w400, ), ), ), Text( widget.cardData.cardNumber, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: 20, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w800, ), ), ], ), ), Container( padding: EdgeInsets.only(top: constants.fieldGap*4), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( padding: EdgeInsets.fromLTRB(0, constants.topGap * 0.5, 0, 0), child: Text( "Balance", style: TextStyle( color: Colors.white, fontSize: 16, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w400, ), ), ), Text( "Valid Through", style: TextStyle( color: Colors.white, fontSize: 16, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w300, ), ), ], ), ), Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( child: Row( children: [ Text( widget.cardData.balance, style: TextStyle( color: Colors.white, fontSize: 20, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w700, ), ), Text( widget.cardData.currency, style: TextStyle( color: Colors.white, fontSize: 12, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w700, ), ), ], ), ), Container( child: Text( widget.cardData.validityDate, style: TextStyle( color: Colors.white, fontSize: 14, fontFamily: AppConstants.fontTitillium, fontWeight: FontWeight.w800, ), ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Models/CardInfo.dart
// Model for Credit/Debit card information class CardInfo { CardInfo({ this.id, this.cardNumber, this.accountType, this.validityDate, this.balance, this.currency, }); int id; String cardNumber; String accountType; String validityDate; String balance; String currency; }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Models/AccountInfo.dart
import 'package:my_accounts/Models/CardInfo.dart'; // Model for user account information class AccountInfo { AccountInfo({ this.id, this.card, this.address, this.accountType, this.currency, }); int id; CardInfo card; // Card instance for the account String address; // Al Nahda Branch - Dubai, UAE String accountType; // Saving Account String currency; //IQD }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Manager/AppDrawer.dart
import 'package:flutter/material.dart'; import 'package:my_accounts/Screens/HomeView.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; import 'package:my_accounts/Settings/ScreenManager.dart'; // The app drawer to show side menu, currently it has only home view item in it // We can add other later according to the requirements class AppDrawer extends StatelessWidget { @override Widget build(BuildContext context) { return Drawer( child: ListView( padding: EdgeInsets.zero, children: <Widget>[ _createHeader(), Divider(), // Home drawer item created with onTap event to take user to home view _createDrawerItem( icon: Icons.home, text: 'Home', onTap: () => ScreenManager.gotoScreenByRouteName(context, HomeView.routeName, data: null)), Divider(), ], ), ); } Widget _createHeader() { // Header section of the drawer return DrawerHeader( margin: EdgeInsets.zero, padding: EdgeInsets.zero, decoration: BoxDecoration(color: AppConstants.appDarkGreenColor), child: Stack(children: <Widget>[ Positioned( // Application name bottom: 12.0, left: 16.0, child: Text(AppConstants.appName, style: TextStyle(color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.w500))), ])); } // Widget for creating drawer items connected to views Widget _createDrawerItem({IconData icon, String text, GestureTapCallback onTap}) { return ListTile( title: Row( children: <Widget>[ Icon(icon, color: AppConstants.appDarkGreenColor), Padding( padding: EdgeInsets.only(left: 8.0), child: Text(text), ) ], ), onTap: onTap, ); } }
0
mirrored_repositories/myaccountsapp/lib
mirrored_repositories/myaccountsapp/lib/Manager/TabBarManager.dart
import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:my_accounts/Screens/AccountsView.dart'; import 'package:my_accounts/Screens/CardsView.dart'; import 'package:my_accounts/Settings/AppConstants.dart'; // This tab bar is in screen tab bar to show different views as tabs class TabBarManager extends StatelessWidget { final TabController _controller; TabBarManager(this._controller); @override Widget build(BuildContext context) { return new ListView( children: <Widget>[ new Container( decoration: new BoxDecoration(color: AppConstants.appBgColor), child: new TabBar( indicator: UnderlineTabIndicator( borderSide: BorderSide(width: 2.5, color: AppConstants.appLightGreenColor), insets: EdgeInsets.symmetric(horizontal:60.0) ), labelColor: AppConstants.appLightGreenColor, unselectedLabelColor: AppConstants.appDarkGreenColor, controller: _controller, tabs: [ // Names of the tabs new Tab( child: Text(AppConstants.sAccounts, style: TextStyle( fontWeight: FontWeight.w800, fontSize: 16),), ), new Tab( child: Text(AppConstants.sCards, style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),), ), ], ), ), new Container( height: AppConstants.shared.screenHeight, child: new TabBarView( controller: _controller, children: <Widget>[ // Views of the tabs AccountsView(), CardsView(), ], ), ), ], ); } }
0
mirrored_repositories/myaccountsapp
mirrored_repositories/myaccountsapp/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:my_accounts/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0