Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            StartButton.AddTarget(startTimeEntry, UIControlEvent.TouchUpInside);
            StopButton.AddTarget(stopTimeEntry, UIControlEvent.TouchUpInside);
            ShowAllTimeEntriesButton.AddTarget((s, e) => openApp(), UIControlEvent.TouchUpInside);

            tapGestureRecognizer = new UITapGestureRecognizer(openApp);

            SuggestionsTableView.RegisterNibForCellReuse(SuggestionTableViewCell.Nib, SuggestionTableViewCell.Identifier);

            var suggestions = SharedStorage.Instance.GetCurrentSuggestions();

            if (suggestions == null)
            {
                ExtensionContext?.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Compact);
                return;
            }

            suggestionsCount = suggestions.Count;
            SuggestionsTableViewHeightConstraint.Constant = 60 * suggestionsCount;
            dataSource                  = new SuggestionsDataSource();
            dataSource.Suggestions      = suggestions;
            dataSource.Callback         = continueSuggestion;
            SuggestionsTableView.Source = dataSource;
        }
 /*
  * Unfourtunalty that will not work because accourding to
  * https://dmtopolog.com/ios-app-extensions-data-sharing/
  * and
  * https://medium.com/@deep_blue_day/how-to-create-an-ios-app-group-for-xamarin-app-a117c172b4
  *
  * to access the database i must have an apple developer account account to make an app group and make the database shared between the app and the extension
  * (sadly i don't have one)
  * there is no other way except having the data coming from an api
  *
  * private Task RefreshDataFromDatabase() => Task.Run(async () =>
  * {
  *
  *  try
  *  {
  *      var database = Ioc.Container.Resolve<ILocalDatabaseService>() as LocalDatabaseService;
  *      if (database != null) _notesList = await database.GetAll<Note>();
  *      isDataReady = true;
  *  }
  *  catch (Exception ex)
  *  {
  *      Debug.WriteLine($"Errroooooooorrr{ex.Message}");
  *      isDataReady = false;
  *      throw ex;
  *  }
  * });
  */
 void SetDatasource()
 {
     NotesTableView.Source    = new TableSource(_notesList, base.ExtensionContext);
     NotesTableView.RowHeight = UITableView.AutomaticDimension;
     ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded);
     NotesTableView.ReloadData();
 }
Esempio n. 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded);

            // Get the possible sizes
            _collapsedSize = ExtensionContext.GetWidgetMaximumSize(NCWidgetDisplayMode.Compact);

            if (IsInitialized())
            {
                if (!_data?.Any() ?? true)
                {
                    MainTitleLabel.Text   = "Loading your favorites...";
                    MainTitleLabel.Hidden = false;
                    SessionsTable.Hidden  = true;
                }
            }
            else
            {
                MainTitleLabel.Text   = "Please open the app and load the sessions list once to initialize.";
                MainTitleLabel.Hidden = false;
                SessionsTable.Hidden  = true;
            }
        }
Esempio n. 4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Tell widget it can be expanded
            ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded);

            // Get the maximum size
            var maxSize = ExtensionContext.GetWidgetMaximumSize(NCWidgetDisplayMode.Expanded);

            Console.WriteLine(maxSize);

            // Do any additional setup after loading the view.
        }
Esempio n. 5
0
        private void renderErrorState(string error)
        {
            ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Compact);
            ErrorMessageLabel.Hidden = false;
            ErrorMessageLabel.Text   = error;
            ErrorMessageLabel.SetLineSpacing(errorMessageLineSpacing, UITextAlignment.Center);

            View.AddGestureRecognizer(tapGestureRecognizer);

            StopButton.Hidden       = true;
            StartButton.Hidden      = true;
            DurationLabel.Hidden    = true;
            DescriptionLabel.Hidden = true;
            ProjectNameLabel.Hidden = true;
            DotView.Hidden          = true;

            elapsedTimeTimer?.Invalidate();
            elapsedTimeTimer = null;
        }
Esempio n. 6
0
        public override void ViewWillAppear(bool animated)
        {
            ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded);
            if (SharedStorage.Instance.GetApiToken() == null)
            {
                renderErrorState(Resources.WidgetLogInToTrackTime);
            }
            else
            {
                networkingHandler = new NetworkingHandler(APIHelper.GetTogglAPI());
                var timeEntry = SharedStorage.Instance.GetRunningTimeEntryViewModel();
                if (timeEntry == null)
                {
                    renderEmptyTimeEntry();
                }
                else
                {
                    renderRunningTimeEntry(timeEntry);
                }
            }

            base.ViewWillAppear(animated);
        }
Esempio n. 7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _webApi = new WebApi();

            ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded);

            _tableView = new UITableView(View.Frame, UITableViewStyle.Plain);
            _tableView.AllowsSelection    = false;
            _tableView.SeparatorStyle     = UITableViewCellSeparatorStyle.None;
            _tableView.RowHeight          = 52;
            _tableView.EstimatedRowHeight = 52;

            _source           = new WidgetTableViewSource();
            _tableView.Source = _source;

            _tapGesutre = new UITapGestureRecognizer((obj) =>
            {
                ExtensionContext.OpenUrl(NSUrl.FromString("jp.kamusoft.sample://"), null);
            });

            View.AddGestureRecognizer(_tapGesutre);
            View.AddSubview(_tableView);
        }