Compare commits

...
10 changed files with 536 additions and 66 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":"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-07-23 11:16:01.877138","version":"1.20.0-7.2.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-23 21:57:48.482248","version":"1.21.0-9.1.pre"}
+78 -42
View File
@@ -1,3 +1,4 @@
import 'package:converterpro/managers/ToolsManager.dart';
import 'package:converterpro/pages/ReorderPage.dart';
import 'package:converterpro/pages/SettingsPage.dart';
import 'package:converterpro/utils/Localization.dart';
@@ -12,7 +13,10 @@ import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import "dart:convert";
int currentPage=0;
int currentPage=0; //page of a topic (e.g. length)
int currentTopic=0; //topic (e.g. conversions)
const MAX_CONVERSION_UNITS=19;
const MAX_TOOLS_NUMBER=1;
class AppManager extends StatefulWidget{
@override
@@ -21,7 +25,9 @@ class AppManager extends StatefulWidget{
class _AppManagerState extends State<AppManager> {
static List<Widget> listaDrawer=new List(MAX_CONVERSION_UNITS+1);//+1 perchè c'è l'intestazione
static List<Widget> listaDrawer = new List(3); //titolo + conversioni + tools
static List<ListTileDrawer> listaDrawerConversions=new List(MAX_CONVERSION_UNITS);//+1 perchè c'è l'intestazione
static List<ListTileDrawer> listDrawerTools = new List(MAX_TOOLS_NUMBER);
static List<int> listaOrderDrawer=[0,1,2,4,5,6,17,7,11,12,14,3,15,16,13,8,18,9,10]; //fino a maxconversionunits-1
static List<String> listaTitoli;
static bool showRateSnackBar = false;
@@ -118,6 +124,31 @@ class _AppManagerState extends State<AppManager> {
void initializeTiles(){
listDrawerTools[0] = ListTileDrawer("Tool 1","resources/images/lunghezza.png",currentTopic==0 && currentPage==0,(){_onSelectItem(0,0);Navigator.of(context).pop();});
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
listaDrawerConversions[listaOrderDrawer[0]]=ListTileDrawer(listaTitoli[0],"resources/images/lunghezza.png",currentTopic==1 && currentPage==0,(){_onSelectItem(1,0);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[1]]=ListTileDrawer(listaTitoli[1],"resources/images/area.png",currentTopic==1 && currentPage==1,(){_onSelectItem(1,1);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[2]]=ListTileDrawer(listaTitoli[2],"resources/images/volume.png",currentTopic==1 && currentPage==2,(){_onSelectItem(1,2);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[3]]=ListTileDrawer(listaTitoli[3],"resources/images/tempo.png",currentTopic==1 && currentPage==3,(){_onSelectItem(1,3);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[4]]=ListTileDrawer(listaTitoli[4],"resources/images/temperatura.png",currentTopic==1 && currentPage==4,(){_onSelectItem(1,4);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[5]]=ListTileDrawer(listaTitoli[5],"resources/images/velocita.png",currentTopic==1 && currentPage==5,(){_onSelectItem(1,5);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[6]]=ListTileDrawer(listaTitoli[6],"resources/images/prefissi.png",currentTopic==1 && currentPage==6,(){_onSelectItem(1,6);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[7]]=ListTileDrawer(listaTitoli[7],"resources/images/massa.png",currentTopic==1 && currentPage==7,(){_onSelectItem(1,7);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[8]]=ListTileDrawer(listaTitoli[8],"resources/images/pressione.png",currentTopic==1 && currentPage==8,(){_onSelectItem(1,8);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[9]]=ListTileDrawer(listaTitoli[9],"resources/images/energia.png",currentTopic==1 && currentPage==9,(){_onSelectItem(1,9);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[10]]=ListTileDrawer(listaTitoli[10],"resources/images/angoli.png",currentTopic==1 && currentPage==10,(){_onSelectItem(1,10);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[11]]=ListTileDrawer(listaTitoli[11],"resources/images/valuta.png",currentTopic==1 && currentPage==11,(){_onSelectItem(1,11);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[12]]=ListTileDrawer(listaTitoli[12],"resources/images/scarpe.png",currentTopic==1 && currentPage==12,(){_onSelectItem(1,12);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[13]]=ListTileDrawer(listaTitoli[13],"resources/images/dati.png",currentTopic==1 && currentPage==13,(){_onSelectItem(1,13);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[14]]=ListTileDrawer(listaTitoli[14],"resources/images/potenza.png",currentTopic==1 && currentPage==14,(){_onSelectItem(1,14);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[15]]=ListTileDrawer(listaTitoli[15],"resources/images/forza.png",currentTopic==1 && currentPage==15,(){_onSelectItem(1,15);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[16]]=ListTileDrawer(listaTitoli[16],"resources/images/torque.png",currentTopic==1 && currentPage==16,(){_onSelectItem(1,16);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[17]]=ListTileDrawer(listaTitoli[17],"resources/images/consumo.png",currentTopic==1 && currentPage==17,(){_onSelectItem(1,17);Navigator.of(context).pop();});
listaDrawerConversions[listaOrderDrawer[18]]=ListTileDrawer(listaTitoli[18],"resources/images/conversione_base.png",currentTopic==1 && currentPage==18,(){_onSelectItem(1,18);Navigator.of(context).pop();});
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Color boxColor=Theme.of(context).primaryColor;
listaDrawer[0]=
isLogoVisible ?
@@ -191,27 +222,22 @@ class _AppManagerState extends State<AppManager> {
],
),
));
listaDrawer[listaOrderDrawer[0]+1]=ListTileConversion(listaTitoli[0],"resources/images/lunghezza.png",currentPage==0,(){_onSelectItem(0);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[1]+1]=ListTileConversion(listaTitoli[1],"resources/images/area.png",currentPage==1,(){_onSelectItem(1);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[2]+1]=ListTileConversion(listaTitoli[2],"resources/images/volume.png",currentPage==2,(){_onSelectItem(2);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[3]+1]=ListTileConversion(listaTitoli[3],"resources/images/tempo.png",currentPage==3,(){_onSelectItem(3);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[4]+1]=ListTileConversion(listaTitoli[4],"resources/images/temperatura.png",currentPage==4,(){_onSelectItem(4);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[5]+1]=ListTileConversion(listaTitoli[5],"resources/images/velocita.png",currentPage==5,(){_onSelectItem(5);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[6]+1]=ListTileConversion(listaTitoli[6],"resources/images/prefissi.png",currentPage==6,(){_onSelectItem(6);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[7]+1]=ListTileConversion(listaTitoli[7],"resources/images/massa.png",currentPage==7,(){_onSelectItem(7);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[8]+1]=ListTileConversion(listaTitoli[8],"resources/images/pressione.png",currentPage==8,(){_onSelectItem(8);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[9]+1]=ListTileConversion(listaTitoli[9],"resources/images/energia.png",currentPage==9,(){_onSelectItem(9);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[10]+1]=ListTileConversion(listaTitoli[10],"resources/images/angoli.png",currentPage==10,(){_onSelectItem(10);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[11]+1]=ListTileConversion(listaTitoli[11],"resources/images/valuta.png",currentPage==11,(){_onSelectItem(11);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[12]+1]=ListTileConversion(listaTitoli[12],"resources/images/scarpe.png",currentPage==12,(){_onSelectItem(12);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[13]+1]=ListTileConversion(listaTitoli[13],"resources/images/dati.png",currentPage==13,(){_onSelectItem(13);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[14]+1]=ListTileConversion(listaTitoli[14],"resources/images/potenza.png",currentPage==14,(){_onSelectItem(14);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[15]+1]=ListTileConversion(listaTitoli[15],"resources/images/forza.png",currentPage==15,(){_onSelectItem(15);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[16]+1]=ListTileConversion(listaTitoli[16],"resources/images/torque.png",currentPage==16,(){_onSelectItem(16);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[17]+1]=ListTileConversion(listaTitoli[17],"resources/images/consumo.png",currentPage==17,(){_onSelectItem(17);Navigator.of(context).pop();});
listaDrawer[listaOrderDrawer[18]+1]=ListTileConversion(listaTitoli[18],"resources/images/conversione_base.png",currentPage==18,(){_onSelectItem(18);Navigator.of(context).pop();});
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
listaDrawer[1] = myExpansionTile(
title: "Tools",
leadingImageAsset: "resources/images/tools.png",
selectedColor: Theme.of(context).accentColor,
unSelectedColor: MediaQuery.of(context).platformBrightness==Brightness.dark ? Color(0xFFCCCCCC) : Colors.black54,
children: listDrawerTools,
selected: currentTopic==0,
);
listaDrawer[2]=myExpansionTile(
title: "Conversions",
leadingImageAsset: "resources/images/conversion.png",
selectedColor: Theme.of(context).accentColor,
unSelectedColor: MediaQuery.of(context).platformBrightness==Brightness.dark ? Color(0xFFCCCCCC) : Colors.black54,
children: listaDrawerConversions,
selected: currentTopic==1,
);
}
_changeOrderDrawer(BuildContext context,String title) async{
@@ -245,9 +271,10 @@ class _AppManagerState extends State<AppManager> {
}
_onSelectItem(int index) {
if(currentPage!=index){
_onSelectItem(int topic, int index) {
if(!(currentTopic==topic && currentPage==index)){
setState(() {
currentTopic = topic;
currentPage = index;
});
}
@@ -300,6 +327,31 @@ class _AppManagerState extends State<AppManager> {
}
}
Builder _getCurrentBody(){
if(currentTopic == 0){ //tools
return Builder(
builder: (context) =>
ToolsManager(
() { Scaffold.of(context).openDrawer();},//open Drawer
),
);
}
return Builder( //conversions
builder: (context) =>
ConversionManager(
() { Scaffold.of(context).openDrawer(); },//open Drawer
currentPage, //first page
_onSelectItem, //change page
listaTitoli,
showRateSnackBar,
listaConversioni,
listaOrder,
lastUpdateCurrency,
currencyValues
),
);
}
@override
Widget build(BuildContext context) {
@@ -314,9 +366,6 @@ class _AppManagerState extends State<AppManager> {
initializeTiles();
/*if(listaConversioni==null)
return SizedBox();
*/
return Scaffold(
resizeToAvoidBottomInset: true,
drawer: new Drawer(
@@ -325,20 +374,7 @@ class _AppManagerState extends State<AppManager> {
children: listaDrawer,
),
),
body: Builder(
builder: (context) =>
ConversionManager(
() { Scaffold.of(context).openDrawer(); }, //open Drawer
currentPage, //first page
_onSelectItem, //change page
listaTitoli,
showRateSnackBar,
listaConversioni,
listaOrder,
lastUpdateCurrency,
currencyValues
),
)
body: _getCurrentBody()
);
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ import "dart:convert";
bool isCurrencyLoading=true;
double appBarSize;
Map jsonSearch;
const MAX_CONVERSION_UNITS=19;
class ConversionManager extends StatefulWidget{
final Function openDrawer;
+352
View File
@@ -0,0 +1,352 @@
import 'package:converterpro/utils/Localization.dart';
import 'package:flutter/material.dart';
import 'package:converterpro/utils/Utils.dart';
const int ANIMATION_DURATION = 300; //milliseconds
const int ANIMATIONS_OVERLAY = 10; //percentage (0-100)
List<int> positions = [0, 1, 2];
String dataSize = "MB";
String dataSpeed = "MB/s";
String dataDuration = "s";
List<TextEditingController> tecList = [TextEditingController(), TextEditingController(), TextEditingController()];
class ToolsManager extends StatefulWidget {
final Function openDrawer;
ToolsManager(this.openDrawer);
@override
_ToolsManager createState() => _ToolsManager();
}
class _ToolsManager extends State<ToolsManager> {
List<Widget> firstCard = new List(3);
@override
Widget build(BuildContext context) {
firstCard[0] = MyListTile(
key: ValueKey(0),
selected: positions[2] == 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: tecList[0],
enabled: positions[2] != 0,
decoration: InputDecoration(labelText: "Data size"),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text) {
if (tecList[positions[0]].text != "" && tecList[positions[1]].text != "") {
setState(() {
tecList[positions[2]].text = getResults(positions[2],
dataSize: double.tryParse(tecList[0].text),
transmissionSpeed: double.tryParse(tecList[1].text),
transferDuration: double.tryParse(tecList[2].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: () {
if (positions[2] != 0) {
setState(() {
swapTwoElementsList(positions, positions.indexWhere((element) => element == 0), 2);
});
}
},
);
firstCard[1] = MyListTile(
key: ValueKey(1),
selected: positions[2] == 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: tecList[1],
enabled: positions[2] != 1,
decoration: InputDecoration(labelText: "Transmission speed"),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text) {
if (tecList[positions[0]].text != "" && tecList[positions[1]].text != "") {
setState(() {
tecList[positions[2]].text = getResults(positions[2],
dataSize: double.tryParse(tecList[0].text),
transmissionSpeed: double.tryParse(tecList[1].text),
transferDuration: double.tryParse(tecList[2].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: () {
if (positions[2] != 1) {
setState(() {
swapTwoElementsList(positions, positions.indexWhere((element) => element == 1), 2);
});
}
},
);
firstCard[2] = MyListTile(
key: ValueKey(2),
selected: positions[2] == 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: tecList[2],
enabled: positions[2] != 2,
decoration: InputDecoration(labelText: "Data transfer duration"),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
onChanged: (String text) {
if (tecList[positions[0]].text != "" && tecList[positions[1]].text != "") {
setState(() {
tecList[positions[2]].text = getResults(positions[2],
dataSize: double.tryParse(tecList[0].text),
transmissionSpeed: double.tryParse(tecList[1].text),
transferDuration: double.tryParse(tecList[2].text))
.toString();
});
}
},
),
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: () {
if (positions[2] != 2) {
setState(() {
swapTwoElementsList(positions, positions.indexWhere((element) => element == 2), 2);
});
}
},
);
return Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Image.asset(
"resources/images/calculator.png",
width: 30.0,
)),
bottomNavigationBar: BottomAppBar(
color: Theme.of(context).primaryColor,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Builder(builder: (context) {
return IconButton(
tooltip: MyLocalizations.of(context).trans('menu'),
icon: Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {
widget.openDrawer();
});
}),
Row(
children: <Widget>[
IconButton(
tooltip: MyLocalizations.of(context).trans('elimina_tutto'),
icon: Icon(Icons.clear, color: Colors.white),
onPressed: () {
setState(() {
tecList[0].text = tecList[1].text = tecList[2].text = "";
});
},
),
IconButton(
tooltip: MyLocalizations.of(context).trans('cerca'),
icon: Icon(
Icons.search,
color: Colors.white,
),
onPressed: () {},
),
],
)
],
),
),
body: ListView(
padding: EdgeInsets.all(10),
children: [
BigTitle(
text: "Data transfer",
subtitle: "",
),
GenericCard(
title: "Data size - Speed - Data transfer duration",
body: Column(
children: [
MyAnimatedSwitcher(
child: firstCard[positions[0]],
tilePosition: positions[0],
duration: ANIMATION_DURATION,
animationsOverlay: ANIMATIONS_OVERLAY,
selected: false,
),
MyAnimatedSwitcher(
child: firstCard[positions[1]],
tilePosition: positions[1],
duration: ANIMATION_DURATION,
animationsOverlay: ANIMATIONS_OVERLAY,
selected: false,
),
Divider(thickness: 1),
MyAnimatedSwitcher(
child: firstCard[positions[2]],
tilePosition: positions[2],
duration: ANIMATION_DURATION,
animationsOverlay: ANIMATIONS_OVERLAY,
selected: true,
),
],
),
)
],
));
}
}
double getResults(int selection, {double transmissionSpeed, double transferDuration, double dataSize}) {
switch (selection) {
case 0:
return (transmissionSpeed * transferDuration);
case 1:
return (dataSize / transferDuration);
case 2:
return (dataSize / transmissionSpeed);
}
return null;
}
class MyAnimatedSwitcher extends StatelessWidget {
final int duration;
final int animationsOverlay;
final Widget child;
final bool selected;
final int tilePosition;
MyAnimatedSwitcher({this.duration, this.animationsOverlay, this.child, this.selected, this.tilePosition});
@override
Widget build(BuildContext context) {
return AnimatedSwitcher(
duration: Duration(milliseconds: selected ? (duration * 200 / (animationsOverlay + 100)).round() : duration),
switchInCurve: selected ? Interval((100 - ANIMATIONS_OVERLAY) / 200, 1, curve: Curves.linear) : Curves.linear,
switchOutCurve: selected ? Interval(0, (ANIMATIONS_OVERLAY + 100) / 200, curve: Curves.linear) : Curves.linear,
child: child,
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(tilePosition)) {
return ClipRect(
child: SlideTransition(
position: inAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
}
return ClipRect(
child: SlideTransition(
position: outAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
);
});
}
}
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;
MyListTile({this.key, this.onTap, this.title, this.unselectedLeading, this.selectedLeading, this.selected, this.trailing});
@override
Widget build(BuildContext context) {
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,
),
);
}
}
+82 -3
View File
@@ -94,6 +94,41 @@ class UnitCard extends StatelessWidget{
}
}
class GenericCard extends StatelessWidget{
GenericCard({this.title, this.body});
final String title;
final Widget body;
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
new Container(
padding: EdgeInsets.only(top: 14.0),
child: new Card(
child: Padding(
padding: EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0),
child: this.body
),
elevation: 4.0,
)),
title==null?SizedBox() : Align(
alignment: Alignment(0.95, -0.9),
child: Card(
elevation: 4.0,
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Text(title, style: TextStyle(color: Colors.white, fontSize: 13.0,fontWeight: FontWeight.bold),),
),
color: Theme.of(context).accentColor,
),
)
],
);
}
}
class Calculator extends StatefulWidget{
Calculator(this.color, this.width);
@@ -406,18 +441,18 @@ class SearchGridTile extends StatelessWidget {
}
}
class ListTileConversion extends StatefulWidget{
class ListTileDrawer extends StatefulWidget{
final String text;
final String imagePath;
final bool selected;
final Function onTapFunction;
ListTileConversion(this.text, this.imagePath, this.selected,this.onTapFunction);
ListTileDrawer(this.text, this.imagePath, this.selected,this.onTapFunction);
@override
_ListTileConversion createState() => new _ListTileConversion();
}
class _ListTileConversion extends State<ListTileConversion>{
class _ListTileConversion extends State<ListTileDrawer>{
@override
Widget build(BuildContext context) {
@@ -441,4 +476,48 @@ class _ListTileConversion extends State<ListTileConversion>{
selectedColor: Theme.of(context).accentColor//widget.color,
);
}
}
class myExpansionTile extends StatefulWidget{
final String title;
final String leadingImageAsset;
final Color selectedColor;
final Color unSelectedColor;
final List<Widget> children;
bool selected;
myExpansionTile({this.title, this.leadingImageAsset, this.selectedColor, this.unSelectedColor, this.selected=false, this.children});
@override
_myExpansionTile createState() => new _myExpansionTile();
}
class _myExpansionTile extends State<myExpansionTile>{
@override
Widget build(BuildContext context) {
return Theme(
data: ThemeData(unselectedWidgetColor: widget.unSelectedColor, accentColor: widget.selectedColor),
child: ExpansionTile(
title: Text(
widget.title,
style: TextStyle(fontSize: 20, color: widget.selected ? widget.selectedColor : widget.unSelectedColor, fontWeight: FontWeight.bold),
),
leading: Image.asset(widget.leadingImageAsset, width: 30, color: widget.selected ? widget.selectedColor : widget.unSelectedColor),
initiallyExpanded: widget.selected,
children: widget.children,
),
);
}
}
List swapTwoElementsList(List list, int pos1, int pos2){
if(list.length>=max(pos1,pos2)){
var temp = list[pos1];
list[pos1] = list[pos2];
list[pos2] = temp;
return list;
}
throw ("OutOfBoundsException");
}
+19 -19
View File
@@ -7,49 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.5.0-nullsafety"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0-nullsafety.2"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.13"
version: "1.15.0-nullsafety.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.0-nullsafety"
file:
dependency: transitive
description:
@@ -104,21 +104,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.8"
version: "0.12.10-nullsafety"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.2"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety"
path_provider_linux:
dependency: transitive
description:
@@ -221,49 +221,49 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.5"
version: "1.10.0-nullsafety"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.17"
version: "0.2.19-nullsafety"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0-nullsafety.2"
url_launcher:
dependency: "direct main"
description:
@@ -305,7 +305,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.2"
xdg_directories:
dependency: transitive
description:
@@ -314,5 +314,5 @@ packages:
source: hosted
version: "0.1.0"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
dart: ">=2.10.0-0.0.dev <2.10.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
+3
View File
@@ -74,3 +74,6 @@ flutter:
- resources/images/forza.png
- resources/images/consumo.png
- 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: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B