mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +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/firebase_analytics.dart';
|
||||||
import 'package:firebase_analytics/observer.dart';
|
import 'package:firebase_analytics/observer.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class JournalApp extends StatelessWidget {
|
class JournalApp extends StatelessWidget {
|
||||||
static FirebaseAnalytics analytics = FirebaseAnalytics();
|
static FirebaseAnalytics analytics = FirebaseAnalytics();
|
||||||
@ -18,6 +19,8 @@ class JournalApp extends StatelessWidget {
|
|||||||
return inDebugMode;
|
return inDebugMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SharedPreferences preferences;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var stateContainer = StateContainer.of(context);
|
var stateContainer = StateContainer.of(context);
|
||||||
|
@ -31,6 +31,8 @@ void main() async {
|
|||||||
|
|
||||||
Future runJournalApp() async {
|
Future runJournalApp() async {
|
||||||
var pref = await SharedPreferences.getInstance();
|
var pref = await SharedPreferences.getInstance();
|
||||||
|
JournalApp.preferences = pref;
|
||||||
|
|
||||||
var localGitRepoConfigured = pref.getBool("localGitRepoConfigured") ?? false;
|
var localGitRepoConfigured = pref.getBool("localGitRepoConfigured") ?? false;
|
||||||
var remoteGitRepoConfigured =
|
var remoteGitRepoConfigured =
|
||||||
pref.getBool("remoteGitRepoConfigured") ?? false;
|
pref.getBool("remoteGitRepoConfigured") ?? false;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
|
import 'package:journal/app.dart';
|
||||||
|
|
||||||
class SettingsScreen extends StatelessWidget {
|
class SettingsScreen extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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
|
@override
|
||||||
SettingsFormsState createState() {
|
SettingsListState createState() {
|
||||||
return new SettingsFormsState();
|
return new SettingsListState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingsFormsState extends State<SettingsForms> {
|
class SettingsListState extends State<SettingsList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Form(
|
child: listView,
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
VersionNumberButton(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VersionNumberButton extends StatefulWidget {
|
class VersionNumberTile extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
VersionNumberButtonState createState() {
|
VersionNumberTileState createState() {
|
||||||
return new VersionNumberButtonState();
|
return new VersionNumberTileState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VersionNumberButtonState extends State<VersionNumberButton> {
|
class VersionNumberTileState extends State<VersionNumberTile> {
|
||||||
PackageInfo packageInfo;
|
PackageInfo packageInfo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -77,16 +119,13 @@ class VersionNumberButtonState extends State<VersionNumberButton> {
|
|||||||
packageInfo.buildNumber;
|
packageInfo.buildNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatButton(
|
return ListTile(
|
||||||
child: SizedBox(
|
title: Text(
|
||||||
width: double.infinity,
|
text,
|
||||||
child: Text(
|
style: Theme.of(context).textTheme.subhead,
|
||||||
text,
|
textAlign: TextAlign.left,
|
||||||
style: Theme.of(context).textTheme.subhead,
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onTap: () {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user