Files
GitJournal/lib/screens/githostsetup_sshkey.dart
Vishesh Handa 74d167e503 GitSetup SSH Keys: Show an explicit loading page
When the SSH Key is being generated, nothing can really be done. The
text can be read, but it cannot really be acted upon, and it's not super
clear that one is just supposed to wait.
2019-02-14 00:35:21 +01:00

112 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'githostsetup_button.dart';
import 'githostsetup_loading.dart';
class GitHostSetupSshKey extends StatelessWidget {
final Function doneFunction;
final Function copyKeyFunction;
final String publicKey;
final Function openDeployKeyPage;
final bool canOpenDeployKeyPage;
GitHostSetupSshKey({
@required this.doneFunction,
@required this.copyKeyFunction,
@required this.openDeployKeyPage,
@required this.publicKey,
@required this.canOpenDeployKeyPage,
});
@override
Widget build(BuildContext context) {
if (this.publicKey == null || this.publicKey.isEmpty) {
return GitHostSetupLoadingPage("Generating SSH Key ...");
}
Widget copyAndDepoyWidget;
Widget cloneButton;
if (this.publicKey.isEmpty) {
copyAndDepoyWidget = Container();
cloneButton = Container();
} else {
cloneButton = GitHostSetupButton(
text: "Clone Repo",
onPressed: this.doneFunction,
);
if (canOpenDeployKeyPage) {
copyAndDepoyWidget = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: RaisedButton(
child: Text(
"Copy Key",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.button,
),
color: Theme.of(context).primaryColor,
onPressed: copyKeyFunction,
),
),
SizedBox(width: 8.0),
Expanded(
child: RaisedButton(
child: Text(
"Open Deploy Key Webpage",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.button,
),
color: Theme.of(context).primaryColor,
onPressed: openDeployKeyPage,
),
),
],
);
} else {
copyAndDepoyWidget = GitHostSetupButton(
text: "Copy Key",
onPressed: this.copyKeyFunction,
);
}
}
var publicKeyWidget = SizedBox(
width: double.infinity,
height: 160.0,
child: Container(
color: Theme.of(context).buttonColor,
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Text(
publicKey,
textAlign: TextAlign.left,
maxLines: null,
style: Theme.of(context).textTheme.body1,
),
),
),
),
);
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Deploy Public Key',
style: Theme.of(context).textTheme.headline,
),
SizedBox(height: 16.0),
publicKeyWidget,
SizedBox(height: 8.0),
copyAndDepoyWidget,
cloneButton,
],
);
}
}