From 3cfa5cdd1928da753237daa9ac8a5343805df99d Mon Sep 17 00:00:00 2001 From: Nov1kov Date: Sun, 29 Sep 2019 08:01:42 +0300 Subject: [PATCH] fix padding and dropdown --- assets/routin_jobs.json | 2 +- lib/hellopage.dart | 44 +++++++++++++++++++++++++++++++++++------ lib/resultpage.dart | 17 +++++++++------- lib/splash.dart | 2 +- lib/util.dart | 1 + 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/assets/routin_jobs.json b/assets/routin_jobs.json index ec85135..8b18fa0 100644 --- a/assets/routin_jobs.json +++ b/assets/routin_jobs.json @@ -37,7 +37,7 @@ "name": "специалист по закупкам", "predictions": [ { - "name": "сетевой юрист", + "name": "Сетевой юрист", "rate": 93 }, { diff --git a/lib/hellopage.dart b/lib/hellopage.dart index d8cb156..5d81f93 100644 --- a/lib/hellopage.dart +++ b/lib/hellopage.dart @@ -21,9 +21,28 @@ class _HelloPageState extends State { List> getDropDownMenuItems() { List> items = new List(); var jobs = Repository().routineJobs; - for( var i = 0 ; i < jobs.length; i++ ){ - var job = Repository().routineJobs[i]; - items.add(new DropdownMenuItem(value: job.name, child: new Text(job.name))); + for (var i = 0; i < jobs.length; i++) { + var job = jobs[i]; + items.add(new DropdownMenuItem( + value: job.name, + child: Row( + children: [ + Container( + padding: EdgeInsets.fromLTRB(12, 0, 16, 0), + child: Image.asset('assets/auth_page_image.png'), + ), + Container( + alignment: Alignment(0.0, 0.0), + child: Text( + job.name, + style: TextStyle( + fontSize: 16, + color: CustomColors.TextHeader, + fontWeight: FontWeight.w500), + ), + ), + ], + ))); } return items; } @@ -33,7 +52,8 @@ class _HelloPageState extends State { _selectedJob = selectedJob; Navigator.push( context, - MaterialPageRoute(builder: (context) => ResultPage(selectedJob: _selectedJob)), + MaterialPageRoute( + builder: (context) => ResultPage(selectedJob: _selectedJob)), ); }); } @@ -95,8 +115,9 @@ class _HelloPageState extends State { flex: 3, child: new Center( child: Container( - width: MediaQuery.of(context).size.width * 0.8, + width: MediaQuery.of(context).size.width * 0.84, height: 70, + padding: EdgeInsets.fromLTRB(16, 16, 16, 16), decoration: BoxDecoration( color: Colors.white, border: new Border.all( @@ -105,13 +126,24 @@ class _HelloPageState extends State { style: BorderStyle.solid), borderRadius: new BorderRadius.all(new Radius.circular(15.0)), + boxShadow: [ui.getShadow()], ), - child: new DropdownButton( + child: Container( + child: DropdownButton( + hint: Text( + "Выбрать", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, + color: CustomColors.DropdownHintText, + ), + ), value: _selectedJob, items: _dropDownMenuItems, onChanged: changedDropDownItem, icon: Image.asset('assets/down_arrow.png'), ), + ), ), ), ), diff --git a/lib/resultpage.dart b/lib/resultpage.dart index 788f3c4..bb48569 100644 --- a/lib/resultpage.dart +++ b/lib/resultpage.dart @@ -82,7 +82,6 @@ class _ResultPageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(48, 0, 0, 0), height: 120.0, child: PredictionsList(predictedJobs, onTappedItem), ), @@ -245,11 +244,15 @@ class PredictionsList extends StatelessWidget { } void itemOnTapped(int index) { - selectedIndex = index; - onItemTap(index); + selectedIndex = index - 1; + onItemTap(index - 1); } Widget _buildProductItem(BuildContext context, int index) { + if (index == 0){ + return SizedBox(width: 48); + } + var itJob = predictionItJobs[index - 1]; return Container( width: 130, margin: const EdgeInsets.symmetric(horizontal: 8), @@ -262,7 +265,7 @@ class PredictionsList extends StatelessWidget { child: Column( children: [ Stack(children: [ - Image.asset('assets/' + predictionItJobs[index].image), + Image.asset('assets/' + itJob.image), Container( height: 60, alignment: Alignment(1.0, 1.0), @@ -277,7 +280,7 @@ class PredictionsList extends StatelessWidget { new BorderRadius.only(topLeft: Radius.circular(35.0)), ), child: Text( - predictionItJobs[index].predictRate.toString() + "%", + itJob.predictRate.toString() + "%", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 11, @@ -286,7 +289,7 @@ class PredictionsList extends StatelessWidget { ), ]), SizedBox(height: 12), - Text(predictionItJobs[index].name, + Text(itJob.name, style: TextStyle( fontWeight: selectedIndex == index ? FontWeight.bold @@ -303,7 +306,7 @@ class PredictionsList extends StatelessWidget { return ListView.builder( scrollDirection: Axis.horizontal, // Must have an item count equal to the number of items! - itemCount: predictionItJobs.length, + itemCount: predictionItJobs.length + 1, // A callback that will return a widget. itemBuilder: _buildProductItem, ); diff --git a/lib/splash.dart b/lib/splash.dart index a1dbffe..11c4bbc 100644 --- a/lib/splash.dart +++ b/lib/splash.dart @@ -40,7 +40,7 @@ class _splashscreenState extends State { void openHelloPage() { Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => QuizPage(), + builder: (context) => HelloPage(), )); } diff --git a/lib/util.dart b/lib/util.dart index db39f9a..13ddc80 100644 --- a/lib/util.dart +++ b/lib/util.dart @@ -66,6 +66,7 @@ class CustomColors { static const Color AccentColor = Color.fromRGBO(84, 104, 255, 1); static const Color AccentShadow = Color.fromRGBO(84, 184, 255, 0.68); static const Color GrayShadow = Color.fromRGBO(190, 190, 190, 0.2); + static const Color DropdownHintText = Color.fromRGBO(195,201,240, 1); static const Color GradientBottom = Color.fromRGBO(194, 212, 248, 1); static const Color StatusBarColor = Color.fromRGBO(194, 212, 248, 0.3);