Skip to content

Commit

Permalink
design : make carousel responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
cho4u4o committed Oct 29, 2024
1 parent 2fa5580 commit aee3f50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/screens/main/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _MainScreenState extends State<MainScreen> {

@override
Widget build(BuildContext context) {
double screenHeight = MediaQuery.of(context).size.height;
return Scaffold(
appBar: AppBar(
centerTitle: false,
Expand Down Expand Up @@ -86,8 +87,8 @@ class _MainScreenState extends State<MainScreen> {
backgroundColor: altWhite,
body: CustomScrollView(
slivers: [
const SliverToBoxAdapter(
child: Carousel(),
SliverToBoxAdapter(
child: Carousel(screenHeight: screenHeight),
),
SliverToBoxAdapter(
child: Padding(
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'package:saphy/utils/colors.dart';
import 'package:saphy/utils/textstyles.dart';

class Carousel extends StatelessWidget {
const Carousel({super.key});
double screenHeight;
Carousel({super.key, required this.screenHeight});

@override
Widget build(BuildContext context) {
Expand All @@ -30,7 +31,7 @@ class Carousel extends StatelessWidget {
child: CarouselSlider.builder(
itemCount: itemList.length,
options: CarouselOptions(
height: 575,
height: screenHeight * 0.6,
viewportFraction: 1,
enlargeCenterPage: false,
autoPlay: true,
Expand Down

0 comments on commit aee3f50

Please sign in to comment.