-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ThomasFercher/develop
Develop
- Loading branch information
Showing
57 changed files
with
2,850 additions
and
381 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
lib/customwidgets/datadisplay/bookshelf/legendBookshelf.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
lib/customwidgets/datadisplay/bookshelf/legendBookshelfItem.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
133
lib/customwidgets/datadisplay/carousel/legendCarousel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
lib/customwidgets/datadisplay/carousel/legendCarouselItem.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.