diff --git a/.gitignore b/.gitignore index 9d532b1..512ffc3 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ app.*.symbols # Obfuscation related app.*.map.json +.env* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f51408b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Moh. Absar Rahman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e3bf6ca..edeaa1f 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,14 @@ -# faculty_info +# Bracu Faculty Info +## -A new Flutter application. +## Features -## Getting Started +- Search email address by department +- Search email address by initial +- Search email address by name -This project is a starting point for a Flutter application. -A few resources to get you started if this is your first Flutter project: +## Tech -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +- Flutter +- REST \ No newline at end of file diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..1e8c3c9 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/lib/customs/app_themes.dart b/lib/customs/app_themes.dart new file mode 100644 index 0000000..ac17fe7 --- /dev/null +++ b/lib/customs/app_themes.dart @@ -0,0 +1,4 @@ +class AppThemes { + static const int Light = 1; + static const int Dark = 2; +} \ No newline at end of file diff --git a/lib/customs/custom_internal.dart b/lib/customs/custom_internal.dart index a95b7e9..1288dcf 100644 --- a/lib/customs/custom_internal.dart +++ b/lib/customs/custom_internal.dart @@ -1,20 +1,18 @@ -import 'package:dynamic_theme/dynamic_theme.dart'; +import 'package:dynamic_themes/dynamic_themes.dart'; +import 'package:faculty_info/customs/app_themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; -bool isDark; +late bool isDark; checkTheme(context) { - isDark = Theme.of(context).brightness == Brightness.dark ? true : false; + isDark = DynamicTheme.of(context)!.themeId == AppThemes.Dark ? true : false; } Color primaryColor = Color(0xff253494); changeBrightness(context) { - DynamicTheme.of(context).setBrightness( - Theme.of(context).brightness == Brightness.dark - ? Brightness.light - : Brightness.dark); + DynamicTheme.of(context)!.setTheme(DynamicTheme.of(context)!.themeId == AppThemes.Light ? AppThemes.Dark : AppThemes.Light); } Widget loading() { diff --git a/lib/main.dart b/lib/main.dart index e93f7ae..7696af6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,11 @@ -import 'package:dynamic_theme/dynamic_theme.dart'; +import 'package:dynamic_themes/dynamic_themes.dart'; import 'package:faculty_info/screens/splash.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'customs/app_themes.dart'; -void main() { +Future main() async { + await dotenv.load(fileName: ".env"); runApp(BracuFacultyApp()); } @@ -10,16 +13,19 @@ class BracuFacultyApp extends StatelessWidget { @override Widget build(BuildContext context) { return DynamicTheme( - defaultBrightness: Brightness.light, - data: (brightness)=> ThemeData( - primarySwatch: Colors.blue, - brightness: brightness, - ), - themedWidgetBuilder: (context, theme) => MaterialApp( + defaultThemeId: AppThemes.Light, + builder: (context, theme) => MaterialApp( debugShowCheckedModeBanner: false, theme: theme, home: SplashScreen(), ), + themeCollection: ThemeCollection( + themes: { + AppThemes.Light: ThemeData.light(), + AppThemes.Dark: ThemeData.dark(), + }, + fallbackTheme: ThemeData.light(), + ), ); } } diff --git a/lib/models/department_model.dart b/lib/models/department_model.dart index 394c3a6..3877cce 100644 --- a/lib/models/department_model.dart +++ b/lib/models/department_model.dart @@ -1,5 +1,5 @@ class DepartmentModel { - String name,link; + String? name,link; DepartmentModel(this.name, this.link); diff --git a/lib/models/faculty_model.dart b/lib/models/faculty_model.dart index b2be340..6917f42 100644 --- a/lib/models/faculty_model.dart +++ b/lib/models/faculty_model.dart @@ -1,5 +1,5 @@ class FacultyModel { - String initial,name,email; + String? initial,name,email; FacultyModel(this.initial, this.name, this.email); diff --git a/lib/screens/departments/departments.dart b/lib/screens/departments/departments.dart index e35ceb4..1b71aa7 100644 --- a/lib/screens/departments/departments.dart +++ b/lib/screens/departments/departments.dart @@ -5,6 +5,7 @@ import 'package:faculty_info/models/faculty_model.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:url_launcher/url_launcher.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; class DepartmentsPage extends StatefulWidget { final deptName; @@ -18,12 +19,13 @@ class DepartmentsPage extends StatefulWidget { class _DepartmentsPageState extends State { var deptName, screenWidth, screenHeight; - List list; - List listShow; + List? list; + List? listShow; _fetchData() async { - final url = - widget.deptLink; + /*final url = + Uri.parse(widget.deptLink);*/ + final url = Uri.parse("${dotenv.env['BASE_URL']}dep=${widget.deptLink}"); var response = await http.get(url); return response.body; } @@ -34,7 +36,6 @@ class _DepartmentsPageState extends State { deptName = widget.deptName; _fetchData().then((value) { var list = json.decode(value.toString()); - list = list[deptName]; List listModel = []; for (var l in list) { listModel.add(FacultyModel.fromJson(l)); @@ -64,7 +65,7 @@ class _DepartmentsPageState extends State { Expanded( child: ListView.builder( physics: BouncingScrollPhysics(), - itemCount: listShow.length, + itemCount: listShow!.length, itemBuilder: (context, index) { return _cardView(index); }, @@ -91,8 +92,8 @@ class _DepartmentsPageState extends State { _onChanged(String value) { setState(() { - listShow = list.where((faculty) { - return ((faculty.name.toLowerCase().contains(value.toLowerCase()))||(faculty.initial.toLowerCase().contains(value.toLowerCase()))); + listShow = list!.where((faculty) { + return ((faculty.name!.toLowerCase().contains(value.toLowerCase()))||(faculty.initial!.toLowerCase().contains(value.toLowerCase()))); }).toList(); }); } @@ -115,7 +116,7 @@ class _DepartmentsPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - "${listShow[index].initial}", + "${listShow![index].initial??"N/A"}", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, @@ -127,7 +128,7 @@ class _DepartmentsPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - "${listShow[index].name}", + "${listShow![index].name}", style: TextStyle( fontSize: 20, // fontWeight: FontWeight.bold, @@ -140,9 +141,9 @@ class _DepartmentsPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( - onDoubleTap: () => _launchEmail(listShow[index].email), + onDoubleTap: () => _launchEmail(listShow![index].email!), child: SelectableText( - "${listShow[index].email}", + "${listShow![index].email}", style: TextStyle( decoration: TextDecoration.underline, fontSize: 20, @@ -170,4 +171,4 @@ class _DepartmentsPageState extends State { throw "Failed"; } } -} +} \ No newline at end of file diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 08243e6..688eb05 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -14,11 +14,10 @@ class HomePage extends StatefulWidget { class _HomePageState extends State { var screenHeight, screenWidth; - List deptNameList; + List? deptNameList; _fetchData() async { - final url = - "https://raw.githubusercontent.com/absarrahman/DataStuffs/master/dept_status.json"; + final url = Uri.parse("https://raw.githubusercontent.com/absarrahman/DataStuffs/master/dept_status.json"); var response = await http.get(url); return response.body; } @@ -60,7 +59,7 @@ class _HomePageState extends State { : RefreshIndicator( onRefresh: _refreshData, child: ListView.builder( - itemCount: deptNameList.length + 1, + itemCount: deptNameList!.length + 1, itemBuilder: (context, index) => index == 0 ? Padding( padding: const EdgeInsets.all(15.0), @@ -83,9 +82,8 @@ class _HomePageState extends State { } Future _refreshData() async { - await Future.delayed(Duration(seconds: 2)); - setState(() { - _fetchData(); + setState(() async { + await _fetchData(); }); } @@ -100,7 +98,7 @@ class _HomePageState extends State { Widget _departmentCard(int index) { return Padding( - padding: const EdgeInsets.only(top: 20.0), + padding: const EdgeInsets.only(top: 20.0,bottom: 10.0), child: InkWell( onTap: () => _redirectRoute(index), child: Center( @@ -117,7 +115,7 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - deptNameList[index].name, + deptNameList![index].name ?? "N/A", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, @@ -137,8 +135,8 @@ class _HomePageState extends State { context, MaterialPageRoute( builder: (context) => DepartmentsPage( - deptName: deptNameList[index].name, - deptLink: deptNameList[index].link, + deptName: deptNameList![index].name, + deptLink: deptNameList![index].link, ), ), ); diff --git a/pubspec.lock b/pubspec.lock index 44a28cf..9068b83 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,117 +7,110 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" + version: "3.1.9" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" + version: "1.15.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" - dynamic_theme: + version: "1.0.4" + dynamic_themes: dependency: "direct main" description: - name: dynamic_theme + name: dynamic_themes url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.2" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_dotenv: + dependency: "direct main" + description: + name: flutter_dotenv + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.2" flutter_spinkit: dependency: "direct main" description: name: flutter_spinkit url: "https://pub.dartlang.org" source: hosted - version: "4.1.2+1" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter @@ -134,147 +127,147 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.4" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" - logging: + version: "4.0.0" + js: dependency: transitive description: - name: logging + name: js url: "https://pub.dartlang.org" source: hosted - version: "0.11.4" + version: "0.6.3" lottie: dependency: "direct main" description: name: lottie url: "https://pub.dartlang.org" source: hosted - version: "0.6.0" + version: "1.2.1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.11" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.7.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+2" + version: "2.1.5" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+1" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.2" + version: "2.0.5" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.1.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "3.0.13" + version: "4.2.4" shared_preferences: dependency: transitive description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.12" + version: "2.0.12" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.10" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+2" + version: "2.0.4" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+10" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+7" + version: "2.0.3" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+1" + version: "2.0.4" sky_engine: dependency: transitive description: flutter @@ -286,119 +279,133 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.4.3" transparent_image: dependency: "direct main" description: name: transparent_image url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "2.0.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" url_launcher: dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.7.2" + version: "6.0.18" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.14" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.14" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+1" + version: "2.0.3" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+8" + version: "2.0.3" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.8" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.4+1" + version: "2.0.6" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+1" + version: "2.0.2" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.1" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "1.7.3" + version: "2.3.8" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" sdks: - dart: ">=2.10.0-110 <=2.11.0-181.0.dev" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 646b607..f56fce3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.14.0 <3.0.0" dependencies: flutter: @@ -28,12 +28,13 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.0 - http: ^0.12.2 - flutter_spinkit: "^4.1.2" - dynamic_theme: - url_launcher: ^5.7.2 - transparent_image: ^1.0.0 - lottie: ^0.6.0 + http: ^0.13.4 + flutter_spinkit: ^5.1.0 + dynamic_themes: + url_launcher: ^6.0.18 + transparent_image: ^2.0.0 + lottie: ^1.2.1 + flutter_dotenv: ^5.0.2 dev_dependencies: flutter_test: @@ -55,6 +56,7 @@ flutter: - assets/ - assets/images/ - assets/animations/ + - .env # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see