-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9500a2
commit 86abf72
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
lib/features/digital_guide_view/presentation/widgets/digital_guide_carousel.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,77 @@ | ||
import "dart:async"; | ||
|
||
import "package:carousel_slider_plus/carousel_slider_plus.dart"; | ||
import "package:fast_immutable_collections/fast_immutable_collections.dart"; | ||
import "package:flutter/material.dart"; | ||
|
||
import "../../../../config/ui_config.dart"; | ||
import "digital_guide_image.dart"; | ||
|
||
class DigitalGuideCarouselWithIndicator extends StatefulWidget { | ||
const DigitalGuideCarouselWithIndicator({super.key, required this.imgListId}); | ||
|
||
final IList<int> imgListId; | ||
|
||
@override | ||
State<StatefulWidget> createState() { | ||
return _CarouselWithIndicatorState(); | ||
} | ||
} | ||
|
||
class _CarouselWithIndicatorState | ||
extends State<DigitalGuideCarouselWithIndicator> { | ||
int _current = 0; | ||
final CarouselSliderController _controller = CarouselSliderController(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Dialog( | ||
insetPadding: EdgeInsets.zero, | ||
backgroundColor: Colors.transparent, | ||
child: Wrap( | ||
children: [ | ||
CarouselSlider( | ||
items: widget.imgListId | ||
.map( | ||
(item) => ClipRRect( | ||
borderRadius: const BorderRadius.all( | ||
Radius.circular(DigitalGuideConfig.borderRadiusMedium),), | ||
child: DigitalGuideImage(id: item), | ||
), | ||
) | ||
.toList(), | ||
controller: _controller, | ||
options: CarouselOptions( | ||
autoPlay: true, | ||
enlargeCenterPage: true, | ||
onPageChanged: (index, reason) { | ||
setState(() => _current = index); | ||
}, | ||
), | ||
), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: widget.imgListId.asMap().entries.map((entry) { | ||
return GestureDetector( | ||
onTap: () => unawaited(_controller.animateToPage(entry.key)), | ||
child: Container( | ||
width: 12, | ||
height: 12, | ||
margin: const EdgeInsets.symmetric( | ||
vertical: DigitalGuideConfig.heightMedium, | ||
horizontal: 4, | ||
), | ||
decoration: BoxDecoration( | ||
shape: BoxShape.circle, | ||
color: Colors.black | ||
.withAlpha(_current == entry.key ? 230 : 102), | ||
), | ||
), | ||
); | ||
}).toList(), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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