wraps/finetune_starcoder2
Updated
•
3
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[33;1m")) ||
(_data[index].startsWith("[33;1m") &&
_data[index].contains("[0m"))
? Text(
(_data[index].contains("travis_fold:start:") &&
_data[index].contains("[0K[33;1m"))
? _data[index]
.split("[0K[33;1m")
.last
.split("[0m")
.first
.trim()
: _data[index]
.split("[33;1m")
.last
.split("[0m")
.first
.trim(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontFamily: 'Cousine',
fontSize: 10.0,
color: Color.fromRGBO(255, 255, 145, 1.0)),
)
: _data[index].startsWith("[32m+ [39m")
? RichText(
text: TextSpan(
text: '+ ',
style: TextStyle(
color: Colors.green,
fontFamily: "Cousine",
fontSize: 10.0),
children: [
TextSpan(
text: _data[index]
.split("[32m+ [39m")
.last
.split("[36m")
.first
.split("[1m")
.last
.replaceAll("[0m", "")
.trimLeft(),
style: TextStyle(
fontSize: 10.0,
color: Colors.white,
fontWeight: FontWeight.w500,
fontFamily: "Cousine",
)),
if (_data[index]
.split("[32m+ [39m")
.last
.contains("[36m") &&
_data[index]
.split("[32m+ [39m")
.last
.contains("[39m"))
TextSpan(
text: _data[index]
.split("[32m+ [39m")
.last
.split("[36m")
.last
.replaceAll("[39m", "")
.trimLeft(),
style: TextStyle(
fontSize: 10.0,
fontFamily: "Cousine",
color: Colors.lightBlueAccent))
]),
)
: Text(
_data[index].contains("[34m[1m")
? _data[index]
.split("[34m[1m")
.last
.split("[0m")
.first
.trimLeft()
: _data[index],
style: TextStyle(
color: _data[index].contains("[34m[1m")
? Colors.lightBlueAccent
: Colors.white,
fontSize: 10.0,
fontWeight: _data[index].contains("[34m[1m")
? 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 |