mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-18 03:10:28 +08:00
AppDrawer: Show repo list
This is just a first attempt and all the values are hardcoded. This needs lots more work.
This commit is contained in:
@ -17,7 +17,37 @@ import 'package:gitjournal/utils.dart';
|
|||||||
import 'package:gitjournal/utils/logger.dart';
|
import 'package:gitjournal/utils/logger.dart';
|
||||||
import 'package:gitjournal/widgets/app_drawer_header.dart';
|
import 'package:gitjournal/widgets/app_drawer_header.dart';
|
||||||
|
|
||||||
class AppDrawer extends StatelessWidget {
|
class AppDrawer extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_AppDrawerState createState() => _AppDrawerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppDrawerState extends State<AppDrawer> {
|
||||||
|
bool repoChooserVisible = false;
|
||||||
|
|
||||||
|
List<Widget> _buildRepoList() {
|
||||||
|
var divider = Row(children: <Widget>[const Expanded(child: Divider())]);
|
||||||
|
|
||||||
|
return [
|
||||||
|
_buildDrawerTile(
|
||||||
|
context,
|
||||||
|
icon: FontAwesomeIcons.book,
|
||||||
|
isFontAwesome: true,
|
||||||
|
title: 'journal',
|
||||||
|
onTap: () => _navTopLevel(context, '/login'),
|
||||||
|
selected: false,
|
||||||
|
),
|
||||||
|
_buildDrawerTile(
|
||||||
|
context,
|
||||||
|
icon: Icons.add,
|
||||||
|
title: 'Add Repository',
|
||||||
|
onTap: () => _navTopLevel(context, '/login'),
|
||||||
|
selected: false,
|
||||||
|
),
|
||||||
|
divider,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget setupGitButton;
|
Widget setupGitButton;
|
||||||
@ -50,7 +80,16 @@ class AppDrawer extends StatelessWidget {
|
|||||||
// Important: Remove any padding from the ListView.
|
// Important: Remove any padding from the ListView.
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
AppDrawerHeader(),
|
AppDrawerHeader(
|
||||||
|
showRepoList: repoChooserVisible,
|
||||||
|
repoListToggled: () {
|
||||||
|
setState(() {
|
||||||
|
repoChooserVisible = !repoChooserVisible;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// If they are multiple show the current one which a tick mark
|
||||||
|
if (repoChooserVisible) ..._buildRepoList(),
|
||||||
if (setupGitButton != null) ...[setupGitButton, divider],
|
if (setupGitButton != null) ...[setupGitButton, divider],
|
||||||
if (!appSettings.proMode)
|
if (!appSettings.proMode)
|
||||||
_buildDrawerTile(
|
_buildDrawerTile(
|
||||||
|
@ -1,85 +1,93 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:dynamic_theme/dynamic_theme.dart';
|
import 'package:dynamic_theme/dynamic_theme.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:function_types/function_types.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'package:gitjournal/app_settings.dart';
|
import 'package:gitjournal/app_settings.dart';
|
||||||
|
|
||||||
class AppDrawerHeader extends StatelessWidget {
|
class AppDrawerHeader extends StatelessWidget {
|
||||||
|
final Func0<void> repoListToggled;
|
||||||
|
final bool showRepoList;
|
||||||
|
|
||||||
|
AppDrawerHeader({
|
||||||
|
@required this.repoListToggled,
|
||||||
|
@required this.showRepoList,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var appSettings = Provider.of<AppSettings>(context);
|
var appSettings = Provider.of<AppSettings>(context);
|
||||||
|
|
||||||
var stack = Stack(
|
var top = Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Padding(
|
const DecoratedBox(
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: DecoratedBox(
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: AssetImage('assets/icon/icon.png'),
|
image: AssetImage('assets/icon/icon.png'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
child: SizedBox(width: 64, height: 64),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
if (appSettings.proMode)
|
padding: const EdgeInsets.fromLTRB(0, 0, 8, 0),
|
||||||
Positioned.fill(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: ProButton(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned.fill(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(0, 8, 8, 0),
|
|
||||||
child: ThemeSwitcherButton(),
|
child: ThemeSwitcherButton(),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
);
|
||||||
|
|
||||||
|
var textTheme = Theme.of(context).textTheme;
|
||||||
|
var repoSelector = Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Text("journal", style: textTheme.headline6),
|
||||||
|
const SizedBox(height: 8.0),
|
||||||
|
Text("github.com/vhanda/journal", style: textTheme.subtitle2),
|
||||||
|
const SizedBox(height: 8.0),
|
||||||
|
],
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
),
|
),
|
||||||
),
|
IconButton(
|
||||||
|
icon: FaIcon(showRepoList
|
||||||
|
? FontAwesomeIcons.angleUp
|
||||||
|
: FontAwesomeIcons.angleDown),
|
||||||
|
onPressed: repoListToggled,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
fit: StackFit.passthrough,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
var header = DrawerHeader(
|
||||||
var dropdownValue = 'One';
|
|
||||||
var repoSelector = DropdownButton<String>(
|
|
||||||
value: dropdownValue,
|
|
||||||
icon: const Icon(Icons.arrow_downward),
|
|
||||||
iconSize: 24,
|
|
||||||
elevation: 16,
|
|
||||||
style: const TextStyle(color: Colors.deepPurple),
|
|
||||||
underline: Container(
|
|
||||||
height: 2,
|
|
||||||
color: Colors.deepPurpleAccent,
|
|
||||||
),
|
|
||||||
onChanged: (String newValue) {
|
|
||||||
dropdownValue = newValue;
|
|
||||||
},
|
|
||||||
items: <String>['One', 'Two', 'Free', 'Four']
|
|
||||||
.map<DropdownMenuItem<String>>((String value) {
|
|
||||||
return DropdownMenuItem<String>(
|
|
||||||
value: value,
|
|
||||||
child: Text(value),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return DrawerHeader(
|
|
||||||
margin: const EdgeInsets.all(0.0),
|
margin: const EdgeInsets.all(0.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).highlightColor,
|
color: Theme.of(context).highlightColor,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.fromLTRB(16, 16, 8, 8),
|
||||||
child: stack,
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
top,
|
||||||
|
repoSelector,
|
||||||
|
],
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!appSettings.proMode) {
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Banner(
|
||||||
|
message: tr('pro'),
|
||||||
|
location: BannerLocation.topStart,
|
||||||
|
color: Theme.of(context).accentColor,
|
||||||
|
child: header,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user