Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion example/lib/features_multi/multi_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:awesome_select/awesome_select.dart';
import 'package:flutter/material.dart';

import '../choices.dart' as choices;

class FeaturesMultiPage extends StatefulWidget {
Expand Down Expand Up @@ -29,6 +30,7 @@ class _FeaturesMultiPageState extends State<FeaturesMultiPage> {
choiceItems: choices.months,
modalType: S2ModalType.fullPage,
onChange: (selected) => setState(() => _month = selected.value),
modalNavigatorType: S2ModalNavigatorType.cupertino,
),
const SizedBox(height: 7),
],
Expand Down
1 change: 1 addition & 0 deletions example/lib/features_single/single_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _FeaturesSinglePageState extends State<FeaturesSinglePage> {
selectedValue: _month,
choiceItems: choices.months,
onChange: (selected) => setState(() => _month = selected.value),
modalNavigatorType: S2ModalNavigatorType.cupertino,
),
const SizedBox(height: 7),
],
Expand Down
17 changes: 17 additions & 0 deletions lib/src/model/modal_config.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

import './modal_theme.dart';

/// Target to open choices list
Expand All @@ -15,12 +17,23 @@ enum S2ModalType {
bottomSheet,
}

enum S2ModalNavigatorType {
/// material, with zooming animation by default
material,

/// cupertino, with sliding animation by default
cupertino,
}

/// Modal configuration
@immutable
class S2ModalConfig with Diagnosticable {
/// Modal type to display choices
final S2ModalType type;

/// Modal navigator type: material or cupertino
final S2ModalNavigatorType navigatorType;

/// Use different title with the trigger widget title
final String? title;

Expand Down Expand Up @@ -82,6 +95,7 @@ class S2ModalConfig with Diagnosticable {
/// Create modal configuration
const S2ModalConfig({
this.type = S2ModalType.fullPage,
this.navigatorType = S2ModalNavigatorType.material,
this.title,
this.useHeader = true,
this.useConfirm = false,
Expand Down Expand Up @@ -138,10 +152,12 @@ class S2ModalConfig with Diagnosticable {
bool? barrierDismissible,
Color? barrierColor,
S2ModalStyle? style,
S2ModalNavigatorType? navigatorType,
S2ModalHeaderStyle? headerStyle,
}) {
return S2ModalConfig(
type: type ?? this.type,
navigatorType: navigatorType ?? this.navigatorType,
title: title ?? this.title,
useHeader: useHeader ?? this.useHeader,
useConfirm: useConfirm ?? this.useConfirm,
Expand Down Expand Up @@ -173,6 +189,7 @@ class S2ModalConfig with Diagnosticable {

return copyWith(
type: other.type,
navigatorType: other.navigatorType,
title: other.title,
useHeader: other.useHeader,
useConfirm: other.useConfirm,
Expand Down
5 changes: 4 additions & 1 deletion lib/src/widget/s2_state.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:awesome_select/awesome_select.dart';
import 'package:collection/collection.dart' show ListEquality;
import 'package:flutter/cupertino.dart' show CupertinoPageRoute;
import 'package:flutter/material.dart';

import '../choices_empty.dart';
Expand Down Expand Up @@ -698,7 +699,9 @@ abstract class S2State<T> extends State<SmartSelect<T>> {
case S2ModalType.fullPage:
confirmed = await (Navigator.push(
context,
MaterialPageRoute(builder: (_) => modal),
modalConfig.navigatorType == S2ModalNavigatorType.material
? MaterialPageRoute(builder: (_) => modal)
: CupertinoPageRoute(builder: (_) => modal),
));
break;
case S2ModalType.bottomSheet:
Expand Down
4 changes: 4 additions & 0 deletions lib/src/widget/smart_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class SmartSelect<T> extends StatefulWidget {
S2ModalStyle? modalStyle,
S2ModalHeaderStyle? modalHeaderStyle,
S2ModalType? modalType,
S2ModalNavigatorType? modalNavigatorType,
String? modalTitle,
bool? modalConfirm,
bool? modalHeader,
Expand Down Expand Up @@ -460,6 +461,7 @@ class SmartSelect<T> extends StatefulWidget {
),
modalConfig: defaultModalConfig.merge(modalConfig).copyWith(
type: modalType,
navigatorType: modalNavigatorType,
title: modalTitle,
filterHint: modalFilterHint,
filterAuto: modalFilterAuto,
Expand Down Expand Up @@ -708,6 +710,7 @@ class SmartSelect<T> extends StatefulWidget {
S2ModalStyle? modalStyle,
S2ModalHeaderStyle? modalHeaderStyle,
S2ModalType? modalType,
S2ModalNavigatorType? modalNavigatorType,
String? modalTitle,
bool? modalConfirm,
bool? modalHeader,
Expand Down Expand Up @@ -783,6 +786,7 @@ class SmartSelect<T> extends StatefulWidget {
),
modalConfig: defaultModalConfig.merge(modalConfig).copyWith(
type: modalType,
navigatorType: modalNavigatorType,
title: modalTitle,
filterHint: modalFilterHint,
filterAuto: modalFilterAuto,
Expand Down