forked from firka/student-legacy
widgets implementation
This commit is contained in:
parent
e32d2483d3
commit
0de763a297
@ -27,6 +27,7 @@
|
||||
<action android:name="list_widget.ACTION_WIDGET_CLICK_NAV_RIGHT" />
|
||||
<action android:name="list_widget.ACTION_WIDGET_CLICK_NAV_TODAY" />
|
||||
<action android:name="list_widget.ACTION_WIDGET_CLICK_NAV_REFRESH" />
|
||||
<action android:name="list_widget.ACTION_WIDGET_CLICK_BUY_PREMIUM" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 528 B |
Binary file not shown.
After Width: | Height: | Size: 156 KiB |
18
filcnaplo/android/app/src/main/res/drawable/btn_shape.xml
Normal file
18
filcnaplo/android/app/src/main/res/drawable/btn_shape.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#ffE0CCEC"></solid>
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<gradient android:endColor="#ffE0CCEC" android:startColor="#C9ABDC" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
@ -5,16 +5,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_margin="@dimen/widget_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Empty"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/tt_grid_cont"
|
||||
android:layout_width="match_parent"
|
||||
@ -23,6 +13,17 @@
|
||||
android:background="@drawable/card_layout_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="Empty"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/widget_list"
|
||||
android:layout_width="match_parent"
|
||||
@ -83,17 +84,73 @@
|
||||
android:id="@+id/nav_current"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="20sp"
|
||||
android:layout_toLeftOf="@id/nav_refresh"
|
||||
android:fontFamily="@font/montserrat_medium"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="Unknown"
|
||||
android:fontFamily="@font/montserrat_medium"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toLeftOf="@id/nav_refresh"
|
||||
android:text="Timetable"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/need_login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/card_layout_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/montserrat_medium"
|
||||
android:gravity="center"
|
||||
android:text="A Widget használatához, bejelentkezés szükséges."
|
||||
android:textColor="@color/green"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/need_premium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:backgroundTint="#ffF4F4F4"
|
||||
android:background="@drawable/card_layout_bg"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:src="@drawable/tinta_widget" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buy_premium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/btn_shape"
|
||||
android:gravity="center"
|
||||
android:text="Vigyél oda!"
|
||||
android:padding="0dp"
|
||||
android:layout_margin="0dp"
|
||||
android:textColor="#ff691A9B"
|
||||
android:fontFamily="@font/montserrat_medium"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -71,6 +71,7 @@ Future<void> syncAll(BuildContext context) {
|
||||
|
||||
Future<bool?> updateWidget() async {
|
||||
try {
|
||||
print("FILC | Widget updated from sync");
|
||||
return HomeWidget.updateWidget(name: 'widget_timetable.WidgetTimetable');
|
||||
} on PlatformException catch (exception) {
|
||||
debugPrint('Error Updating Widget. $exception');
|
||||
|
@ -2,6 +2,8 @@ import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo/models/user.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/student.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:home_widget/home_widget.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class UserProvider with ChangeNotifier {
|
||||
final Map<String, User> _users = {};
|
||||
@ -26,9 +28,20 @@ class UserProvider with ChangeNotifier {
|
||||
void setUser(String userId) {
|
||||
_selectedUserId = userId;
|
||||
_settings.update(lastAccountId: userId);
|
||||
updateWidget();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool?> updateWidget() async {
|
||||
try {
|
||||
print("FILC | Widget updated from users");
|
||||
return HomeWidget.updateWidget(name: 'widget_timetable.WidgetTimetable');
|
||||
} on PlatformException catch (exception) {
|
||||
print('Error Updating Widget After setUser. $exception');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void addUser(User user) {
|
||||
_users[user.id] = user;
|
||||
if (kDebugMode) {
|
||||
@ -36,9 +49,15 @@ class UserProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
void removeUser(String userId) {
|
||||
void removeUser(String userId) async {
|
||||
_users.removeWhere((key, value) => key == userId);
|
||||
if (_users.isNotEmpty) _selectedUserId = _users.keys.first;
|
||||
if (_users.isNotEmpty) {
|
||||
setUser(_users.keys.first);
|
||||
} else {
|
||||
print("FILC | Setting last account id to null");
|
||||
await _settings.update(lastAccountId: "");
|
||||
}
|
||||
updateWidget();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user