Improved poc with new animations and ideas

This commit is contained in:
Damiano
2020-08-04 20:07:11 +02:00
parent baacef1860
commit 56cc7a3fd7
6 changed files with 313 additions and 195 deletions
+1 -1
View File
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"url_launcher","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"android":[{"name":"shared_preferences","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/","dependencies":[]},{"name":"url_launcher","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/home/damiano/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider_linux","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-08-01 13:28:33.903859","version":"1.20.0-7.3.pre"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.8\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.5.0\\\\","dependencies":[]}],"android":[{"name":"shared_preferences","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.8\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.5.0\\\\","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+10\\\\","dependencies":[]},{"name":"url_launcher_macos","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-0.0.1+7\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]},{"name":"shared_preferences_linux","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_linux-0.0.2+1\\\\","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_linux-0.0.1+1\\\\","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+7\\\\","dependencies":[]},{"name":"url_launcher_web","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-0.1.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider_linux","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-08-04 19:54:08.462134","version":"1.20.0-7.4.pre"}
+5 -5
View File
@@ -1,12 +1,12 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/home/damiano/flutter"
export "FLUTTER_APPLICATION_PATH=/home/damiano/Scrivania/converterpro"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_ROOT=C:\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\Damia\Desktop\ConverterNOW"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/home/damiano/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=2.3.1"
export "FLUTTER_BUILD_NUMBER=20"
export "DART_OBFUSCATION=false"
+300 -183
View File
@@ -2,7 +2,11 @@ import 'package:converterpro/utils/Localization.dart';
import 'package:flutter/material.dart';
import 'package:converterpro/utils/Utils.dart';
int groupValue = 0;
const int ANIMATION_DURATION = 3000; //milliseconds
const int ANIMATIONS_OVERLAY = 10; //percentage (0-100)
int currentSelection = 0;
List<int> positions = [0, 1];
int ciao = 2;
String dataSize = "MB";
String dataSpeed = "MB/s";
String dataDuration = "s";
@@ -10,7 +14,6 @@ TextEditingController TEC1 = TextEditingController();
TextEditingController TEC2 = TextEditingController();
TextEditingController TEC3 = TextEditingController();
class ToolsManager extends StatefulWidget {
final Function openDrawer;
@@ -21,131 +24,162 @@ class ToolsManager extends StatefulWidget {
}
class _ToolsManager extends State<ToolsManager> {
List<Widget> firstCard = new List(3);
@override
Widget build(BuildContext context) {
firstCard[0] = myListTile(
key: ValueKey(0),
selected: currentSelection == 0,
selectedLeading: Image.asset("resources/images/x.png",
width: 40,
color: MediaQuery.of(context).platformBrightness == Brightness.dark
? Color(0xFFCCCCCC)
: Colors.black54),
unselectedLeading: Icon(Icons.expand_more,
size: 40,
color: MediaQuery.of(context).platformBrightness == Brightness.dark
? Color(0xFFCCCCCC)
: Colors.black54),
title: TextFormField(
controller: TEC1,
enabled: currentSelection != 0,
decoration: InputDecoration(labelText: "Data size"),
keyboardType:
TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text) {
if (text != "" && TEC2.text != "") {
setState(() {
TEC3.text =
(double.parse(text) / double.parse(TEC2.text)).toString();
});
}
},
),
trailing: Container(
width: 70,
alignment: Alignment.centerRight,
child: DropdownButton<String>(
value: dataSize,
underline: SizedBox(),
items: <String>['GB', 'MB', 'kB', 'B'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val) {
setState(() {
dataSize = val;
});
},
),
),
onTap: () {
setState(() {
currentSelection = 0;
});
},
);
firstCard[0]=(RadioListTile<int>(
key: ValueKey(0),
value: 0,
groupValue: groupValue,
title: TextFormField(
controller: TEC1,
enabled: groupValue != 0,
decoration: InputDecoration(labelText: "Data size"),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text){
if(text!="" && TEC2.text!=""){
setState(() {
TEC3.text = (double.parse(text)/double.parse(TEC2.text)).toString();
});
}
},
),
secondary: Container(
width: 70,
alignment: Alignment.centerRight,
child: DropdownButton<String>(
value: dataSize,
underline: SizedBox(),
items: <String>['GB','MB', 'kB', 'B'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val){
setState(() {
dataSize = val;
});
},
),
),
onChanged: (int val) {
setState(() {
groupValue = val;
});
},
));
firstCard[1]=(RadioListTile<int>(
key: ValueKey(1),
value: 1,
groupValue: groupValue,
title: TextFormField(
controller: TEC2,
enabled: groupValue != 1,
decoration: InputDecoration(labelText: "Transmission speed"),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text){
if(text!="" && TEC1.text!=""){
setState(() {
TEC3.text = (double.parse(TEC1.text)/double.parse(text)).toString();
});
}
},
),
secondary: Container(
width: 70,
alignment: Alignment.centerRight,
child: DropdownButton<String>(
value: dataSpeed,
underline: SizedBox(),
items: <String>['GB/s','MB/s', 'kB/s', 'B/s'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val){
setState(() {
dataSpeed = val;
});
},
),
),
onChanged: (int val) {
setState(() {
groupValue = val;
});
},
));
firstCard[2]=(RadioListTile<int>(
key: ValueKey(2),
value: 2,
groupValue: groupValue,
title: TextFormField(
controller: TEC3,
enabled: groupValue != 2,
decoration:InputDecoration(labelText: "Data transfer duration"),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
),
secondary: Container(
width: 70,
alignment: Alignment.centerRight,
child: DropdownButton<String>(
value: dataDuration,
underline: SizedBox(),
items: <String>['s','min', 'h', 'd'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val){
setState(() {
dataDuration = val;
});
},
),
),
onChanged: (int val) {
setState(() {
groupValue = val;
});
},
));
firstCard[1] = myListTile(
key: ValueKey(1),
selected: currentSelection == 1,
selectedLeading: Image.asset("resources/images/x.png",
width: 40,
color: MediaQuery.of(context).platformBrightness == Brightness.dark
? Color(0xFFCCCCCC)
: Colors.black54),
unselectedLeading: Icon(Icons.expand_more,
size: 40,
color: MediaQuery.of(context).platformBrightness == Brightness.dark
? Color(0xFFCCCCCC)
: Colors.black54),
title: TextFormField(
controller: TEC2,
enabled: currentSelection != 1,
decoration: InputDecoration(labelText: "Transmission speed"),
keyboardType:
TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text) {
if (text != "" && TEC1.text != "") {
setState(() {
TEC3.text =
(double.parse(TEC1.text) / double.parse(text)).toString();
});
}
},
),
trailing: Container(
width: 70,
alignment: Alignment.centerRight,
child: DropdownButton<String>(
value: dataSpeed,
underline: SizedBox(),
items: <String>['GB/s', 'MB/s', 'kB/s', 'B/s'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val) {
setState(() {
dataSpeed = val;
});
},
),
),
onTap: () {
setState(() {
currentSelection = 1;
});
},
);
firstCard[2] = myListTile(
key: ValueKey(2),
selected: currentSelection == 2,
selectedLeading: Image.asset("resources/images/x.png",
width: 40,
color: MediaQuery.of(context).platformBrightness == Brightness.dark
? Color(0xFFCCCCCC)
: Colors.black54),
unselectedLeading: Icon(Icons.expand_more,
size: 40,
color: MediaQuery.of(context).platformBrightness == Brightness.dark
? Color(0xFFCCCCCC)
: Colors.black54),
title: TextFormField(
controller: TEC3,
enabled: currentSelection != 2,
decoration: InputDecoration(labelText: "Data transfer duration"),
keyboardType:
TextInputType.numberWithOptions(decimal: true, signed: false),
),
trailing: Container(
width: 70,
alignment: Alignment.centerRight,
child: DropdownButton<String>(
value: dataDuration,
underline: SizedBox(),
items: <String>['s', 'min', 'h', 'd'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val) {
setState(() {
dataDuration = val;
});
},
),
),
onTap: () {
setState(() {
currentSelection = 2;
});
},
);
return Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
@@ -179,7 +213,7 @@ class _ToolsManager extends State<ToolsManager> {
icon: Icon(Icons.clear, color: Colors.white),
onPressed: () {
setState(() {
TEC1.text=TEC2.text=TEC3.text="";
TEC1.text = TEC2.text = TEC3.text = "";
});
},
),
@@ -189,11 +223,6 @@ class _ToolsManager extends State<ToolsManager> {
Icons.search,
color: Colors.white,
),
/*onPressed: () async {
final int paginaReindirizzamento=await showSearch(context: context,delegate: _searchDelegate);
if(paginaReindirizzamento!=null)
_onSelectItem(paginaReindirizzamento);
},*/
),
],
)
@@ -212,48 +241,127 @@ class _ToolsManager extends State<ToolsManager> {
body: Column(
children: [
AnimatedSwitcher(
child: getfirstTwoTiles(firstCard, groupValue)[0],
duration: Duration(milliseconds: 600,),
transitionBuilder: (child, animation) {
final offsetAnimation =
Tween<Offset>(begin: Offset(0.0, 1), end: Offset(0.0, 0.0)).animate(animation);
child: getfirstTwoTiles(firstCard, currentSelection)[0],
duration: Duration(
milliseconds: ANIMATION_DURATION,
),
switchInCurve: Curves.linear,
switchOutCurve: Curves.linear,
transitionBuilder:
(Widget child, Animation<double> animation) {
final outAnimation = Tween<Offset>(
begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0))
.animate(animation);
final inAnimation = Tween<Offset>(
begin: Offset(0.0, -1.0), end: Offset(0.0, 0.0))
.animate(animation);
if (child.key == ValueKey(positions[0])) {
return ClipRect(
child: SlideTransition(
position: offsetAnimation,
child: child,
position: inAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
},
),
} else {
return ClipRect(
child: SlideTransition(
position: outAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
}
},
),
AnimatedSwitcher(
child: getfirstTwoTiles(firstCard, groupValue)[1],
duration: Duration(milliseconds: 600,),
transitionBuilder: (child, animation) {
final offsetAnimation =
Tween<Offset>(begin: Offset(0.0, 1), end: Offset(0.0, 0.0)).animate(animation);
child: getfirstTwoTiles(firstCard, currentSelection)[1],
duration: Duration(
milliseconds: ANIMATION_DURATION,
),
switchInCurve: Curves.linear,
switchOutCurve: Curves.linear,
transitionBuilder:
(Widget child, Animation<double> animation) {
final outAnimation = Tween<Offset>(
begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0))
.animate(animation);
final inAnimation = Tween<Offset>(
begin: Offset(0.0, -1.0), end: Offset(0.0, 0.0))
.animate(animation);
if (child.key == ValueKey(positions[1])) {
return ClipRect(
child: SlideTransition(
position: offsetAnimation,
child: child,
position: inAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
},
),
Divider(thickness: 1,),
} else {
return ClipRect(
child: SlideTransition(
position: outAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
}
},
),
Divider(
thickness: 1,
),
Container(
height: 70.0,
child: AnimatedSwitcher(
child: firstCard[groupValue],
duration: Duration(milliseconds: 600,),
transitionBuilder: (child, animation) {
final offsetAnimation =
Tween<Offset>(begin: Offset(0.0, -1), end: Offset(0.0, 0.0)).animate(animation);
return ClipRect(
child: SlideTransition(
position: offsetAnimation,
child: child,
),
);
child: firstCard[currentSelection],
duration: Duration(
milliseconds: (ANIMATION_DURATION*200 / (ANIMATIONS_OVERLAY+100)).round(),
),
switchInCurve: Interval((100-ANIMATIONS_OVERLAY)/200, 1,
curve: Curves.linear), //Curves.elasticIn,
switchOutCurve: Interval(0, (ANIMATIONS_OVERLAY+100)/200,
curve: Curves.linear), //Curves.elasticOut,
transitionBuilder:
(Widget child, Animation<double> animation) {
final outAnimation = Tween<Offset>(
begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0))
.animate(animation);
final inAnimation = Tween<Offset>(
begin: Offset(0.0, -1.0), end: Offset(0.0, 0.0))
.animate(animation);
if (child.key == ValueKey(currentSelection)) {
return ClipRect(
child: SlideTransition(
position: inAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
} else {
return ClipRect(
child: SlideTransition(
position: outAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
}
},
),
)
@@ -265,40 +373,49 @@ class _ToolsManager extends State<ToolsManager> {
}
}
List getfirstTwoTiles(List tiles, selectedTile){
List getfirstTwoTiles(List tiles, selectedTile) {
List returnTiles = new List();
for(int i=0; i<tiles.length;i++){
if (i!=selectedTile)
int position = 0;
for (int i = 0; i < tiles.length; i++) {
if (i != selectedTile) {
returnTiles.add(tiles[i]);
positions[position] = i;
position++;
}
}
return returnTiles;
}
Widget mySlideTransition(Widget child, Animation<double> animation) {
final offsetAnimation =
Tween<Offset>(begin: Offset(0.0, 0.0), end: Offset(0.0, -1.0)).animate(animation);
return SlideTransition(
position: offsetAnimation,
child: child,
);
}
class myRadioListTile extends StatelessWidget {
final Function onChanged;
final int value;
final int groupValue;
class myListTile extends StatelessWidget {
final Key key;
final Function onTap;
final Widget title;
final Widget selectedLeading;
final Widget unselectedLeading;
final Widget trailing;
final bool selected;
myRadioListTile({this.onChanged, this.value, this.groupValue, this.title});
myListTile(
{this.key,
this.onTap,
this.title,
this.unselectedLeading,
this.selectedLeading,
this.selected,
this.trailing});
@override
Widget build(BuildContext context) {
return Row(children: [
Radio(onChanged: onChanged, value: value, groupValue: groupValue),
title
]);
return Theme(
data: Theme.of(context).copyWith(
splashColor: Colors.transparent, highlightColor: Colors.transparent),
child: ListTile(
key: key,
leading: selected ? selectedLeading : unselectedLeading,
trailing: trailing,
title: title,
onTap: onTap,
),
);
}
}
+6 -6
View File
@@ -21,7 +21,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.0.0"
charcode:
dependency: transitive
description:
@@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety"
version: "1.14.13"
fake_async:
dependency: transitive
description:
@@ -111,7 +111,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety"
version: "1.1.8"
path:
dependency: transitive
description:
@@ -263,7 +263,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety"
version: "1.2.0"
url_launcher:
dependency: "direct main"
description:
@@ -305,7 +305,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.0.8"
xdg_directories:
dependency: transitive
description:
@@ -314,5 +314,5 @@ packages:
source: hosted
version: "0.1.0"
sdks:
dart: ">=2.9.0-18.0 <2.9.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
+1
View File
@@ -76,3 +76,4 @@ flutter:
- resources/images/conversione_base.png
- resources/images/conversion.png
- resources/images/tools.png
- resources/images/x.png
Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B