//import 'package:filepicker_windows/filepicker_windows.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/l10n/app_localizations.dart'; import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/rounded_button.dart'; import 'package:manager_app/Components/string_input_container.dart'; import 'package:manager_app/Helpers/FileHelper.dart'; import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; Future showNewConfiguration(AppContext appContext, ValueChanged isImport, BuildContext context, BuildContext mainContext) { final l = AppLocalizations.of(mainContext)!; ConfigurationDTO configurationDTO = new ConfigurationDTO(); configurationDTO.label = ""; var configuration = showDialog( builder: (BuildContext context) => Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(20.0)) ), child: SizedBox( width: 460, child: Padding( padding: const EdgeInsets.fromLTRB(24, 20, 24, 24), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Center(child: Text(l.newConfiguration, style: new TextStyle(fontSize: 22, fontWeight: FontWeight.w400))), SizedBox(height: 8), SizedBox( height: 90, child: StringInputContainer( label: l.configNameLabel, initialValue: configurationDTO.label, onChanged: (value) { configurationDTO.label = value; }, ), ), SizedBox(height: 8), Text(l.orText), SizedBox(height: 4), Column( children: [ Padding( padding: const EdgeInsets.only(bottom: 5.0), child: Text(l.importLabel, style: TextStyle(fontSize: 18, fontWeight: FontWeight.w300)), ), InkWell( onTap: () async { FilePickerResult? result = await FilePicker.platform.pickFiles(); if (result != null) { await FileHelper().importConfiguration(result, null, (appContext.getContext() as ManagerAppContext).clientAPI!, mainContext); isImport(true); Navigator.of(context).pop(); } }, child: Padding( padding: const EdgeInsets.all(10.0), child: Icon(Icons.file_upload, color: kPrimaryColor, size: 30), ), ) ] ) ], ), ), ), const SizedBox(height: 16), Wrap( spacing: 8, runSpacing: 8, alignment: WrapAlignment.end, children: [ RoundedButton( text: l.cancel, icon: Icons.undo, color: kSecond, press: () => Navigator.of(context).pop(), fontSize: 16, ), RoundedButton( text: l.create, icon: Icons.check, color: kPrimaryColor, textColor: kWhite, press: () { if(configurationDTO.label != null && configurationDTO.label!.length > 2) { Navigator.of(context).pop(configurationDTO); } else { showNotification(Colors.orange, kWhite, l.configNameRequired, context, null); } }, fontSize: 16, ), ], ), ], ), ), ), ), context: context ); return configuration; } String filePicker() { var result; return result != null ? result.path : null; } void create(ConfigurationDTO configurationDTO, AppContext appContext, context) async { if (configurationDTO.label != null) { Navigator.of(context).pop(configurationDTO); } }