Coder Social home page Coder Social logo

mono0926 / adaptive_dialog Goto Github PK

View Code? Open in Web Editor NEW
338.0 5.0 61.0 25.34 MB

Show alert dialog or modal action sheet adaptively according to platform.

Home Page: https://pub.dev/packages/adaptive_dialog

License: MIT License

Kotlin 0.09% Ruby 1.98% Swift 1.37% Objective-C 0.03% Dart 73.79% HTML 3.77% CMake 5.53% C++ 12.79% C 0.54% Shell 0.10%
flutter material material-design material-theme ios cupertino cupertino-design cupertino-widgets widget text

adaptive_dialog's Introduction

adaptive_dialog

Show alert dialog or modal action sheet adaptively according to platform.

Web Demo: https://mono0926.com/adaptive_dialog/

Convenient wrapper of showAlertDialog.

iOS Android
n1 n2

Convenient wrapper of showAlertDialog.

iOS Android
n3 n4
n5 n6

Show Confirmation Dialog. For Cupertino, fallback to ActionSheet.

iOS Android
n3 n5
iOS Android
n7 n8
n9 n10
n11 n12
iOS Android
n1 n2
n3 n4

Show text input dialog until answer is correct or cancelled. This is useful for preventing very destructive action is executed mistakenly.

iOS Android
n5 n6

FAQ

How can I customize it flexibly?

This packages keeps usage and UI simple like iOS official alert dialog. Therefore, if you need more flexibility than this package provides, I recommend that you build your own directly using standard APIs to meet your requirements without using this package.

The getter modalBarrierDismissLabel was called on null

adaptive_dialog uses Cupertino-style widgets internally on iOS, so GlobalCupertinoLocalizations.delegate is required under certain conditions.

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

class App extends StatelessWidget {
  const App({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //...
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate, // This is required
      ],
    );
  }
}

The input text color same with backgound when using CupertinoTextInputDialog

This fixes the problem.

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart' hide Router;

class App extends StatelessWidget {
  const App({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      darkTheme: ThemeData(
        cupertinoOverrideTheme: const CupertinoThemeData(
          textTheme: CupertinoTextThemeData(), // This is required
        ),
      ),
    );
  }
}

adaptive_dialog's People

Contributors

838 avatar dependabot[bot] avatar iametornam avatar junaid1460 avatar koji-1009 avatar krille-chan avatar lcsvcn avatar mono0926 avatar nilsreichardt avatar ted-chiptech avatar theachoem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

adaptive_dialog's Issues

showConfirmationDialog height

Hi,
Is there any way while using showConfirmationDialog to have a more "responsive" height?
The widget works well when the list is long enough to be scrollable, and I am aware of contentMaxHeight which I am using currently, but it's not ideal.

Maybe you could add an option to pass to the widget's ListView a shrinkWrap value, so one could set it to true.

Thanks!

"showTextInputDialog" returns double the value in ios.

MyCode:

showTextInputDialog(
context: context,
title: 'Test Text Input Dialog',
textFields: [
DialogTextField(
hintText: 'Input value',
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter number';
}
debugPrint('Value: $value');
return null;
},
)
],
)

Screenshot terminal in iOS:
Screen Shot 2021-04-06 at 11 15 52

Screenshot terminal in Android:
Screen Shot 2021-04-06 at 11 22 46

Provide a way to override default theme

By default buttons use primary color. but I want use a different color, or secondary color. is there any plan to support this?
as you see from the below image, primary color is orange and reduces readability.

Screen Shot 2021-03-12 at 15 05 45

how to implement onOkPressed function?

The showTextInputDialog will return a String with closing the dialog.

I don't want to close the dialog, how could I finish the aysncronous validation when ok pressed?

Nested Navigators

Hi!
I have a tabbed setup that use nested Navigators. It seems that the dialogs are displayed using the root navigator, because when the void pop(T key) => Navigator.of(context).pop(key); is executed in showAlertDialog<T> after pressing any dialog's action button, the tab's page is popped but the dialog stays on the screen.

I was able to successfully fix the issue by forcing to pop using root navigator, so that the dialog is actually removed off the screen after pressing an action button:
void pop(T key) => Navigator.of(context, rootNavigator: true).pop(key);

Would you be so kind to extend your API to support this scenario? Thank you in advance, I love your work.

No background color in Modal Action Sheet Android

Hi, sorry for my english.

I have a issue when I use showModalActioSheet. In iOS looks good but in Android the background color it's transparent and I don't see the content. This is my code:

import 'package:adaptive_dialog/adaptive_dialog.dart' as adaptive;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

Future<String> showOptionsBottomMenu({
  @required BuildContext context,
  String title = 'Opciones',
  String cancelLabel = 'Cancelar',
  String message,
}) async {
  return await adaptive.showModalActionSheet<String>(
    context: context,
    title: title,
    cancelLabel: cancelLabel,
    message: message,
    isDismissible: true,
    style: adaptive.AdaptiveStyle.material,
    actions: [
      const adaptive.SheetAction(
        label: 'Tomar Foto',
        icon: Icons.insert_photo,
        key: 'tomar',
      ),
      const adaptive.SheetAction(
        label: 'Seleccionar Fotos',
        icon: Icons.insert_photo,
        key: 'seleccionar',
      ),
      const adaptive.SheetAction(
        label: 'Seleccionar archivos pdf, word, excel, power point',
        icon: Icons.insert_photo,
        key: 'seleccionar_archivos',
      ),
    ],
  );
}

I'm using Flutter v1.17.3.

Here the screenshots:

  1. iOS
    imagen

  2. Android
    imagen

DialogTextField set maxLines is not effect

It can be input more then 5 lines.

final introductions = await showTextInputDialog(
context: context,
textFields: [
DialogTextField(
initialText: _userInfo.introduction,
keyboardType: TextInputType.multiline,
// minLines: 1,
maxLines: 5,
),
],
title: 'input introduction',
);

More than 1 message

Is there a way to have more than 1 message for the alert? So the 2nd message will be on a new line

Help me please

I do not understand how i can handle OK and CANCEL buttons in showTextInputDialog. In future i get only text from textField.

and why i have this?

showTextInputDialog(
context: context,
textFields: [DialogTextField()],
title: 'Создание папки',
message: 'Введите название папки',
okLabel: 'Создать',
cancelLabel: 'Отмена',
).then((newFolder) {
print(newFolder.isEmpty); ----This is FALSE
print(newFolder); ---- and this get me [ ] - empty!

Docs or pub link ?

Looks nice but where is the pub link or docs so that tell us how to use this ?

Migrate to null safety

On projects with null safety we now get a warning that this package should not be imported. A migration to null safety would solve this. I guess I shouldnt be too much work because most of the code should already be null safe.

The getter 'modalBarrierDismissLabel' was called on null

I use your plugin but on iOS 14 i've this error:

The following NoSuchMethodError was thrown while handling a gesture:
The getter 'modalBarrierDismissLabel' was called on null.
Receiver: null
Tried calling: modalBarrierDismissLabel

this is my code:

return GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), itemBuilder: (_, index) => Builder( builder: (context) => InkWell( onTap: () { if (index == TeouResponses.MAP_OF_RESPONSES.length - 1) { showTextInputDialog( context: context, title: "Je suis...", textFields: [DialogTextField(hintText: "test")], okLabel: "Envoyer", cancelLabel: "Annuler", barrierDismissible: true) .then((inputText) { if (inputText != null && inputText.length > 0) { _textResponse = inputText[0]; _actionsAfterCLick(index); } }); } else if (index == TeouResponses.MAP_OF_RESPONSES.length - 2) { _onImageButtonPressed(ImageSource.camera, context: context, index: TeouResponses.MAP_OF_RESPONSES.length - 2); } else { _actionsAfterCLick(index); } }, child: Card( elevation: 4, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SizedBox( height: 60, child: Image( image: TeouResponses.MAP_OF_RESPONSES.values .toList()[index]), ), SizedBox( height: 10, ), Center( child: Text( TeouResponses.MAP_OF_RESPONSES.keys.toList()[index], textAlign: TextAlign.center, ), ) ], ), ), )), ), itemCount: TeouResponses.MAP_OF_RESPONSES.length, );

How to prevent physical return/back action?

Hi, thanks for your attention in advance.
Is there any param to prevent physical return/back action? Such as the back key on android device? The param 'barrierDismissible' can't satisfy my requirement.

please help

i have showTextInputDialog()

but where i can past functions on OK and CANCEL buttons?

for example i expect some like this:

showTextInputDialog(
onPressOKButton(){
doSomeThing
}
onPressCANCELButton(){
doSomeThing
}
)

How i can handle tap on OK and CANCEL buttons???

Cannot build example on any flutter channel

Your sdk requirement of >=2.12.0-0 prevents this from being built on the stable channel of flutter, and on the beta channel and below, the following error arises upon trying to build and run the example flutter app.

/C:/Software/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'.
        context != null ? Localizations.localeOf(context, nullOk: true) : null,
                                                          ^^^^^^
/C:/Software/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
  static Locale localeOf(BuildContext context) {
                ^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\Software\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Software\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s
Exception: Gradle task assembleDebug failed with exit code 1

Option to change the directionality of text and text-direction-sensitive render objects

In my app, I need to change the text direction of the title and the content in the dialog but I could not because there is no argument provided for text direction.

Expected Behaviour
The dialog should have support for text direction by making Directionality the root child of the dialog.

showModal(
      context: context,
      useRootNavigator: useRootNavigator,
      configuration: FadeScaleTransitionConfiguration(
        barrierDismissible: barrierDismissible,
      ),
      builder: (context) => Directionality(
        textDirection: TextDirection.rtl,
        child: WillPopScope(
          onWillPop: onWillPop,
          child: AlertDialog(
            title: titleText,
            content: messageText,
            actions: actions.convertToMaterialDialogActions(
              onPressed: pop,
              destructiveColor: colorScheme.error,
              fullyCapitalized: fullyCapitalizedForMaterial,
            ),
            actionsOverflowDirection: actionsOverflowDirection,
            scrollable: true,
          ),
        ),
      ),
    );

iOS dark mode text input is invisible

Hello, I really love your package and use it in my app FluffyChat but I have seen that on iOS in dark mode the text is not visible in the showTextInputDialog().

Screenshot

Cannot be UITested

Need to add optional parameter Key to be able to use integration test

can we use buttons??? too

i want to show this instead of a full add a post page in a FB like app//// i want to have a add image. and a textbox too in this model dialog pleas etell

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.