Fixed the overflow in the login screen, the page is scrollable.

- Fixed Scrolling wasent working in login screen
- Changed Home page to indexed based view instead of PageView
This commit is contained in:
Mohammad Salameh
2024-03-19 13:29:12 +03:00
parent 79279180df
commit 42051bb977
10 changed files with 148 additions and 373 deletions
@@ -27,8 +27,8 @@ class LightsView extends StatelessWidget {
as DeviceModel;
}
List<DeviceModel> lights = [];
if (DevicesCubit.allCategories[1].devices != null) {
for (var device in DevicesCubit.allCategories[1].devices!) {
if (DevicesCubit.allCategories![1].devices != null) {
for (var device in DevicesCubit.allCategories![1].devices!) {
lights.add(device);
}
}
@@ -30,7 +30,7 @@ class LightsViewList extends StatelessWidget {
children: [
const BodySmall(text: "All Lights"),
UniversalSwitch(
category: DevicesCubit.allCategories[1],
category: DevicesCubit.allCategories![1],
),
LightsList(lights: lights),
],
@@ -18,71 +18,80 @@ class WizartSwitches extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return state is DevicesLoading
? const Center(child: CircularProgressIndicator())
: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
padding: const EdgeInsets.only(top: 10),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: DevicesCubit.allCategories.length,
itemBuilder: (_, index) {
return InkWell(
onTap: () {
DevicesCubit.get(context).selectCategory(index);
//Navigate to the chosen category view without animation
return state is! DevicesLoading
? DevicesCubit.allCategories != null
? GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
padding: const EdgeInsets.only(top: 10),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: DevicesCubit.allCategories!.length,
itemBuilder: (_, index) {
return InkWell(
onTap: () {
DevicesCubit.get(context).selectCategory(index);
//Navigate to the chosen category view without animation
Navigator.push(context,
CustomPageRoute(builder: (context) {
return DevicesCubit.get(context).chosenCategoryView!;
}));
},
child: DefaultContainer(
child: Padding(
padding:
const EdgeInsets.only(top: 10, right: 10, left: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
Navigator.push(context,
CustomPageRoute(builder: (context) {
return DevicesCubit.get(context)
.chosenCategoryView!;
}));
},
child: DefaultContainer(
child: Padding(
padding: const EdgeInsets.only(
top: 10, right: 10, left: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
DevicesCubit.allCategories[index].icon!,
fit: BoxFit.contain,
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
DevicesCubit.allCategories![index].icon!,
fit: BoxFit.contain,
),
CustomSwitch(
category:
DevicesCubit.allCategories![index],
),
],
),
CustomSwitch(
category: DevicesCubit.allCategories[index],
Expanded(
child: FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: DevicesCubit
.allCategories![index].name!,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,
fontSize: 24,
color: Colors.grey,
),
),
),
),
],
),
Expanded(
child: FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: DevicesCubit.allCategories[index].name!,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,
fontSize: 24,
color: Colors.grey,
),
),
),
),
],
),
),
),
),
);
},
);
},
)
: const SizedBox.shrink()
: const Center(
child: CircularProgressIndicator(),
);
},
);