Snippets Collections
   func setView() {
     
        [emailView, passwordView].forEach { (view) in
            if let view = view {
                view.layer.borderWidth = 2
                view.layer.borderColor = hexStringToUIColor(hex: "E9E9E9").cgColor
                view.layer.cornerRadius = view.layer.frame.height/3
            }
        }
    }
  func setCardView() {
        cardView.backgroundColor = .white

        cardView.layer.cornerRadius = 10.0

        cardView.layer.shadowColor = UIColor.gray.cgColor

        cardView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)

        cardView.layer.shadowRadius = 6.0
        cardView.layer.shadowOpacity = 0.7
    }
class MySwitcher extends StatelessWidget {
  const MySwitcher({super.key});

  @override
  Widget build(BuildContext context) {
    final status = context.select((MyBloc bloc) => bloc.state.status);
    switch (status) {
      case MyStatus.initial:
      case MyStatus.loading:
        return const Center(child: CircularProgressIndicator());
      case MyStatus.success:
        return const MyView();
      case MyStatus.error:
        return Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Text('Something went wrong.'),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () {
                  context.read<MyBloc>().add(MyDataRequested());
                },
                child: const Text('Try again'),
              ),
            ],
          ),
        );
    }
  }
}
// PAGE
class MyPage extends StatelessWidget {
  const MyPage({super.key});
 
  static String path = 'my';
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // Inject Bloc(s)
      body: BlocProvider(
        create: (context) => MyBloc(
          dependency: context.read<Dependency>(),
        )..add(MyDataRequested()),
        // SWITCHER
        // MySwitcher, and all its nested child Widgets, will have access to MyBloc
        child: const MySwitcher(),
      ),
    );
  }
}
class MyBloc extends Bloc<MyEvent, MyState> {
  MyBloc({required Dependency dependency})
      : _dependency = dependency,
        super(const MyState()) {
    on<MyDataRequested>(_dataRequested);
  }

  final Dependency _dependency;

  FutureOr<void> _dataRequested(
    MyDataRequested event,
    Emitter<MyState> emit,
  ) async {
    emit(state.copyWith(status: MyStatus.loading));
    try {
      final myAsyncData = await _dependency.asyncCall();
      emit(
        state.copyWith(
          myAsyncData: myAsyncData,
          status: MyStatus.success,
        ),
      );
    } catch (error, stackTrace) {
      addError(error, stackTrace);
      emit(state.copyWith(status: MyStatus.error));
    }
  }
}
enum MyStatus { initial, loading, success, error }

class MyState extends Equatable {
  const MyState({
    this.myAsyncData,
    this.status = MyStatus.initial,
  });

  final AsyncData? myAsyncData;
  final MyStatus status;

  @override
  List<Object> get props => [myAsyncData, status];

  // Creates a new state with the changed data keeping the BlocState immutable
  MyState copyWith({
    AsyncData? myAsyncData,
    MyStatus? status,
  }) {
    return MyState(
      myAsyncData: myAsyncData ?? this.myAsyncData,
      status: status ?? this.status,
    );
  }
}
// PAGE
class MyPage extends StatelessWidget {
  const MyPage({super.key});
 
  static String path = 'my';
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // Inject Bloc(s)
      body: BlocProvider(
        create: (context) => MyBloc(dependency: context.read<Dependency>()),
        // VIEW
        // MyView, and all its nested child Widgets, will have access to MyBloc
        child: const MyView(),
      ),
    );
  }
}
    let add = { (n1 : Int, n2: Int) -> (String) in
            
            return String(n1 + n2)
        }
        let result = add(5, 3)
        print("result = ", result)
        let xPosition = payPalSingleClickView.frame.origin.x
            let yPosition = payPalSingleClickView.frame.origin.y // Slide Up - 20px

            let width = payPalSingleClickView.frame.size.width
            let height = payPalSingleClickView.frame.size.height

        UIView.animate(withDuration: 0.0, animations: {
            self.personalBalanceView.frame = CGRect(x: xPosition, y: yPosition, width: width, height: height)
            })
        nameImageView.layer.cornerRadius = nameImageView.frame.height/2
        nameImageView.layer.borderWidth = 0.75
        nameImageView.layer.borderColor = UIColor.lightGray.cgColor
override func layoutSubviews() {
    super.layoutSubviews()
    roundCorners(corners: [.topLeft, .topRight], radius: 3.0)
}

extension UIView {
   func roundCorners(corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        layer.mask = mask
    }
}
func getDataFromFireStore() {
            print("getting data")
            let activityView = activityIndicatorView()
            activityView.startAnimating()
            let db = Firestore.firestore()
            db.collection("Groups").getDocuments() { (querySnapshot, error) in
                if error != nil {
                    print("Error getting documents: \(error!)")
                } else {
                    self.mentalHealthArray.removeAll()
                    self.circumstanceArray.removeAll()
                    self.identityArray.removeAll()
                    for document in querySnapshot!.documents {
                        print("for loop")
                        let group = JoinGroupModel()
                        let data = document.data()
                            group.name = data["name"] as! String
                            group.description = data["description"] as! String
                            group.image_url = data["image_url"] as! String
                        let groupType = data["type"] as! String
                        print("Group Type = \(groupType)")
                    
                        if groupType == "Mental Health" {
                            self.mentalHealthArray.append(group)
                        } else if groupType == "Circumstance" {
                            self.circumstanceArray.append(group)
                        } else {
                            self.identityArray.append(group)
                        }
                    }
                    self.mentalHealthCollectionView.reloadData()
                    self.circumstanceCollectionView.reloadData()
                    self.identityCollectionView.reloadData()
                    activityView.stopAnimating()
                }
            }
        }
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        if collectionView.tag == 1 {
            let cell = mentalHealthCollectionView.dequeueReusableCell(withReuseIdentifier: "MentalHealthCollectionViewCell", for: indexPath) as! MentalHealthCollectionViewCell
            cell.groupNameLabel.text = mentalHealthArray[indexPath.row].name
           let imageUrl = mentalHealthArray[indexPath.row].image_url
            cell.groupImageView.sd_setImage(with: URL(string: imageUrl.replacingOccurrences(of: " ", with: "%20")))
            cell.cellButton.tag = indexPath.row
            cell.cellButton.addTarget(self, action: #selector(metalHealthCellPressed(sender:)), for: UIControl.Event.touchUpInside)
                return cell
        } else if collectionView.tag == 2 {
            let cell = circumstanceCollectionView.dequeueReusableCell(withReuseIdentifier: "CircumstancesCollectionViewCell", for: indexPath) as! CircumstancesCollectionViewCell
            cell.groupNameLabel.text = circumstanceArray[indexPath.row].name
            let imageUrl = circumstanceArray[indexPath.row].image_url
            cell.groupImageView.sd_setImage(with: URL(string: imageUrl.replacingOccurrences(of: " ", with: "%20")))
            cell.cellButton.tag = indexPath.row
            cell.cellButton.addTarget(self, action: #selector(circumstanceCellPressed(sender:)), for: UIControl.Event.touchUpInside)
            return cell
        }
        else {
            let cell = identityCollectionView.dequeueReusableCell(withReuseIdentifier: "IdentityCollectionViewCell", for: indexPath) as! IdentityCollectionViewCell
            cell.groupNameLabel.text = identityArray[indexPath.row].name
            let imageUrl = identityArray[indexPath.row].image_url
            cell.groupImageView.sd_setImage(with: URL(string: imageUrl.replacingOccurrences(of: " ", with: "%20")))
            cell.cellButton.tag = indexPath.row
            cell.cellButton.addTarget(self, action: #selector(identityCellPressed(sender:)), for: UIControl.Event.touchUpInside)
            return cell
        }
    }
PSA: How to View Variables in Lists
by 
Bradford Shelley
 Forum Level 2
created 4y ago (edited 3y ago ) in Developer Community
After having to play around with variables quite a bit in a recent project, I thought I'd share how to display variables on a list of Requested Items / Catalog Tasks. This applies to lists and related lists, as reports have their own method of displaying variables. Important note: This was performed on Fuji. Your experience may differ on older versions of ServiceNow.

Step 1 Identify the variables you'd like to display on your list, then copy the sys_id for each variable. This is as simple as heading to the Catalog Item, and jumping into the variable(s) in question. We'll need the sys_id to add the column into the list.

Step 2 Head over to System UI -> Lists

Step 3 Identify the list you'd like to display the variable(s) on. We're looking for one of two things here. Either the name of the view of the list you'd like to include the variable(s) on (I highly recommend creating a new view instead of using the Default view for this, as most likely the variables will apply to certain catalog items instead of every single one), or for a related list look at the Parent and Relationship columns for the table and name of the tab for the related list. Head into the list when you've found it.



Step 4 Create a new List Element(s) from the related list at, using "variables.sys_id" (no quotes) in the actual Element field on the List Element form. Create a new List Element for each variable you wish to add.



Step 5 Head over to the list where variables were just added. They won't show up immediately, so don't panic. Edit the list layout, and move around the variables to the spots you'd like them in the list (even if the position is already how you'd like it, move a variable one position up/down, then move it back and save). At this point, the variables should be visible!

Hope this helps at least one person out there. Take care!
star

Fri Jan 27 2023 17:17:47 GMT+0000 (Coordinated Universal Time)

#ios #swift #view #snippet
star

Fri Dec 16 2022 12:24:19 GMT+0000 (Coordinated Universal Time)

#ios #swift #card #view #cardview
star

Thu Oct 06 2022 15:54:44 GMT+0000 (Coordinated Universal Time)

#dart #flutter #bloc #page #view
star

Thu Oct 06 2022 14:58:50 GMT+0000 (Coordinated Universal Time)

#dart #flutter #bloc #page #view
star

Thu Oct 06 2022 14:19:52 GMT+0000 (Coordinated Universal Time)

#dart #flutter #bloc #page #view
star

Thu Oct 06 2022 14:18:34 GMT+0000 (Coordinated Universal Time)

#dart #flutter #bloc #page #view
star

Thu Oct 06 2022 11:22:44 GMT+0000 (Coordinated Universal Time)

#dart #flutter #bloc #page #view
star

Wed Jun 08 2022 05:35:30 GMT+0000 (Coordinated Universal Time)

#ios #swift #view #change #animate
star

Fri Jun 03 2022 11:39:59 GMT+0000 (Coordinated Universal Time)

#ios #swift #view #change #animate
star

Wed Mar 16 2022 11:20:40 GMT+0000 (Coordinated Universal Time)

#ios #swift #view #setview
star

Mon Feb 07 2022 07:41:03 GMT+0000 (Coordinated Universal Time)

#ios #swift #round #corner #view #viewround
star

Wed Jan 12 2022 05:32:21 GMT+0000 (Coordinated Universal Time)

##ios ##swift #collectionview #collection #view
star

Thu Nov 19 2020 21:32:35 GMT+0000 (Coordinated Universal Time) https://community.servicenow.com/community?id

#servicenow #catalog #servicecatalog #variables #list #listview #view

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension