mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
OnBoarding: Simplify the code
This commit is contained in:
@ -62,18 +62,14 @@ class OnBoardingGitUrl extends StatefulWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
OnBoardingGitUrlState createState() {
|
OnBoardingGitUrlState createState() {
|
||||||
return new OnBoardingGitUrlState(doneFunction: this.doneFunction);
|
return new OnBoardingGitUrlState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnBoardingGitUrlState extends State<OnBoardingGitUrl> {
|
class OnBoardingGitUrlState extends State<OnBoardingGitUrl> {
|
||||||
final Function doneFunction;
|
|
||||||
|
|
||||||
final GlobalKey<FormFieldState<String>> sshUrlKey =
|
final GlobalKey<FormFieldState<String>> sshUrlKey =
|
||||||
GlobalKey<FormFieldState<String>>();
|
GlobalKey<FormFieldState<String>>();
|
||||||
|
|
||||||
OnBoardingGitUrlState({@required this.doneFunction});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
@ -84,7 +80,7 @@ class OnBoardingGitUrlState extends State<OnBoardingGitUrl> {
|
|||||||
_formKey.currentState.save();
|
_formKey.currentState.save();
|
||||||
|
|
||||||
var url = sshUrlKey.currentState.value;
|
var url = sshUrlKey.currentState.value;
|
||||||
this.doneFunction(url);
|
this.widget.doneFunction(url);
|
||||||
inputFormFocus.unfocus();
|
inputFormFocus.unfocus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -144,17 +140,13 @@ class OnBoardingSshKey extends StatefulWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
OnBoardingSshKeyState createState() {
|
OnBoardingSshKeyState createState() {
|
||||||
return new OnBoardingSshKeyState(doneFunction: this.doneFunction);
|
return new OnBoardingSshKeyState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnBoardingSshKeyState extends State<OnBoardingSshKey> {
|
class OnBoardingSshKeyState extends State<OnBoardingSshKey> {
|
||||||
final Function doneFunction;
|
|
||||||
|
|
||||||
String publicKey = "Generating ...";
|
String publicKey = "Generating ...";
|
||||||
|
|
||||||
OnBoardingSshKeyState({@required this.doneFunction});
|
|
||||||
|
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
generateSSHKeys(comment: "GitJournal").then((String _publicKey) {
|
generateSSHKeys(comment: "GitJournal").then((String _publicKey) {
|
||||||
@ -184,7 +176,7 @@ class OnBoardingSshKeyState extends State<OnBoardingSshKey> {
|
|||||||
),
|
),
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
child: Text("Start Clone"),
|
child: Text("Start Clone"),
|
||||||
onPressed: this.doneFunction,
|
onPressed: this.widget.doneFunction,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -198,16 +190,13 @@ class OnBoardingGitClone extends StatefulWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
OnBoardingGitCloneState createState() {
|
OnBoardingGitCloneState createState() {
|
||||||
return new OnBoardingGitCloneState(doneFunction: this.doneFunction);
|
return new OnBoardingGitCloneState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnBoardingGitCloneState extends State<OnBoardingGitClone> {
|
class OnBoardingGitCloneState extends State<OnBoardingGitClone> {
|
||||||
final Function doneFunction;
|
|
||||||
String errorMessage = "";
|
String errorMessage = "";
|
||||||
|
|
||||||
OnBoardingGitCloneState({@required this.doneFunction});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -224,7 +213,7 @@ class OnBoardingGitCloneState extends State<OnBoardingGitClone> {
|
|||||||
errorMessage = error;
|
errorMessage = error;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
doneFunction();
|
this.widget.doneFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user