mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 10:09:40 +00:00
using Align to keep the container stick with elemnts number (tested for many items)
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/model/community_model.dart';
|
||||||
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
|
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
@ -16,49 +17,26 @@ class ManageHomeView extends StatelessWidget {
|
|||||||
var spaces = HomeCubit.getInstance().spaces;
|
var spaces = HomeCubit.getInstance().spaces;
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: 'Manage Your Home',
|
title: 'Manage Your Home',
|
||||||
height: MediaQuery.sizeOf(context).height,
|
child: Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
child: spaces.isEmpty
|
child: spaces.isEmpty
|
||||||
? const Center(
|
? const Center(child: BodyMedium(text: 'No spaces found'))
|
||||||
child: BodyMedium(text: 'No spaces found'),
|
|
||||||
)
|
|
||||||
: DefaultContainer(
|
: DefaultContainer(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 25),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
itemCount: spaces.length,
|
itemCount: spaces.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == spaces.length - 1) {
|
final space = spaces[index];
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(CustomPageRoute(
|
Navigator.of(context).push(
|
||||||
builder: (context) => HomeSettingsView(
|
CustomPageRoute(
|
||||||
space: spaces[index],
|
builder: (context) =>
|
||||||
)));
|
HomeSettingsView(space: space),
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
BodyMedium(text: StringHelpers.toTitleCase(spaces[index].name)),
|
|
||||||
const Icon(
|
|
||||||
Icons.arrow_forward_ios,
|
|
||||||
color: ColorsManager.greyColor,
|
|
||||||
size: 15,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
return InkWell(
|
|
||||||
onTap: () {
|
|
||||||
//TODO refactor the routing to use named routes
|
|
||||||
// Navigator.of(context).pushNamed(
|
|
||||||
// '/home_settings',
|
|
||||||
// arguments: spaces[index],
|
|
||||||
// );
|
|
||||||
|
|
||||||
Navigator.of(context).push(CustomPageRoute(
|
|
||||||
builder: (context) => HomeSettingsView(
|
|
||||||
space: spaces[index],
|
|
||||||
)));
|
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -67,7 +45,8 @@ class ManageHomeView extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
BodyMedium(text: HomeCubit.getInstance().spaces[index].name),
|
BodyMedium(
|
||||||
|
text: StringHelpers.toTitleCase(space.name)),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.arrow_forward_ios,
|
Icons.arrow_forward_ios,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
@ -75,6 +54,7 @@ class ManageHomeView extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
if (index != spaces.length - 1)
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 15),
|
margin: const EdgeInsets.symmetric(vertical: 15),
|
||||||
height: 1,
|
height: 1,
|
||||||
@ -83,7 +63,10 @@ class ManageHomeView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user