Skip to content

Commit

Permalink
Merge pull request #7 from ThomasFercher/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ThomasFercher authored Aug 22, 2021
2 parents aba6952 + 2cb4161 commit 72f079d
Show file tree
Hide file tree
Showing 57 changed files with 2,850 additions and 381 deletions.
104 changes: 104 additions & 0 deletions lib/customwidgets/datadisplay/bookshelf/legendBookshelf.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'package:flutter/material.dart';
import 'package:webstore/customwidgets/datadisplay/carousel/legendCarouselItem.dart';
import 'package:webstore/customwidgets/legendButton/legendButton.dart';

class LegendBookshelf extends StatefulWidget {
final double? height;
final List<Widget> items;
final Duration? animationDuration;

LegendBookshelf({
Key? key,
this.height,
required this.items,
this.animationDuration,
}) : super(key: key);

@override
_LegendBookshelfState createState() => _LegendBookshelfState();
}

class _LegendBookshelfState extends State<LegendBookshelf> {
late int selected;
late CrossFadeState state;

@override
void initState() {
super.initState();
selected = widget.items.indexOf(widget.items.first);
state = CrossFadeState.showFirst;
}
/*
List<Widget> getItems(double width) {
List<Widget> items = widget.items
.map(
(w) => LegendCarouselItem(
maxWidth: width,
item: w,
duration: widget.animationDuration ?? Duration(milliseconds: 250),
selected: selected == widget.items.indexOf(w),
),
)
.toList();
return items;
}*/

void changedSelected(bool right) {
int dir = right ? 1 : -1;

if ((right && selected < widget.items.length - 1) ||
(!right && selected > 0)) {
setState(() {
selected += dir;
});
}
}

@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, c) {
double w = c.maxWidth;
return Container(
height: widget.height,
width: MediaQuery.of(context).size.width,
color: Colors.transparent,
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [], //getItems(w),
),
),
Align(
alignment: Alignment.centerRight,
child: SizedBox(
width: 100,
child: LegendButton(
text: Text("next"),
onPressed: () {
changedSelected(true);
},
),
),
),
Align(
alignment: Alignment.centerLeft,
child: Container(
width: 100,
child: LegendButton(
text: Text("back"),
onPressed: () {
changedSelected(false);
},
),
),
),
],
),
);
});
}
}
37 changes: 37 additions & 0 deletions lib/customwidgets/datadisplay/bookshelf/legendBookshelfItem.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class LegendBookshelfItem extends StatelessWidget {
final Widget item;
final Duration duration;
final bool selected;
final double maxWidth;

LegendBookshelfItem({
required this.item,
required this.duration,
required this.selected,
required this.maxWidth,
});

@override
Widget build(BuildContext context) {
return Container(
child: AnimatedCrossFade(
firstChild: SizedBox(
child: item,
width: maxWidth,
height: MediaQuery.of(context).size.height,
),
secondChild: Container(
width: 0,
child: item,
height: MediaQuery.of(context).size.height,
),
crossFadeState:
selected ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: duration,
),
);
}
}
133 changes: 133 additions & 0 deletions lib/customwidgets/datadisplay/carousel/legendCarousel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:webstore/customwidgets/datadisplay/carousel/legendCarouselItem.dart';
import 'package:webstore/customwidgets/icons/legendAnimatedIcon.dart';
import 'package:webstore/customwidgets/legendButton/legendButton.dart';

const Duration duration = const Duration(milliseconds: 360);
Curve curve = Curves.easeInOutSine;

class LegendCarousel extends StatefulWidget {
final double? height;
final List<Widget> items;
final Duration? animationDuration;
final EdgeInsetsGeometry? padding;
late bool isInfinite;

LegendCarousel({
required this.items,
this.height,
this.animationDuration,
this.padding,
bool? isInfinite,
}) {
this.isInfinite = isInfinite ?? false;
}

@override
_LegendCarouselState createState() => _LegendCarouselState();
}

class _LegendCarouselState extends State<LegendCarousel> {
late int selected;
late PageController _scrollController;

@override
void initState() {
super.initState();
selected = widget.items.indexOf(widget.items.first);

_scrollController = PageController(initialPage: selected, keepPage: true)
..addListener(_onScroll);
}

void _onScroll() {
int page = _scrollController.page?.toInt() ?? -1;
print(page);
}

void selectPage(int page) {
_scrollController.animateToPage(page, duration: duration, curve: curve);
}

List<Widget> getItems(double width) {
List<Widget> items = widget.items
.map(
(w) => LegendCarouselItem(
maxWidth: width,
item: w,
duration: widget.animationDuration ?? Duration(milliseconds: 250),
),
)
.toList();

return items;
}

void changedSelected(bool right) {
int toSelect = selected + (right ? 1 : -1);

if (toSelect >= 0 && toSelect < widget.items.length) {
setState(() {
selected = toSelect;
});

selectPage(toSelect);
}
}

@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, c) {
double width = MediaQuery.of(context).size.width;
List<Widget> items = getItems(width);
return Container(
height: widget.height,
width: MediaQuery.of(context).size.width,
color: Colors.transparent,
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: PageView(
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
children: items,
pageSnapping: true,
controller: _scrollController,
),
),
Align(
alignment: Alignment.centerRight,
child: LegendAnimatedIcon(
icon: Icons.arrow_forward_ios,
theme: LegendAnimtedIconTheme(
enabled: Colors.black87,
disabled: Colors.black38,
),
padding: EdgeInsets.all(32.0),
onPressed: () {
changedSelected(true);
},
),
),
Align(
alignment: Alignment.centerLeft,
child: LegendAnimatedIcon(
icon: Icons.arrow_back_ios,
theme: LegendAnimtedIconTheme(
enabled: Colors.black87,
disabled: Colors.black38,
),
padding: EdgeInsets.all(32.0),
onPressed: () {
changedSelected(false);
},
),
),
],
),
);
});
}
}
26 changes: 26 additions & 0 deletions lib/customwidgets/datadisplay/carousel/legendCarouselItem.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class LegendCarouselItem extends StatelessWidget {
final Widget item;
final Duration duration;

final double maxWidth;

LegendCarouselItem({
required this.item,
required this.duration,
required this.maxWidth,
});

@override
Widget build(BuildContext context) {
return Container(
child: SizedBox(
child: item,
width: maxWidth,
height: MediaQuery.of(context).size.height,
),
);
}
}
2 changes: 1 addition & 1 deletion lib/customwidgets/datadisplay/table/legendTable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:webstore/customwidgets/legendButton/legendButton.dart';
import 'package:webstore/customwidgets/legendButton/legendButtonStyle.dart';
import 'package:webstore/customwidgets/typography/legendText.dart';
import 'package:webstore/styles/sizeProvider.dart';
import 'package:webstore/styles/typography.dart';
import 'package:webstore/customwidgets/typography/typography.dart';

class LegendTable extends StatelessWidget {
final double? height;
Expand Down
2 changes: 1 addition & 1 deletion lib/customwidgets/datadisplay/table/legendTableCell.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:webstore/customwidgets/legendButton/legendButton.dart';
import 'package:webstore/customwidgets/typography/legendText.dart';
import 'package:webstore/styles/typography.dart';
import 'package:webstore/customwidgets/typography/typography.dart';

enum LegendTableValueType {
TEXT,
Expand Down
Loading

0 comments on commit 72f079d

Please sign in to comment.