|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:opso/modals/book_mark_model.dart'; |
| 3 | +import 'package:url_launcher/url_launcher.dart'; |
| 4 | + |
| 5 | +class DjangonautSpaceProgram extends StatefulWidget { |
| 6 | + const DjangonautSpaceProgram({super.key}); |
| 7 | + |
| 8 | + @override |
| 9 | + State<DjangonautSpaceProgram> createState() => _DjangonautSpaceProgramState(); |
| 10 | +} |
| 11 | + |
| 12 | +class _DjangonautSpaceProgramState extends State<DjangonautSpaceProgram> { |
| 13 | + bool isBookmarked = true; |
| 14 | + String currectPage = "/DjangonautSpaceProgram"; |
| 15 | + String currentProject = "Djangonaut Space Program"; |
| 16 | + |
| 17 | + @override |
| 18 | + void initState() { |
| 19 | + super.initState(); |
| 20 | + _checkBookmarkStatus(); |
| 21 | + } |
| 22 | + |
| 23 | + Future<void> _checkBookmarkStatus() async { |
| 24 | + bool bookmarkStatus = await HandleBookmark.isBookmarked(currentProject); |
| 25 | + setState(() { |
| 26 | + isBookmarked = bookmarkStatus; |
| 27 | + }); |
| 28 | + } |
| 29 | + |
| 30 | + Future<void> _refresh() async { |
| 31 | + setState(() {}); |
| 32 | + } |
| 33 | + |
| 34 | + @override |
| 35 | + Widget build(BuildContext context) { |
| 36 | + double screenWidth = MediaQuery.of(context).size.width; |
| 37 | + double gap = screenWidth * 0.05; |
| 38 | + double pad = screenWidth * 0.04; |
| 39 | + double titleSize = screenWidth * 0.05; |
| 40 | + double contentSize = screenWidth * 0.04; |
| 41 | + |
| 42 | + return RefreshIndicator( |
| 43 | + onRefresh: _refresh, |
| 44 | + child: Scaffold( |
| 45 | + appBar: AppBar( |
| 46 | + leading: IconButton( |
| 47 | + icon: const Icon(Icons.arrow_back_ios), |
| 48 | + onPressed: () => Navigator.of(context).pop(), |
| 49 | + ), |
| 50 | + centerTitle: true, |
| 51 | + title: const Text('Djangonaut Space Program'), |
| 52 | + actions: [ |
| 53 | + IconButton( |
| 54 | + icon: Icon( |
| 55 | + isBookmarked |
| 56 | + ? Icons.bookmark_add_rounded |
| 57 | + : Icons.bookmark_add_outlined, |
| 58 | + ), |
| 59 | + onPressed: () { |
| 60 | + setState(() { |
| 61 | + isBookmarked = !isBookmarked; |
| 62 | + }); |
| 63 | + ScaffoldMessenger.of(context).showSnackBar( |
| 64 | + SnackBar( |
| 65 | + content: Text( |
| 66 | + isBookmarked ? 'Bookmark added' : 'Bookmark removed'), |
| 67 | + duration: const Duration(seconds: 2), |
| 68 | + ), |
| 69 | + ); |
| 70 | + if (isBookmarked) { |
| 71 | + HandleBookmark.addBookmark(currentProject, currectPage); |
| 72 | + } else { |
| 73 | + HandleBookmark.deleteBookmark(currentProject); |
| 74 | + } |
| 75 | + }, |
| 76 | + ) |
| 77 | + ], |
| 78 | + ), |
| 79 | + body: SingleChildScrollView( |
| 80 | + padding: EdgeInsets.all(pad), |
| 81 | + child: Column( |
| 82 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 83 | + children: [ |
| 84 | + Text( |
| 85 | + 'Become a Djangonaut and Explore the Open Source Universe!', |
| 86 | + style: TextStyle( |
| 87 | + fontSize: titleSize, |
| 88 | + fontWeight: FontWeight.bold, |
| 89 | + ), |
| 90 | + ), |
| 91 | + SizedBox(height: pad), |
| 92 | + Text( |
| 93 | + 'The Djangonaut Space Program is a community-driven initiative that helps newcomers and enthusiasts contribute to the Django ecosystem. Whether you’re a beginner or an experienced dev, Djangonauts will guide you through real-world contributions and mentorship in Django.', |
| 94 | + style: TextStyle(fontSize: contentSize, height: 1.5), |
| 95 | + ), |
| 96 | + SizedBox(height: pad * 1.5), |
| 97 | + Row( |
| 98 | + children: [ |
| 99 | + ElevatedButton( |
| 100 | + style: ElevatedButton.styleFrom( |
| 101 | + backgroundColor: Colors.deepPurple, |
| 102 | + foregroundColor: Colors.white, |
| 103 | + ), |
| 104 | + onPressed: () async { |
| 105 | + await _launchUrl("https://djangonaut.space/"); |
| 106 | + }, |
| 107 | + child: const Text("Website"), |
| 108 | + ), |
| 109 | + SizedBox(width: gap), |
| 110 | + ElevatedButton( |
| 111 | + onPressed: () async { |
| 112 | + await _launchUrl("https://github.com/djangonaut-space/program/blob/main/README.md"); |
| 113 | + }, |
| 114 | + child: const Text("About Djangonaut"), |
| 115 | + ), |
| 116 | + ], |
| 117 | + ), |
| 118 | + SizedBox(height: pad * 2), |
| 119 | + Text( |
| 120 | + 'How to Get Started with Djangonaut Program', |
| 121 | + style: TextStyle( |
| 122 | + fontSize: titleSize, |
| 123 | + fontWeight: FontWeight.bold, |
| 124 | + ), |
| 125 | + ), |
| 126 | + SizedBox(height: pad), |
| 127 | + Text( |
| 128 | + '1. Visit the Django GitHub organization.\n' |
| 129 | + '2. Look for beginner-friendly issues with labels like "good first issue".\n' |
| 130 | + '3. Join the Django Forum and IRC channels for guidance.\n' |
| 131 | + '4. Start contributing and submit your PRs for review!', |
| 132 | + style: TextStyle(fontSize: contentSize, height: 1.8), |
| 133 | + ), |
| 134 | + SizedBox(height: pad * 2), |
| 135 | + Text( |
| 136 | + 'Mentorship in the Program', |
| 137 | + style: TextStyle( |
| 138 | + fontSize: titleSize, |
| 139 | + fontWeight: FontWeight.bold, |
| 140 | + ), |
| 141 | + ), |
| 142 | + SizedBox(height: pad), |
| 143 | + Text( |
| 144 | + 'The program pairs experienced Django contributors with mentees to help them navigate:\n\n' |
| 145 | + '• The Django codebase\n' |
| 146 | + '• Contribution guidelines and standards\n' |
| 147 | + '• Submitting quality patches\n' |
| 148 | + '• Building confidence as a contributor', |
| 149 | + style: TextStyle(fontSize: contentSize, height: 1.6), |
| 150 | + ), |
| 151 | + SizedBox(height: pad * 2), |
| 152 | + Text( |
| 153 | + 'What Can You Contribute To?', |
| 154 | + style: TextStyle( |
| 155 | + fontSize: titleSize, |
| 156 | + fontWeight: FontWeight.bold, |
| 157 | + ), |
| 158 | + ), |
| 159 | + SizedBox(height: pad), |
| 160 | + Text( |
| 161 | + 'As part of the Djangonaut Space Program, contributors can work on projects like Django, Django CMS, and Django Debug Toolbar. ' |
| 162 | + 'Session organizers guide contributors based on their skills and interests to ensure meaningful contributions across these projects.', |
| 163 | + style: TextStyle(fontSize: contentSize, height: 1.6), |
| 164 | + ), |
| 165 | + SizedBox(height: pad * 2), |
| 166 | + Center( |
| 167 | + child: ElevatedButton( |
| 168 | + onPressed: () { |
| 169 | + _launchUrl('https://djangonaut.space/sessions/'); |
| 170 | + }, |
| 171 | + child: const Text('Explore Sessions'), |
| 172 | + ), |
| 173 | + ), |
| 174 | + ], |
| 175 | + ), |
| 176 | + ), |
| 177 | + ), |
| 178 | + ); |
| 179 | + } |
| 180 | + |
| 181 | + Future<void> _launchUrl(String url) async { |
| 182 | + final Uri uri = Uri.parse(url); |
| 183 | + if (!await launchUrl(uri)) { |
| 184 | + throw Exception('Could not launch $url'); |
| 185 | + } |
| 186 | + } |
| 187 | +} |
0 commit comments