iOS 디자인 원칙에 부합하는 매끄럽고 시각적으로 일관된 경험을 보장하는 컵ertino 스타일의 날짜 및 시간 선택기 제공하는 플러터 패키지입니다. 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스 등 여러 플랫폼에서 날짜와 시간을 선택하기 위한 네이티브처럼 생긴 컴포넌트를 제공합니다. 애플의 미학을 목표로 하는 앱에서 사용자 인터페이스의 일관성을 강화하면서도 크로스플랫폼 기능을 유지합니다.
사용 사례
크로스 플랫폼 앱에서 iOS 스타일의 날짜 선택
스케줄링 기능 내 통합 캘린더 보기
일관된 UI를 갖춘 시간 추적
날짜 선택이 필요한 폼 입력
플랫폼 고유의 디자인을 통한 UX 향상
모바일 앱용 사용자 정의 가능한 날짜 선택기
주요 기능
Cupertino 테마의 날짜 선택기
크로스 플랫폼 호환성
Flutter와의 원활한 통합
iOS 디자인 언어 준수
사용자 정의 가능한 외관
다중 플랫폼 지원
적합한 대상
iOS 미학을 목표로 하는 개발자
일관된 날짜 입력이 필요한 앱
크로스 플랫폼 모바일 애플리케이션
디자인 중심의 UI 구현
네이티브 룩과 느낌을 우선시하는 팀
고려 사항
Cupertino 스타일을 넘어서는 사용자 정의가 제한적
iOS 외 디자인 테마에 적합하지 않을 수 있습니다
비-iOS 플랫폼에서는 신중한 조작이 필요합니다
Flutter의 Cupertino 위젯에 대한 종속성
큰 캘린더와 함께 잠재적인 성능 영향
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
The package provides a sleek and stylish cupertino calendar widgets designed to mimic the aesthetics of iOS. With smooth animations and intuitive user interactions, it seamlessly integrates into your Flutter app to deliver a delightful user experience.
Features
iOS Style: The cupertino calendar picker follows the design principles of iOS, ensuring consistency and familiarity for iOS users.
Smooth Animations: Enjoy fluid animations that enhance the overall look and feel of the calendar, providing a polished user experience.
Customizable: Easily customize the appearance of the calendar to match your app's theme and branding.
Intuitive Interactions: Users can effortlessly navigate through years, months and interact with the calendar thanks to its intuitive design.
Getting started
In the pubspec.yaml of your flutter project, add the following dependency:
You can add actions to the calendar picker by passing a list of CupertinoCalendarAction objects.
The package provides two built-in actions: CancelCupertinoCalendarAction and ConfirmCupertinoCalendarAction.
Call the showCupertinoCalendarPicker passing date constrains and widget's RenderBox of the widget above/below which you wish to display the calendar.
@overrideWidgetbuild(BuildContext context) {
returnCupertinoApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: CupertinoPageScaffold(
child: Builder(
builder: (context) {
/// Passing exactly this `BuildContext` is mandatory here to /// get the `RenderBox` of the appropriate widget.returnYourWidget(
onTap: () => onTap(context),
);
},
),
),
);
}
/// The `BuildContext` comes from the `Builder` above the widget tree.Future<void> onTap(BuildContext context) {
final renderBox = context.findRenderObject() asRenderBox?;
final nowDate = DateTime.now();
returnshowCupertinoCalendarPicker(
context,
widgetRenderBox: renderBox,
minimumDate: nowDate.subtract(constDuration(days: 15)),
initialDate: nowDate,
maximumDate: nowDate.add(constDuration(days: 360)),
);
}
How to get a RenderBox?
There are 3 simple ways of how you can get the widget's render box to pass it to the showCupertinoCalendarPicker or showCupertinoTimePicker function.
You can choose any of these.
Wrap your widget with Builder widget.
Builder(
builder: (context) {
returnYourWidget(
onTap: () => onTap(context),
);
},
);
Future<void> onTap(BuildContext context) {
/// And here you can get the `RenderBox` of your widget /// using the `Builder`s `BuildContext`final renderBox = context.findRenderObject() asRenderBox?;
returnshowCupertinoCalendarPicker(...);
}
Use a GlobalKey.
final globalKey = GlobalKey();
@overrideWidgetbuild(BuildContext context) {
returnCupertinoApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: CupertinoPageScaffold(
child: YourWidget(
key: globalKey,
onTap: onTap,
),
),
);
}
Future<void> onTap(BuildContext context) {
/// And here you can get the `RenderBox` of your widget using the `GlobalKey`.final renderBox = globalKey.currentContext?.findRenderObject() asRenderBox?;
returnshowCupertinoCalendarPicker(...);
}
Pass a BuildContext directly from your widget's build method.
classYourWidgetextendsStatelessWidget{
constYourWidget({
requiredthis.onTap,
});
finalvoidFunction(BuildContext context) onTap;
@overrideWidgetbuild(BuildContext context) {
returnGestureDetector(
onTap: () => onTap(context),
child: ...,
);
}
}
Future<void> onTap(BuildContext context) {
/// And here you can get the `RenderBox` of your widget's `build` method.final renderBox = context.findRenderObject() asRenderBox?;
returnshowCupertinoCalendarPicker(...);
}