Add border radius to alert dialog + test file picker on windows + new and show ressource (WIP) + ressource screen (wip)

This commit is contained in:
Thomas Fransolet 2021-05-06 23:05:29 +02:00
parent 9a5e9b74a0
commit 869c071de5
10 changed files with 363 additions and 15 deletions

View File

@ -12,6 +12,9 @@ showColorPicker (Color currentColor, Function onSelect, BuildContext context) {
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
content: SingleChildScrollView( content: SingleChildScrollView(
child: ColorPicker( child: ColorPicker(
pickerColor: currentColor, pickerColor: currentColor,

View File

@ -6,6 +6,9 @@ import 'package:manager_app/constants.dart';
showConfirmationDialog (String question, Function onNo, Function onYes, BuildContext context) { showConfirmationDialog (String question, Function onNo, Function onYes, BuildContext context) {
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Text( child: Text(
question, question,

View File

@ -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,*/ showMultiStringInput (String text, List<TranslationDTO> values, List<TranslationDTO> newValues, Function onGetResult, int maxLines, BuildContext context) { /*Function onSelect,*/
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
title: Text(text), title: Text(text),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Column( child: Column(

View File

@ -11,6 +11,9 @@ void showNewConfiguration(AppContext appContext, BuildContext context) {
ConfigurationDTO configurationDTO = new ConfigurationDTO(); ConfigurationDTO configurationDTO = new ConfigurationDTO();
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
@ -60,7 +63,6 @@ void showNewConfiguration(AppContext appContext, BuildContext context) {
color: kPrimaryColor, color: kPrimaryColor,
textColor: kWhite, textColor: kWhite,
press: () { press: () {
//onYes();
create(configurationDTO, appContext, context); create(configurationDTO, appContext, context);
}, },
fontSize: 20, fontSize: 20,

View File

@ -14,6 +14,9 @@ void showNewSection(ConfigurationDTO configurationDTO, AppContext appContext, Bu
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [

View 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);
}
}

View File

@ -1,5 +1,10 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.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/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart'; import 'package:managerapi/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -20,22 +25,13 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
return Container( return Container(
child: Column( child: Column(
children: [ children: [
Text(
"Resources"
),
FutureBuilder( FutureBuilder(
future: getResources(appContext), future: getResources(appContext),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
return GridView.builder( var tempOutput = new List<RessourceDTO>.from(snapshot.data);
shrinkWrap: true, tempOutput.add(RessourceDTO(id: null));
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), return bodyGrid(tempOutput, size, appContext);
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return // User Picture
Text("Test resources");
}
);
} else if (snapshot.connectionState == ConnectionState.none) { } else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data"); return Text("No data");
} else { } 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 { Future<List<RessourceDTO>> getResources(dynamic appContext) async {

View 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);*/
}
}

View File

@ -71,6 +71,27 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" 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: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -83,11 +104,23 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.0" 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: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http: http:
dependency: transitive dependency: transitive
description: description:
@ -109,6 +142,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.16.1" version: "0.16.1"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
managerapi: managerapi:
dependency: "direct main" dependency: "direct main"
description: description:
@ -165,6 +205,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.11.0" 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: provider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -240,6 +287,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0" flutter: ">=1.20.0"

View File

@ -32,6 +32,7 @@ dependencies:
material_segmented_control: ^3.1.2 material_segmented_control: ^3.1.2
convert: ^3.0.0 convert: ^3.0.0
collection: any collection: any
filepicker_windows: ^2.0.0
managerapi: managerapi:
path: manager_api path: manager_api