#sprint-1
This commit is contained in:
parent
16a4323da7
commit
63457cdc67
24
example/lib/categories_section.dart
Normal file
24
example/lib/categories_section.dart
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:ui_kit/categories.dart';
|
||||||
|
import 'package:ui_kit/utils.dart';
|
||||||
|
|
||||||
|
class CategoriesSection extends StatefulWidget {
|
||||||
|
const CategoriesSection({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CategoriesSection> createState() => _CategoriesSectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CategoriesSectionState extends State<CategoriesSection> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.only(bottom: height(context) * 5),
|
||||||
|
width: width(context) * 100,
|
||||||
|
height: 48,
|
||||||
|
child: CategoriesWidget(
|
||||||
|
itemsList: ['Популярные', 'Женщинам', 'Мужчинам'],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ import 'package:example/bottom_sheet_section.dart';
|
|||||||
import 'package:example/button_section.dart';
|
import 'package:example/button_section.dart';
|
||||||
import 'package:example/card_section.dart';
|
import 'package:example/card_section.dart';
|
||||||
import 'package:example/cart_button_section.dart';
|
import 'package:example/cart_button_section.dart';
|
||||||
|
import 'package:example/categories_section.dart';
|
||||||
import 'package:example/chips_section.dart';
|
import 'package:example/chips_section.dart';
|
||||||
import 'package:example/colors_section.dart';
|
import 'package:example/colors_section.dart';
|
||||||
import 'package:example/counter_section.dart';
|
import 'package:example/counter_section.dart';
|
||||||
@ -53,6 +54,7 @@ class MainApp extends StatelessWidget {
|
|||||||
ChipsSection(),
|
ChipsSection(),
|
||||||
LogInSection(),
|
LogInSection(),
|
||||||
CartButtonSection(),
|
CartButtonSection(),
|
||||||
|
CategoriesSection(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -7,10 +7,12 @@ class PrimaryCard extends StatefulWidget {
|
|||||||
required this.title,
|
required this.title,
|
||||||
required this.category,
|
required this.category,
|
||||||
required this.price,
|
required this.price,
|
||||||
|
this.onChange,
|
||||||
});
|
});
|
||||||
final String title;
|
final String title;
|
||||||
final String category;
|
final String category;
|
||||||
final String price;
|
final String price;
|
||||||
|
final Function(bool value)? onChange;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PrimaryCard> createState() => _PrimaryCardState();
|
State<PrimaryCard> createState() => _PrimaryCardState();
|
||||||
@ -45,6 +47,7 @@ class _PrimaryCardState extends State<PrimaryCard> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
inCart = !inCart;
|
inCart = !inCart;
|
||||||
|
widget.onChange!(inCart);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
size: 'small',
|
size: 'small',
|
||||||
|
46
lib/categories.dart
Normal file
46
lib/categories.dart
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:ui_kit/ui_kit.dart';
|
||||||
|
|
||||||
|
class CategoriesWidget extends StatefulWidget {
|
||||||
|
const CategoriesWidget({super.key, required this.itemsList});
|
||||||
|
final List<String> itemsList;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CategoriesWidget> createState() => _CategoriesWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CategoriesWidgetState extends State<CategoriesWidget> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
String selectedItem = widget.itemsList[0];
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
width: width(context) * 100,
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: widget.itemsList.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
final currentItem = widget.itemsList[index];
|
||||||
|
Color currentItemColor = selectedItem == widget.itemsList[index]
|
||||||
|
? primaryColor
|
||||||
|
: inputBgColor;
|
||||||
|
return Chips(
|
||||||
|
onPressed: () => {
|
||||||
|
setState(() {
|
||||||
|
selectedItem = currentItem;
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
buttonText: widget.itemsList[index],
|
||||||
|
buttonStyle: textMedium.copyWith(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: selectedItem == widget.itemsList[index]
|
||||||
|
? whiteColor
|
||||||
|
: descColor,
|
||||||
|
),
|
||||||
|
bgColor: currentItemColor,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,12 @@ class Chips extends StatefulWidget {
|
|||||||
required this.buttonText,
|
required this.buttonText,
|
||||||
required this.buttonStyle,
|
required this.buttonStyle,
|
||||||
required this.bgColor,
|
required this.bgColor,
|
||||||
|
this.onPressed,
|
||||||
});
|
});
|
||||||
final String buttonText;
|
final String buttonText;
|
||||||
final TextStyle buttonStyle;
|
final TextStyle buttonStyle;
|
||||||
final Color bgColor;
|
final Color bgColor;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Chips> createState() => _ChipsState();
|
State<Chips> createState() => _ChipsState();
|
||||||
@ -18,15 +20,20 @@ class Chips extends StatefulWidget {
|
|||||||
class _ChipsState extends State<Chips> {
|
class _ChipsState extends State<Chips> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return GestureDetector(
|
||||||
width: 129,
|
onTap: () {
|
||||||
height: 48,
|
widget.onPressed;
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
},
|
||||||
decoration: BoxDecoration(
|
child: Container(
|
||||||
color: widget.bgColor,
|
width: 129,
|
||||||
borderRadius: BorderRadius.circular(10),
|
height: 48,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: widget.bgColor,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Text(widget.buttonText, style: widget.buttonStyle),
|
||||||
),
|
),
|
||||||
child: Text(widget.buttonText, style: widget.buttonStyle),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,3 +19,4 @@ export 'chips.dart';
|
|||||||
export "cards/log_in_card.dart";
|
export "cards/log_in_card.dart";
|
||||||
export 'cart_button.dart';
|
export 'cart_button.dart';
|
||||||
export 'bubbles.dart';
|
export 'bubbles.dart';
|
||||||
|
export 'categories.dart';
|
||||||
|
@ -1,5 +1,71 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:ui_kit/ui_kit.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('adds one to input values', () {});
|
testWidgets(
|
||||||
|
"Инпут ошибки. Проверяемые параметры: фон, обводка, Наличие текста ошибки и соответствие его цвета",
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
final TextEditingController controller = TextEditingController();
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
builder: (context, child) => Scaffold(
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
InputWidget(
|
||||||
|
controller: controller,
|
||||||
|
hintText: 'This error input',
|
||||||
|
errorText: 'Eror Input Text',
|
||||||
|
isError: 'true',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final input = find.byType(InputWidget);
|
||||||
|
expect(input.hasFound, true);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
testWidgets(
|
||||||
|
"Кнопка chips. Кнопка при значениях status ON и OFF соответствует макету",
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
bool isSelected = false;
|
||||||
|
Color bgColor = primaryColor;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
builder: (context, child) => Scaffold(
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
isSelected = !isSelected;
|
||||||
|
bgColor = bgColor == primaryColor
|
||||||
|
? inputBgColor
|
||||||
|
: primaryColor;
|
||||||
|
},
|
||||||
|
child: Text('Click to make chip enabled'),
|
||||||
|
),
|
||||||
|
Chips(
|
||||||
|
buttonText: 'Testtest',
|
||||||
|
buttonStyle: title2Semibold,
|
||||||
|
bgColor: bgColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final currentWidget = find.widgetWithText(
|
||||||
|
TextButton,
|
||||||
|
'Click to make chip enabled',
|
||||||
|
);
|
||||||
|
await tester.tap(currentWidget);
|
||||||
|
expect(isSelected, true);
|
||||||
|
expect(bgColor, inputBgColor);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user