Skip to content

Commit

Permalink
Fix Linting Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber committed Dec 17, 2024
1 parent 1d9e822 commit c060c7a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
2 changes: 0 additions & 2 deletions lib/base/enums/search_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ extension SearchCategoryExtension on SearchCategory {
return context.tr("rooms");
case SearchCategory.studentClub:
return "Student Clubs";
default:
return context.tr("unknown");
}
}

Expand Down
19 changes: 19 additions & 0 deletions lib/base/extensions/color.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'dart:ui';

extension IntColorComponents on Color {
int get intValue {
return _floatToInt8(a) << 24 |
_floatToInt8(r) << 16 |
_floatToInt8(g) << 8 |
_floatToInt8(b) << 0;
}

int get intAlpha => _floatToInt8(a);
int get intRed => _floatToInt8(r);
int get intGreen => _floatToInt8(g);
int get intBlue => _floatToInt8(b);

int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}
}
3 changes: 2 additions & 1 deletion lib/calendarComponent/model/calendar_event.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:campus_flutter/base/extensions/color.dart';
import 'package:campus_flutter/base/theme/constants.dart';
import 'package:campus_flutter/base/util/read_list_value.dart';
import 'package:campus_flutter/searchComponent/model/comparison_token.dart';
Expand Down Expand Up @@ -77,7 +78,7 @@ class CalendarEvent extends Searchable {
}

void setColor(Color? color) {
this.color = color?.value;
this.color = color?.intValue;
}

Color getColor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:campus_flutter/base/extensions/color.dart';
import 'package:campus_flutter/calendarComponent/model/calendar_preferences.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -16,7 +17,7 @@ class CalendarPreferenceService {
CalendarPreferenceService(this.sharedPreferences);

void saveColorPreference(String id, Color color) {
colorPreferences[id] = color.value;
colorPreferences[id] = color.intValue;
try {
sharedPreferences.setString(
key,
Expand Down
1 change: 0 additions & 1 deletion lib/calendarComponent/views/calendar_event_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:campus_flutter/base/util/diagonalStripePattern/diagonal_stripe_pattern_view.dart';
import 'package:campus_flutter/calendarComponent/model/calendar_event.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';

class CalendarEventView extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/searchComponent/protocols/global_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class GlobalSearch {
if (result.contains(null)) {
return null;
} else {
return result.whereNotNull().toList();
return result.nonNulls.toList();
}
}

Expand Down
2 changes: 0 additions & 2 deletions lib/searchComponent/views/search_result_view_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class SearchResultViewBuilder extends StatelessWidget {
return PersonSearchResultView(searchVM: searchVM);
case SearchCategory.rooms:
return NavigaTumSearchResultView(searchVM: searchVM);
default:
return Container();
}
}
}
2 changes: 1 addition & 1 deletion lib/studentCardComponent/views/student_card_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class StudentCardView extends ConsumerWidget {
Widget _warningCard(BuildContext context) {
return CardWithPadding(
elevation: 0,
color: context.primaryColor.withOpacity(0.2),
color: context.primaryColor.withValues(alpha: 0.2),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down

0 comments on commit c060c7a

Please sign in to comment.