|
|
|
@ -13,55 +13,53 @@
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:meta/meta.dart';
|
|
|
|
|
import 'package:scoped_model/scoped_model.dart';
|
|
|
|
|
|
|
|
|
|
import 'colors.dart';
|
|
|
|
|
import 'model/app_state_model.dart';
|
|
|
|
|
import 'model/product.dart';
|
|
|
|
|
|
|
|
|
|
class CategoryMenuPage extends StatelessWidget {
|
|
|
|
|
final Category currentCategory;
|
|
|
|
|
final ValueChanged<Category> onCategoryTap;
|
|
|
|
|
final List<Category> _categories = Category.values;
|
|
|
|
|
|
|
|
|
|
const CategoryMenuPage({
|
|
|
|
|
Key key,
|
|
|
|
|
@required this.currentCategory,
|
|
|
|
|
@required this.onCategoryTap,
|
|
|
|
|
}) : assert(currentCategory != null),
|
|
|
|
|
assert(onCategoryTap != null);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Widget _buildCategory(Category category, BuildContext context) {
|
|
|
|
|
final categoryString =
|
|
|
|
|
category.toString().replaceAll('Category.', '').toUpperCase();
|
|
|
|
|
final ThemeData theme = Theme.of(context);
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () => onCategoryTap(category),
|
|
|
|
|
child: category == currentCategory
|
|
|
|
|
? Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
SizedBox(height: 16.0),
|
|
|
|
|
Text(
|
|
|
|
|
categoryString,
|
|
|
|
|
style: theme.textTheme.body2,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 14.0),
|
|
|
|
|
Container(
|
|
|
|
|
width: 70.0,
|
|
|
|
|
height: 2.0,
|
|
|
|
|
color: kShrinePink400,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
categoryString,
|
|
|
|
|
style: theme.textTheme.body2
|
|
|
|
|
.copyWith(color: kShrineBrown900.withAlpha(153)),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
return ScopedModelDescendant<AppStateModel>(
|
|
|
|
|
builder: (context, child, model) => GestureDetector(
|
|
|
|
|
onTap: () => model.setCategory(category),
|
|
|
|
|
child: model.selectedCategory == category
|
|
|
|
|
? Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
SizedBox(height: 16.0),
|
|
|
|
|
Text(
|
|
|
|
|
categoryString,
|
|
|
|
|
style: theme.textTheme.body2,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 14.0),
|
|
|
|
|
Container(
|
|
|
|
|
width: 70.0,
|
|
|
|
|
height: 2.0,
|
|
|
|
|
color: kShrinePink400,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
categoryString,
|
|
|
|
|
style: theme.textTheme.body2
|
|
|
|
|
.copyWith(color: kShrineBrown900.withAlpha(153)),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|