Skip to content

Commit

Permalink
fix padding and dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Nov1kov committed Sep 29, 2019
1 parent 0621159 commit 3cfa5cd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
2 changes: 1 addition & 1 deletion assets/routin_jobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"name": "специалист по закупкам",
"predictions": [
{
"name": "сетевой юрист",
"name": "Сетевой юрист",
"rate": 93
},
{
Expand Down
44 changes: 38 additions & 6 deletions lib/hellopage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,28 @@ class _HelloPageState extends State<HelloPage> {
List<DropdownMenuItem<String>> getDropDownMenuItems() {
List<DropdownMenuItem<String>> 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: <Widget>[
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;
}
Expand All @@ -33,7 +52,8 @@ class _HelloPageState extends State<HelloPage> {
_selectedJob = selectedJob;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ResultPage(selectedJob: _selectedJob)),
MaterialPageRoute(
builder: (context) => ResultPage(selectedJob: _selectedJob)),
);
});
}
Expand Down Expand Up @@ -95,8 +115,9 @@ class _HelloPageState extends State<HelloPage> {
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(
Expand All @@ -105,13 +126,24 @@ class _HelloPageState extends State<HelloPage> {
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'),
),
),
),
),
),
Expand Down
17 changes: 10 additions & 7 deletions lib/resultpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class _ResultPageState extends State<ResultPage> {
),
),
Container(
margin: EdgeInsets.fromLTRB(48, 0, 0, 0),
height: 120.0,
child: PredictionsList(predictedJobs, onTappedItem),
),
Expand Down Expand Up @@ -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),
Expand All @@ -262,7 +265,7 @@ class PredictionsList extends StatelessWidget {
child: Column(
children: <Widget>[
Stack(children: <Widget>[
Image.asset('assets/' + predictionItJobs[index].image),
Image.asset('assets/' + itJob.image),
Container(
height: 60,
alignment: Alignment(1.0, 1.0),
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class _splashscreenState extends State<splashscreen> {

void openHelloPage() {
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => QuizPage(),
builder: (context) => HelloPage(),
));
}

Expand Down
1 change: 1 addition & 0 deletions lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3cfa5cd

Please sign in to comment.