-
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 #40 from 2024-Saphy/feat/SAPHY-31-mainpage
feat : 캐러셀 추가, 오류 해결
- Loading branch information
Showing
5 changed files
with
122 additions
and
76 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import 'package:carousel_slider/carousel_slider.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:cached_network_image/cached_network_image.dart'; | ||
import 'package:saphy/utils/colors.dart'; | ||
|
||
class Carousel extends StatelessWidget { | ||
const Carousel({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
const itemList = [ | ||
( | ||
link: | ||
"https://i.pinimg.com/736x/cf/aa/d7/cfaad78b35a7b752054dd564b77f1f10.jpg", | ||
type: "Phone", | ||
content: "iPhone 15도\nSaphy에서.", | ||
color: Colors.white, | ||
), | ||
( | ||
link: | ||
"https://i.pinimg.com/736x/d3/81/bb/d381bbb3036599443634fef9503d888c.jpg", | ||
type: "Collaboration", | ||
content: "전 세계를 홀린\nKirby와의 콜라보!", | ||
color: Colors.black | ||
), | ||
]; | ||
int totalCount = itemList.length; | ||
return SizedBox( | ||
child: CarouselSlider.builder( | ||
itemCount: itemList.length, | ||
options: CarouselOptions( | ||
height: 575, | ||
viewportFraction: 1, | ||
enlargeCenterPage: false, | ||
autoPlay: true, | ||
autoPlayInterval: const Duration(seconds: 5), | ||
), | ||
itemBuilder: (context, index, realIndex) { | ||
return contentBuilder( | ||
itemList[index].link, | ||
itemList[index].type, | ||
itemList[index].content, | ||
itemList[index].color, | ||
realIndex, | ||
totalCount, | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
|
||
Container contentBuilder(String link, String type, String content, | ||
Color color, int index, int totalCount) { | ||
return Container( | ||
width: double.infinity, | ||
decoration: BoxDecoration( | ||
image: DecorationImage( | ||
image: CachedNetworkImageProvider( | ||
link, | ||
), | ||
fit: BoxFit.cover), | ||
), | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 30), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.end, | ||
children: [ | ||
Text( | ||
type, | ||
style: TextStyle(color: color, fontSize: 25), | ||
), | ||
Text( | ||
content, | ||
style: TextStyle( | ||
color: color, | ||
fontFamily: 'Pretendard', | ||
fontWeight: FontWeight.bold, | ||
fontSize: 50, | ||
height: 1.2), | ||
), | ||
const SizedBox( | ||
height: 30, | ||
), | ||
// SizedBox( | ||
// height: 3, | ||
// width: 280, | ||
// child: Row( | ||
// children: [ | ||
// Expanded(flex: index, child: Container(color: color)), | ||
// Expanded( | ||
// flex: totalCount + index, | ||
// child: Container( | ||
// color: | ||
// color == Colors.white ? Colors.black : Colors.white, | ||
// ), | ||
// ), | ||
// ], | ||
// ), | ||
// ), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
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