mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
GitHostSetup: Reduce code duplication
Make the ErrorPage into its own widget, instead of duplicating the code.
This commit is contained in:
@ -3,6 +3,7 @@ import 'package:journal/apis/git.dart';
|
|||||||
import 'package:journal/apis/githost_factory.dart';
|
import 'package:journal/apis/githost_factory.dart';
|
||||||
import 'package:journal/settings.dart';
|
import 'package:journal/settings.dart';
|
||||||
|
|
||||||
|
import 'githostsetup_error.dart';
|
||||||
import 'githostsetup_loading.dart';
|
import 'githostsetup_loading.dart';
|
||||||
|
|
||||||
class GitHostSetupAutoConfigure extends StatefulWidget {
|
class GitHostSetupAutoConfigure extends StatefulWidget {
|
||||||
@ -76,29 +77,6 @@ class GitHostSetupAutoConfigureState extends State<GitHostSetupAutoConfigure> {
|
|||||||
return GitHostSetupLoadingPage("Configuring ...");
|
return GitHostSetupLoadingPage("Configuring ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var children = <Widget>[
|
return GitHostSetupErrorPage(errorMessage);
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
'Failed',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.display1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
this.errorMessage,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.display1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: children,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'githostsetup_error.dart';
|
||||||
import 'githostsetup_loading.dart';
|
import 'githostsetup_loading.dart';
|
||||||
|
|
||||||
class GitHostSetupGitClone extends StatelessWidget {
|
class GitHostSetupGitClone extends StatelessWidget {
|
||||||
@ -15,29 +16,6 @@ class GitHostSetupGitClone extends StatelessWidget {
|
|||||||
return GitHostSetupLoadingPage("Cloning ...");
|
return GitHostSetupLoadingPage("Cloning ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var children = <Widget>[
|
return GitHostSetupErrorPage(errorMessage);
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
'Failed',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.display1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
this.errorMessage,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.display1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: children,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
lib/screens/githostsetup_error.dart
Normal file
35
lib/screens/githostsetup_error.dart
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class GitHostSetupErrorPage extends StatelessWidget {
|
||||||
|
final String errorMessage;
|
||||||
|
|
||||||
|
GitHostSetupErrorPage(this.errorMessage);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var children = <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
'Failed',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.display1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
errorMessage,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.display1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: children,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user