mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 01:45:55 +08:00
Settings: Add 'GitAuthor' and 'Git Author Email'
These are just dummy values for now and cannot be actually changed.
This commit is contained in:
@ -6,6 +6,7 @@ import 'package:journal/state_container.dart';
|
||||
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:firebase_analytics/observer.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class JournalApp extends StatelessWidget {
|
||||
static FirebaseAnalytics analytics = FirebaseAnalytics();
|
||||
@ -18,6 +19,8 @@ class JournalApp extends StatelessWidget {
|
||||
return inDebugMode;
|
||||
}
|
||||
|
||||
static SharedPreferences preferences;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var stateContainer = StateContainer.of(context);
|
||||
|
@ -31,6 +31,8 @@ void main() async {
|
||||
|
||||
Future runJournalApp() async {
|
||||
var pref = await SharedPreferences.getInstance();
|
||||
JournalApp.preferences = pref;
|
||||
|
||||
var localGitRepoConfigured = pref.getBool("localGitRepoConfigured") ?? false;
|
||||
var remoteGitRepoConfigured =
|
||||
pref.getBool("remoteGitRepoConfigured") ?? false;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import 'package:journal/app.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -14,44 +16,84 @@ class SettingsScreen extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
body: SettingsForms(),
|
||||
body: SettingsList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsForms extends StatefulWidget {
|
||||
class SettingsList extends StatefulWidget {
|
||||
@override
|
||||
SettingsFormsState createState() {
|
||||
return new SettingsFormsState();
|
||||
SettingsListState createState() {
|
||||
return new SettingsListState();
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsFormsState extends State<SettingsForms> {
|
||||
class SettingsListState extends State<SettingsList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var gitAuthorForm = Form(
|
||||
child: TextFormField(
|
||||
style: Theme.of(context).textTheme.title,
|
||||
decoration: const InputDecoration(
|
||||
icon: Icon(Icons.person),
|
||||
hintText: 'Who should author the changes?',
|
||||
labelText: 'Git Author',
|
||||
),
|
||||
validator: (String value) {
|
||||
value = value.trim();
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter a name';
|
||||
}
|
||||
},
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (String _) {},
|
||||
initialValue:
|
||||
JournalApp.preferences.getString("gitAuthor") ?? "GitJournal",
|
||||
),
|
||||
);
|
||||
|
||||
var gitAuthorEmailForm = Form(
|
||||
child: TextFormField(
|
||||
style: Theme.of(context).textTheme.title,
|
||||
decoration: const InputDecoration(
|
||||
icon: Icon(Icons.email),
|
||||
hintText: 'Who should author the changes?',
|
||||
labelText: 'Git Author Email',
|
||||
),
|
||||
validator: (String value) {
|
||||
value = value.trim();
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter an email';
|
||||
}
|
||||
},
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (String _) {},
|
||||
initialValue: JournalApp.preferences.getString("gitAuthorEmail") ??
|
||||
"app@gitjournal.io",
|
||||
),
|
||||
);
|
||||
|
||||
var listView = ListView(children: <Widget>[
|
||||
ListTile(title: gitAuthorForm),
|
||||
ListTile(title: gitAuthorEmailForm),
|
||||
VersionNumberTile(),
|
||||
]);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Form(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
VersionNumberButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: listView,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VersionNumberButton extends StatefulWidget {
|
||||
class VersionNumberTile extends StatefulWidget {
|
||||
@override
|
||||
VersionNumberButtonState createState() {
|
||||
return new VersionNumberButtonState();
|
||||
VersionNumberTileState createState() {
|
||||
return new VersionNumberTileState();
|
||||
}
|
||||
}
|
||||
|
||||
class VersionNumberButtonState extends State<VersionNumberButton> {
|
||||
class VersionNumberTileState extends State<VersionNumberTile> {
|
||||
PackageInfo packageInfo;
|
||||
|
||||
@override
|
||||
@ -77,16 +119,13 @@ class VersionNumberButtonState extends State<VersionNumberButton> {
|
||||
packageInfo.buildNumber;
|
||||
}
|
||||
|
||||
return FlatButton(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
return ListTile(
|
||||
title: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.subhead,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
onPressed: () {},
|
||||
onTap: () {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user