Skip to content

Commit

Permalink
Merge pull request #261 from RishavKumarSinha/fix#251
Browse files Browse the repository at this point in the history
Implemented UI Page for Redox OS Summer of Code
  • Loading branch information
andoriyaprashant authored Jul 27, 2024
2 parents 50667c1 + f828381 commit 374da88
Show file tree
Hide file tree
Showing 10 changed files with 470 additions and 13 deletions.
Binary file added assets/redox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:opso/programs%20screen/linux_foundation.dart';
import 'package:opso/programs%20screen/major_league_hacking_fellowship.dart';
import 'package:opso/programs%20screen/open_summer_of_code.dart';
import 'package:opso/programs%20screen/outreachy.dart';
import 'package:opso/programs%20screen/redox.dart';
import 'package:opso/programs%20screen/season_of_kde.dart';
import 'package:opso/programs%20screen/summer_of_bitcoin.dart';
import 'package:opso/programs%20screen/social_winter_of_code.dart';
Expand Down Expand Up @@ -122,6 +123,10 @@ class _HomePageState extends State<HomePage> {
title: 'Season of KDE',
imageAssetPath: 'assets/sokde.png',
),
Program(
title: 'Redox OS Summer of Code',
imageAssetPath: 'assets/redox.png',
),
Program(
title: 'Open Summer of Code',
imageAssetPath: 'assets/open_summer_of_code.png',
Expand Down Expand Up @@ -403,6 +408,15 @@ class _HomePageState extends State<HomePage> {
);
break;

case 'Redox OS Summer of Code':
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const RsocPage(),
),
);
break;


case 'Outreachy':
Navigator.push(context,
Expand Down Expand Up @@ -522,6 +536,10 @@ class ProgramSearchDelegate extends SearchDelegate<String> {
title: 'Hacktoberfest',
imageAssetPath: 'assets/hacktoberfest.png',
),
Program(
title: 'Redox OS Summer of Code',
imageAssetPath: 'assets/redox.png',
),
Program(
title: 'Linux Foundation',
imageAssetPath: 'assets/linux_foundation_logo.png',
Expand Down Expand Up @@ -623,6 +641,14 @@ class ProgramSearchDelegate extends SearchDelegate<String> {
);
break;

case 'Redox OS Summer of Code':
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const RsocPage(),
),
);
break;

case 'Major League Hacking Fellowship':
Navigator.push(
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:opso/programs%20screen/linux_foundation.dart';
import 'package:opso/programs%20screen/major_league_hacking_fellowship.dart';
import 'package:opso/programs%20screen/open_summer_of_code.dart';
import 'package:opso/programs%20screen/outreachy.dart';
import 'package:opso/programs%20screen/redox.dart';
import 'package:opso/programs%20screen/season_of_kde.dart';
import 'package:opso/programs%20screen/summer_of_bitcoin.dart';
import 'package:opso/programs%20screen/social_winter_of_code.dart';
Expand Down Expand Up @@ -53,6 +54,7 @@ class OpSoApp extends StatelessWidget {
"/summer_of_bitcoin": (context) => const SummerOfBitcoin(),
"/hacktoberfest_screen": (context) => const Hacktoberfest(),
"/open_summer_of_code": (context) => const OpenSummerOfCode(),
"/rsoc": (context) => const RsocPage(),
"/outreachy": (context) => const OutreachyScreen(),
"/major_league_hacking_fellowship": (context) =>
const MajorLeagueHackingFellowship(),
Expand Down
36 changes: 36 additions & 0 deletions lib/modals/rsoc_project_modal.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class RsocProjectModal {
String name;
String contributor;
String description;
String githubUrl;

RsocProjectModal({
required this.name,
required this.contributor,
required this.description,
required this.githubUrl,
});

factory RsocProjectModal.fromJson(Map<String, dynamic> json) {
return RsocProjectModal(
name: json['name'],
contributor: json['contributor'],
description: json['description'],
githubUrl: json['githubUrl'],
);
}

Map<String, dynamic> toJson() {
return {
'name': name,
'contributor': contributor,
'description': description,
'githubUrl': githubUrl,
};
}

@override
String toString() {
return 'RsocProjectModal(name: $name, contributor: $contributor, description: $description, githubUrl: $githubUrl)';
}
}
6 changes: 6 additions & 0 deletions lib/opso_timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class OpsoTimeLineScreen extends StatelessWidget {
'startDate': DateTime.utc(2024, 5, 1),
'endDate': DateTime.utc(2024, 5, 10),
},
{
'description':
"Redox OS Summer of Code\nApplication Period - 01/05/2024 to 01/06/2024",
'startDate': DateTime.utc(2024, 5, 01),
'endDate': DateTime.utc(2024, 6, 01),
},
{
'description':
"Linux Foundation Mentorship(Fall Term)\nApplication Period - 15/07/2024 to 15/08/2024",
Expand Down
201 changes: 201 additions & 0 deletions lib/programs screen/redox.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:opso/modals/book_mark_model.dart';
import 'package:opso/modals/rsoc_project_modal.dart';
import 'package:opso/programs_info_pages/rsoc_info.dart';
import 'package:opso/widgets/rsoc_project_widget.dart';

class RsocPage extends StatefulWidget {
const RsocPage({super.key});

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

class _RsocPageState extends State<RsocPage> {
List<RsocProjectModal> projectList = [];
String currectPage = "/rsoc";
String currentProject = "RSoC";
bool isBookmarked = true;
late Future<void> getProjectFunction;

Future<void> initializeProjectLists() async {
var response =
await rootBundle.loadString('assets/projects/redox/redox.json');
var jsonList = await json.decode(response);
for (var data in jsonList) {
projectList.add(RsocProjectModal.fromJson(data));
}
print(projectList);
}

@override
void initState() {
super.initState();
getProjectFunction = initializeProjectLists();
_checkBookmarkStatus();
}

Future<void> _checkBookmarkStatus() async {
bool bookmarkStatus = await HandleBookmark.isBookmarked(currentProject);
setState(() {
isBookmarked = bookmarkStatus;
});
}

void searchTag(String searchTag) {
projectList = projectList
.where((element) => element.name.toLowerCase().contains(searchTag))
.toList();
setState(() {});
}

void search(String searchText) {
if (searchText.isEmpty) {
setState(() {});
return;
}
searchText = searchText.toLowerCase();
projectList = projectList
.where((element) =>
element.name.toLowerCase().contains(searchText) ||
element.contributor.toLowerCase().contains(searchText))
.toList();
setState(() {});
}

Future<void> _refresh() async {
projectList.clear();
await initializeProjectLists();
setState(() {});
}

@override
Widget build(BuildContext context) {
return RefreshIndicator(
onRefresh: _refresh,
child: Scaffold(
appBar: AppBar(
title: const Text('Redox Summer of Code'),
actions: <Widget>[
IconButton(
icon: Icon(
isBookmarked
? Icons.bookmark_add_rounded
: Icons.bookmark_add_outlined,
),
onPressed: () {
setState(() {
isBookmarked = !isBookmarked;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
isBookmarked ? 'Bookmark added' : 'Bookmark removed',
),
duration: const Duration(seconds: 2),
),
);
if (isBookmarked) {
HandleBookmark.addBookmark(currentProject, currectPage);
} else {
HandleBookmark.deleteBookmark(currentProject);
}
},
),
IconButton(
icon: const Icon(Icons.info_outline),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const RsocInfo()),
);
},
),
],
),
body: FutureBuilder<void>(
future: getProjectFunction,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return Center(child: Text("Error: ${snapshot.error}"));
} else if (snapshot.connectionState == ConnectionState.done) {
return Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(46),
vertical: ScreenUtil().setHeight(16),
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
decoration: InputDecoration(
filled: true,
hintText: 'Search',
suffixIcon: const Icon(Icons.search),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Color(0xFFEEEEEE)),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Color(0xFFEEEEEE)),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Color(0xFFEEEEEE)),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Color(0xFFEEEEEE)),
),
contentPadding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(12),
horizontal: ScreenUtil().setWidth(20),
),
),
onFieldSubmitted: (value) {
search(value.trim());
},
onChanged: (value) {
if (value.isEmpty) {
search(value);
}
},
),
SizedBox(height: ScreenUtil().setHeight(20)),
SizedBox(
height: MediaQuery.of(context).size.height * 0.8,
child: ListView.builder(
itemCount: projectList.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: RsocProjectWidget(
modal: projectList[index],
height: ScreenUtil().screenHeight * 0.3,
width: ScreenUtil().screenWidth,
index: index,
),
);
},
),
),
],
),
),
);
} else {
return const Center(child: Text("Some error occurred"));
}
},
),
),
);
}
}
Loading

0 comments on commit 374da88

Please sign in to comment.