This file contains hidden or 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
| double _calculatePagePosition(int index) { | |
| // 卡片在整個畫面顯示的百分比 | |
| final viewFraction = this.viewPortFraction ?? 1.0; | |
| // 卡片大小(viewportDimension 是手機畫面的 width | |
| final itemWidth = (this.scrollMetrics?.viewportDimension ?? 1.0) * viewFraction; | |
| // 卡片在整個 scrollView 中移動的距離 | |
| final scrollX = this.scrollMetrics?.pixels ?? 0.0; | |
This file contains hidden or 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
| Widget _buildImageContainer() { | |
| return Image.asset( | |
| this.trip.imageUrl, | |
| fit: BoxFit.cover, | |
| alignment: Alignment( | |
| this.tripPageVisibility.pagePosition, | |
| 0, | |
| ) | |
| ); | |
| } |
This file contains hidden or 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
| Widget build(BuildContext context) { | |
| return Center( | |
| child: SizedBox.fromSize( | |
| size: Size.fromHeight(550), | |
| child: PageView.builder( | |
| controller: PageController(viewportFraction: 0.8), | |
| itemCount: trips.length, | |
| itemBuilder: (context, index){ | |
| return TripPageItem(trip: trips[index]); | |
| }, |
This file contains hidden or 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
| return Padding( | |
| padding: EdgeInsets.symmetric( | |
| horizontal: 16, | |
| ), | |
| child: ClipRRect( | |
| borderRadius: BorderRadius.circular(20), | |
| child: Stack( | |
| fit: StackFit.expand, | |
| children: <Widget>[ | |
| image, |
This file contains hidden or 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
| @override | |
| Widget build(BuildContext context) { | |
| return Center( | |
| child: SizedBox.fromSize( | |
| size: Size.fromHeight(550), | |
| child: PageView.builder( | |
| itemCount: trips.length, | |
| itemBuilder: (context, index){ | |
| return TripPageItem(trip: trips[index]); | |
| }, |
This file contains hidden or 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
| return Container( | |
| child: ClipRRect( | |
| borderRadius: BorderRadius.circular(20), | |
| child: Stack( | |
| fit: StackFit.expand, | |
| children: <Widget>[ | |
| image, | |
| imageOverlayGradient, | |
| _buildTextContainer(), | |
| ], |
This file contains hidden or 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
| var imageOverlayGradient = DecoratedBox( | |
| decoration: BoxDecoration( | |
| gradient: LinearGradient( | |
| begin: FractionalOffset.topCenter, | |
| end: FractionalOffset.bottomCenter, | |
| colors: [ | |
| Color.fromRGBO(0, 0, 0, 0), | |
| Color.fromRGBO(0, 0, 0, 0.8), | |
| ], | |
| ), |
This file contains hidden or 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
| Widget _buildTextContainer() { | |
| var titleContainer = Text( | |
| this.trip.title, | |
| style: TextStyle( | |
| color: Colors.white, | |
| fontWeight: FontWeight.bold, | |
| letterSpacing: 1.0, | |
| fontSize: 14, | |
| ), | |
| ); |
This file contains hidden or 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
| Widget _getPageView() { | |
| return pageView = PageView.builder( | |
| itemCount: this.widget.imagePaths.length, | |
| itemBuilder: (BuildContext context, int index) { | |
| return Image( | |
| image: AssetImage(this.widget.imagePaths[index]), | |
| fit: BoxFit.cover, | |
| ); | |
| }, | |
| onPageChanged: (index) { |
This file contains hidden or 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
| Widget _getIndicator() { | |
| return Code4Indicator( | |
| dotCount: this.widget.imagePaths.length, | |
| currentIndex: currentIndex, | |
| dotColor: Color.fromRGBO(255, 255, 255, 1), | |
| dotSelectedColor: Color.fromRGBO(255, 255, 255, 0.3), | |
| dotPadding: 12, | |
| dotSize: 14, | |
| onItemTap: (index) { | |
| pageController.jumpToPage(index); |