mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 08:36:50 +08:00
Monarch: Add most of the host setup screens
I've also renamed all the host setup screens with "Page" in the end. This way it's more obvious.
This commit is contained in:
@ -149,7 +149,7 @@ class _GitRemoteSettingsScreenState extends State<GitRemoteSettingsScreen> {
|
|||||||
void _customSshKeys() {
|
void _customSshKeys() {
|
||||||
var route = MaterialPageRoute(
|
var route = MaterialPageRoute(
|
||||||
builder: (context) => Scaffold(
|
builder: (context) => Scaffold(
|
||||||
body: GitHostUserProvidedKeys(
|
body: GitHostUserProvidedKeysPage(
|
||||||
doneFunction: _updateKeys,
|
doneFunction: _updateKeys,
|
||||||
saveText: tr("setup.sshKey.save"),
|
saveText: tr("setup.sshKey.save"),
|
||||||
),
|
),
|
||||||
|
@ -14,22 +14,23 @@ import 'button.dart';
|
|||||||
import 'error.dart';
|
import 'error.dart';
|
||||||
import 'loading.dart';
|
import 'loading.dart';
|
||||||
|
|
||||||
class GitHostSetupAutoConfigure extends StatefulWidget {
|
class GitHostSetupAutoConfigurePage extends StatefulWidget {
|
||||||
final GitHostType gitHostType;
|
final GitHostType gitHostType;
|
||||||
final Func2<GitHost?, UserInfo?, void> onDone;
|
final Func2<GitHost?, UserInfo?, void> onDone;
|
||||||
|
|
||||||
GitHostSetupAutoConfigure({
|
GitHostSetupAutoConfigurePage({
|
||||||
required this.gitHostType,
|
required this.gitHostType,
|
||||||
required this.onDone,
|
required this.onDone,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
GitHostSetupAutoConfigureState createState() {
|
GitHostSetupAutoConfigurePageState createState() {
|
||||||
return GitHostSetupAutoConfigureState();
|
return GitHostSetupAutoConfigurePageState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GitHostSetupAutoConfigureState extends State<GitHostSetupAutoConfigure> {
|
class GitHostSetupAutoConfigurePageState
|
||||||
|
extends State<GitHostSetupAutoConfigurePage> {
|
||||||
GitHost? gitHost;
|
GitHost? gitHost;
|
||||||
String errorMessage = "";
|
String errorMessage = "";
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
|
|
||||||
if (pos == 2) {
|
if (pos == 2) {
|
||||||
if (_pageChoice[0] == PageChoice0.CustomProvider) {
|
if (_pageChoice[0] == PageChoice0.CustomProvider) {
|
||||||
return GitHostSetupKeyChoice(
|
return GitHostSetupKeyChoicePage(
|
||||||
onGenerateKeys: () {
|
onGenerateKeys: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_keyGenerationChoice = KeyGenerationChoice.AutoGenerated;
|
_keyGenerationChoice = KeyGenerationChoice.AutoGenerated;
|
||||||
@ -175,7 +175,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
initialValue: _gitCloneUrl,
|
initialValue: _gitCloneUrl,
|
||||||
);
|
);
|
||||||
} else if (_pageChoice[1] == PageChoice1.Auto) {
|
} else if (_pageChoice[1] == PageChoice1.Auto) {
|
||||||
return GitHostSetupAutoConfigure(
|
return GitHostSetupAutoConfigurePage(
|
||||||
gitHostType: _gitHostType,
|
gitHostType: _gitHostType,
|
||||||
onDone: (GitHost? gitHost, UserInfo? userInfo) {
|
onDone: (GitHost? gitHost, UserInfo? userInfo) {
|
||||||
if (gitHost == null) {
|
if (gitHost == null) {
|
||||||
@ -200,7 +200,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
if (_pageChoice[0] == PageChoice0.CustomProvider) {
|
if (_pageChoice[0] == PageChoice0.CustomProvider) {
|
||||||
assert(_keyGenerationChoice != KeyGenerationChoice.Unknown);
|
assert(_keyGenerationChoice != KeyGenerationChoice.Unknown);
|
||||||
if (_keyGenerationChoice == KeyGenerationChoice.AutoGenerated) {
|
if (_keyGenerationChoice == KeyGenerationChoice.AutoGenerated) {
|
||||||
return GitHostSetupSshKeyUnknownProvider(
|
return GitHostSetupSshKeyUnknownProviderPage(
|
||||||
doneFunction: () {
|
doneFunction: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_pageCount = pos + 2;
|
_pageCount = pos + 2;
|
||||||
@ -220,7 +220,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
copyKeyFunction: _copyKeyToClipboard,
|
copyKeyFunction: _copyKeyToClipboard,
|
||||||
);
|
);
|
||||||
} else if (_keyGenerationChoice == KeyGenerationChoice.UserProvided) {
|
} else if (_keyGenerationChoice == KeyGenerationChoice.UserProvided) {
|
||||||
return GitHostUserProvidedKeys(
|
return GitHostUserProvidedKeysPage(
|
||||||
doneFunction:
|
doneFunction:
|
||||||
(String publicKey, String privateKey, String password) async {
|
(String publicKey, String privateKey, String password) async {
|
||||||
var settings = Provider.of<Settings>(context, listen: false);
|
var settings = Provider.of<Settings>(context, listen: false);
|
||||||
@ -243,7 +243,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_pageChoice[1] == PageChoice1.Manual) {
|
if (_pageChoice[1] == PageChoice1.Manual) {
|
||||||
return GitHostSetupKeyChoice(
|
return GitHostSetupKeyChoicePage(
|
||||||
onGenerateKeys: () {
|
onGenerateKeys: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_keyGenerationChoice = KeyGenerationChoice.AutoGenerated;
|
_keyGenerationChoice = KeyGenerationChoice.AutoGenerated;
|
||||||
@ -293,7 +293,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
if (_pageChoice[1] == PageChoice1.Manual) {
|
if (_pageChoice[1] == PageChoice1.Manual) {
|
||||||
assert(_keyGenerationChoice != KeyGenerationChoice.Unknown);
|
assert(_keyGenerationChoice != KeyGenerationChoice.Unknown);
|
||||||
if (_keyGenerationChoice == KeyGenerationChoice.AutoGenerated) {
|
if (_keyGenerationChoice == KeyGenerationChoice.AutoGenerated) {
|
||||||
return GitHostSetupSshKeyKnownProvider(
|
return GitHostSetupSshKeyKnownProviderPage(
|
||||||
doneFunction: () {
|
doneFunction: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_pageCount = 6;
|
_pageCount = 6;
|
||||||
@ -315,7 +315,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
|||||||
openDeployKeyPage: _launchDeployKeyPage,
|
openDeployKeyPage: _launchDeployKeyPage,
|
||||||
);
|
);
|
||||||
} else if (_keyGenerationChoice == KeyGenerationChoice.UserProvided) {
|
} else if (_keyGenerationChoice == KeyGenerationChoice.UserProvided) {
|
||||||
return GitHostUserProvidedKeys(
|
return GitHostUserProvidedKeysPage(
|
||||||
doneFunction: (publicKey, privateKey, password) async {
|
doneFunction: (publicKey, privateKey, password) async {
|
||||||
var settings = Provider.of<Settings>(context, listen: false);
|
var settings = Provider.of<Settings>(context, listen: false);
|
||||||
settings.sshPublicKey = publicKey;
|
settings.sshPublicKey = publicKey;
|
||||||
|
@ -4,36 +4,112 @@ import 'package:gitjournal/apis/githost_factory.dart';
|
|||||||
import 'package:gitjournal/setup/autoconfigure.dart';
|
import 'package:gitjournal/setup/autoconfigure.dart';
|
||||||
import 'package:gitjournal/setup/clone_url.dart';
|
import 'package:gitjournal/setup/clone_url.dart';
|
||||||
import 'package:gitjournal/setup/error.dart';
|
import 'package:gitjournal/setup/error.dart';
|
||||||
import 'package:gitjournal/setup/key_editors.dart';
|
|
||||||
import 'package:gitjournal/setup/loading.dart';
|
import 'package:gitjournal/setup/loading.dart';
|
||||||
|
import 'package:gitjournal/setup/screens.dart';
|
||||||
|
import 'package:gitjournal/setup/sshkey.dart';
|
||||||
|
|
||||||
Widget autoConfigure() {
|
Widget autoConfigureChoice() {
|
||||||
return Padding(
|
return Padding(
|
||||||
child: GitHostSetupAutoConfigure(
|
|
||||||
gitHostType: GitHostType.GitHub,
|
|
||||||
onDone: (host, userInfo) => null,
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostAutoConfigureChoicePage(
|
||||||
|
onDone: (_) {},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget cloneUrl() => GitCloneUrlPage(
|
Widget gitHostChoice() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostChoicePage(
|
||||||
|
onCustomGitHost: () {},
|
||||||
|
onKnownGitHost: (_) {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget autoConfigure() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostSetupAutoConfigurePage(
|
||||||
|
gitHostType: GitHostType.GitHub,
|
||||||
|
onDone: (host, userInfo) => null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget cloneUrl() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitCloneUrlPage(
|
||||||
initialValue: "foo?",
|
initialValue: "foo?",
|
||||||
doneFunction: (val) => null,
|
doneFunction: (val) => null,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
Widget keyEditors() => KeyEditor(
|
}
|
||||||
GlobalKey(),
|
|
||||||
TextEditingController(),
|
|
||||||
(val) => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
// FIXME: Create widgets for all the errors!
|
// FIXME: Create widgets for all the errors!
|
||||||
Widget loadingError() => GitHostSetupErrorPage(
|
Widget loadingError() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostSetupErrorPage(
|
||||||
"This is an error message",
|
"This is an error message",
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Create widgets for all the loading screen messages!
|
// FIXME: Create widgets for all the loading screen messages!
|
||||||
Widget loading() => GitHostSetupLoadingPage(
|
Widget loading() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostSetupLoadingPage(
|
||||||
"Loading Message",
|
"Loading Message",
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _publicKey =
|
||||||
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBJ9OSG+YIxqsZiXWisqJIqRStX5wjy9oMrT9gnB85jgR03RjMBWpxXAtrlreo7ljDqhs9g3zdXq/oxcPgzyS+mm33A4WTGGY0u4RbxY14q8V1p/CVu5sd39UYpwYsj0HLw== vishesh@Visheshs-MacBook-Pro.local";
|
||||||
|
|
||||||
|
Widget sshKeyKnownProviderPage() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostSetupSshKeyKnownProviderPage(
|
||||||
|
openDeployKeyPage: () {},
|
||||||
|
copyKeyFunction: (_) {},
|
||||||
|
publicKey: _publicKey,
|
||||||
|
regenerateFunction: () {},
|
||||||
|
doneFunction: () {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget sshKeyUnknownProviderPage() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostSetupSshKeyUnknownProviderPage(
|
||||||
|
publicKey: _publicKey,
|
||||||
|
regenerateFunction: () {},
|
||||||
|
doneFunction: () {},
|
||||||
|
copyKeyFunction: (_) {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget keyChoicePage() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostSetupKeyChoicePage(
|
||||||
|
onGenerateKeys: () {},
|
||||||
|
onUserProvidedKeys: () {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget keyUserProvidedKeysPage() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: GitHostUserProvidedKeysPage(
|
||||||
|
doneFunction: (_, __, ___) {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -7,7 +7,7 @@ import 'button.dart';
|
|||||||
import 'key_editors.dart';
|
import 'key_editors.dart';
|
||||||
import 'loading.dart';
|
import 'loading.dart';
|
||||||
|
|
||||||
class GitHostSetupSshKeyKnownProvider extends StatelessWidget {
|
class GitHostSetupSshKeyKnownProviderPage extends StatelessWidget {
|
||||||
final Func0<void> doneFunction;
|
final Func0<void> doneFunction;
|
||||||
final Func0<void> regenerateFunction;
|
final Func0<void> regenerateFunction;
|
||||||
final Func1<BuildContext, void> copyKeyFunction;
|
final Func1<BuildContext, void> copyKeyFunction;
|
||||||
@ -15,7 +15,7 @@ class GitHostSetupSshKeyKnownProvider extends StatelessWidget {
|
|||||||
|
|
||||||
final Func0<void> openDeployKeyPage;
|
final Func0<void> openDeployKeyPage;
|
||||||
|
|
||||||
GitHostSetupSshKeyKnownProvider({
|
GitHostSetupSshKeyKnownProviderPage({
|
||||||
required this.doneFunction,
|
required this.doneFunction,
|
||||||
required this.regenerateFunction,
|
required this.regenerateFunction,
|
||||||
required this.copyKeyFunction,
|
required this.copyKeyFunction,
|
||||||
@ -91,13 +91,13 @@ class GitHostSetupSshKeyKnownProvider extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GitHostSetupSshKeyUnknownProvider extends StatelessWidget {
|
class GitHostSetupSshKeyUnknownProviderPage extends StatelessWidget {
|
||||||
final Func0<void> doneFunction;
|
final Func0<void> doneFunction;
|
||||||
final Func0<void> regenerateFunction;
|
final Func0<void> regenerateFunction;
|
||||||
final Func1<BuildContext, void> copyKeyFunction;
|
final Func1<BuildContext, void> copyKeyFunction;
|
||||||
final String? publicKey;
|
final String? publicKey;
|
||||||
|
|
||||||
GitHostSetupSshKeyUnknownProvider({
|
GitHostSetupSshKeyUnknownProviderPage({
|
||||||
required this.doneFunction,
|
required this.doneFunction,
|
||||||
required this.regenerateFunction,
|
required this.regenerateFunction,
|
||||||
required this.copyKeyFunction,
|
required this.copyKeyFunction,
|
||||||
@ -167,11 +167,11 @@ class GitHostSetupSshKeyUnknownProvider extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GitHostSetupKeyChoice extends StatelessWidget {
|
class GitHostSetupKeyChoicePage extends StatelessWidget {
|
||||||
final Func0<void> onGenerateKeys;
|
final Func0<void> onGenerateKeys;
|
||||||
final Func0<void> onUserProvidedKeys;
|
final Func0<void> onUserProvidedKeys;
|
||||||
|
|
||||||
GitHostSetupKeyChoice({
|
GitHostSetupKeyChoicePage({
|
||||||
required this.onGenerateKeys,
|
required this.onGenerateKeys,
|
||||||
required this.onUserProvidedKeys,
|
required this.onUserProvidedKeys,
|
||||||
});
|
});
|
||||||
@ -203,22 +203,23 @@ class GitHostSetupKeyChoice extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GitHostUserProvidedKeys extends StatefulWidget {
|
class GitHostUserProvidedKeysPage extends StatefulWidget {
|
||||||
final Func3<String, String, String, void>
|
final Func3<String, String, String, void>
|
||||||
doneFunction; // public, private, password
|
doneFunction; // public, private, password
|
||||||
final String saveText;
|
final String saveText;
|
||||||
|
|
||||||
GitHostUserProvidedKeys({
|
GitHostUserProvidedKeysPage({
|
||||||
required this.doneFunction,
|
required this.doneFunction,
|
||||||
this.saveText = "",
|
this.saveText = "",
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_GitHostUserProvidedKeysState createState() =>
|
_GitHostUserProvidedKeysPageState createState() =>
|
||||||
_GitHostUserProvidedKeysState();
|
_GitHostUserProvidedKeysPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GitHostUserProvidedKeysState extends State<GitHostUserProvidedKeys> {
|
class _GitHostUserProvidedKeysPageState
|
||||||
|
extends State<GitHostUserProvidedKeysPage> {
|
||||||
late GlobalKey<FormState> _publicFormKey;
|
late GlobalKey<FormState> _publicFormKey;
|
||||||
late GlobalKey<FormState> _privateFormKey;
|
late GlobalKey<FormState> _privateFormKey;
|
||||||
late TextEditingController _publicKeyController;
|
late TextEditingController _publicKeyController;
|
||||||
|
Reference in New Issue
Block a user