mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +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/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
|
||||
Widget build(BuildContext context) {
|
||||
Widget setupGitButton;
|
||||
@ -50,7 +80,16 @@ class AppDrawer extends StatelessWidget {
|
||||
// Important: Remove any padding from the ListView.
|
||||
padding: EdgeInsets.zero,
|
||||
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 (!appSettings.proMode)
|
||||
_buildDrawerTile(
|
||||
|
@ -1,85 +1,93 @@
|
||||
import 'package:flutter/material.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:function_types/function_types.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:gitjournal/app_settings.dart';
|
||||
|
||||
class AppDrawerHeader extends StatelessWidget {
|
||||
final Func0<void> repoListToggled;
|
||||
final bool showRepoList;
|
||||
|
||||
AppDrawerHeader({
|
||||
@required this.repoListToggled,
|
||||
@required this.showRepoList,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var appSettings = Provider.of<AppSettings>(context);
|
||||
|
||||
var stack = Stack(
|
||||
var top = Row(
|
||||
children: <Widget>[
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/icon/icon.png'),
|
||||
),
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/icon/icon.png'),
|
||||
),
|
||||
),
|
||||
child: SizedBox(width: 64, height: 64),
|
||||
),
|
||||
if (appSettings.proMode)
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 8, 0),
|
||||
child: ThemeSwitcherButton(),
|
||||
),
|
||||
],
|
||||
fit: StackFit.passthrough,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
);
|
||||
|
||||
/*
|
||||
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(),
|
||||
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,
|
||||
),
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
);
|
||||
*/
|
||||
|
||||
return DrawerHeader(
|
||||
var header = DrawerHeader(
|
||||
margin: const EdgeInsets.all(0.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).highlightColor,
|
||||
),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: stack,
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 8, 8),
|
||||
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