Last active
July 15, 2020 06:18
-
-
Save roketstorm/47a64368892b4c971339bd106ce7a4b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(title: 'Список услуг'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: ListView(padding: EdgeInsets.all(16.0), children: <Widget>[ | |
ServiceTile( | |
name: | |
"Очень длинное название услуги с кучей различных слов и ништяков", | |
count: "5", | |
price: "100 ₽"), | |
ServiceTile(name: "Услуга 5", count: "1", price: "5000 ₽"), | |
ServiceTile(name: "Услуга 1", count: "2", price: "750 ₽"), | |
]), | |
), | |
); | |
} | |
} | |
class ServiceTile extends StatelessWidget { | |
final String name; | |
final String count; | |
final String price; | |
ServiceTile({this.name, this.count, this.price}); | |
@override | |
Widget build(BuildContext context) { | |
return ListTile( | |
onTap: () {}, | |
title: Text(name), | |
subtitle: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Text("25000.1"), | |
FlatButton.icon( | |
onPressed: () { | |
_showDialog(context); | |
}, | |
icon: Icon(Icons.create), | |
label: Row(children: <Widget>[ | |
Text(price), | |
Text(" x "), | |
Text(count + " шт."), | |
]), | |
), | |
Text("7000 ₽"), | |
]), | |
); | |
} | |
void _showDialog(BuildContext context) { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
title: Text("Выберите количество"), | |
content: Text("ну допуситим 1"), | |
actions: <Widget>[ | |
FlatButton( | |
onPressed: () { | |
Navigator.of(context).pop(); | |
}, | |
child: Text("OK") | |
) | |
] | |
); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment