Add border radius to alert dialog + test file picker on windows + new and show ressource (WIP) + ressource screen (wip)
This commit is contained in:
parent
9a5e9b74a0
commit
869c071de5
@ -12,6 +12,9 @@ showColorPicker (Color currentColor, Function onSelect, BuildContext context) {
|
||||
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: ColorPicker(
|
||||
pickerColor: currentColor,
|
||||
|
||||
@ -6,6 +6,9 @@ import 'package:manager_app/constants.dart';
|
||||
showConfirmationDialog (String question, Function onNo, Function onYes, BuildContext context) {
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Text(
|
||||
question,
|
||||
|
||||
@ -9,6 +9,9 @@ import 'package:collection/collection.dart';
|
||||
showMultiStringInput (String text, List<TranslationDTO> values, List<TranslationDTO> newValues, Function onGetResult, int maxLines, BuildContext context) { /*Function onSelect,*/
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
title: Text(text),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
|
||||
@ -11,6 +11,9 @@ void showNewConfiguration(AppContext appContext, BuildContext context) {
|
||||
ConfigurationDTO configurationDTO = new ConfigurationDTO();
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
@ -60,7 +63,6 @@ void showNewConfiguration(AppContext appContext, BuildContext context) {
|
||||
color: kPrimaryColor,
|
||||
textColor: kWhite,
|
||||
press: () {
|
||||
//onYes();
|
||||
create(configurationDTO, appContext, context);
|
||||
},
|
||||
fontSize: 20,
|
||||
|
||||
@ -14,6 +14,9 @@ void showNewSection(ConfigurationDTO configurationDTO, AppContext appContext, Bu
|
||||
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
124
lib/Screens/Resources/new_ressource_popup.dart
Normal file
124
lib/Screens/Resources/new_ressource_popup.dart
Normal file
@ -0,0 +1,124 @@
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:filepicker_windows/filepicker_windows.dart';
|
||||
import 'package:flutter/material.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/Models/managerContext.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
import 'package:managerapi/api.dart';
|
||||
|
||||
void showNewRessource(AppContext appContext, BuildContext context) {
|
||||
RessourceDetailDTO ressourceDetailDTO = new RessourceDetailDTO();
|
||||
dynamic url = null;
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Nouvelle ressource", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||
Column(
|
||||
children: [
|
||||
StringContainer(
|
||||
label: "Nom :",
|
||||
initialValue: ressourceDetailDTO.label,
|
||||
onChanged: (value) {
|
||||
ressourceDetailDTO.label = value;
|
||||
},
|
||||
),
|
||||
if (url != null) Image.network(url)
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
print("onTap upload");
|
||||
final file = OpenFilePicker()
|
||||
..filterSpecification = {
|
||||
'Images (*.jpg; *.png)': '*.jpg;*.png',
|
||||
'Video (*.mp4)': '*.mp4',
|
||||
'All Files': '*.*'
|
||||
}
|
||||
..defaultFilterIndex = 0
|
||||
..title = 'Sélectionner un fichier';
|
||||
|
||||
final result = file.getFile();
|
||||
if (result != null) {
|
||||
print(result.path);
|
||||
print(result.uri);
|
||||
|
||||
// Read the file.
|
||||
dynamic contents = await result.readAsBytes();
|
||||
print(contents);
|
||||
|
||||
url = result.path;
|
||||
|
||||
}
|
||||
},
|
||||
child: Text("UPLOAD !"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: Container(
|
||||
width: 175,
|
||||
height: 70,
|
||||
child: RoundedButton(
|
||||
text: "Annuler",
|
||||
icon: Icons.undo,
|
||||
color: kSecond,
|
||||
press: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: 70,
|
||||
child: RoundedButton(
|
||||
text: "Créer",
|
||||
icon: Icons.check,
|
||||
color: kPrimaryColor,
|
||||
textColor: kWhite,
|
||||
press: () {
|
||||
create(ressourceDetailDTO, appContext, context);
|
||||
},
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
), context: context
|
||||
);
|
||||
}
|
||||
|
||||
void create(RessourceDetailDTO ressourceDetailDTO, AppContext appContext, context) async {
|
||||
if (ressourceDetailDTO.label != null) {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
RessourceDetailDTO newRessource = await appContext.getContext().clientAPI.ressourceApi.ressourceCreate(ressourceDetailDTO);
|
||||
print("newRessource");
|
||||
print(newRessource);
|
||||
|
||||
// To refresh only (UGLY COOOOODE)
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
appContext.setContext(managerAppContext);
|
||||
|
||||
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,10 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Models/managerContext.dart';
|
||||
import 'package:manager_app/Screens/Resources/new_ressource_popup.dart';
|
||||
import 'package:manager_app/Screens/Resources/show_ressource_popup.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
import 'package:managerapi/api.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@ -20,22 +25,13 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Resources"
|
||||
),
|
||||
FutureBuilder(
|
||||
future: getResources(appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
itemCount: snapshot.data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return // User Picture
|
||||
Text("Test resources");
|
||||
}
|
||||
);
|
||||
var tempOutput = new List<RessourceDTO>.from(snapshot.data);
|
||||
tempOutput.add(RessourceDTO(id: null));
|
||||
return bodyGrid(tempOutput, size, appContext);
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text("No data");
|
||||
} else {
|
||||
@ -47,6 +43,84 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bodyGrid(data, Size size, AppContext appContext) {
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return // User Picture
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (data[index].id == null) {
|
||||
showNewRessource(appContext, context);
|
||||
} else {
|
||||
showRessource(data[index], appContext, context);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: boxDecoration(data[index]),
|
||||
padding: const EdgeInsets.all(15),
|
||||
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: getElement(data[index], size)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getElement(RessourceDTO ressource, Size size) {
|
||||
if (ressource.id != null) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: AutoSizeText(
|
||||
ressource.label,
|
||||
style: new TextStyle(fontSize: 25),
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: AutoSizeText(
|
||||
ressource.type.toString(),
|
||||
style: new TextStyle(fontSize: 18, fontFamily: ""),
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
Icons.add,
|
||||
color: kTextLightColor,
|
||||
size: 80.0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boxDecoration(RessourceDTO ressourceDTO) {
|
||||
return BoxDecoration(
|
||||
color: ressourceDTO.id == null ? Colors.lightGreen : kTextLightColor,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kSecond,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 1.5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<RessourceDTO>> getResources(dynamic appContext) async {
|
||||
|
||||
81
lib/Screens/Resources/show_ressource_popup.dart
Normal file
81
lib/Screens/Resources/show_ressource_popup.dart
Normal file
@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/rounded_button.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
import 'package:managerapi/api.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
void showRessource(RessourceDTO ressourceDTO,AppContext appContext, BuildContext context) {
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(ressourceDTO.label, style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||
Text('TODO CHARGE IMAGE'),
|
||||
Text("TODO SHOW IMAGE OR VIDEO")
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: Container(
|
||||
width: 175,
|
||||
height: 70,
|
||||
child: RoundedButton(
|
||||
text: "Retour",
|
||||
icon: Icons.undo,
|
||||
color: kSecond,
|
||||
press: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: Container(
|
||||
width: 200,
|
||||
height: 70,
|
||||
child: RoundedButton(
|
||||
text: "Supprimer",
|
||||
icon: Icons.delete,
|
||||
color: kPrimaryColor,
|
||||
textColor: kWhite,
|
||||
press: () {
|
||||
delete(ressourceDTO, appContext, context);
|
||||
},
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
), context: context
|
||||
);
|
||||
}
|
||||
|
||||
void delete(RessourceDTO ressourceDTO, AppContext appContext, context) async {
|
||||
if (ressourceDTO.label != null) {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
//RessourceDetailDTO newRessource = await appContext.getContext().clientAPI.ressourceApi.ressourceCreate(ressourceDetailDTO);
|
||||
print("TODO DELETE");
|
||||
/*print(newRessource);
|
||||
|
||||
// To refresh only (UGLY COOOOODE)
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
appContext.setContext(managerAppContext);
|
||||
|
||||
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);*/
|
||||
}
|
||||
}
|
||||
56
pubspec.lock
56
pubspec.lock
@ -71,6 +71,27 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
file_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
filepicker_windows:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: filepicker_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -83,11 +104,23 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.0"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -109,6 +142,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.16.1"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.3"
|
||||
managerapi:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -165,6 +205,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -240,6 +287,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
sdks:
|
||||
dart: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
flutter: ">=1.20.0"
|
||||
|
||||
@ -32,6 +32,7 @@ dependencies:
|
||||
material_segmented_control: ^3.1.2
|
||||
convert: ^3.0.0
|
||||
collection: any
|
||||
filepicker_windows: ^2.0.0
|
||||
managerapi:
|
||||
path: manager_api
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user