You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
909 B
30 lines
909 B
import 'package:flutter/material.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
import 'package:thesis_shop/benchmark_counter.dart';
|
|
import 'package:thesis_shop/stores/store_injector.dart';
|
|
|
|
class UserSwitch extends StatelessWidget {
|
|
const UserSwitch() : super(key: const Key('user_switch'));
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final userStore = StoreInjector.of(context).userStore;
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.account_circle),
|
|
Observer(
|
|
builder: (context) {
|
|
BenchmarkCounters.userSwitch++;
|
|
return Switch(
|
|
value: userStore.isSignedIn,
|
|
onChanged: (shouldSignIn) =>
|
|
shouldSignIn ? userStore.logIn() : userStore.logOut(),
|
|
activeColor: Colors.green,
|
|
);
|
|
},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|