Created screens
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
}
|
||||||
BIN
assets/logo.png
Normal file
BIN
assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
290
lib/main.dart
290
lib/main.dart
@@ -8,7 +8,7 @@ void main() {
|
|||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DemoScreen { counter, textField }
|
enum GymLinkScreen { mainPage, basketPage, historyPage }
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
class MyApp extends StatefulWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
@@ -20,9 +20,8 @@ class MyApp extends StatefulWidget {
|
|||||||
|
|
||||||
@js.JSExport()
|
@js.JSExport()
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
final _streanController = StreamController<void>.broadcast();
|
final _streamController = StreamController<void>.broadcast();
|
||||||
DemoScreen _currentDemoScreen = DemoScreen.counter;
|
GymLinkScreen _currentGymLinkScreen = GymLinkScreen.mainPage;
|
||||||
int _counterScreenCount = 0;
|
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -35,39 +34,19 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_streanController.close();
|
_streamController.close();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@js.JSExport()
|
|
||||||
void increment() {
|
|
||||||
if (_currentDemoScreen == DemoScreen.counter) {
|
|
||||||
setState(() {
|
|
||||||
_counterScreenCount++;
|
|
||||||
_streanController.add(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@js.JSExport()
|
|
||||||
void addHandler(void Function() handler) {
|
|
||||||
_streanController.stream.listen((event) {
|
|
||||||
handler();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@js.JSExport()
|
|
||||||
int get count => _counterScreenCount;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Aboba app',
|
title: 'GymLink Module',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: demoScreenRouter(_currentDemoScreen),
|
home: gymLinkScreenRouter(_currentGymLinkScreen),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,147 +59,196 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget demoScreenRouter(DemoScreen which) {
|
Widget gymLinkScreenRouter(GymLinkScreen which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DemoScreen.counter:
|
case GymLinkScreen.mainPage:
|
||||||
return CounterDemo(
|
return MainPage(
|
||||||
title: 'Counter',
|
title: 'Counter',
|
||||||
numToDisplay: _counterScreenCount,
|
isLoading: _isLoading,
|
||||||
incrementHandler: increment,
|
changeGymLinkScreenTo: changeGymLinkScreenTo);
|
||||||
isLoading: _isLoading);
|
case GymLinkScreen.basketPage:
|
||||||
case DemoScreen.textField:
|
return BasketPage(changeGymLinkScreenTo: changeGymLinkScreenTo);
|
||||||
return const TextFieldDemo(title: 'Nasdfs');
|
case GymLinkScreen.historyPage:
|
||||||
|
return HistoryPage(changeGymLinkScreenTo: changeGymLinkScreenTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@js.JSExport()
|
@js.JSExport()
|
||||||
void changeDemoScreenTo(String screenString) {
|
void changeGymLinkScreenTo(String screenString) {
|
||||||
setState(() {
|
setState(() {
|
||||||
switch (screenString) {
|
switch (screenString) {
|
||||||
case 'counter':
|
case 'main':
|
||||||
_currentDemoScreen = DemoScreen.counter;
|
_currentGymLinkScreen = GymLinkScreen.mainPage;
|
||||||
break;
|
break;
|
||||||
case 'textField':
|
case 'basket':
|
||||||
_currentDemoScreen = DemoScreen.textField;
|
_currentGymLinkScreen = GymLinkScreen.basketPage;
|
||||||
|
break;
|
||||||
|
case 'history':
|
||||||
|
_currentGymLinkScreen = GymLinkScreen.historyPage;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CounterDemo extends StatefulWidget {
|
class MainPage extends StatefulWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final int numToDisplay;
|
|
||||||
final VoidCallback incrementHandler;
|
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
|
final void Function(String) changeGymLinkScreenTo;
|
||||||
|
|
||||||
const CounterDemo(
|
const MainPage(
|
||||||
{super.key,
|
{super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.numToDisplay,
|
required this.isLoading,
|
||||||
required this.incrementHandler,
|
required this.changeGymLinkScreenTo});
|
||||||
required this.isLoading});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CounterDemo> createState() => _CounterDemoState();
|
State<MainPage> createState() => _MainPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CounterDemoState extends State<CounterDemo> {
|
class _MainPageState extends State<MainPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: widget.isLoading
|
appBar: widget.isLoading
|
||||||
? null
|
? null
|
||||||
: AppBar(
|
: AppBar(
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Expanded(
|
children: [
|
||||||
child: TextField(
|
Padding(
|
||||||
decoration: InputDecoration(
|
padding: const EdgeInsets.only(right: 8),
|
||||||
hintText: 'Search',
|
child: Image.asset('logo.png', width: 24, height: 24),
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
suffixIcon: const Icon(
|
|
||||||
Icons.search,
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
Align(
|
||||||
const SizedBox(width: 8),
|
alignment: Alignment.centerRight,
|
||||||
ElevatedButton(
|
child: Text('Powered by GymLink',
|
||||||
onPressed: () {},
|
style: Theme.of(context).textTheme.titleSmall),
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.all(0),
|
|
||||||
shape: const CircleBorder(
|
|
||||||
side: BorderSide(
|
|
||||||
color: Colors.blue,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: const Icon(
|
])),
|
||||||
Icons.shopping_basket,
|
body: widget.isLoading
|
||||||
color: Colors.white,
|
? const Center(child: CircularProgressIndicator())
|
||||||
size: 36,
|
: Column(
|
||||||
),
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {},
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.all(0),
|
|
||||||
shape: const CircleBorder(
|
|
||||||
side: BorderSide(
|
|
||||||
color: Colors.blue,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.history,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 36,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: widget.isLoading
|
|
||||||
? const Center(child: CircularProgressIndicator())
|
|
||||||
: const Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Row(
|
||||||
'Здесь будут товары',
|
children: [
|
||||||
),
|
Expanded(
|
||||||
],
|
child: TextField(
|
||||||
),
|
decoration: InputDecoration(
|
||||||
),
|
hintText: 'Search',
|
||||||
);
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
suffixIcon: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
debugPrint('tap on search icon');
|
||||||
|
},
|
||||||
|
child: const Icon(
|
||||||
|
Icons.search,
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
widget.changeGymLinkScreenTo('basket');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
backgroundColor: Colors.blue,
|
||||||
|
shape: const CircleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color: Colors.blue,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.shopping_basket,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
widget.changeGymLinkScreenTo('history');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
backgroundColor: Colors.blue,
|
||||||
|
shape: const CircleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color: Colors.blue,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.history,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
])
|
||||||
|
// : const Center(
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: <Widget>[
|
||||||
|
// Text(
|
||||||
|
// 'Здесь будут товары',
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextFieldDemo extends StatelessWidget {
|
class BasketPage extends StatelessWidget {
|
||||||
const TextFieldDemo({super.key, required this.title});
|
final void Function(String) changeGymLinkScreenTo;
|
||||||
final String title;
|
const BasketPage({super.key, required this.changeGymLinkScreenTo});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(title),
|
leading: IconButton(
|
||||||
),
|
icon: const Icon(Icons.arrow_back),
|
||||||
body: const Center(
|
onPressed: () => changeGymLinkScreenTo('main'),
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(14.0),
|
|
||||||
child: TextField(
|
|
||||||
maxLines: null,
|
|
||||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
|
||||||
),
|
),
|
||||||
|
title: const Text('Корзина'),
|
||||||
),
|
),
|
||||||
),
|
body: const Center(
|
||||||
);
|
child: Text('Корзина'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HistoryPage extends StatelessWidget {
|
||||||
|
final void Function(String) changeGymLinkScreenTo;
|
||||||
|
const HistoryPage({super.key, required this.changeGymLinkScreenTo});
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
onPressed: () => changeGymLinkScreenTo('main'),
|
||||||
|
),
|
||||||
|
title: const Text('История заказов'),
|
||||||
|
),
|
||||||
|
body: const Center(
|
||||||
|
child: Text('История заказов'),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ flutter:
|
|||||||
# included with your application, so that you can use the icons in
|
# included with your application, so that you can use the icons in
|
||||||
# the material Icons class.
|
# the material Icons class.
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
assets:
|
||||||
|
- assets/logo.png
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
# assets:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#flutter_target {
|
#flutter_target {
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
width: 320px;
|
width: 480px;
|
||||||
height: 480px;
|
height: 600px;
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
transition: all 150ms ease-in;
|
transition: all 150ms ease-in;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user