adding packages
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../three_column_navigation.dart';
|
||||
|
||||
class DetailsView extends StatelessWidget {
|
||||
const DetailsView({
|
||||
Key key,
|
||||
@required int listIndex,
|
||||
@required DetailsWidget details,
|
||||
this.previous,
|
||||
this.next,
|
||||
this.isLast = false,
|
||||
this.isFirst = false,
|
||||
this.automaticallyImplyLeading = true,
|
||||
this.showDetailsArrows = false,
|
||||
this.scaffoldKey,
|
||||
}) : _listIndex = listIndex,
|
||||
_details = details,
|
||||
super(key: key);
|
||||
|
||||
final int _listIndex;
|
||||
final DetailsWidget _details;
|
||||
final VoidCallback previous, next;
|
||||
final bool showDetailsArrows;
|
||||
final bool isLast, isFirst;
|
||||
final bool automaticallyImplyLeading;
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: automaticallyImplyLeading,
|
||||
title: !showDetailsArrows
|
||||
? _details.title
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_upward),
|
||||
onPressed: isFirst ? null : previous,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_downward),
|
||||
onPressed: isLast ? null : next,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_details?.title != null)
|
||||
Expanded(
|
||||
child: Center(child: _details.title),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: _details?.actions,
|
||||
),
|
||||
body: _details.child,
|
||||
bottomNavigationBar: _details?.bottomAppBar,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export 'details.dart';
|
||||
export 'section_list.dart';
|
||||
export 'sections.dart';
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
|
||||
import '../three_column_navigation.dart';
|
||||
|
||||
class SectionList extends StatelessWidget {
|
||||
const SectionList({
|
||||
Key key,
|
||||
@required this.controller,
|
||||
@required MainSection section,
|
||||
@required int listIndex,
|
||||
@required this.listTap,
|
||||
}) : _section = section,
|
||||
_listIndex = listIndex,
|
||||
super(key: key);
|
||||
|
||||
final AutoScrollController controller;
|
||||
final MainSection _section;
|
||||
final int _listIndex;
|
||||
final ValueChanged<int> listTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
controller: controller,
|
||||
itemBuilder: (context, index) {
|
||||
final _item = _section.itemBuilder(context, index, _listIndex == index);
|
||||
return AutoScrollTag(
|
||||
controller: controller,
|
||||
key: ValueKey(index),
|
||||
index: index,
|
||||
child: GestureDetector(
|
||||
child: _item,
|
||||
onTap: () => listTap(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: _section.itemCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../three_column_navigation.dart';
|
||||
|
||||
class SectionsList extends StatelessWidget {
|
||||
const SectionsList({
|
||||
Key key,
|
||||
@required this.sectionTap,
|
||||
@required int sectionIndex,
|
||||
@required this.sections,
|
||||
}) : _sectionIndex = sectionIndex,
|
||||
super(key: key);
|
||||
|
||||
final int _sectionIndex;
|
||||
final ValueChanged<int> sectionTap;
|
||||
final List<MainSection> sections;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
final _item = sections[index];
|
||||
return ListTile(
|
||||
leading: _item.icon,
|
||||
title: _item.label,
|
||||
selected: index == _sectionIndex,
|
||||
onTap: () => sectionTap(index),
|
||||
);
|
||||
},
|
||||
itemCount: sections.length,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user