Skip to content

Commit

Permalink
Resolved Merge Conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberWake committed Jun 11, 2021
2 parents 9d8d7a3 + 969d29e commit 68bc3bc
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 39 deletions.
2 changes: 1 addition & 1 deletion lib/services/user_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'navigation_service.dart';

class UserConfig with ChangeNotifier {
late User? _currentUser = User(id: 'null', authToken: 'null');
late OrgInfo? _currentOrg;
late OrgInfo? _currentOrg = OrgInfo(name: 'Organization Name', id: 'null');

OrgInfo get currentOrg => _currentOrg!;
set currentOrg(OrgInfo org) => _currentOrg = org;
Expand Down
7 changes: 7 additions & 0 deletions lib/view_model/explore_events_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import 'package:talawa/models/organization/org_info.dart';
import 'package:talawa/view_model/base_view_model.dart';

class ExploreEventsViewModel extends BaseModel {
String _chosenValue = 'My Events';
final List<Event> _events = [];
late OrgInfo currentOrg;

String get chosenValue => _chosenValue;
choseValue(String value) {
_chosenValue = value;
notifyListeners();
}

List<Event> get events => _events;

void initialise(OrgInfo org) {
Expand Down
16 changes: 5 additions & 11 deletions lib/view_model/main_screen_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@ import 'package:talawa/models/user/user_info.dart';
import 'package:talawa/services/navigation_service.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/view_model/base_view_model.dart';
import 'package:talawa/views/after_auth_screens/add_post_page.dart';
import 'package:talawa/views/after_auth_screens/events/explore_events.dart';
import 'package:talawa/views/after_auth_screens/feed_page/organization_feed.dart';
import 'package:talawa/widgets/raised_round_edge_button.dart';

import '../locator.dart';

class MainScreenViewModel extends BaseModel {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
late List<Widget> childrenPage;
int currentIndex = 0;

initialize() {
childrenPage = [
const OrganizationFeed(
key: Key("OrganizationFeed"),
),
const ExploreEvents(
key: Key('ExploreEvents'),
),
Container(
child: const Center(
child: Text('Post Screen'),
),
),
OrganizationFeed(key: const Key("HomeView"), drawerKey: scaffoldKey),
ExploreEvents(key: const Key('ExploreEvents'), drawerKey: scaffoldKey),
AddPost(key: const Key('AddPost'), drawerKey: scaffoldKey),
Container(
child: const Center(
child: Text('Chat Screen'),
Expand Down
78 changes: 78 additions & 0 deletions lib/views/after_auth_screens/add_post_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';

class AddPost extends StatelessWidget {
const AddPost({Key? key, this.drawerKey}) : super(key: key);
final GlobalKey<ScaffoldState>? drawerKey;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0.9,
centerTitle: true,
title: Text(
'Share News',
style: Theme.of(context).textTheme.headline6!.copyWith(
fontWeight: FontWeight.w600,
fontSize: 20,
),
),
leading: IconButton(
icon: const Icon(Icons.menu),
onPressed: () => drawerKey!.currentState!.openDrawer(),
),
actions: [
TextButton(
onPressed: () {},
child: Text(
"Post",
style: Theme.of(context).textTheme.headline5!.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).accentColor),
),
),
],
),
body: Column(
children: <Widget>[
const ListTile(
leading: CircleAvatar(
radius: 25,
),
title: Text('Rutvik Chandla'),
subtitle: Text('Organization Name'),
),
Row(
children: <Widget>[
IconButton(onPressed: () {}, icon: const Icon(Icons.photo)),
IconButton(
onPressed: () {}, icon: const Icon(Icons.camera_alt)),
IconButton(
onPressed: () {}, icon: const Icon(Icons.file_upload)),
TextButton(
onPressed: () {},
child: Text(
'# Add hasthtag',
style: Theme.of(context).textTheme.headline6,
)),
],
),
const Divider(),
const Expanded(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: TextField(
maxLines: null,
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
hintText: "Write here what do you want to share"),
),
))
],
));
}
}
27 changes: 11 additions & 16 deletions lib/views/after_auth_screens/events/explore_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ import 'package:talawa/widgets/event_card.dart';

import '../../../locator.dart';

class ExploreEvents extends StatefulWidget {
const ExploreEvents({required Key key}) : super(key: key);

@override
_ExploreEventsState createState() => _ExploreEventsState();
}

class _ExploreEventsState extends State<ExploreEvents> {
String _chosenValue = 'My Events';

class ExploreEvents extends StatelessWidget {
const ExploreEvents({required Key key, this.drawerKey}) : super(key: key);
final GlobalKey<ScaffoldState>? drawerKey;
@override
Widget build(BuildContext context) {
return BaseView<ExploreEventsViewModel>(builder: (context, model, child) {
Expand All @@ -38,6 +31,10 @@ class _ExploreEventsState extends State<ExploreEvents> {
fontSize: 20,
),
),
leading: IconButton(
icon: const Icon(Icons.menu),
onPressed: () => drawerKey!.currentState!.openDrawer(),
),
actions: [
Padding(
padding: EdgeInsets.only(
Expand Down Expand Up @@ -69,7 +66,7 @@ class _ExploreEventsState extends State<ExploreEvents> {
const EdgeInsets.symmetric(horizontal: 20),
width: SizeConfig.screenWidth! * 0.55,
child: DropdownButtonHideUnderline(
child: dropDownList()),
child: dropDownList(model, context)),
),
),
GestureDetector(
Expand Down Expand Up @@ -152,9 +149,9 @@ class _ExploreEventsState extends State<ExploreEvents> {
});
}

Widget dropDownList() {
Widget dropDownList(ExploreEventsViewModel model, BuildContext context) {
return DropdownButton<String>(
value: _chosenValue,
value: model.chosenValue,
items: <String>[
'My Events',
'Public Events',
Expand All @@ -172,9 +169,7 @@ class _ExploreEventsState extends State<ExploreEvents> {
);
}).toList(),
onChanged: (value) {
setState(() {
_chosenValue = value.toString();
});
model.choseValue(value!);
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'package:talawa/widgets/pinned_carousel_widget.dart';
import 'package:talawa/widgets/post_list_widget.dart';

class OrganizationFeed extends StatelessWidget {
const OrganizationFeed({required Key key}) : super(key: key);
const OrganizationFeed({required Key key, this.drawerKey}) : super(key: key);
final GlobalKey<ScaffoldState>? drawerKey;

@override
Widget build(BuildContext context) {
Expand All @@ -23,6 +24,10 @@ class OrganizationFeed extends StatelessWidget {
fontSize: 20,
),
),
leading: IconButton(
icon: const Icon(Icons.menu),
onPressed: () => drawerKey!.currentState!.openDrawer(),
),
),
body: model.isBusy
? const CircularProgressIndicator()
Expand Down
106 changes: 106 additions & 0 deletions lib/views/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:talawa/models/user/user_info.dart';
import 'package:talawa/services/navigation_service.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/views/after_auth_screens/add_post_page.dart';
import 'package:talawa/views/after_auth_screens/events/explore_events.dart';
import 'package:talawa/views/after_auth_screens/feed_page/organization_feed.dart';
import 'package:talawa/widgets/raised_round_edge_button.dart';

import '../locator.dart';

class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);

@override
HomeScreenState createState() => HomeScreenState();
}

class HomeScreenState extends State<HomeScreen> {
int _currentIndex = 0;
final List<Widget> _childrenPages = [
const OrganizationFeed(key: Key("HomeView")),
const ExploreEvents(key: Key('ExploreEvents')),
const AddPost(key: Key('AddPost')),
Container(
child: const Center(
child: Text('Chat Screen'),
),
),
Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: SizeConfig.screenHeight! * 0.4,
),
const Text('Profile Screen'),
SizedBox(
height: SizeConfig.screenHeight! * 0.4,
),
RaisedRoundedButton(
buttonLabel: 'Log out',
onTap: () {
final user = Hive.box<User>('currentUser');
final url = Hive.box('url');
user.clear();
url.clear();
locator<NavigationService>()
.removeAllAndPush('/selectLang', '/', arguments: '0');
},
textColor: const Color(0xFF008A37),
key: const Key('Logout'),
backgroundColor: Colors.white,
),
SizedBox(
height: SizeConfig.screenHeight! * 0.0215,
),
],
),
),
),
];

@override
Widget build(BuildContext context) {
return Scaffold(
body: _childrenPages[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex,
onTap: onTabTapped,
selectedItemColor: const Color(0xff34AD64),
items: [
const BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
const BottomNavigationBarItem(
icon: Icon(Icons.event_note),
label: 'Events',
),
const BottomNavigationBarItem(
icon: Icon(Icons.add_box),
label: 'Post',
),
const BottomNavigationBarItem(
icon: Icon(Icons.chat_bubble_outline),
label: 'Chat',
),
const BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
label: 'Profile',
)
],
),
);
}

void onTabTapped(int index) {
setState(() {
_currentIndex = index;
});
}
}
9 changes: 2 additions & 7 deletions lib/views/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ import 'package:talawa/widgets/custom_drawer.dart';

import 'base_view.dart';

class MainScreen extends StatefulWidget {
class MainScreen extends StatelessWidget {
const MainScreen({Key? key}) : super(key: key);

@override
MainScreenState createState() => MainScreenState();
}

class MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
return BaseView<MainScreenViewModel>(
onModelReady: (model) => model.initialize(),
builder: (context, model, child) {
return Scaffold(
key: model.scaffoldKey,
drawer: const CustomDrawer(),
body: model.childrenPage[model.currentIndex],
bottomNavigationBar: BottomNavigationBar(
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/post_detailed_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _DescriptionTextWidgetState extends State<DescriptionTextWidget> {
style: Theme.of(context)
.textTheme
.bodyText2!
.copyWith(fontFamily: 'open-sans', fontSize: 16),
.copyWith(fontFamily: 'open-sans'),
)
: Column(
children: <Widget>[
Expand All @@ -46,7 +46,7 @@ class _DescriptionTextWidgetState extends State<DescriptionTextWidget> {
style: Theme.of(context)
.textTheme
.bodyText2!
.copyWith(fontFamily: 'open-sans', fontSize: 16),
.copyWith(fontFamily: 'open-sans'),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
Expand Down
2 changes: 1 addition & 1 deletion test/widget_tests/home_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void main() {
await tester.tap(postIcon);
await tester.pump();
//Post Screen should show up
expect(find.text('Post Screen'), findsOneWidget);
expect(find.text('Share News'), findsOneWidget);
});

testWidgets('Testing if Chat Screen up', (tester) async {
Expand Down

0 comments on commit 68bc3bc

Please sign in to comment.