mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
GitHostSetup: Move the button to its own file
This commit is contained in:
58
lib/screens/githostsetup_button.dart
Normal file
58
lib/screens/githostsetup_button.dart
Normal file
@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:journal/analytics.dart';
|
||||
|
||||
class GitHostSetupButton extends StatelessWidget {
|
||||
final Function onPressed;
|
||||
final String text;
|
||||
final String iconUrl;
|
||||
|
||||
GitHostSetupButton({
|
||||
@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: this._onPressedWithAnalytics,
|
||||
),
|
||||
);
|
||||
} 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: this._onPressedWithAnalytics,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _onPressedWithAnalytics() {
|
||||
print("githostsetup_button_click " + text);
|
||||
getAnalytics().logEvent(
|
||||
name: "githostsetup_button_click",
|
||||
parameters: <String, dynamic>{
|
||||
'text': text,
|
||||
'icon_url': iconUrl == null ? "" : iconUrl,
|
||||
},
|
||||
);
|
||||
onPressed();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:journal/analytics.dart';
|
||||
|
||||
import 'githostsetup_button.dart';
|
||||
|
||||
class GitCloneUrlPage extends StatefulWidget {
|
||||
final Function doneFunction;
|
||||
@ -87,59 +88,3 @@ class GitCloneUrlPageState extends State<GitCloneUrlPage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GitHostSetupButton extends StatelessWidget {
|
||||
final Function onPressed;
|
||||
final String text;
|
||||
final String iconUrl;
|
||||
|
||||
GitHostSetupButton({
|
||||
@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: this._onPressedWithAnalytics,
|
||||
),
|
||||
);
|
||||
} 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: this._onPressedWithAnalytics,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _onPressedWithAnalytics() {
|
||||
print("githostsetup_button_click " + text);
|
||||
getAnalytics().logEvent(
|
||||
name: "githostsetup_button_click",
|
||||
parameters: <String, dynamic>{
|
||||
'text': text,
|
||||
'icon_url': iconUrl == null ? "" : iconUrl,
|
||||
},
|
||||
);
|
||||
onPressed();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'githostsetup_autoconfigure.dart';
|
||||
import 'githostsetup_button.dart';
|
||||
import 'githostsetup_clone.dart';
|
||||
import 'githostsetup_clone_url.dart';
|
||||
|
||||
|
Reference in New Issue
Block a user