mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
Reduce code duplication by introducing an OnBoardingButton
This commit is contained in:
@ -77,19 +77,55 @@ class OnBoardingGitUrlState extends State<OnBoardingGitUrl> {
|
|||||||
child: inputForm,
|
child: inputForm,
|
||||||
),
|
),
|
||||||
SizedBox(height: 8.0),
|
SizedBox(height: 8.0),
|
||||||
SizedBox(
|
OnBoardingButton(
|
||||||
width: double.infinity,
|
text: "Next",
|
||||||
child: RaisedButton(
|
|
||||||
child: Text(
|
|
||||||
"Next",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.button,
|
|
||||||
),
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
onPressed: formSubmitted,
|
onPressed: formSubmitted,
|
||||||
),
|
),
|
||||||
)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OnBoardingButton extends StatelessWidget {
|
||||||
|
final Function onPressed;
|
||||||
|
final String text;
|
||||||
|
final String iconUrl;
|
||||||
|
|
||||||
|
OnBoardingButton({
|
||||||
|
@required this.text,
|
||||||
|
@required this.onPressed,
|
||||||
|
this.iconUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (iconUrl == null) {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: RaisedButton(
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.button,
|
||||||
|
),
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: RaisedButton.icon(
|
||||||
|
label: Text(
|
||||||
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.button,
|
||||||
|
),
|
||||||
|
icon: Image.asset(iconUrl, width: 32, height: 32),
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -336,20 +336,9 @@ class OnBoardingCreateRepo extends StatelessWidget {
|
|||||||
style: Theme.of(context).textTheme.headline,
|
style: Theme.of(context).textTheme.headline,
|
||||||
),
|
),
|
||||||
SizedBox(height: 16.0),
|
SizedBox(height: 16.0),
|
||||||
SizedBox(
|
OnBoardingButton(
|
||||||
width: double.infinity,
|
text: "GitHub",
|
||||||
child: RaisedButton.icon(
|
iconUrl: 'assets/icon/github-icon.png',
|
||||||
label: Text(
|
|
||||||
"GitHub",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.button,
|
|
||||||
),
|
|
||||||
icon: Image.asset(
|
|
||||||
'assets/icon/github-icon.png',
|
|
||||||
width: 32,
|
|
||||||
height: 32,
|
|
||||||
),
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
try {
|
try {
|
||||||
await launch("https://github.com/new");
|
await launch("https://github.com/new");
|
||||||
@ -361,22 +350,10 @@ class OnBoardingCreateRepo extends StatelessWidget {
|
|||||||
onDone();
|
onDone();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
SizedBox(height: 8.0),
|
SizedBox(height: 8.0),
|
||||||
SizedBox(
|
OnBoardingButton(
|
||||||
width: double.infinity,
|
text: "GitLab",
|
||||||
child: RaisedButton.icon(
|
iconUrl: 'assets/icon/gitlab-icon.png',
|
||||||
label: Text(
|
|
||||||
"GitLab",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.button,
|
|
||||||
),
|
|
||||||
icon: Image.asset(
|
|
||||||
'assets/icon/gitlab-icon.png',
|
|
||||||
width: 32,
|
|
||||||
height: 32,
|
|
||||||
),
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
try {
|
try {
|
||||||
await launch("https://gitlab.com/projects/new");
|
await launch("https://gitlab.com/projects/new");
|
||||||
@ -388,7 +365,6 @@ class OnBoardingCreateRepo extends StatelessWidget {
|
|||||||
onDone();
|
onDone();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
Reference in New Issue
Block a user